Whether or not the 'outcomeIdentifier'/'templateIdentifier' set on a templateElement/feedbackElement/choice
matches its 'identifier' attribute.

@param QtiComponent $component A TemplateElement or FeedbackElement or Choice element.
@return boolean
511327
protected function identifierMatches(QtiComponent $component)
    {
        $variableIdentifier = ($component instanceof FeedbackElement || $component instanceof ModalFeedback) ? $component->getOutcomeIdentifier() : $component->getTemplateIdentifier();
        $identifier = new QtiIdentifier($component->getIdentifier());
        $showHide = $component->getShowHide();
        $state = $this->getState();
        
        $matches = false;
        
        if (($val = $state[$variableIdentifier]) !== null) {
            if ($val instanceof QtiScalar) {
                $matches = $val->equals($identifier);
            } elseif ($val instanceof Container) {
                $matches = $val->contains($identifier);
            }
        }
        
        return $matches;
    }
592411
public static function getComponentWithIdentifier(string $identifier)
    {
        $components = self::getComponents();
        foreach ($components as $component) {
            if (empty($component->getIdentifier())) {
                continue;
            }
            
            if ($component->getIdentifier() == $identifier) {
                return $component;
            }
        }
        
        return null;
    }
588864
public function requirementExistsForComponent( $component ) {
		foreach ( $this->requirements as $requirement ) {
			if ( $requirement->component() === $component ) {
				return true;
			}
		}

		return false;
	}
1044219
public function setResponseIdentifier($responseIdentifier)
    {
        if (Format::isIdentifier($responseIdentifier, false) === true) {
            $this->responseIdentifier = $responseIdentifier;
        } else {
            $msg = "The 'responseIdentifier' argument must be a valid QTI identifier.";
            throw new InvalidArgumentException($msg);
        }
    }
183875
public function setTemplate($template)
    {
        if(!$template instanceof TemplateInterface)
        {
            if(empty($template) || (is_string($template) && strpos($template, '.') === false) )
            {
                $identifier         = $this->getIdentifier()->toArray();
                $identifier['path'] = array('template');
                $identifier['name'] = $template;

                $identifier = $this->getIdentifier($identifier);
            }
            else $identifier = $this->getIdentifier($template);

            $template = $identifier;
        }

        $this->__template = $template;

        return $this->__template;
    }
263127
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());
        $this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
        
        foreach ($component->getShufflingGroups() as $shufflingGroup) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($shufflingGroup);
            $element->appendChild($marshaller->marshall($shufflingGroup));
        }

        return $element;
    }
154027
protected function marshall(QtiComponent $component)
    {
        $element = self::getDOMCradle()->createElement($component->getQtiClassName());

        if ($component->hasTemplate() === true) {
            $this->setDOMElementAttribute($element, 'template', $component->getTemplate());
        }

        if ($component->hasTemplateLocation() === true) {
            $this->setDOMElementAttribute($element, 'templateLocation', $component->getTemplateLocation());
        }

        foreach ($component->getResponseRules() as $responseRule) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseRule);
            $element->appendChild($marshaller->marshall($responseRule));
        }

        return $element;
    }
984562
public static function doesComponentExist(string $addonComponentIdentifier): bool
    {
        $component = self::getComponentWithIdentifier($addonComponentIdentifier);
        return (!empty($component));
    }
259597
public function setTable(ContainerComponentInterface $component)
    {
        return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
    }
346592
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());

        $this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
        $this->setDOMElementAttribute($element, 'title', $component->getTitle());
        $this->setDOMElementAttribute($element, 'timeDependent', $component->isTimeDependent());
        $this->setDOMElementAttribute($element, 'adaptive', $component->isAdaptive());

        if ($component->hasLang() === true) {
            $this->setDOMElementAttribute($element, 'lang', $component->getLang());
        }

        if ($component->hasLabel() === true) {
            $this->setDOMElementAttribute($element, 'label', $component->getLabel());
        }

        if ($component->hasToolName() === true) {
            $this->setDOMElementAttribute($element, 'toolName', $component->getToolName());
        }

        if ($component->hasToolVersion() === true) {
            $this->setDOMElementAttribute($element, 'toolVersion', $component->getToolVersion());
        }

        foreach ($component->getResponseDeclarations() as $responseDeclaration) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclaration);
            $element->appendChild($marshaller->marshall($responseDeclaration));
        }

        foreach ($component->getOutcomeDeclarations() as $outcomeDeclaration) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclaration);
            $element->appendChild($marshaller->marshall($outcomeDeclaration));
        }

        foreach ($component->getTemplateDeclarations() as $templateDeclaration) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclaration);
            $element->appendChild($marshaller->marshall($templateDeclaration));
        }

        if ($component->hasTemplateProcessing() === true) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getTemplateProcessing());
            $element->appendChild($marshaller->marshall($component->getTemplateProcessing()));
        }

        foreach ($component->getStylesheets() as $stylesheet) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($stylesheet);
            $element->appendChild($marshaller->marshall($stylesheet));
        }

        if ($component->hasItemBody() === true) {
            $itemBody = $component->getItemBody();
            $marshaller = $this->getMarshallerFactory()->createMarshaller($itemBody);
            $element->appendChild($marshaller->marshall($itemBody));
        }

        if ($component->hasResponseProcessing() === true) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getResponseProcessing());
            $element->appendChild($marshaller->marshall($component->getResponseProcessing()));
        }

        foreach ($component->getModalFeedbacks() as $modalFeedback) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedback);
            $element->appendChild($marshaller->marshall($modalFeedback));
        }

        return $element;
    }
