Esempio n. 1
0
 /**
  * Marshall a QTI identifier datatype into its PCI JSON Representation.
  *
  * @param \qtism\common\datatypes\Identifier $identifier
  * @return array
  */
 protected function marshallIdentifier(QtiIdentifier $identifier)
 {
     return array('base' => array('identifier' => $identifier->getValue()));
 }
Esempio n. 2
0
 public function testUnmarshallState()
 {
     $json = '
         {
             "RESPONSE1": { "base" : { "identifier" : "ChoiceA" } },
             "RESPONSE2": { "list" : { "identifier" : ["_id1", "id2", "ID3"] } },
             "RESPONSE3": { "record" : [ { "name" : "rock", "base": { "identifier" : "Paper" } } ] },
             "RESPONSE4": { "base" : null }
         }
     ';
     $unmarshaller = self::createUnmarshaller();
     $state = $unmarshaller->unmarshall($json);
     $this->assertEquals(4, count($state));
     $this->assertEquals(array('RESPONSE1', 'RESPONSE2', 'RESPONSE3', 'RESPONSE4'), array_keys($state));
     $response1 = new QtiIdentifier('ChoiceA');
     $response2 = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('_id1'), new QtiIdentifier('id2'), new QtiIdentifier('ID3')));
     $response3 = new RecordContainer(array('rock' => new QtiIdentifier('Paper')));
     $response4 = null;
     $this->assertTrue($response1->equals($state['RESPONSE1']));
     $this->assertTrue($response2->equals($state['RESPONSE2']));
     $this->assertTrue($response3->equals($state['RESPONSE3']));
     $this->assertSame($response4, $state['RESPONSE4']);
 }