Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ResultTransmissionEventHandler | |
0.00% |
0 / 14 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| transmitResultItemVariable | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| transmitResultTestVariable | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| buildTransmitter | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 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\eventHandler\ResultTransmissionEventHandler; |
| 24 | |
| 25 | use oat\oatbox\service\ServiceNotFoundException; |
| 26 | use oat\tao\model\service\InjectionAwareService; |
| 27 | use oat\taoDelivery\model\execution\DeliveryServerService; |
| 28 | use oat\taoQtiTest\models\classes\event\ResultTestVariablesTransmissionEvent; |
| 29 | use oat\taoQtiTest\models\event\ResultItemVariablesTransmissionEvent; |
| 30 | use taoQtiCommon_helpers_ResultTransmitter; |
| 31 | use oat\oatbox\service\exception\InvalidServiceManagerException; |
| 32 | |
| 33 | class ResultTransmissionEventHandler extends InjectionAwareService implements |
| 34 | Api\ResultTransmissionEventHandlerInterface |
| 35 | { |
| 36 | /** |
| 37 | * @throws \taoQtiCommon_helpers_ResultTransmissionException |
| 38 | */ |
| 39 | public function transmitResultItemVariable(ResultItemVariablesTransmissionEvent $event): void |
| 40 | { |
| 41 | $this->buildTransmitter($event->getDeliveryExecutionId())->transmitItemVariable( |
| 42 | $event->getVariables(), |
| 43 | $event->getTransmissionId(), |
| 44 | $event->getItemUri(), |
| 45 | $event->getTestUri() |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @param ResultTestVariablesTransmissionEvent $event |
| 51 | * @throws InvalidServiceManagerException |
| 52 | * @throws ServiceNotFoundException |
| 53 | * @throws \taoQtiCommon_helpers_ResultTransmissionException |
| 54 | */ |
| 55 | public function transmitResultTestVariable(ResultTestVariablesTransmissionEvent $event): void |
| 56 | { |
| 57 | $this->buildTransmitter($event->getDeliveryExecutionId())->transmitTestVariable( |
| 58 | $event->getVariables(), |
| 59 | $event->getTransmissionId(), |
| 60 | $event->getTestUri() |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @param $deliveryExecutionIdigcicd |
| 66 | * @return taoQtiCommon_helpers_ResultTransmitter |
| 67 | * @throws InvalidServiceManagerException |
| 68 | * @throws \oat\oatbox\service\ServiceNotFoundException |
| 69 | */ |
| 70 | private function buildTransmitter($deliveryExecutionId): taoQtiCommon_helpers_ResultTransmitter |
| 71 | { |
| 72 | /** @var DeliveryServerService $deliveryServerService */ |
| 73 | $deliveryServerService = $this->getServiceManager()->get(DeliveryServerService::SERVICE_ID); |
| 74 | $resultStore = $deliveryServerService->getResultStoreWrapper($deliveryExecutionId); |
| 75 | |
| 76 | return new taoQtiCommon_helpers_ResultTransmitter($resultStore); |
| 77 | } |
| 78 | } |