public function testMarshall20()
 {
     // check that suffled systematically out and no required attribute.
     $inlineChoices = new InlineChoiceCollection();
     $choice = new InlineChoice('inlineChoice1');
     $choice->setFixed(true);
     $choice->setContent(new TextOrVariableCollection(array(new TextRun('Option1'))));
     $inlineChoices[] = $choice;
     $inlineChoiceInteraction = new InlineChoiceInteraction('RESPONSE', $inlineChoices);
     $inlineChoiceInteraction->setShuffle(false);
     $inlineChoiceInteraction->setRequired(true);
     $element = $this->getMarshallerFactory('2.0.0')->createMarshaller($inlineChoiceInteraction)->marshall($inlineChoiceInteraction);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<inlineChoiceInteraction responseIdentifier="RESPONSE" shuffle="false"><inlineChoice identifier="inlineChoice1" fixed="true">Option1</inlineChoice></inlineChoiceInteraction>', $dom->saveXML($element));
 }
 public function testMarshall()
 {
     $inlineChoices = new InlineChoiceCollection();
     $choice = new InlineChoice('inlineChoice1');
     $choice->setFixed(true);
     $choice->setContent(new TextOrVariableCollection(array(new TextRun('Option1'))));
     $inlineChoices[] = $choice;
     $choice = new InlineChoice('inlineChoice2');
     $choice->setContent(new TextOrVariableCollection(array(new TextRun('Option2'))));
     $inlineChoices[] = $choice;
     $choice = new InlineChoice('inlineChoice3');
     $choice->setContent(new TextOrVariableCollection(array(new TextRun('Option3'))));
     $inlineChoices[] = $choice;
     $inlineChoiceInteraction = new InlineChoiceInteraction('RESPONSE', $inlineChoices);
     $inlineChoiceInteraction->setShuffle(true);
     $inlineChoiceInteraction->setRequired(true);
     $element = $this->getMarshallerFactory()->createMarshaller($inlineChoiceInteraction)->marshall($inlineChoiceInteraction);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<inlineChoiceInteraction responseIdentifier="RESPONSE" shuffle="true" required="true"><inlineChoice identifier="inlineChoice1" fixed="true">Option1</inlineChoice><inlineChoice identifier="inlineChoice2">Option2</inlineChoice><inlineChoice identifier="inlineChoice3">Option3</inlineChoice></inlineChoiceInteraction>', $dom->saveXML($element));
 }
예제 #3
0
 public function testCreateShufflingFromInlineChoiceInteraction()
 {
     $choiceCollection = new InlineChoiceCollection();
     $choiceCollection[] = new InlineChoice('id1');
     $choiceCollection[] = new InlineChoice('id2');
     $choiceCollection[] = new InlineChoice('id3');
     $inlineChoiceInteraction = new InlineChoiceInteraction('RESPONSE', $choiceCollection);
     $inlineChoiceInteraction->setShuffle(true);
     $shuffling = StateUtils::createShufflingFromInteraction($inlineChoiceInteraction);
     $this->assertEquals('RESPONSE', $shuffling->getResponseIdentifier());
     $shufflingGroups = $shuffling->getShufflingGroups();
     $this->assertEquals(1, count($shufflingGroups));
     $this->assertEquals(array('id1', 'id2', 'id3'), $shufflingGroups[0]->getIdentifiers()->getArrayCopy());
 }