Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 16 |
CRAP | |
0.00% |
0 / 1 |
Resource | |
0.00% |
0 / 20 |
|
0.00% |
0 / 16 |
462 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
isAllowed | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
20 | |||
isAssessmentItem | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
isAssessmentTest | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
getTestTypes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getItemTypes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIdentifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setIdentifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setAuxiliaryFiles | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addAuxiliaryFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAuxiliaryFiles | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDependencies | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addDependency | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDependencies | |
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-2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
19 | * |
20 | * |
21 | */ |
22 | |
23 | namespace oat\taoQtiItem\model\qti; |
24 | |
25 | /** |
26 | * A QTI Resource from the point of view of the imsmanifest v1.1 : Content Packaging). |
27 | * |
28 | * @package taoQTI |
29 | |
30 | */ |
31 | class Resource |
32 | { |
33 | /** |
34 | * defines the list of known authorized type of resources |
35 | * |
36 | * @var array |
37 | */ |
38 | protected static $allowedTypes = [ |
39 | 'imsqti_apipsectionroot_xmlv2p1', |
40 | 'controlfile/apip_xmlv1p0', |
41 | 'associatedcontent/apip_xmlv1p0/learning-application-resource' |
42 | ]; |
43 | |
44 | /** |
45 | * defines the list of known authorized type of qti test |
46 | * |
47 | * @var array |
48 | */ |
49 | protected static $testTypes = [ |
50 | 'imsqti_apiptestroot_xmlv2p1', |
51 | 'imsqti_test_xmlv2p1', |
52 | 'imsqti_test_xmlv2p2', |
53 | 'imsqti_assessment_xmlv2p1', |
54 | 'imsqti_test_xmlv3p0' |
55 | ]; |
56 | |
57 | /** |
58 | * defines the list of known authorized type of qti item |
59 | * |
60 | * @var array |
61 | */ |
62 | protected static $itemTypes = [ |
63 | 'imsqti_item_xmlv2p0', |
64 | 'imsqti_item_xmlv2p1', |
65 | 'imsqti_item_xmlv2p2', |
66 | 'imsqti_apipitemroot_xmlv2p1', |
67 | 'imsqti_apipitem_xmlv2p1', |
68 | 'imsqti_apipitem_xmlv2p2', |
69 | 'imsqti_item_xmlv3p0' |
70 | ]; |
71 | |
72 | /** |
73 | * The identifier of the resource. |
74 | * |
75 | * @var string |
76 | */ |
77 | protected $identifier = ''; |
78 | |
79 | /** |
80 | * The URI representing the file bound to the resource. |
81 | * |
82 | * @var string |
83 | */ |
84 | protected $file = ''; |
85 | |
86 | /** |
87 | * The valid IMS resource type. |
88 | * |
89 | * @var string |
90 | */ |
91 | protected $type = ''; |
92 | |
93 | /** |
94 | * Array containing the auxiliary files. |
95 | * |
96 | * @access protected |
97 | * @var array |
98 | */ |
99 | protected $auxiliaryFiles = []; |
100 | |
101 | /** |
102 | * Array containing dependencies. |
103 | * |
104 | * @var array |
105 | */ |
106 | protected $dependencies = []; |
107 | |
108 | /** |
109 | * Create a new QTI Resource object. |
110 | * |
111 | * @param string $id |
112 | * @param string $type |
113 | * @param string $file |
114 | */ |
115 | public function __construct($id, $type, $file) |
116 | { |
117 | $this->identifier = $id; |
118 | $this->type = $type; |
119 | $this->file = $file; |
120 | } |
121 | |
122 | /** |
123 | * Check if the given type is allowed as a QTI Resource |
124 | * |
125 | * @param string $type |
126 | * @return boolean |
127 | */ |
128 | public static function isAllowed($type) |
129 | { |
130 | return (!empty($type) && (in_array($type, self::$allowedTypes))) |
131 | || self::isAssessmentItem($type) |
132 | || self::isAssessmentTest($type); |
133 | } |
134 | |
135 | /** |
136 | * Check if the given type is allowed as a QTI item type |
137 | * |
138 | * @param string $type |
139 | * @return boolean |
140 | */ |
141 | public static function isAssessmentItem($type) |
142 | { |
143 | return (!empty($type) && in_array($type, self::$itemTypes)); |
144 | } |
145 | /** |
146 | * Check if the given type is allowed as a QTI test type |
147 | * |
148 | * @param string $type |
149 | * @return boolean |
150 | */ |
151 | public static function isAssessmentTest($type) |
152 | { |
153 | return (!empty($type) && in_array($type, self::$testTypes)); |
154 | } |
155 | |
156 | /** |
157 | * Get all valid test types |
158 | * |
159 | * @return array |
160 | */ |
161 | public static function getTestTypes() |
162 | { |
163 | return self::$testTypes; |
164 | } |
165 | |
166 | /** |
167 | * Get all valid item types |
168 | * |
169 | * @return array |
170 | */ |
171 | public static function getItemTypes() |
172 | { |
173 | return self::$itemTypes; |
174 | } |
175 | |
176 | /** |
177 | * Get the identifier of the resource. |
178 | * |
179 | * @return string |
180 | */ |
181 | public function getIdentifier() |
182 | { |
183 | return $this->identifier; |
184 | } |
185 | |
186 | public function setIdentifier($identifier) |
187 | { |
188 | $this->identifier = $identifier; |
189 | } |
190 | |
191 | /** |
192 | * Get the URI of the main referenced file. |
193 | * |
194 | * @return string |
195 | */ |
196 | public function getFile() |
197 | { |
198 | return (string) $this->file; |
199 | } |
200 | |
201 | /** |
202 | * Get the qti resource type: |
203 | * |
204 | * @return string |
205 | */ |
206 | public function getType() |
207 | { |
208 | return (string) $this->type; |
209 | } |
210 | |
211 | /** |
212 | * Set the list of auxiliary files bound to this resource. |
213 | * |
214 | * @param array $files An array of strings representing URIs. |
215 | */ |
216 | public function setAuxiliaryFiles(array $files) |
217 | { |
218 | $this->auxiliaryFiles = $files; |
219 | } |
220 | |
221 | /** |
222 | * Add an auxiliary file to the resource. |
223 | * |
224 | * @param string $file The URI referencing the file. |
225 | */ |
226 | public function addAuxiliaryFile($file) |
227 | { |
228 | $this->auxiliaryFiles[] = $file; |
229 | } |
230 | |
231 | /** |
232 | * Get the list of auxiliary files bound to this resource. |
233 | * |
234 | * @return array An array of strings representing URIs. |
235 | */ |
236 | public function getAuxiliaryFiles() |
237 | { |
238 | return (array) $this->auxiliaryFiles; |
239 | } |
240 | |
241 | /** |
242 | * Set the list of dependencies to this resource. |
243 | * |
244 | * @param array $dependencies An array of strings representing identifiers. |
245 | */ |
246 | public function setDependencies(array $dependencies) |
247 | { |
248 | $this->dependencies = $dependencies; |
249 | } |
250 | |
251 | /** |
252 | * Add a dependency to this resource. |
253 | * |
254 | * @param string $dependency An identifier. |
255 | */ |
256 | public function addDependency($dependency) |
257 | { |
258 | $this->dependencies[] = $dependency; |
259 | } |
260 | |
261 | /** |
262 | * Get the list of dependencies to this resource. |
263 | * |
264 | * @return array An array of strings representing identifiers. |
265 | */ |
266 | public function getDependencies() |
267 | { |
268 | return $this->dependencies; |
269 | } |
270 | } |