コード例 #1
0
 /**
  * @depends testMarshall21
  */
 public function testMarshall20()
 {
     // Make sure that maxAssociations is always in the output but never minAssociations.
     $object = new Object('myimg.png', 'image/png');
     $choice1 = new AssociableHotspot('choice1', 2, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15)));
     $choice1->setMatchMin(1);
     $choice2 = new AssociableHotspot('choice2', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15)));
     $choice3 = new AssociableHotspot('choice3', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15)));
     $choices = new AssociableHotspotCollection(array($choice1, $choice2, $choice3));
     $graphicAssociateInteraction = new GraphicAssociateInteraction('RESPONSE', $object, $choices);
     $graphicAssociateInteraction->setMaxAssociations(3);
     $graphicAssociateInteraction->setMinAssociations(2);
     $element = $this->getMarshallerFactory('2.0.0')->createMarshaller($graphicAssociateInteraction)->marshall($graphicAssociateInteraction);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<graphicAssociateInteraction responseIdentifier="RESPONSE" maxAssociations="3"><object data="myimg.png" type="image/png"/><associableHotspot identifier="choice1" shape="circle" coords="0,0,15" matchMax="2"/><associableHotspot identifier="choice2" shape="circle" coords="2,2,15" matchMax="1"/><associableHotspot identifier="choice3" shape="circle" coords="4,4,15" matchMax="1"/></graphicAssociateInteraction>', $dom->saveXML($element));
 }
 public function testMarshall()
 {
     $prompt = new Prompt();
     $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...'))));
     $object = new Object('myimg.png', 'image/png');
     $choice1 = new AssociableHotspot('choice1', 2, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15)));
     $choice1->setMatchMin(1);
     $choice2 = new AssociableHotspot('choice2', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15)));
     $choice3 = new AssociableHotspot('choice3', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15)));
     $choices = new AssociableHotspotCollection(array($choice1, $choice2, $choice3));
     $graphicAssociateInteraction = new GraphicAssociateInteraction('RESPONSE', $object, $choices, 'prout');
     $graphicAssociateInteraction->setPrompt($prompt);
     $element = $this->getMarshallerFactory()->createMarshaller($graphicAssociateInteraction)->marshall($graphicAssociateInteraction);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<graphicAssociateInteraction id="prout" responseIdentifier="RESPONSE"><prompt>Prompt...</prompt><object data="myimg.png" type="image/png"/><associableHotspot identifier="choice1" shape="circle" coords="0,0,15" matchMax="2" matchMin="1"/><associableHotspot identifier="choice2" shape="circle" coords="2,2,15" matchMax="1"/><associableHotspot identifier="choice3" shape="circle" coords="4,4,15" matchMax="1"/></graphicAssociateInteraction>', $dom->saveXML($element));
 }