Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Lti1p3ResultServerServiceFactory | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| create | |
0.00% |
0 / 9 |
|
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 (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | declare(strict_types=1); |
| 23 | |
| 24 | namespace oat\ltiDeliveryProvider\model\execution; |
| 25 | |
| 26 | use common_session_SessionManager; |
| 27 | use oat\oatbox\service\ConfigurableService; |
| 28 | use oat\oatbox\service\ServiceManager; |
| 29 | use oat\taoDelivery\model\execution\ResultServerServiceFactoryInterface; |
| 30 | use oat\taoLti\models\classes\LtiRoles; |
| 31 | use oat\taoResultServer\models\classes\NoResultStorage; |
| 32 | use oat\taoResultServer\models\classes\ResultServerService; |
| 33 | use oat\taoResultServer\models\classes\implementation\ResultServerService as ResultServerServiceImplementation; |
| 34 | |
| 35 | class Lti1p3ResultServerServiceFactory extends ConfigurableService implements ResultServerServiceFactoryInterface |
| 36 | { |
| 37 | public function __construct() |
| 38 | { |
| 39 | $serviceManager = ServiceManager::getServiceManager(); |
| 40 | |
| 41 | $this->setServiceManager($serviceManager); |
| 42 | } |
| 43 | |
| 44 | public function create(): ResultServerService |
| 45 | { |
| 46 | $session = common_session_SessionManager::getSession(); |
| 47 | |
| 48 | $isDryRun = $session && in_array(LtiRoles::CONTEXT_LTI1P3_INSTRUCTOR, $session->getUser()->getRoles()); |
| 49 | |
| 50 | if ($isDryRun) { |
| 51 | $service = new ResultServerServiceImplementation([ |
| 52 | ResultServerServiceImplementation::OPTION_RESULT_STORAGE => NoResultStorage::class |
| 53 | ]); |
| 54 | |
| 55 | $this->propagate($service); |
| 56 | |
| 57 | return $service; |
| 58 | } |
| 59 | |
| 60 | return $this->getServiceLocator()->get(ResultServerService::SERVICE_ID); |
| 61 | } |
| 62 | } |