public function testMarshallMinimal()
 {
     $identifier = 'Q01';
     $timeDependent = false;
     $title = 'Question 1';
     $label = 'Label of Question 1';
     $toolName = 'QTISM';
     $toolVersion = '0.6.0';
     $assessmentItem = new AssessmentItem($identifier, $title, $timeDependent);
     $assessmentItem->setLabel($label);
     $assessmentItem->setToolName($toolName);
     $assessmentItem->setToolVersion($toolVersion);
     $marshaller = $this->getMarshallerFactory()->createMarshaller($assessmentItem);
     $element = $marshaller->marshall($assessmentItem);
     $this->assertInstanceOf('\\DOMElement', $element);
     $this->assertEquals('assessmentItem', $element->nodeName);
     // adaptive, timeDependent, identifier, title, label, toolName, toolVersion
     $this->assertEquals($element->attributes->length, 7);
     $this->assertEquals($identifier, $element->getAttribute('identifier'));
     $this->assertEquals($title, $element->getAttribute('title'));
     $this->assertEquals('false', $element->getAttribute('timeDependent'));
     $this->assertEquals('false', $element->getAttribute('adaptive'));
     $this->assertEquals($label, $element->getAttribute('label'));
     $this->assertEquals($toolName, $element->getAttribute('toolName'));
     $this->assertEquals($toolVersion, $element->getAttribute('toolVersion'));
 }
 public function build($itemIdentifier, $itemLabel, array $questions, $content = '')
 {
     // Initialise our <assessmentItem>
     $assessmentItem = new AssessmentItem($itemIdentifier, $itemIdentifier, false);
     $assessmentItem->setLabel($itemLabel);
     $assessmentItem->setOutcomeDeclarations($this->buildOutcomeDeclarations());
     $assessmentItem->setToolName('Learnosity');
     // Store interactions on this array to later be placed on <itemBody>
     $interactions = [];
     $responseDeclarationCollection = new ResponseDeclarationCollection();
     $responseProcessingTemplates = [];
     foreach ($questions as $question) {
         /** @var Question $question */
         // Map the `questions` and its validation objects to be placed at <itemBody>
         // The extraContent usually comes from `stimulus` of item that mapped to inline interaction and has no `prompt`
         list($interaction, $responseDeclaration, $responseProcessing, $extraContent) = $this->map($question);
         if (!empty($responseDeclaration)) {
             // TODO: Need to tidy this up
             // Well sometimes we can have multiple response declarations, ie. clozetext
             if ($responseDeclaration instanceof ResponseDeclarationCollection) {
                 $responseDeclarationCollection->merge($responseDeclaration);
             } else {
                 $responseDeclarationCollection->attach($responseDeclaration);
             }
         }
         if (!empty($responseProcessing)) {
             /** @var ResponseProcessing $responseProcessing */
             $responseProcessingTemplates[] = $responseProcessing->getTemplate();
         }
         $interactions[$question->get_reference()]['interaction'] = $interaction;
         if (!empty($extraContent)) {
             $interactions[$question->get_reference()]['extraContent'] = $extraContent;
         }
     }
     // Build <itemBody>
     $assessmentItem->setItemBody($this->itemBodyBuilder->buildItemBody($interactions, $content));
     // Map <responseDeclaration>
     if (!empty($responseDeclarationCollection)) {
         $assessmentItem->setResponseDeclarations($responseDeclarationCollection);
     }
     // Map <responseProcessing> - combine response processing from questions
     // TODO: Tidy up this stuff
     if (!empty($responseProcessingTemplates)) {
         $templates = array_unique($responseProcessingTemplates);
         $isOnlyMatchCorrect = count($templates) === 1 && $templates[0] === Constants::RESPONSE_PROCESSING_TEMPLATE_MATCH_CORRECT;
         $responseProcessing = new ResponseProcessing();
         $responseProcessing->setTemplate($isOnlyMatchCorrect ? Constants::RESPONSE_PROCESSING_TEMPLATE_MATCH_CORRECT : Constants::RESPONSE_PROCESSING_TEMPLATE_MAP_RESPONSE);
         $assessmentItem->setResponseProcessing($responseProcessing);
     }
     return $assessmentItem;
 }