/**
  * Unmarshall a DOMElement to its TestFeedbackRef data model representation.
  *
  * @param \DOMElement $element
  * @return \qtism\data\QtiComponent A TestFeedbackRef object.
  * @throws \qtism\data\storage\xml\marshalling\UnmarshallingException If the element cannot be unmarshalled.
  */
 public function unmarshall(DOMElement $element)
 {
     if (($identifier = self::getDOMElementAttributeAs($element, 'identifier')) !== null) {
         if (($href = self::getDOMElementAttributeAs($element, 'href')) !== null) {
             if (($outcomeIdentifier = self::getDOMElementAttributeAs($element, 'outcomeIdentifier')) !== null) {
                 if (($access = self::getDOMElementAttributeAs($element, 'access')) !== null) {
                     if (($showHide = self::getDOMElementAttributeAs($element, 'showHide')) !== null) {
                         $access = TestFeedbackAccess::getConstantByName($access);
                         $showHide = ShowHide::getConstantByName($showHide);
                         $component = new TestFeedbackRef($identifier, $outcomeIdentifier, $access, $showHide, $href);
                         return $component;
                     } else {
                         $msg = "The mandatory 'showHide' attribute is missing from element 'testFeedbackRef'.";
                         throw new UnmarshallingException($msg, $element);
                     }
                 } else {
                     $msg = "The mandatory 'access' attribute is missing from element 'testFeedbackRef'.";
                     throw new UnmarshallingException($msg, $element);
                 }
             } else {
                 $msg = "The mandatory 'outcomeIdentifier' attribute is missing from element 'testFeedbackRef'.";
                 throw new UnmarshallingException($msg, $element);
             }
         } else {
             $msg = "The mandatory 'href' attribute is missing from element 'testFeedbackRef'.";
             throw new UnmarshallingException($msg, $element);
         }
     } else {
         $msg = "The mandatory 'identifier' attribute is missing from element 'testFeedbackRef'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
Exemple #2
0
 /**
  * Set how the feedback is shown to the candidate.
  *
  * * TestFeedbackAccess::DURING = At outcome processing time.
  * * TestFeedbackAccess:AT_END = At the end of the TestPart or AssessmentTest.
  *
  * @param int $access A value of the TestFeedbackAccess enumeration.
  * @throws \InvalidArgumentException If $access is not a value from the TestFeedbackAccess enumeration.
  */
 public function setAccess($access)
 {
     if (in_array($access, TestFeedbackAccess::asArray())) {
         $this->access = $access;
     } else {
         $msg = "'{$access}' is not a value from the TestFeedbackAccess enumeration.";
         throw new InvalidArgumentException($msg);
     }
 }