Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| QtiToolsStateRepository | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| save | |
0.00% |
0 / 10 |
|
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) 2021 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * @author Ricardo Quintanilha <ricardo.quintanilha@taotesting.com> |
| 21 | */ |
| 22 | |
| 23 | declare(strict_types=1); |
| 24 | |
| 25 | namespace oat\taoQtiTest\model\Infrastructure; |
| 26 | |
| 27 | use oat\taoQtiTest\model\Domain\Model\ToolsState; |
| 28 | use oat\taoQtiTest\model\Domain\Model\ToolsStateRepositoryInterface; |
| 29 | use oat\taoQtiTest\models\runner\QtiRunnerService; |
| 30 | use oat\taoQtiTest\models\runner\RunnerServiceContext; |
| 31 | |
| 32 | class QtiToolsStateRepository implements ToolsStateRepositoryInterface |
| 33 | { |
| 34 | /** @var QtiRunnerService */ |
| 35 | private $runnerService; |
| 36 | |
| 37 | public function __construct(QtiRunnerService $runnerService) |
| 38 | { |
| 39 | $this->runnerService = $runnerService; |
| 40 | } |
| 41 | |
| 42 | public function save(ToolsState $toolsState, RunnerServiceContext $serviceContext): void |
| 43 | { |
| 44 | if (empty($toolsState->getStates())) { |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | $toolStates = $toolsState->getStates(); |
| 49 | |
| 50 | array_walk( |
| 51 | $toolStates, |
| 52 | function (&$toolState) { |
| 53 | $toolState = json_encode($toolState); |
| 54 | } |
| 55 | ); |
| 56 | |
| 57 | $this->runnerService->setToolsStates($serviceContext, $toolStates); |
| 58 | } |
| 59 | } |