Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ResultItemVariableTransmissionTask | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| __invoke | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 | |||
| 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 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoQtiTest\models\classes\tasks\ResultTransmission; |
| 24 | |
| 25 | use oat\oatbox\reporting\Report; |
| 26 | use oat\tao\model\taskQueue\Task\TaskAwareInterface; |
| 27 | use oat\tao\model\taskQueue\Task\TaskAwareTrait; |
| 28 | use oat\taoQtiTest\models\classes\tasks\ResultTransmission\Exception\ResultTransmissionTaskValidationException; |
| 29 | use taoResultServer_models_classes_Variable; |
| 30 | |
| 31 | class ResultItemVariableTransmissionTask extends AbstractResultTransmissionTask implements TaskAwareInterface |
| 32 | { |
| 33 | use TaskAwareTrait; |
| 34 | |
| 35 | protected const REQUIRED_PARAMS = [ |
| 36 | self::EXECUTION_ID_PARAMETER_KEY, |
| 37 | self::VARIABLES_PARAMETER_KEY, |
| 38 | self::TRANSMISSION_ID_PARAMETER_KEY, |
| 39 | ]; |
| 40 | |
| 41 | public function __invoke($params): Report |
| 42 | { |
| 43 | try { |
| 44 | $this->validateParams($params); |
| 45 | } catch (ResultTransmissionTaskValidationException $e) { |
| 46 | $this->getLogger()->error($e->getMessage(), ['exception' => $e]); |
| 47 | return Report::createError($e->getMessage()); |
| 48 | } |
| 49 | |
| 50 | try { |
| 51 | $this->buildTransmitter($params[self::EXECUTION_ID_PARAMETER_KEY])->transmitItemVariable( |
| 52 | $this->unpackVariables($params[self::VARIABLES_PARAMETER_KEY]), |
| 53 | $params[self::TRANSMISSION_ID_PARAMETER_KEY], |
| 54 | $params[self::ITEM_URI_PARAMETER_KEY] ?? '', |
| 55 | $params[self::TEST_URI_PARAMETER_KEY] ?? '' |
| 56 | ); |
| 57 | } catch (\taoQtiCommon_helpers_ResultTransmissionException $e) { |
| 58 | $this->getLogger()->error($e->getMessage(), ['exception' => $e]); |
| 59 | return Report::createError("Result items variable transmission problem, check logs for details"); |
| 60 | } |
| 61 | |
| 62 | $this->getLogger()->info(sprintf( |
| 63 | 'Results item variable successfully transmitted for deliver execution - %s', |
| 64 | $params[self::EXECUTION_ID_PARAMETER_KEY] |
| 65 | )); |
| 66 | return Report::createSuccess("Result item transmission succeeded"); |
| 67 | } |
| 68 | } |