예제 #1
0
 public function testCreateShufflingFromAssociateInteraction()
 {
     $choiceCollection = new SimpleAssociableChoiceCollection();
     $choiceCollection[] = new SimpleAssociableChoice('id1', 1);
     $choiceCollection[] = new SimpleAssociableChoice('id2', 1);
     $choiceCollection[] = new SimpleAssociableChoice('id3', 1);
     $associateInteraction = new AssociateInteraction('RESPONSE', $choiceCollection);
     $associateInteraction->setShuffle(true);
     $shuffling = StateUtils::createShufflingFromInteraction($associateInteraction);
     $this->assertEquals('RESPONSE', $shuffling->getResponseIdentifier());
     $shufflingGroups = $shuffling->getShufflingGroups();
     $this->assertEquals(1, count($shufflingGroups));
     $this->assertEquals(array('id1', 'id2', 'id3'), $shufflingGroups[0]->getIdentifiers()->getArrayCopy());
 }
 /**
  * @depends testMarshallSimple20
  */
 public function testMarshallMinAssociationAvoided20()
 {
     // Aims at testing that minAssociation is not in the output
     // in a QTI 2.0 context.
     $choice1 = new SimpleAssociableChoice('choice_1', 1);
     $choice1->setContent(new FlowStaticCollection(array(new TextRun('Choice #1'))));
     $choices = new SimpleAssociableChoiceCollection(array($choice1));
     $component = new AssociateInteraction('RESPONSE', $choices);
     $component->setMinAssociations(1);
     $marshaller = $this->getMarshallerFactory('2.0.0')->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<associateInteraction responseIdentifier="RESPONSE" shuffle="false" maxAssociations="1"><simpleAssociableChoice identifier="choice_1" matchMax="1">Choice #1</simpleAssociableChoice></associateInteraction>', $dom->saveXML($element));
 }
 public function testMarshall()
 {
     $choice1 = new SimpleAssociableChoice('choice_1', 1);
     $choice1->setContent(new FlowStaticCollection(array(new TextRun('Choice #1'))));
     $choice2 = new SimpleAssociableChoice('choice_2', 2);
     $choice2->setMatchMin(1);
     $choice2->setContent(new FlowStaticCollection(array(new TextRun('Choice #2'))));
     $choices = new SimpleAssociableChoiceCollection(array($choice1, $choice2));
     $component = new AssociateInteraction('RESPONSE', $choices);
     $component->setMaxAssociations(2);
     $prompt = new Prompt();
     $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...'))));
     $component->setPrompt($prompt);
     $marshaller = $this->getMarshallerFactory()->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<associateInteraction responseIdentifier="RESPONSE" maxAssociations="2"><prompt>Prompt...</prompt><simpleAssociableChoice identifier="choice_1" matchMax="1">Choice #1</simpleAssociableChoice><simpleAssociableChoice identifier="choice_2" matchMax="2" matchMin="1">Choice #2</simpleAssociableChoice></associateInteraction>', $dom->saveXML($element));
 }