Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
20 / 20 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Skip | |
100.00% |
20 / 20 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
process | |
100.00% |
19 / 19 |
|
100.00% |
1 / 1 |
3 | |||
getRequiredFields | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
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\SkipCommand; |
29 | use oat\taoQtiTest\model\Service\SkipService; |
30 | use oat\taoQtiTest\models\runner\synchronisation\TestRunnerAction; |
31 | |
32 | class Skip extends TestRunnerAction |
33 | { |
34 | /** |
35 | * Process the skip action. |
36 | * |
37 | * Validate required fields. |
38 | * Stop timer. |
39 | * Wrap the skip to runner service. |
40 | * Start next timer. |
41 | * |
42 | * @throws common_Exception |
43 | * @throws common_exception_Error |
44 | * @throws common_exception_InconsistentData |
45 | */ |
46 | public function process(): array |
47 | { |
48 | $this->validate(); |
49 | |
50 | try { |
51 | if ($this->getRequestParameter('offline') === true) { |
52 | $this->setOffline(); |
53 | } |
54 | |
55 | $command = new SkipCommand( |
56 | $this->getServiceContext(), |
57 | $this->hasRequestParameter('start') |
58 | ); |
59 | |
60 | $this->setNavigationContextToCommand($command); |
61 | $this->setItemContextToCommand($command); |
62 | $this->setToolsStateContextToCommand($command); |
63 | |
64 | /** @var SkipService $skip */ |
65 | $skip = $this->getPsrContainer()->get(SkipService::class); |
66 | |
67 | $response = $skip($command); |
68 | |
69 | return $response->toArray(); |
70 | } catch (Exception $e) { |
71 | common_Logger::e( |
72 | $e->getMessage(), |
73 | ['deliveryExecutionId' => $this->getServiceContext()->getTestExecutionUri()] |
74 | ); |
75 | return $this->getErrorResponse($e); |
76 | } |
77 | } |
78 | |
79 | protected function getRequiredFields(): array |
80 | { |
81 | return array_merge(parent::getRequiredFields(), ['scope']); |
82 | } |
83 | } |