Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| IMSPciDataObject | |
0.00% |
0 / 30 |
|
0.00% |
0 / 6 |
272 | |
0.00% |
0 / 1 |
| getRegistrationSourcePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRegistrationFileId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isRegistrableFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRegistrationExcludedKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRuntimePath | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
110 | |||
| getRuntimeAliases | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 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\qtiItemPci\model\portableElement\dataObject; |
| 23 | |
| 24 | class IMSPciDataObject extends PciDataObject |
| 25 | { |
| 26 | /** |
| 27 | * Get the registration path of the source within a standard QTI package |
| 28 | * @param $packagePath - absolute path to the root of the item package |
| 29 | * @param $itemPath - absolute path to the root of the item folder |
| 30 | * @return string |
| 31 | */ |
| 32 | public function getRegistrationSourcePath($packagePath, $itemPath) |
| 33 | { |
| 34 | return $packagePath . DIRECTORY_SEPARATOR; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get the registration file entry |
| 39 | * @param $file - the relative path to the file |
| 40 | * @return string |
| 41 | */ |
| 42 | public function getRegistrationFileId($file) |
| 43 | { |
| 44 | //use it as it is without changes |
| 45 | return $file; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Check the given file entry should be registered or not |
| 50 | * @param $file |
| 51 | * @return bool |
| 52 | */ |
| 53 | public function isRegistrableFile($file) |
| 54 | { |
| 55 | //register all files for now |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get the array of key in the portable element model that should not be registered as files |
| 61 | * @return array |
| 62 | */ |
| 63 | public function getRegistrationExcludedKey() |
| 64 | { |
| 65 | //per standard the waitSeconds is an integer so should not be registered as a file |
| 66 | return ['waitSeconds']; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Return runtime files with relative path |
| 71 | * |
| 72 | * @return array |
| 73 | */ |
| 74 | public function getRuntimePath() |
| 75 | { |
| 76 | $paths = []; |
| 77 | |
| 78 | $runtimeManifest = $this->getRuntime(); |
| 79 | if (isset($runtimeManifest['src'])) { |
| 80 | $paths['src'] = preg_replace('/^' . $this->getTypeIdentifier() . '/', '.', $runtimeManifest['src']); |
| 81 | } |
| 82 | |
| 83 | $modules = []; |
| 84 | if (isset($runtimeManifest['modules'])) { |
| 85 | foreach ($runtimeManifest['modules'] as $module) { |
| 86 | //merge all module declaration as numeric array |
| 87 | $modules = array_merge($modules, array_values($module)); |
| 88 | } |
| 89 | } |
| 90 | if (isset($runtimeManifest['config'])) { |
| 91 | $configs = []; |
| 92 | foreach ($runtimeManifest['config'] as $config) { |
| 93 | if (isset($config['file'])) { |
| 94 | $configs[] = $config['file']; |
| 95 | } |
| 96 | if (isset($config['data']) && isset($config['data']['paths']) && is_array($config['data']['paths'])) { |
| 97 | $modules = array_merge($modules, array_values($config['data']['paths'])); |
| 98 | } |
| 99 | } |
| 100 | $paths['config'] = $configs; |
| 101 | } |
| 102 | |
| 103 | $paths['modules'] = $modules; |
| 104 | |
| 105 | return $paths; |
| 106 | } |
| 107 | |
| 108 | public function getRuntimeAliases() |
| 109 | { |
| 110 | $runtimeManifest = $this->getRuntime(); |
| 111 | if (isset($runtimeManifest['src'])) { |
| 112 | $runtimeManifest['src'] = preg_replace( |
| 113 | '/^(.\/)?(.*)/', |
| 114 | $this->getTypeIdentifier() . "/$2", |
| 115 | $runtimeManifest['src'] |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | return $runtimeManifest; |
| 120 | } |
| 121 | } |