Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| taoItems_actions_ItemRunner | |
0.00% |
0 / 24 |
|
0.00% |
0 / 4 |
90 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
42 | |||
| selectView | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getResultServerEndpoint | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getResultServerParams | |
0.00% |
0 / 1 |
|
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-2018 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | use oat\tao\model\state\StateStorage; |
| 23 | |
| 24 | /** |
| 25 | * This module runs the items |
| 26 | * |
| 27 | * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu} |
| 28 | * @package taoItems |
| 29 | |
| 30 | */ |
| 31 | class taoItems_actions_ItemRunner extends tao_actions_ServiceModule |
| 32 | { |
| 33 | public function index() |
| 34 | { |
| 35 | $userId = $this->getSession()->getUserUri(); |
| 36 | if (is_null($userId)) { |
| 37 | throw new common_exception_Error('No user is logged in'); |
| 38 | } |
| 39 | $lang = $this->getSession()->getDataLanguage(); |
| 40 | |
| 41 | if ($this->hasRequestParameter('serviceCallId')) { |
| 42 | $serviceCallId = $this->getRequestParameter('serviceCallId'); |
| 43 | $variableData = $this->getServiceLocator()->get(StateStorage::SERVICE_ID)->get($userId, $serviceCallId); |
| 44 | $this->setData('storageData', [ |
| 45 | 'serial' => $serviceCallId, |
| 46 | 'data' => is_null($variableData) ? [] : $variableData |
| 47 | ]); |
| 48 | } |
| 49 | |
| 50 | $directory = $this->getDirectory($this->getRequestParameter('itemPath')); |
| 51 | |
| 52 | if (!$directory->has($lang) && $directory->has(DEFAULT_LANG)) { |
| 53 | $lang = DEFAULT_LANG; |
| 54 | } |
| 55 | |
| 56 | $this->setData('itemPath', $directory->getPublicAccessUrl() . $lang . '/index.html'); |
| 57 | $this->setData('itemId', $this->getRequestParameter('itemUri')); |
| 58 | $this->setData('resultServerEndpoint', $this->getResultServerEndpoint()); |
| 59 | $this->setData('resultServerParams', $this->getResultServerParams()); |
| 60 | $this->setData('client_timeout', $this->getClientTimeout()); |
| 61 | $this->setData('client_config_url', $this->getClientConfigUrl()); |
| 62 | |
| 63 | $this->selectView(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * The implementation of this method calls ItemRunner::setView in order to |
| 68 | * select the view to be displayed. |
| 69 | */ |
| 70 | protected function selectView() |
| 71 | { |
| 72 | $this->setView('runtime/item_runner.tpl', 'taoItems'); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get the URL of the result server |
| 77 | * @return string |
| 78 | */ |
| 79 | protected function getResultServerEndpoint() |
| 80 | { |
| 81 | return _url('', 'ResultServerStateFull', 'taoResultServer'); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Get extra parameters to give the result server |
| 86 | * @return array an assoc array of additional parameters |
| 87 | */ |
| 88 | protected function getResultServerParams() |
| 89 | { |
| 90 | return []; |
| 91 | } |
| 92 | } |