Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_ServiceJavascripts | |
0.00% |
0 / 27 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| getServiceStorage | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| getUserInfoService | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getServiceApi | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| getFinishedSniplet | |
0.00% |
0 / 5 |
|
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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | use oat\oatbox\service\ServiceManager; |
| 23 | |
| 24 | /** |
| 25 | * @access public |
| 26 | * @package tao |
| 27 | |
| 28 | */ |
| 29 | class tao_helpers_ServiceJavascripts |
| 30 | { |
| 31 | public static function getServiceStorage($serviceCallId) |
| 32 | { |
| 33 | $serviceService = ServiceManager::getServiceManager()->get('tao/stateStorage'); |
| 34 | |
| 35 | $state = $serviceService->get( |
| 36 | common_session_SessionManager::getSession()->getUserUri(), |
| 37 | $serviceCallId |
| 38 | ); |
| 39 | $submitUrl = _url('submitState', 'ServiceModule', 'tao', ['serviceCallId' => $serviceCallId]); |
| 40 | return 'new StateStorage(' . tao_helpers_Javascript::buildObject($state) . ', ' |
| 41 | . tao_helpers_Javascript::buildObject($submitUrl) . ')'; |
| 42 | } |
| 43 | |
| 44 | public static function getUserInfoService() |
| 45 | { |
| 46 | $preloaded = []; |
| 47 | $requestUrl = _url('getUserPropertyValues', 'ServiceModule', 'tao'); |
| 48 | return 'new UserInfoService(' . tao_helpers_Javascript::buildObject($requestUrl) . ',' |
| 49 | . tao_helpers_Javascript::buildObject($preloaded) . ')'; |
| 50 | } |
| 51 | |
| 52 | public static function getServiceApi( |
| 53 | tao_models_classes_service_ServiceCall $serviceCall, |
| 54 | $serviceCallId, |
| 55 | $customParams = [] |
| 56 | ) { |
| 57 | $inputParameters = tao_models_classes_service_ServiceCallHelper::getInputValues($serviceCall, $customParams); |
| 58 | $inputParameters['standalone'] = true; |
| 59 | return 'new ServiceApi(' |
| 60 | . tao_helpers_Javascript::buildObject( |
| 61 | tao_models_classes_service_ServiceCallHelper::getBaseUrl($serviceCall->getServiceDefinitionId()) |
| 62 | ) |
| 63 | . ',' . tao_helpers_Javascript::buildObject($inputParameters) |
| 64 | . ',' . tao_helpers_Javascript::buildObject($serviceCallId) |
| 65 | . ',' . self::getServiceStorage($serviceCallId) . ',' . ')'; |
| 66 | } |
| 67 | |
| 68 | public static function getFinishedSniplet() |
| 69 | { |
| 70 | $taoExt = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); |
| 71 | $tpl = $taoExt->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'snippet' |
| 72 | . DIRECTORY_SEPARATOR . 'finishService.tpl'; |
| 73 | $renderer = new Renderer($tpl); |
| 74 | return $renderer->render(); |
| 75 | } |
| 76 | } |