Ejemplo n.º 1
0
 private function assertInteractionTwo(ChoiceInteraction $interaction, ResponseDeclaration $responseDeclaration)
 {
     // And its prompt is mapped correctly
     $promptString = QtiMarshallerUtil::marshallCollection($interaction->getPrompt()->getComponents());
     $this->assertEquals('Pick the odd one out', $promptString);
     // All the choices also mapped properly
     /** @var SimpleChoice[] $simpleChoices */
     $simpleChoices = $interaction->getSimpleChoices()->getArrayCopy(true);
     $this->assertEquals($simpleChoices[0]->getIdentifier(), 'CHOICE_0');
     $this->assertEquals(QtiMarshallerUtil::marshallCollection($simpleChoices[0]->getContent()), 'Tomato');
     $this->assertEquals($simpleChoices[1]->getIdentifier(), 'CHOICE_1');
     $this->assertEquals(QtiMarshallerUtil::marshallCollection($simpleChoices[1]->getContent()), 'Orange');
     $this->assertEquals($simpleChoices[2]->getIdentifier(), 'CHOICE_2');
     $this->assertEquals(QtiMarshallerUtil::marshallCollection($simpleChoices[2]->getContent()), 'Celery');
     $this->assertEquals($simpleChoices[3]->getIdentifier(), 'CHOICE_3');
     $this->assertEquals(QtiMarshallerUtil::marshallCollection($simpleChoices[3]->getContent()), 'Pear');
     // Check usual stuff
     $this->assertEquals(1, $interaction->getMinChoices());
     $this->assertEquals(1, $interaction->getMaxChoices());
     $this->assertFalse($interaction->mustShuffle());
     $this->assertEquals(Orientation::HORIZONTAL, $interaction->getOrientation());
     // Check the response declaration fine for mcq with multiple responses
     $this->assertEquals(BaseType::IDENTIFIER, $responseDeclaration->getBaseType());
     $this->assertEquals(Cardinality::SINGLE, $responseDeclaration->getCardinality());
     $correctResponse = $responseDeclaration->getCorrectResponse();
     $this->assertTrue($correctResponse instanceof CorrectResponse);
     /** @var Value[] $values */
     $values = $correctResponse->getValues()->getArrayCopy(true);
     $this->assertEquals($values[0]->getValue(), 'CHOICE_2');
     $this->assertNull($responseDeclaration->getMapping());
 }