Exemplo n.º 1
0
 public function testEquality()
 {
     $p1 = new Pair('A', 'B');
     $p2 = new Pair('A', 'B');
     $p3 = new Pair('C', 'D');
     $p4 = new Pair('D', 'C');
     $this->assertTrue($p1->equals($p2));
     $this->assertTrue($p2->equals($p1));
     $this->assertFalse($p1->equals($p3));
     $this->assertFalse($p3->equals($p1));
     $this->assertFalse($p3->equals(1337));
     $this->assertTrue($p3->equals($p3));
     $this->assertTrue($p4->equals($p3));
 }
 /**
  * Write a Pair in the current binary stream.
  * 
  * @param Pair $pair A Pair object.
  * @throws QtiBinaryStreamAccessException
  */
 public function writePair(Pair $pair)
 {
     try {
         $this->writeString($pair->getFirst());
         $this->writeString($pair->getSecond());
     } catch (BinaryStreamAccessException $e) {
         $msg = "An error occured while writing a pair.";
         throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PAIR, $e);
     }
 }
    public function testCreateFromVariableDeclarationDefaultValueSingleCardinality()
    {
        $factory = $this->getMarshallerFactory();
        $element = $this->createDOMElement('
			<outcomeDeclaration xmlns="http://www.imsglobal.org/xsd/imsqti_v2p0" identifier="outcome1" baseType="pair" cardinality="single">
				<defaultValue>
					<value>A B</value>
				</defaultValue>
			</outcomeDeclaration>
		');
        $outcomeDeclaration = $factory->createMarshaller($element)->unmarshall($element);
        $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration);
        $pair = new Pair('A', 'B');
        $this->assertTrue($pair->equals($outcomeVariable->getDefaultValue()));
    }
Exemplo n.º 4
0
 /**
  * Marshall a QTI pair datatype into its PCI JSON Representation.
  *
  * @param \qtism\common\datatypes\Pair $pair
  * @return array
  */
 protected function marshallPair(Pair $pair)
 {
     return array('base' => array('pair' => array($pair->getFirst(), $pair->getSecond())));
 }