public function testSimpleCaseWithMapResponseValidation()
 {
     $interaction = InlineChoiceInteractionBuilder::buildSimple('testIdentifier', ['sydney' => 'Sydney', 'melbourne' => 'Melbourne', 'canberra' => 'Canberra']);
     $responseDeclaration = ResponseDeclarationBuilder::buildWithMapping('testIdentifier', ['sydney' => ['0.5', false], 'melbourne' => ['1', true]]);
     $mapper = new InlineChoiceInteractionMapper($interaction, $responseDeclaration, ResponseProcessingTemplate::mapResponse());
     $question = $mapper->getQuestionType();
     $this->assertNotNull($question);
     $this->assertEquals('clozedropdown', $question->get_type());
     // Should populate possible responses
     $this->assertCount(1, $question->get_possible_responses());
     $this->assertCount(3, $question->get_possible_responses()[0]);
     $this->assertContains('Sydney', $question->get_possible_responses()[0]);
     $this->assertContains('Melbourne', $question->get_possible_responses()[0]);
     $this->assertContains('Canberra', $question->get_possible_responses()[0]);
     // Should have validation object
     $validation = $question->get_validation();
     $this->assertNotNull($validation);
     $this->assertInstanceOf('LearnosityQti\\Entities\\QuestionTypes\\clozedropdown_validation', $validation);
     $this->assertEquals('exactMatch', $validation->get_scoring_type());
     // Should set both `valid_response` and `alt_responses` for multiple correct values
     // Also, the highest value should be put as `valid_response`
     $validResponse = $validation->get_valid_response();
     $this->assertNotNull($validResponse);
     $this->assertEquals(1, $validResponse->get_score());
     $this->assertEquals(["Melbourne"], $validResponse->get_value());
     $altResponses = $validation->get_alt_responses();
     $this->assertNotNull($altResponses);
     $this->assertCount(1, $altResponses);
     $this->assertEquals(0.5, $altResponses[0]->get_score());
     $this->assertEquals(["Sydney"], $altResponses[0]->get_value());
 }
예제 #2
0
 protected function buildAssessmentItemWithDifferentInteractionTypes()
 {
     $interactionOne = new TextEntryInteraction('testInteractionOne');
     $interactionTwo = InlineChoiceInteractionBuilder::buildSimple('testInteractionTwo', ['choice' => 'The Choice Label']);
     return $this->buildAssessmentItem([$interactionOne, $interactionTwo], ResponseProcessingTemplate::MAP_RESPONSE);
 }
 private function buildItemBodyWithTwoInteractions()
 {
     $interactionOne = InlineChoiceInteractionBuilder::buildSimple('testIdentifierOne', ['sydney' => 'Sydney', 'melbourne' => 'Melbourne', 'canberra' => 'Canberra']);
     $interactionTwo = InlineChoiceInteractionBuilder::buildSimple('testIdentifierTwo', ['hugh' => 'Hugh Jackman', 'keanu' => 'Keanu Reeves', 'gloria' => 'Gloria Foster']);
     $itemBody = new ItemBody();
     $itemBodyCollection = new BlockCollection();
     // Build `<p>The Matrix .... <inlineChoiceInteraction...></inlineChoiceInteraction>.</p>`
     $p = new P();
     $pCollection = new InlineCollection();
     $pCollection->attach(new TextRun('The Matrix movie is filmed at '));
     $pCollection->attach($interactionOne);
     $pCollection->attach(new TextRun(', and starring '));
     $pCollection->attach($interactionTwo);
     $p->setContent($pCollection);
     // Build the <itemBody>
     $itemBodyCollection->attach($p);
     $itemBody->setContent($itemBodyCollection);
     return $itemBody;
 }