public function testWriteShufflingState() { $shufflingGroup = new ShufflingGroup(new IdentifierCollection(array('id1', 'id2', 'id3'))); $shufflingGroup->setFixedIdentifiers(new IdentifierCollection(array('id2'))); $shufflingGroups = new ShufflingGroupCollection(array($shufflingGroup)); $shuffling = new Shuffling('RESPONSE', $shufflingGroups); $stream = new MemoryStream(); $stream->open(); $access = new QtiBinaryStreamAccess($stream, new FileSystemFileManager()); $access->writeShufflingState($shuffling); $stream->rewind(); $shufflingState = $access->readShufflingState(); $this->assertEquals('RESPONSE', $shufflingState->getResponseIdentifier()); $shufflingGroups = $shufflingState->getShufflingGroups(); $this->assertEquals(array('id1', 'id2', 'id3'), $shufflingGroups[0]->getIdentifiers()->getArrayCopy()); $this->assertEquals(array('id2'), $shufflingGroups[0]->getFixedIdentifiers()->getArrayCopy()); }
public function testWritePendingResponses() { $doc = new XmlCompactDocument(); $doc->load(self::samplesDir() . 'custom/runtime/itemsubset_simultaneous.xml'); $seeker = new AssessmentTestSeeker($doc->getDocumentComponent(), array('assessmentItemRef', 'assessmentSection', 'testPart', 'outcomeDeclaration', 'responseDeclaration', 'branchRule', 'preCondition')); $stream = new MemoryStream(); $stream->open(); $access = new QtiBinaryStreamAccessFsFile($stream); $factory = new SessionManager(); $session = $factory->createAssessmentTestSession($doc->getDocumentComponent()); $session->beginTestSession(); $session->beginAttempt(); $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); $store = $session->getPendingResponseStore(); $pendingResponses = $store->getPendingResponses($doc->getDocumentComponent()->getComponentByIdentifier('Q01')); $access->writePendingResponses($seeker, $pendingResponses); $stream->rewind(); $pendingResponses = $access->readPendingResponses($seeker); $state = $pendingResponses->getState(); $this->assertEquals('ChoiceB', $state['RESPONSE']->getValue()); $this->assertEquals('Q01', $pendingResponses->getAssessmentItemRef()->getIdentifier()); $this->assertEquals(0, $pendingResponses->getOccurence()); $this->assertInternalType('integer', $pendingResponses->getOccurence()); }