Skip to content

Commit

Permalink
Merge branch 'release-48.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 4, 2023
2 parents 45e87f2 + 6c864f1 commit c68ace7
Show file tree
Hide file tree
Showing 149 changed files with 3,571 additions and 583 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ Environment variables
| Var | Description |
|-----------------------------------------------|-------------------------------------------------------------------------------------|
| FEATURE_FLAG_FORCE_DISPLAY_TEST_ITEM_FEEDBACK | Even if itemSessionControl `showFeedback` option is false, show item feedback modal |
| FEATURE_FLAG_PAUSE_CONCURRENT_SESSIONS | When set, forces restoring the timers state from the browser storage on test init |
55 changes: 42 additions & 13 deletions actions/class.Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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) 2016-2020 (original work) Open Assessment Technologies SA ;
* Copyright (c) 2016-2023 (original work) Open Assessment Technologies SA.
*/

/**
Expand All @@ -25,10 +25,10 @@
*/

use oat\libCat\exception\CatEngineConnectivityException;
use oat\tao\model\routing\AnnotationReader\security;
use oat\taoDelivery\model\execution\DeliveryExecutionInterface;
use oat\taoDelivery\model\execution\DeliveryExecutionService;
use oat\taoDelivery\model\RuntimeService;
use oat\taoQtiTest\model\Service\ConcurringSessionService;
use oat\taoQtiTest\model\Service\ExitTestCommand;
use oat\taoQtiTest\model\Service\ExitTestService;
use oat\taoQtiTest\model\Service\ItemContextAwareInterface;
Expand Down Expand Up @@ -59,6 +59,7 @@
use oat\taoQtiTest\models\runner\QtiRunnerServiceContext;
use oat\taoQtiTest\models\runner\RunnerToolStates;
use oat\taoQtiTest\models\runner\StorageManager;
use qtism\runtime\tests\AssessmentTestSessionState;
use taoQtiTest_helpers_TestRunnerUtils as TestRunnerUtils;
use oat\oatbox\session\SessionService;

Expand Down Expand Up @@ -143,7 +144,7 @@ protected function getSessionId()
/**
* Gets the test service context
* @return QtiRunnerServiceContext
* @throws \common_Exception
* @throws common_Exception
*/
protected function getServiceContext()
{
Expand All @@ -168,6 +169,7 @@ protected function getServiceContext()
}
$testDefinition = $container->getSourceTest($execution);
$testCompilation = $container->getPrivateDirId($execution) . '|' . $container->getPublicDirId($execution);

$this->serviceContext = $this->getRunnerService()->getServiceContext(
$testDefinition,
$testCompilation,
Expand Down Expand Up @@ -295,7 +297,6 @@ public function init()
$this->validateSecurityToken();

try {
/** @var QtiRunnerServiceContext $serviceContext */
$serviceContext = $this->getRunnerService()->initServiceContext($this->getServiceContext());
$this->returnJson($this->getInitResponse($serviceContext));
} catch (Exception $e) {
Expand Down Expand Up @@ -492,7 +493,7 @@ protected function getItemData($itemIdentifier)
* Save the actual item state.
* Requires params itemIdentifier and itemState
* @return boolean true if saved
* @throws \common_Exception
* @throws common_Exception
*/
protected function saveItemState()
{
Expand All @@ -509,7 +510,7 @@ protected function saveItemState()
* End the item timer and save the duration
* Requires params itemDuration and optionaly consumedExtraTime
* @return boolean true if saved
* @throws \common_Exception
* @throws common_Exception
*/
protected function endItemTimer()
{
Expand All @@ -526,7 +527,7 @@ protected function endItemTimer()
* Requires params itemDuration and optionally consumedExtraTime
* @param boolean $emptyAllowed if we allow empty responses
* @return boolean true if saved
* @throws \common_Exception
* @throws common_Exception
* @throws QtiRunnerEmptyResponsesException if responses are empty, emptyAllowed is false and no allowSkipping
*/
protected function saveItemResponses($emptyAllowed = true)
Expand Down Expand Up @@ -618,6 +619,9 @@ public function submitItem()

/**
* Moves the current position to the provided scoped reference: item, section, part
*
* This action is called when the user sends a test response, but not when
* the test starts.
*/
public function move()
{
Expand All @@ -638,10 +642,10 @@ public function move()

$response = $moveService($moveCommand);

common_Logger::d('Test session state : ' . $this->getServiceContext()->getTestSession()->getState());

$this->returnJson($response->toArray());
} catch (common_Exception $e) {
$this->checkExceptionForTestSessionConflict($e);

$this->returnJson(
$this->getErrorResponse($e),
$this->getStatusCodeFromException($e)
Expand Down Expand Up @@ -673,6 +677,8 @@ public function skip()

$this->returnJson($response->toArray());
} catch (common_Exception $e) {
$this->checkExceptionForTestSessionConflict($e);

$this->returnJson(
$this->getErrorResponse($e),
$this->getStatusCodeFromException($e)
Expand Down Expand Up @@ -706,6 +712,8 @@ public function timeout()

$this->returnJson($response->toArray());
} catch (common_Exception $e) {
$this->checkExceptionForTestSessionConflict($e);

$this->returnJson(
$this->getErrorResponse($e),
$this->getStatusCodeFromException($e)
Expand Down Expand Up @@ -771,10 +779,7 @@ public function pause()

$this->setItemContextToCommand($command);

/** @var PauseService $pause */
$pause = $this->getPsrContainer()->get(PauseService::class);

$response = $pause($command);
$response = $this->getPauseService()($command);

$this->returnJson($response->toArray());
} catch (common_Exception $e) {
Expand Down Expand Up @@ -1102,6 +1107,11 @@ private function getRuntimeService(): RuntimeService
return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID);
}

private function getPauseService(): PauseService
{
return $this->getPsrContainer()->get(PauseService::class);
}

private function getItemDuration(): ?float
{
if (!$this->hasRequestParameter('itemDuration')) {
Expand Down Expand Up @@ -1168,4 +1178,23 @@ private function createErrorResponseFromException(Exception $exception): void
$this->getStatusCodeFromException($exception)
);
}

private function checkExceptionForTestSessionConflict($exception): void
{
if (!$exception instanceof common_exception_Unauthorized) {
return;
}

try {
if ($this->getServiceContext()->getTestSession()->getState() === AssessmentTestSessionState::INTERACTING) {
$this->getConcurringSessionService()->setConcurringSession($this->getSessionId());
}
} catch (common_Exception $exception) {
}
}

private function getConcurringSessionService(): ConcurringSessionService
{
return $this->getPsrContainer()->get(ConcurringSessionService::class);
}
}
Loading

0 comments on commit c68ace7

Please sign in to comment.