Skip to content

Commit

Permalink
Merge pull request #560 from oat-sa/release-5.8.2
Browse files Browse the repository at this point in the history
Release 5.8.2
  • Loading branch information
ssipasseuth authored Aug 26, 2016
2 parents a67d79a + d578ed1 commit e5bdbfa
Show file tree
Hide file tree
Showing 36 changed files with 2,342 additions and 792 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/.settings/
/.buildpath
composer.lock
/vendor/
/vendor/
55 changes: 34 additions & 21 deletions actions/class.Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* @author Jean-Sébastien Conan <[email protected]>
*/

use oat\taoQtiTest\models\runner\QtiRunnerRequiredException;
use oat\taoQtiTest\models\runner\QtiRunnerService;
use oat\taoQtiTest\models\runner\QtiRunnerServiceContext;
use oat\taoQtiTest\models\runner\QtiRunnerClosedException;
Expand All @@ -29,6 +28,7 @@
use oat\taoQtiTest\models\event\TraceVariableStored;
use \oat\taoTests\models\runner\CsrfToken;
use \oat\taoQtiTest\models\runner\session\TestCsrfToken;
use taoQtiTest_helpers_TestRunnerUtils as TestRunnerUtils;


/**
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct()
$this->runnerService = $this->getServiceManager()->get(QtiRunnerService::CONFIG_ID);

// Prevent anything to be cached by the client.
taoQtiTest_helpers_TestRunnerUtils::noHttpClientCache();
TestRunnerUtils::noHttpClientCache();
}

/**
Expand Down Expand Up @@ -441,6 +441,7 @@ public function submitItem()

$state = isset($data['itemState']) ? $data['itemState'] : new stdClass();
$itemResponse = isset($data['itemResponse']) ? $data['itemResponse'] : [];
$emptyAllowed = isset($data['emptyAllowed']) ? $data['emptyAllowed'] : false;

try {
$serviceContext = $this->getServiceContext(false);
Expand All @@ -455,29 +456,40 @@ public function submitItem()
// do not allow to store the response if the session is in a wrong state
$this->runnerService->check($serviceContext);

$successResponse = $this->runnerService->storeItemResponse($serviceContext, $itemRef, $itemResponse);
$displayFeedback = $this->runnerService->displayFeedbacks($serviceContext);
$responses = $this->runnerService->parsesItemResponse($serviceContext, $itemRef, $itemResponse);

$response = [
'success' => $successState && $successResponse,
'displayFeedbacks' => $displayFeedback,
];

if ($displayFeedback == true) {
//FIXME there is here a performance issue, at the end we need the defitions only once, not at each storage
$response['feedbacks'] = $this->runnerService->getFeedbacks($serviceContext, $itemRef);
$response['itemSession'] = $this->runnerService->getItemSession($serviceContext);
$allowed = true;
$session = $serviceContext->getTestSession();
if (!$emptyAllowed && !TestRunnerUtils::doesAllowSkipping($session) &&
$this->runnerService->getTestConfig()->getConfigValue('enableAllowSkipping')) {
$allowed = !$this->runnerService->emptyResponse($serviceContext, $responses);
}

if ($allowed) {
$successResponse = $this->runnerService->storeItemResponse($serviceContext, $itemRef, $responses);
$displayFeedback = $this->runnerService->displayFeedbacks($serviceContext);

$this->runnerService->persist($serviceContext);
$response = [
'success' => $successState && $successResponse,
'displayFeedbacks' => $displayFeedback,
];

} catch (QtiRunnerRequiredException $e) {
// we need to restart timer
$this->runnerService->startTimer($this->getServiceContext());
if ($displayFeedback == true) {
//FIXME there is here a performance issue, at the end we need the defitions only once, not at each storage
$response['feedbacks'] = $this->runnerService->getFeedbacks($serviceContext, $itemRef);
$response['itemSession'] = $this->runnerService->getItemSession($serviceContext);
}

$this->runnerService->persist($serviceContext);
} else {
$this->runnerService->startTimer($serviceContext);
$response = [
'success' => true,
'notAllowed' => true,
'message' => __('You must answer the question before leaving this item!'),
];
}

$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);

} catch (common_Exception $e) {
$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);
Expand All @@ -499,6 +511,7 @@ public function move()

try {
$serviceContext = $this->getServiceContext();
$serviceContext->getTestSession()->initItemTimer();
$result = $this->runnerService->move($serviceContext, $direction, $scope, $ref);

$response = [
Expand Down Expand Up @@ -709,7 +722,7 @@ public function flagItem()
$flag = true;
}

taoQtiTest_helpers_TestRunnerUtils::setItemFlag($testSession, $itemPosition, $flag);
TestRunnerUtils::setItemFlag($testSession, $itemPosition, $flag);

$response = [
'success' => true,
Expand Down
26 changes: 25 additions & 1 deletion config/default/testRunner.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,29 @@
* Enable Allow/Disallow Skipping feature.
* @type boolean
*/
'enable-allow-skipping' => false
'enable-allow-skipping' => false,

/*
* Force branch rules to be executed even if the current navigation mode is non-linear.
* @type boolean
*/
'force-branchrules' => false,

/*
* Force preconditions to be executed even if the current navigation mode is non-linear.
* @type boolean
*/
'force-preconditions' => false,

/**
* Enable path tracking (consider taken route items, rather than default route item flow for navigation).
* @type boolean
*/
'path-tracking' => false,

/**
* Always allow jumps, even if the current navigation mode is linear.
* @type boolean
*/
'always-allow-jumps' => false
);
17 changes: 16 additions & 1 deletion helpers/class.SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,28 @@ public function getTest() {
*/
protected function instantiateAssessmentTestSession(AssessmentTest $test, Route $route) {
$config = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('testRunner');

// Test Session class instantiation, depending on configuration.
if (!isset($config) || !isset($config['test-session'])) {
$className = self::DEFAULT_TEST_SESSION;
\common_Logger::w("Missing configuration for TestRunner session class, using '${className}' by default!");
} else {
$className = $config['test-session'];
}
return new $className($test, $this, $route, $this->getResultServer(), $this->getTest());

$assessmentTestSession = new $className($test, $this, $route, $this->getResultServer(), $this->getTest());

$forceBranchrules = (isset($config['force-branchrules'])) ? $config['force-branchrules'] : false;
$forcePreconditions = (isset($config['force-preconditions'])) ? $config['force-preconditions'] : false;
$pathTracking = (isset($config['path-tracking'])) ? $config['path-tracking'] : false;
$alwaysAllowJumps = (isset($config['always-allow-jumps'])) ? $config['always-allow-jumps'] : false;

$assessmentTestSession->setForceBranching($forceBranchrules);
$assessmentTestSession->setForcePreconditions($forcePreconditions);
$assessmentTestSession->setAlwaysAllowJumps($alwaysAllowJumps);
$assessmentTestSession->setPathTracking($pathTracking);

return $assessmentTestSession;
}

/**
Expand Down
Binary file modified install/local/qtiv2p1Examples.zip
Binary file not shown.
Empty file modified locales/de-DE/aclrole.rdf
100644 → 100755
Empty file.
Loading

0 comments on commit e5bdbfa

Please sign in to comment.