Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| TestRunnerMessageService | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
90 | |
0.00% |
0 / 1 |
| isProctorAction | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| getProctorPausedStateMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getProctorTerminatedStateMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPausedStateMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getTerminatedStateMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2017 (original work) Open Assessment Technologies SA ; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com> |
| 24 | */ |
| 25 | |
| 26 | namespace oat\taoProctoring\model\implementation; |
| 27 | |
| 28 | use oat\taoProctoring\model\ProctorService; |
| 29 | use oat\taoQtiTest\models\runner\QtiRunnerMessageService; |
| 30 | use qtism\runtime\tests\AssessmentTestSession; |
| 31 | |
| 32 | /** |
| 33 | * Class QtiRunnerMessageService |
| 34 | * |
| 35 | * Defines a service that will provide messages for the test runner |
| 36 | * |
| 37 | * @package oat\taoQtiTest\models |
| 38 | */ |
| 39 | class TestRunnerMessageService extends QtiRunnerMessageService |
| 40 | { |
| 41 | /** Proctor roles option in options. */ |
| 42 | public const PROCTOR_ROLES_OPTION = 'proctorRoles'; |
| 43 | |
| 44 | /** |
| 45 | * Returns TRUE when the current role is proctor like. |
| 46 | * |
| 47 | * @param AssessmentTestSession $testSession |
| 48 | * |
| 49 | * @return bool |
| 50 | * |
| 51 | * @throws \common_exception_Error |
| 52 | */ |
| 53 | protected function isProctorAction(AssessmentTestSession $testSession) |
| 54 | { |
| 55 | $userRoles = \common_session_SessionManager::getSession()->getUserRoles(); |
| 56 | $proctorRoles = $this->getOption(static::PROCTOR_ROLES_OPTION); |
| 57 | |
| 58 | foreach ($proctorRoles as $proctorRole) { |
| 59 | if (in_array($proctorRole, $userRoles)) { |
| 60 | return true; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Gets a message about the paused status of the assessment when a proctor is the sender |
| 69 | * @param AssessmentTestSession $testSession |
| 70 | * @return string |
| 71 | */ |
| 72 | protected function getProctorPausedStateMessage(AssessmentTestSession $testSession) |
| 73 | { |
| 74 | // phpcs:disable Generic.Files.LineLength |
| 75 | return __('The assessment has been suspended. To resume your assessment, please relaunch it and contact your proctor if required.'); |
| 76 | // phpcs:enable Generic.Files.LineLength |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Gets a message about the terminated status of the assessment when a proctor is the sender |
| 81 | * @param AssessmentTestSession $testSession |
| 82 | * @return string |
| 83 | */ |
| 84 | protected function getProctorTerminatedStateMessage(AssessmentTestSession $testSession) |
| 85 | { |
| 86 | // phpcs:disable Generic.Files.LineLength |
| 87 | return __('The assessment has been terminated. You cannot interact with it anymore. Please contact your proctor if required.'); |
| 88 | // phpcs:enable Generic.Files.LineLength |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Gets a message about the paused status of the assessment |
| 93 | * @param AssessmentTestSession $testSession |
| 94 | * @return string |
| 95 | */ |
| 96 | protected function getPausedStateMessage(AssessmentTestSession $testSession) |
| 97 | { |
| 98 | if ($this->isProctorAction($testSession)) { |
| 99 | return $this->getProctorPausedStateMessage($testSession); |
| 100 | } |
| 101 | |
| 102 | return parent::getPausedStateMessage($testSession); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Gets a message about the terminated status of the assessment |
| 107 | * @param AssessmentTestSession $testSession |
| 108 | * @return string |
| 109 | */ |
| 110 | protected function getTerminatedStateMessage(AssessmentTestSession $testSession) |
| 111 | { |
| 112 | if ($this->isProctorAction($testSession)) { |
| 113 | return $this->getProctorTerminatedStateMessage($testSession); |
| 114 | } |
| 115 | |
| 116 | return parent::getTerminatedStateMessage($testSession); |
| 117 | } |
| 118 | } |