Skip to content

Commit

Permalink
Merge pull request #666 from oat-sa/release-5.46.0
Browse files Browse the repository at this point in the history
Release 5.46.0
  • Loading branch information
no-chris authored Dec 2, 2016
2 parents 42c35ad + 37295ce commit 641f7cc
Show file tree
Hide file tree
Showing 51 changed files with 2,964 additions and 300 deletions.
27 changes: 27 additions & 0 deletions actions/class.Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public function index(){
$this->setData('saveUrl', _url('saveTest', null, null, array('uri' => $testUri)));
$this->setData('itemsUrl', _url('get', 'Items'));
$this->setData('categoriesUrl', _url('getCategories', 'Items'));

if(common_ext_ExtensionsManager::singleton()->isInstalled('taoBlueprints')){
$this->setData('blueprintsByIdUrl', _url('getBlueprintsByIdentifier', 'Blueprints', 'taoBlueprints'));
$this->setData('blueprintsByTestSectionUrl', _url('getBlueprintsByTestSection', 'Blueprints', 'taoBlueprints', array('test' => $testUri)));
}
$this->setData('identifierUrl', _url('getIdentifier', null, null, array('uri' => $testUri)));

$this->setView('creator.tpl');
Expand Down Expand Up @@ -79,6 +84,28 @@ public function saveTest(){
$qtiTestService = taoQtiTest_models_classes_QtiTestService::singleton();

$saved = $qtiTestService->saveJsonTest($test, $parameters['model']);

//save the blueprint if the extension is installed
if(common_ext_ExtensionsManager::singleton()->isInstalled('taoBlueprints')){
$testSectionLinkService = $this->getServiceManager()->get(\oat\taoBlueprints\model\TestSectionLinkService::SERVICE_ID);
$model = json_decode($parameters['model'],true);
if(isset($model['testParts'])){
foreach($model['testParts'] as $testPart){
if(isset($testPart['assessmentSections'])){
foreach($testPart['assessmentSections'] as $section){
if(isset($section['blueprint'])){
if(!empty($section['blueprint'])){
$testSectionLinkService->setBlueprintForTestSection($test, $section['identifier'], $section['blueprint']);
} else {
$testSectionLinkService->removeBlueprintForTestSection($test, $section['identifier']);
}
}
}
}
}

}
}
}
}
$this->setContentHeader('application/json', 'UTF-8');
Expand Down
129 changes: 106 additions & 23 deletions actions/class.RestQtiTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
*
*/

use oat\taoQtiTest\models\tasks\ImportQtiTest;
use oat\oatbox\task\Task;

/**
*
* @author Absar Gilani & Rashid - PCG Team - {[email protected]}
*/
class taoQtiTest_actions_RestQtiTests extends tao_actions_RestController
class taoQtiTest_actions_RestQtiTests extends \tao_actions_TaskQueue
{
private static $accepted_types = array(
'application/zip',
Expand All @@ -34,13 +37,6 @@ public function index()
$this->returnFailure(new \common_exception_NotImplemented('This API does not support this call.'));
}

public function __construct()
{
parent::__construct();
// The service that implements or inherits get/getAll/getRootClass ... for that particular type of resources
$this->service = taoQtiTest_models_classes_CrudQtiTestsService::singleton();
}

/**
* Import file entry point by using $this->service
* Check POST method & get valid uploaded file
Expand All @@ -57,26 +53,113 @@ public function import()
if (!in_array($mimeType, self::$accepted_types)) {
$this->returnFailure(new common_exception_BadRequest());
} else {
$report = $this->service->importQtiTest($file['tmp_name']);
if ($report->getType() === common_report_Report::TYPE_SUCCESS) {
$data = array();
foreach ($report as $r) {
$values = $r->getData();
$testid = $values->rdfsResource->getUri();
foreach ($values->items as $item) {
$itemsid[] = $item->getUri();
}
$data[] = array(
'testId' => $testid,
'testItems' => $itemsid);
$task = ImportQtiTest::createTask($file);
$result = [
'reference_id' => $task->getId()
];
$report = $task->getReport();
if (!empty($report)) {
if ($report instanceof \common_report_Report) {
//serialize report to array
$report = json_encode($report);
$report = json_decode($report);
}
return $this->returnSuccess($data);
} else {
return $this->returnFailure(new common_exception_InconsistentData($report->getMessage()));
$result['report'] = $report;
}
return $this->returnSuccess($result);
}
} else {
return $this->returnFailure(new common_exception_BadRequest());
}
}

/**
* Action to retrieve test import status from queue
*/
public function getStatus()
{
try {
if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) {
throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI());
}
$data = $this->getTaskData($this->getRequestParameter(self::TASK_ID_PARAM));
$this->returnSuccess($data);
} catch (\Exception $e) {
$this->returnFailure($e);
}
}

/**
* @param Task $taskId
* @return Task
* @throws common_exception_BadRequest
*/
protected function getTask($taskId)
{
$task = parent::getTask($taskId);
if ($task->getInvocable() !== 'oat\taoQtiTest\models\tasks\ImportQtiTest') {
throw new \common_exception_BadRequest("Wrong task type");
}
return $task;
}

