Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
LtiLaunchDataService | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
findDeliveryFromLaunchData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
findDeliveryExecutionFromLaunchData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
findResource | |
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 (original work) Open Assessment Technologies SA; |
19 | * |
20 | */ |
21 | |
22 | namespace oat\ltiDeliveryProvider\model; |
23 | |
24 | use core_kernel_classes_Container; |
25 | use core_kernel_classes_Resource; |
26 | use oat\oatbox\service\ConfigurableService; |
27 | use oat\taoLti\models\classes\LtiLaunchData; |
28 | use RuntimeException; |
29 | |
30 | /** |
31 | * @package oat\ltiDeliveryProvider\model |
32 | * @author Aleksej Tikhanovich, <aleksej@taotesting.com> |
33 | */ |
34 | class LtiLaunchDataService extends ConfigurableService |
35 | { |
36 | public const SERVICE_ID = 'ltiDeliveryProvider/LtiLaunchData'; |
37 | |
38 | /** |
39 | * @param LtiLaunchData $launchData |
40 | * @return core_kernel_classes_Resource |
41 | */ |
42 | public function findDeliveryFromLaunchData(LtiLaunchData $launchData) |
43 | { |
44 | return $this->findResource($launchData->getCustomParameter('delivery')); |
45 | } |
46 | |
47 | /** |
48 | * @param LtiLaunchData $launchData |
49 | * |
50 | * @return core_kernel_classes_Container|core_kernel_classes_Resource |
51 | */ |
52 | public function findDeliveryExecutionFromLaunchData(LtiLaunchData $launchData) |
53 | { |
54 | return $this->findResource($launchData->getCustomParameter('execution')); |
55 | } |
56 | |
57 | /** |
58 | * @param $uri |
59 | * |
60 | * @return core_kernel_classes_Container|core_kernel_classes_Resource |
61 | */ |
62 | private function findResource($uri) |
63 | { |
64 | return $this->getServiceLocator()->get(LtiDeliveryFactory::SERVICE_ID)->create($uri); |
65 | } |
66 | } |