protected function beforeAction() { // Controller initialization. $this->retrieveTestDefinition($this->getRequestParameter('QtiTestCompilation')); $resultServer = taoResultServer_models_classes_ResultServerStateFull::singleton(); // Initialize storage and test session. $testResource = new core_kernel_classes_Resource($this->getRequestParameter('QtiTestDefinition')); $sessionManager = new taoQtiTest_helpers_SessionManager($resultServer, $testResource); $userUri = common_session_SessionManager::getSession()->getUserUri(); $seeker = new BinaryAssessmentTestSeeker($this->getTestDefinition()); $this->setStorage(new taoQtiTest_helpers_TestSessionStorage($sessionManager, $seeker, $userUri)); $this->retrieveTestSession(); $this->retrieveTestMeta(); // Prevent anything to be cached by the client. taoQtiTest_helpers_TestRunnerUtils::noHttpClientCache(); $metaData = $this->getSessionMeta(); if (!empty($metaData)) { $this->getTestSessionMetaData()->save($metaData); } }
/** * Common stuff processessed on almost all actions. * If something goes wrong, print a report and return false, otherwise return true. * @param bool $notifyError Allow to print error message if needed * @return bool Returns a flag telling whether or not the action can be processed * @throws \oat\oatbox\service\ServiceNotFoundException * @throws common_exception_Error */ protected function beforeAction($notifyError = true) { // Controller initialization. $this->retrieveTestDefinition($this->getRequestParameter('QtiTestCompilation')); $resultServer = taoResultServer_models_classes_ResultServerStateFull::singleton(); // Initialize storage and test session. $testResource = new core_kernel_classes_Resource($this->getRequestParameter('QtiTestDefinition')); $sessionManager = new taoQtiTest_helpers_SessionManager($resultServer, $testResource); $userUri = common_session_SessionManager::getSession()->getUserUri(); $seeker = new BinaryAssessmentTestSeeker($this->getTestDefinition()); $this->setStorage(new taoQtiTest_helpers_TestSessionStorage($sessionManager, $seeker, $userUri)); $this->retrieveTestSession(); // @TODO: use some storage to get the potential reason of the state (close/suspended) $session = $this->getTestSession(); $state = $session->getState(); if ($state == AssessmentTestSessionState::CLOSED) { if ($notifyError) { $this->notifyError(__('This test has been terminated'), $state); } return false; } // @TODO: maybe use an option to enable this behavior if ($state == AssessmentTestSessionState::SUSPENDED) { if ($notifyError) { $this->notifyError(__('This test has been suspended'), $state); } return false; } $sessionStateService = $this->getServiceManager()->get('taoQtiTest/SessionStateService'); $sessionStateService->resumeSession($session); $this->retrieveTestMeta(); // Prevent anything to be cached by the client. taoQtiTest_helpers_TestRunnerUtils::noHttpClientCache(); $metaData = $this->getMetaDataHandler()->getData(); if (!empty($metaData)) { $this->getMetaDataHandler()->save($metaData); } return true; }
/** * taoQtiTest_actions_Runner constructor. */ public function __construct() { $this->runnerService = $this->getServiceManager()->get(QtiRunnerService::CONFIG_ID); // Prevent anything to be cached by the client. TestRunnerUtils::noHttpClientCache(); }