199589
protected function marshall(QtiComponent $component)
    {
        $element = $this->createElement($component);
        $this->fillElement($element, $component);
        $this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
        $this->setDOMElementAttribute($element, 'lowerBound', $component->getLowerBound());
        $this->setDOMElementAttribute($element, 'upperBound', $component->getUpperBound());

        if ($component->hasStep() === true) {
            $this->setDOMElementAttribute($element, 'step', $component->getStep());
        }

        if ($component->mustStepLabel() === true) {
            $this->setDOMElementAttribute($element, 'stepLabel', true);
        }

        if ($component->getOrientation() === Orientation::VERTICAL) {
            $this->setDOMElementAttribute($element, 'orientation', Orientation::getNameByConstant(Orientation::VERTICAL));
        }

        if ($component->mustReverse() === true) {
            $this->setDOMElementAttribute($element, 'reverse', true);
        }

        if ($component->hasXmlBase() === true) {
            self::setXmlBase($element, $component->getXmlBase());
        }

        if ($component->hasPrompt() === true) {
            $element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getPrompt())->marshall($component->getPrompt()));
        }

        return $element;
    }
1067539
protected function createFinalRendering(QtiComponent $component)
    {
        $dom = $this->getDocument();
        if (($last = $this->getLastRendering()) !== null) {
            $dom->appendChild($last);
        }

        // If we are rendering an item, let's try to find some Math to
        // for template variable mapping. 
        if ($component instanceof AssessmentItem && count($templateDeclarations = $component->getTemplateDeclarations()) > 0) {
            $xpath = new DOMXPath($dom);
            $xpath->registerNamespace('m', 'http://www.w3.org/1998/Math/MathML');
            $maths = $xpath->query('//m:math|//math');
            
            if ($maths->length > 0) {
                $printedVariableRenderer = new PrintedVariableRenderer($this);
                
                foreach ($templateDeclarations as $templateDeclaration) {
                    if ($templateDeclaration->isMathVariable() === true) {
                        $templateIdentifier = $templateDeclaration->getIdentifier();
                        
                        foreach ($maths as $math) {
                            // Find <mi> and <ci> elements.
                            foreach ($xpath->query(".//m:mi[text() = '${templateIdentifier}']|.//m:ci[text() = '${templateIdentifier}']|.//mi[text() = '${templateIdentifier}']|.//ci[text() = '${templateIdentifier}']", $math) as $mathElement) {
                                $localElementName = ($mathElement->localName === 'mi') ? 'mn' : 'cn';
                                $newMathElement = $mathElement->ownerDocument->createElement($localElementName);
                                $printedVariable = new PrintedVariable($templateIdentifier);
                                $printedVariableFragment = $printedVariableRenderer->render($printedVariable);
                                
                                if ($this->getPrintedVariablePolicy() === self::CONTEXT_STATIC) {
                                    foreach ($printedVariableFragment->childNodes as $node) {
                                        $newMathElement->appendChild($node);
                                        $mathElement->parentNode->replaceChild($newMathElement, $mathElement);
                                    }
                                } else if ($this->getPrintedVariablePolicy() === self::CONTEXT_AWARE) {
                                    $newMathElement->appendChild($newMathElement->ownerDocument->createTextNode($printedVariableFragment->firstChild->nodeValue));
                                    $mathElement->parentNode->replaceChild($newMathElement, $mathElement);
                                } else {
                                    foreach ($printedVariableFragment->firstChild->childNodes as $node) {
                                        $newMathElement->appendChild($node);
                                        $mathElement->parentNode->replaceChild($newMathElement, $mathElement);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return $dom;
    }
887038
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());

        $this->setDOMElementAttribute($element, 'sourceIdentifier', $component->getSource());
        $this->setDOMElementAttribute($element, 'targetIdentifier', $component->getTarget());

        return $element;
    }
912719
protected function marshall(QtiComponent $component)
    {
        $element = self::getDOMCradle()->createElement('colgroup');
        $this->setDOMElementAttribute($element, 'span', $component->getSpan());

        foreach ($component->getContent() as $col) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($col);
            $element->appendChild($marshaller->marshall($col));
        }

        $this->fillElement($element, $component);

        return $element;
    }
310269
public function setSectionIdentifier($sectionIdentifier)
    {
        if (Format::isIdentifier($sectionIdentifier) || empty($sectionIdentifier)) {
            $this->sectionIdentifier = $sectionIdentifier;
        } else {
            $msg = "'${sectionIndentifier}' is not a valid QTI Identifier.";
            throw new InvalidArgumentException($msg);
        }
    }
144147
public static boolean isHideNoSelectionOption(UIComponent component)
    {
        // check hideNoSelectionOption for literal value (String) or ValueExpression (Boolean)
        Object hideNoSelectionOptionAttr = component.getAttributes().get(
                JSFAttr.HIDE_NO_SELECTION_OPTION_ATTR);
        return ((hideNoSelectionOptionAttr instanceof String && "true"
                .equalsIgnoreCase((String) hideNoSelectionOptionAttr)) || 
                (hideNoSelectionOptionAttr instanceof Boolean && ((Boolean) hideNoSelectionOptionAttr)));
    }
31318
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());

        $this->setDOMElementAttribute($element, 'shape', QtiShape::getNameByConstant($component->getShape()));
        $this->setDOMElementAttribute($element, 'coords', $component->getCoords());
        $this->setDOMElementAttribute($element, 'mappedValue', $component->getMappedValue());

        return $element;
    }