*/ namespace oat\taoQtiTest\models\runner; use oat\oatbox\service\ConfigurableService; use qtism\runtime\tests\AssessmentTestSession; use qtism\runtime\tests\AssessmentTestSessionState; /** * Class QtiRunnerMessageService * * Defines a service that will provide messages for the test runner * * @package oat\taoQtiTest\models */ class QtiRunnerMessageService extends ConfigurableService implements RunnerMessageService { const SERVICE_ID = 'taoQtiTest/QtiRunnerMessageService'; /** * Gets a message related to the state of the assessment test session * @param mixed $testSession * @return string * @throws \common_exception_InvalidArgumentType */ public function getStateMessage($testSession) { if ($testSession instanceof AssessmentTestSession) { switch ($testSession->getState()) { case AssessmentTestSessionState::SUSPENDED: return $this->getPausedStateMessage($testSession); case AssessmentTestSessionState::CLOSED: return $this->getTerminatedStateMessage($testSession); case AssessmentTestSessionState::INITIAL: return $this->getInitialStateMessage($testSession); default: return $this->getRunningStateMessages($testSession); } } else { throw new \common_exception_InvalidArgumentType( 'QtiRunnerMessageService', 'getStateMessage', 0, 'qtism\runtime\tests\AssessmentTestSession', $testSession ); } } /** * Gets a message about the paused status of the assessment * @param AssessmentTestSession $testSession * @return string */ protected function getPausedStateMessage(AssessmentTestSession $testSession) { return __('The assessment has been suspended. To resume your assessment, please relaunch it.'); } /** * Gets a message about the terminated status of the assessment * @param AssessmentTestSession $testSession * @return string */ protected function getTerminatedStateMessage(AssessmentTestSession $testSession) { return __('The assessment has been terminated. You cannot interact with it anymore.'); } /** * Gets a message about the initial status of the assessment * @param AssessmentTestSession $testSession * @return string */ protected function getInitialStateMessage(AssessmentTestSession $testSession) { return __('The assessment has been created but is not already running.'); } /** * Gets a message about the running status of the assessment * @param AssessmentTestSession $testSession * @return string */ protected function getRunningStateMessages(AssessmentTestSession $testSession) { return __('The assessment is still running.'); } }