Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| LtiOutcomeService | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
| deferTransmit | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |||
| 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 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\ltiDeliveryProvider\model; |
| 23 | |
| 24 | use common_session_SessionManager; |
| 25 | use oat\ltiDeliveryProvider\model\tasks\SendLtiOutcomeTask; |
| 26 | use oat\oatbox\service\ConfigurableService; |
| 27 | use oat\tao\model\taskQueue\QueueDispatcherInterface; |
| 28 | use oat\taoDelivery\model\execution\DeliveryExecutionInterface; |
| 29 | use oat\taoDelivery\models\classes\execution\event\DeliveryExecutionState; |
| 30 | use oat\taoLti\models\classes\LtiService; |
| 31 | use oat\taoLti\models\classes\TaoLtiSession; |
| 32 | |
| 33 | class LtiOutcomeService extends ConfigurableService |
| 34 | { |
| 35 | public const SERVICE_ID = 'ltiDeliveryProvider/LtiOutcome'; |
| 36 | |
| 37 | /** |
| 38 | * @param DeliveryExecutionState $event |
| 39 | * @throws \common_exception_Error |
| 40 | * @throws \common_exception_NotFound |
| 41 | * @throws \oat\taoLti\models\classes\LtiException |
| 42 | * @throws \oat\taoLti\models\classes\LtiVariableMissingException |
| 43 | */ |
| 44 | public function deferTransmit(DeliveryExecutionState $event) |
| 45 | { |
| 46 | if ( |
| 47 | DeliveryExecutionInterface::STATE_FINISHIED === $event->getState() |
| 48 | && DeliveryExecutionInterface::STATE_FINISHIED !== $event->getPreviousState() |
| 49 | && common_session_SessionManager::getSession() instanceof TaoLtiSession |
| 50 | ) { |
| 51 | |
| 52 | /** @var QueueDispatcherInterface $taskQueue */ |
| 53 | $taskQueue = $this->getServiceLocator()->get(QueueDispatcherInterface::SERVICE_ID); |
| 54 | $launchData = LtiService::singleton()->getLtiSession()->getLaunchData(); |
| 55 | if ($launchData->hasVariable('lis_outcome_service_url')) { |
| 56 | $params['deliveryResultIdentifier'] = $event->getDeliveryExecution()->getIdentifier(); |
| 57 | $params['consumerKey'] = $launchData->getOauthKey(); |
| 58 | $params['serviceUrl'] = $launchData->getVariable('lis_outcome_service_url'); |
| 59 | $taskQueue->createTask(new SendLtiOutcomeTask(), $params, 'Submit LTI results'); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |