Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
92.86% |
13 / 14 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Pause | |
92.86% |
13 / 14 |
|
0.00% |
0 / 1 |
3.00 | |
0.00% |
0 / 1 |
| process | |
92.86% |
13 / 14 |
|
0.00% |
0 / 1 |
3.00 | |||
| 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-2022 (original work) Open Assessment Technologies SA ; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoQtiTest\models\runner\synchronisation\action; |
| 22 | |
| 23 | use common_Exception; |
| 24 | use common_exception_Error; |
| 25 | use common_exception_InconsistentData; |
| 26 | use common_Logger; |
| 27 | use Exception; |
| 28 | use oat\taoQtiTest\model\Service\PauseCommand; |
| 29 | use oat\taoQtiTest\model\Service\PauseService; |
| 30 | use oat\taoQtiTest\models\runner\synchronisation\TestRunnerAction; |
| 31 | |
| 32 | class Pause extends TestRunnerAction |
| 33 | { |
| 34 | /** |
| 35 | * Process the pause action. |
| 36 | * |
| 37 | * @throws common_Exception |
| 38 | * @throws common_exception_Error |
| 39 | * @throws common_exception_InconsistentData |
| 40 | */ |
| 41 | public function process(): array |
| 42 | { |
| 43 | $this->validate(); |
| 44 | |
| 45 | try { |
| 46 | if ($this->getRequestParameter('offline') === true) { |
| 47 | $this->setOffline(); |
| 48 | } |
| 49 | |
| 50 | $command = new PauseCommand($this->getServiceContext()); |
| 51 | |
| 52 | $this->setItemContextToCommand($command); |
| 53 | |
| 54 | /** @var PauseService $pause */ |
| 55 | $pause = $this->getPsrContainer()->get(PauseService::class); |
| 56 | |
| 57 | $response = $pause($command); |
| 58 | |
| 59 | return $response->toArray(); |
| 60 | } catch (Exception $e) { |
| 61 | common_Logger::e( |
| 62 | $e->getMessage(), |
| 63 | ['deliveryExecutionId' => $this->getServiceContext()->getTestExecutionUri()] |
| 64 | ); |
| 65 | return $this->getErrorResponse($e); |
| 66 | } |
| 67 | } |
| 68 | } |