/**
* @param Task $task
* @return string
*/
protected function getTaskStatus(Task $task)
{
$report = $task->getReport();
if (in_array(
$task->getStatus(),
[Task::STATUS_CREATED, Task::STATUS_RUNNING, Task::STATUS_STARTED])
) {
$result = 'In Progress';
} else if ($report) {
$report = \common_report_Report::jsonUnserialize($report);
$plainReport = $this->getPlainReport($report);
$success = true;
foreach ($plainReport as $r) {
$success = $success && $r->getType() != \common_report_Report::TYPE_ERROR;
}
$result = $success ? 'Success' : 'Failed';
}
return $result;
}

/**
* @param Task $task
* @return array
*/
protected function getTaskReport(Task $task)
{
$report = \common_report_Report::jsonUnserialize($task->getReport());
$result = [];
if ($report) {
$plainReport = $this->getPlainReport($report);
foreach ($plainReport as $r) {
$result[] = [
'type' => $r->getType(),
'message' => $r->getMessage(),
];
}
}
return $result;
}

/**
* @param $report
* @return array
*/
private function getPlainReport($report)
{
$result = [];
$result[] = $report;
if ($report->hasChildren()) {
foreach ($report as $r) {
$result = array_merge($result, $this->getPlainReport($r));
}
}
return $result;
}
}
25 changes: 24 additions & 1 deletion config/default/testRunner.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,29 @@
* @type bool
*/
'hover' => false
],

/**
* A student tool that provides a magnifier glass
*/
'magnifier' => [
/**
* Smallest magnification factor
* @type int
*/
'zoomMin' => 2,

/**
* Biggest magnification factor
* @type int
*/
'zoomMax' => 8,

/**
* Increment between min an max
* @type int
*/
'zoomStep' => .5
]
],

Expand Down Expand Up @@ -356,7 +379,7 @@
'toggle' => 'R',
'flag' => 'M'
],
'responsesAccess' => [
'keyNavigation' => [
'previous' => 'Shift+Tab',
'next' => 'Tab'
],
Expand Down
13 changes: 9 additions & 4 deletions helpers/class.TestSessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2013-2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*/

Expand All @@ -26,7 +26,9 @@
use qtism\runtime\storage\common\StorageException;
use qtism\data\AssessmentTest;
use qtism\runtime\tests\AssessmentTestSession;
use qtism\runtime\storage\binary\QtiBinaryStreamAccessFsFile;
use qtism\runtime\storage\binary\QtiBinaryStreamAccess;
use oat\taoQtiTest\models\files\QtiFlysystemFileManager;
use oat\oatbox\service\ServiceManager;

/**
* A QtiSm AssessmentTestSession Storage Service implementation for TAO.
Expand Down Expand Up @@ -161,6 +163,9 @@ public function exists($sessionId) {
}

protected function createBinaryStreamAccess(IStream $stream) {
return new QtiBinaryStreamAccessFsFile($stream);
return new QtiBinaryStreamAccess(
$stream,
ServiceManager::getServiceManager()->get(QtiFlysystemFileManager::SERVICE_ID)
);
}
}
}
13 changes: 8 additions & 5 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*
*/
?>
<?php

/*
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
* @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php
*
*/
use oat\taoQtiTest\scripts\install\RegisterQtiFlysystemManager;

$extpath = dirname(__FILE__).DIRECTORY_SEPARATOR;
$taopath = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'tao'.DIRECTORY_SEPARATOR;

Expand All @@ -33,12 +34,12 @@
'label' => 'QTI test model',
'description' => 'TAO QTI test implementation',
'license' => 'GPL-2.0',
'version' => '5.39.1',
'version' => '5.46.0',
'author' => 'Open Assessment Technologies',
'requires' => array(
'taoTests' => '>=3.7.0',
'taoQtiItem' => '>=5.14.0',
'tao' => '>=7.27.0'
'tao' => '>=7.35.0'
),
'models' => array(
'http://www.tao.lu/Ontologies/TAOTest.rdf'
Expand All @@ -54,6 +55,8 @@
dirname(__FILE__) . '/scripts/install/addExtraTestRunnerButtons.php',
'oat\\taoQtiTest\\scripts\\install\\RegisterTestRunnerPlugins',
'oat\\taoQtiTest\\scripts\\install\\RegisterTestMetadataExporter',
'oat\\taoQtiTest\\scripts\\install\\CreateTestSessionFilesystem',
RegisterQtiFlysystemManager::class
)
),
'update' => 'oat\\taoQtiTest\\scripts\\update\\Updater',
Expand Down
2 changes: 1 addition & 1 deletion models/classes/export/class.QtiTestExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected function exportItems()

$rootDir = $this->getTestService()->getQtiTestDir($this->getItem());
$file = $this->getTestService()->getQtiTestFile($this->getItem());
$extraPath = dirname($rootDir->getRelPath($file));
$extraPath = str_replace('\\', '/', dirname($rootDir->getRelPath($file)));
$extraPath = trim($extraPath, '/');

$extraReversePath = '';
Expand Down
Loading

0 comments on commit 641f7cc

Please sign in to comment.