Skip to content

Commit

Permalink
Merge pull request #313 from oat-sa/release-2.17.0
Browse files Browse the repository at this point in the history
Release 2.17.0
  • Loading branch information
llecaque committed Jan 29, 2016
2 parents 963ae37 + 4bb6d21 commit ebf8fde
Show file tree
Hide file tree
Showing 71 changed files with 8,175 additions and 88 deletions.
568 changes: 568 additions & 0 deletions actions/class.Runner.php

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion actions/class.TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*
*/

use qtism\data\storage\php\PhpDocument;
use qtism\runtime\tests\AssessmentTestSessionException;
use qtism\runtime\tests\AssessmentTestSessionState;
use qtism\runtime\tests\AssessmentTestSession;
Expand Down Expand Up @@ -765,6 +764,15 @@ public function storeItemVariableSet()
}

$this->afterAction(false);
} else {
$session = $this->getTestSession();
$state = $session->getState();
if($state == AssessmentTestSessionState::SUSPENDED){
if (\oat\oatbox\service\ServiceManager::getServiceManager()->has('taoProctoring/delivery')) {
$deliveryService = \oat\oatbox\service\ServiceManager::getServiceManager()->get('taoProctoring/delivery');
$deliveryService->setHasBeenPaused($session->getSessionId(), true);
}
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions config/default/QtiRunnerService.conf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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) 2015 (original work) Open Assessment Technologies SA;
*
*
*/

return new oat\taoQtiTest\models\runner\QtiRunnerService();
10 changes: 9 additions & 1 deletion helpers/class.TestRunnerUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static protected function getExtendedStateService()
static public function buildItemServiceCall(AssessmentTestSession $session, $testDefinitionUri, $testCompilationUri) {

$href = $session->getCurrentAssessmentItemRef()->getHref();

// retrive itemUri & itemPath.
$parts = explode('|', $href);

Expand Down Expand Up @@ -400,6 +400,14 @@ static public function buildAssessmentTestContext(AssessmentTestSession $session
$context['submissionMode'] = null;
$context['remainingAttempts'] = 0;
$context['isAdaptive'] = false;

$hasBeenPaused = false;
if(common_ext_ExtensionsManager::singleton()->isEnabled('taoProctoring') && \oat\oatbox\service\ServiceManager::getServiceManager()->has('taoProctoring/delivery')){
$deliveryService = \oat\oatbox\service\ServiceManager::getServiceManager()->get('taoProctoring/delivery');
$hasBeenPaused = $deliveryService->getHasBeenPaused($session->getSessionId());
}
$context['hasBeenPaused'] = $hasBeenPaused;


if ($session->getState() === AssessmentTestSessionState::INTERACTING) {
$config = common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('testRunner');
Expand Down
23 changes: 10 additions & 13 deletions helpers/class.TestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use oat\oatbox\service\ServiceManager;
use oat\oatbox\event\EventManager;
use oat\taoQtiTest\models\event\QtiTestChangeEvent;
use Zend\ServiceManager\ServiceLocatorAwareInterface;

/**
* A TAO Specific extension of QtiSm's AssessmentTestSession class.
Expand Down Expand Up @@ -321,25 +322,21 @@ public function moveNextAssessmentItem()
}

protected function triggerEventChange() {
/*
$pos = $this->getRoute()->getPosition();
$count = $this->getRouteCount();
if ($this->isRunning()) {
$section = $this->getCurrentAssessmentSection();
$description = __('%1$s - item %2$s/%3$s', $section->getTitle(), $pos, $count);
} else {
$description = __('finished');
$event = new QtiTestChangeEvent($this);
if ($event instanceof ServiceLocatorAwareInterface) {
$event->setServiceLocator($this->getServiceLocator());
}
$serviceCallId = $this->getSessionId();
*/
$this->getEventManager()->trigger(new QtiTestChangeEvent($this));
$this->getEventManager()->trigger($event);
}

/**
* @return EventManager
*/
protected function getEventManager() {
return ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID);
return $this->getServiceLocator()->get(EventManager::CONFIG_ID);
}

protected function getServiceLocator() {
return ServiceManager::getServiceManager();
}
}
3 changes: 2 additions & 1 deletion manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'label' => 'QTI test model',
'description' => 'TAO QTI test implementation',
'license' => 'GPL-2.0',
'version' => '2.16.0',
'version' => '2.17.0',
'author' => 'Open Assessment Technologies',
'requires' => array(
'taoTests' => '>=2.6',
Expand Down Expand Up @@ -64,6 +64,7 @@
array('grant', 'http://www.tao.lu/Ontologies/TAOTest.rdf#TaoQtiManagerRole', array('ext'=>'taoQtiTest')),
array('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole', array('ext'=>'taoQtiTest', 'mod' => 'ItemRunner')),
array('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole', array('ext'=>'taoQtiTest', 'mod' => 'TestRunner')),
array('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole', array('ext'=>'taoQtiTest', 'mod' => 'Runner')),
array('grant', 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestsManagerRole', array('ext'=>'taoQtiTest', 'mod' => 'Creator')),
array('grant', 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestsManagerRole', array('ext'=>'taoQtiTest', 'mod' => 'Items'))
),
Expand Down
26 changes: 26 additions & 0 deletions models/classes/SessionStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
*/
class SessionStateService extends ConfigurableService
{
const SERVICE_ID = 'taoQtiTest/SessionStateService';

const OPTION_STATE_FORMAT = 'stateFormat';

/**
* @var \taoDelivery_models_classes_execution_ServiceProxy
*/
Expand Down Expand Up @@ -126,4 +130,26 @@ public function getClientImplementation($resetTimerAfterResume = false){
}
return 'taoQtiTest/testRunner/resumingStrategy/resetAfterResume';
}

/**
* Return a human readable description of the test session
*
* @return string
*/
public function getSessionDescription(\taoQtiTest_helpers_TestSession $session)
{
if ($session->isRunning()) {
$format = $this->hasOption(self::OPTION_STATE_FORMAT)
? $this->getOption(self::OPTION_STATE_FORMAT)
: __('%s - item %p/%c');
$map = array(
'%s' => $session->getCurrentAssessmentSection()->getTitle(),
'%p' => $session->getRoute()->getPosition(),
'%c' => $session->getRouteCount()
);
return strtr($format, $map);
} else {
return __('finished');
}
}
}
15 changes: 1 addition & 14 deletions models/classes/class.TestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/
class taoQtiTest_models_classes_TestModel implements taoTests_models_classes_TestModel, tao_models_classes_import_ImportProvider, tao_models_classes_export_ExportProvider
{

const CONFIG_QTITEST_FOLDER = 'qtiTestFolder';

/**
* default constructor to ensure the implementation
* can be instanciated
Expand Down Expand Up @@ -91,16 +88,6 @@ public function getAuthoringUrl( core_kernel_classes_Resource $test) {
return _url('index', 'Creator', 'taoQtiTest', array('uri' => $test->getUri()));
}

public static function setQtiTestDirectory(core_kernel_file_File $folder) {
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');
$ext->setConfig(self::CONFIG_QTITEST_FOLDER, $folder->getUri());
}

public static function getQtiTestDirectory() {
$service = taoQtiTest_models_classes_QtiTestService::singleton();
return $service->getQtiTestDirectory();
}

/**
* Clone a QTI Test Resource.
*
Expand Down Expand Up @@ -139,6 +126,6 @@ public function getCompilerClass() {


public function getPackerClass() {
return 'oat\\taoQtiTest\\model\\pack\\QtiTestPacker';
return 'oat\\taoQtiTest\\models\\pack\\QtiTestPacker';
}
}
19 changes: 9 additions & 10 deletions models/classes/event/QtiTestChangeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
namespace oat\taoQtiTest\models\event;

use oat\taoTests\models\event\TestChangedEvent;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use oat\taoQtiTest\models\SessionStateService;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
/**
*
*/
class QtiTestChangeEvent extends TestChangedEvent
class QtiTestChangeEvent extends TestChangedEvent implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;

private $session;

public function __construct(\taoQtiTest_helpers_TestSession $testSession)
Expand All @@ -40,13 +45,7 @@ public function getServiceCallId()

public function getNewStateDescription()
{
$pos = $this->session->getRoute()->getPosition();
$count = $this->session->getRouteCount();
if ($this->session->isRunning()) {
$section = $this->session->getCurrentAssessmentSection();
return __('%1$s - item %2$s/%3$s', $section->getTitle(), $pos+1, $count);
} else {
return __('finished');
}
}
$sessionService = $this->getServiceLocator()->get(SessionStateService::SERVICE_ID);
return $sessionService->getSessionDescription($this->session);
}
}
4 changes: 1 addition & 3 deletions models/classes/pack/QtiTestPacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ public function packTest(core_kernel_classes_Resource $test)
try {

$qtiTestService = taoQtiTest_models_classes_QtiTestService::singleton();
$itemService = taoItems_models_classes_ItemsService::singleton();


$doc = $qtiTestService->getDoc($test);
$converter = new \taoQtiTest_models_classes_QtiTestConverter($doc);
$itemPacker = new QtiItemPacker();
$items = array();
foreach($qtiTestService->getItems($test) as $item){
$items[$item->getUri()] = $itemPacker->packItem($item, $itemService->getItemFolder($item));
$items[$item->getUri()] = $itemPacker->packItem($item);
}
$testPack = new TestPack(self::$testType, $converter->toArray(), $items);
} catch(common_Exception $e){
Expand Down
47 changes: 47 additions & 0 deletions models/classes/runner/QtiRunnerClosedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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) 2016 (original work) Open Assessment Technologies SA ;
*/
/**
* @author Jean-Sébastien Conan <[email protected]>
*/

namespace oat\taoQtiTest\models\runner;

use qtism\runtime\tests\AssessmentTestSessionState;

class QtiRunnerClosedException extends \common_Exception implements \common_exception_UserReadableException
{
/**
* Create a new QtiRunnerClosedException object.
*
* @param string $message A technical infiormation message.
* @param integer $code A code to explicitely identify the nature of the error.
*/
public function __construct($message = 'The test has been terminated', $code = AssessmentTestSessionState::CLOSED) {
parent::__construct($message, $code);
}

/**
* Returns a translated human-readable message destinated to the end-user.
*
* @return string A human-readable message.
*/
public function getUserMessage() {
return __('This test has been terminated');
}
}
47 changes: 47 additions & 0 deletions models/classes/runner/QtiRunnerPausedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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) 2016 (original work) Open Assessment Technologies SA ;
*/
/**
* @author Jean-Sébastien Conan <[email protected]>
*/

namespace oat\taoQtiTest\models\runner;

use qtism\runtime\tests\AssessmentTestSessionState;

class QtiRunnerPausedException extends \common_Exception implements \common_exception_UserReadableException
{
/**
* Create a new QtiRunnerClosedException object.
*
* @param string $message A technical infiormation message.
* @param integer $code A code to explicitely identify the nature of the error.
*/
public function __construct($message = 'The test has been suspended', $code = AssessmentTestSessionState::SUSPENDED) {
parent::__construct($message, $code);
}

/**
* Returns a translated human-readable message destinated to the end-user.
*
* @return string A human-readable message.
*/
public function getUserMessage() {
return __('This test has been suspended');
}
}
Loading

0 comments on commit ebf8fde

Please sign in to comment.