Skip to content

Commit

Permalink
Merge pull request #354 from oat-sa/release-20.0.0
Browse files Browse the repository at this point in the history
Release 20.0.0
  • Loading branch information
bugalot authored Feb 1, 2023
2 parents f86e4dc + 407eef5 commit 888ab2b
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<p align="center"><img src="https://cloud.githubusercontent.com/assets/4217431/6734391/3b3ef4e8-ce58-11e4-83a1-d6e39a91400f.png" alt="QTI-SDK" /></p>

[![Latest Version](https://img.shields.io/github/tag/oat-sa/qti-sdk.svg?style=flat&label=release)](https://github.com/oat-sa/qti-sdk/tags)
[![Build Status](https://travis-ci.org/oat-sa/qti-sdk.svg?branch=master)](https://travis-ci.org/oat-sa/qti-sdk)
[![Coverage Status](https://codecov.io/gh/oat-sa/qti-sdk/branch/master/graph/badge.svg?token=Z02IN6NSmp)](https://codecov.io/gh/oat-sa/qti-sdk)
[![License GPL2](http://img.shields.io/badge/licence-gpl2-blue.svg)](http://www.gnu.org/licenses/gpl-2.0.html)
[![Packagist Downloads](http://img.shields.io/packagist/dt/qtism/qtism.svg)](https://packagist.org/packages/qtism/qtism)
Expand Down
8 changes: 4 additions & 4 deletions src/qtism/runtime/storage/binary/AbstractQtiBinaryStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function persist(AssessmentTestSession $assessmentTestSession): void

// Write the current position in the route.
$route = $assessmentTestSession->getRoute();
$access->writeTinyInt($route->getPosition());
$access->writeInteger($route->getPosition());

// persist time reference.
$timeReference = $assessmentTestSession->getTimeReference();
Expand All @@ -174,7 +174,7 @@ public function persist(AssessmentTestSession $assessmentTestSession): void
$access->writeShort($assessmentTestSession->getConfig());

// -- Persist the Route of the AssessmentTestSession and the related item sessions.
$access->writeTinyInt($route->count());
$access->writeInteger($route->count());
$itemSessionStore = $assessmentTestSession->getAssessmentItemSessionStore();
$pendingResponseStore = $assessmentTestSession->getPendingResponseStore();

Expand Down Expand Up @@ -257,7 +257,7 @@ public function retrieve($sessionId): AssessmentTestSession

// Deal with intrinsic values of the Test Session.
$assessmentTestSessionState = $access->readTinyInt();
$currentPosition = $access->readTinyInt();
$currentPosition = ($this->version->storesRouteCountAsInteger()) ? $access->readInteger() : $access->readTinyInt();

if ($access->readBoolean() === true) {
$timeReference = $access->readDateTime();
Expand All @@ -281,7 +281,7 @@ public function retrieve($sessionId): AssessmentTestSession
$lastOccurenceUpdate = new SplObjectStorage();
$itemSessionStore = new AssessmentItemSessionStore();
$pendingResponseStore = new PendingResponseStore();
$routeCount = $access->readTinyInt();
$routeCount = ($this->version->storesRouteCountAsInteger()) ? $access->readInteger() : $access->readTinyInt();

// Create the item session factory that will be used to instantiate
// new item sessions.
Expand Down
14 changes: 13 additions & 1 deletion src/qtism/runtime/storage/binary/QtiBinaryVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class QtiBinaryVersion
/**
* The QTI binary data version number.
*/
public const CURRENT_VERSION = self::VERSION_VARIABLE_WITH_DEFAULT_VALUE_INITIALIZATION_FLAG;
public const CURRENT_VERSION = self::VERSION_ROUTE_COUNT_INTEGER;

/**
* The QTI Sdk branch to select behaviour of the binary storage.
Expand All @@ -44,6 +44,7 @@ class QtiBinaryVersion
/**
* These constants make the different versions a bit more self-explanatory.
*/
public const VERSION_ROUTE_COUNT_INTEGER = 13;
public const VERSION_VARIABLE_WITH_DEFAULT_VALUE_INITIALIZATION_FLAG = 12;
public const VERSION_VARIABLE_COUNT_INTEGER = 11;
public const VERSION_FIRST_MASTER = 10;
Expand Down Expand Up @@ -110,6 +111,17 @@ public function isCurrentVersion(): bool
return $this->version === self::CURRENT_VERSION;
}

/**
* @return bool
*/
public function storesRouteCountAsInteger(): bool
{
return $this->version >= self::VERSION_ROUTE_COUNT_INTEGER;
}

/**
* @return bool
*/
public function storesVariableDefaultValueInitializationFlag(): bool
{
return $this->version >= self::VERSION_VARIABLE_WITH_DEFAULT_VALUE_INITIALIZATION_FLAG;
Expand Down
2 changes: 2 additions & 0 deletions test/qtismtest/common/datatypes/files/FileSystemFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public function testCreateFromExistingFileMalformedDestinationPathTwo(): void
sys_get_temp_dir() . '/abcd\\t/v**',
'text/plain'
);

$this->assertTrue(true, 'File could not be created from existing file.');
} catch (RuntimeException $e) {
$this::assertInstanceOf(RuntimeException::class, $e);
}
Expand Down
2 changes: 1 addition & 1 deletion test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function unmarshallFileProvider(): array
$file = $fileManager->retrieve($samples . 'datatypes/file/text-plain_text_data.txt');
$returnValue[] = [$file, '{ "base" : { "file" : { "mime" : "text\/plain", "data" : ' . json_encode(base64_encode('Some text...')) . ', "name" : "text.txt" } } }'];

$targetPath = $samples . 'datatypes/file/target_text-plain_text_data.txt';
$targetPath = sys_get_temp_dir() . '/target_text-plain_text_data.txt';
$file = $fileManager->createFromData($file->getData(), $file->getMimeType(), $file->getFilename(), $targetPath);
$returnValue[] = [$file, '{ "base" : { "file" : { "mime" : "text\/plain", "data" : ' . json_encode(base64_encode('Some text...')) . ', "name" : "text.txt", "path" : "' . $targetPath . '" } } }'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,41 @@ public function testVisitedTestPartsNonLinear3TestPartJumpEndOfTestPart(): void
$this::assertTrue($session->isTestPartVisited($session->getCurrentTestPart()));
}

public function test300Items(): void
{
// Test to prove that a test with more than 255 items can be instantiated and handled.
$doc = new XmlCompactDocument();
$doc->load(self::samplesDir() . 'custom/runtime/route_count/300_items_long.xml');
$test = $doc->getDocumentComponent();
$sessionManager = new SessionManager(new FileSystemFileManager());
$storage = new LocalQtiBinaryStorage($sessionManager, $test);
$session = $storage->instantiate();
$session->beginTestSession();
$sessionId = $session->getSessionId();

// To start, persist and forget.
$storage->persist($session);

// Let's test!
$expectedRouteCount = $test->getComponentsByClassName('assessmentItemRef')->count();

// Let's perform 300 moveNext calls to reach the end of the test.
for ($i = 0; $i < $expectedRouteCount; $i++) {
$session = $storage->retrieve($sessionId);

$position = $session->getRoute()->getPosition();
$assessmentItemRefIdentifier = $session->getCurrentAssessmentItemRef()->getIdentifier();
$this->assertEquals($i, $position);
$this->assertEquals('Q' . ($i + 1), $assessmentItemRefIdentifier);

$session->moveNext();
$storage->persist($session);
}

$this->assertEquals(300, $i);
$this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState());
}

public function testConfigPersistence(): void
{
$doc = new XmlCompactDocument();
Expand Down
Loading

0 comments on commit 888ab2b

Please sign in to comment.