*/ namespace oat\taoProctoring\model\implementation; use oat\taoProctoring\model\ProctorService; use oat\taoQtiTest\models\runner\QtiRunnerMessageService; use qtism\runtime\tests\AssessmentTestSession; /** * Class QtiRunnerMessageService * * Defines a service that will provide messages for the test runner * * @package oat\taoQtiTest\models */ class TestRunnerMessageService extends QtiRunnerMessageService { /** Proctor roles option in options. */ const PROCTOR_ROLES_OPTION = 'proctorRoles'; /** * Returns TRUE when the current role is proctor like. * * @param AssessmentTestSession $testSession * * @return bool * * @throws \common_exception_Error */ protected function isProctorAction(AssessmentTestSession $testSession) { $userRoles = \common_session_SessionManager::getSession()->getUserRoles(); $proctorRoles = $this->getOption(static::PROCTOR_ROLES_OPTION); foreach ($proctorRoles as $proctorRole) { if (in_array($proctorRole, $userRoles)) { return true; } } return false; } /** * Gets a message about the paused status of the assessment when a proctor is the sender * @param AssessmentTestSession $testSession * @return string */ protected function getProctorPausedStateMessage(AssessmentTestSession $testSession) { return __('The assessment has been suspended. To resume your assessment, please relaunch it and contact your proctor if required.'); } /** * Gets a message about the terminated status of the assessment when a proctor is the sender * @param AssessmentTestSession $testSession * @return string */ protected function getProctorTerminatedStateMessage(AssessmentTestSession $testSession) { return __('The assessment has been terminated. You cannot interact with it anymore. Please contact your proctor if required.'); } /** * Gets a message about the paused status of the assessment * @param AssessmentTestSession $testSession * @return string */ protected function getPausedStateMessage(AssessmentTestSession $testSession) { if ($this->isProctorAction($testSession)) { return $this->getProctorPausedStateMessage($testSession); } return parent::getPausedStateMessage($testSession); } /** * Gets a message about the terminated status of the assessment * @param AssessmentTestSession $testSession * @return string */ protected function getTerminatedStateMessage(AssessmentTestSession $testSession) { if ($this->isProctorAction($testSession)) { return $this->getProctorTerminatedStateMessage($testSession); } return parent::getTerminatedStateMessage($testSession); } }