ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilQTIItem.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24define ("QT_UNKNOWN", "unknown");
25define ("QT_KPRIM_CHOICE", "assKprimChoice");
26define ("QT_LONG_MENU", "assLongMenu");
27define ("QT_MULTIPLE_CHOICE_SR", "assSingleChoice");
28define ("QT_MULTIPLE_CHOICE_MR", "assMultipleChoice");
29define ("QT_CLOZE", "assClozeTest");
30define ("QT_ERRORTEXT", "assErrorText");
31define ("QT_MATCHING", "assMatchingQuestion");
32define ("QT_ORDERING", "assOrderingQuestion");
33define ("QT_ORDERING_HORIZONTAL", "assOrderingHorizontal");
34define ("QT_IMAGEMAP", "assImagemapQuestion");
35define ("QT_JAVAAPPLET", "assJavaApplet");
36define ("QT_FLASHAPPLET", "assFlashApplet");
37define ("QT_TEXT", "assTextQuestion");
38define ("QT_FILEUPLOAD", "assFileUpload");
39define ("QT_NUMERIC", "assNumeric");
40define ("QT_FORMULA", "assFormulaQuestion");
41define ("QT_TEXTSUBSET", "assTextSubset");
42
52{
53 var $ident;
54 var $title;
56 var $label;
58
71
73 protected $iliasSourceNic;
74
75 function ilQTIItem()
76 {
77 $this->response = array();
78 $this->resprocessing = array();
79 $this->itemfeedback = array();
80 $this->presentation = NULL;
81 $this->presentationitem = array();
82 $this->suggested_solutions = array();
83 $this->itemmetadata = array();
84
85 $this->iliasSourceVersion = null;
86 $this->iliasSourceNic = null;
87 }
88
89 function setIdent($a_ident)
90 {
91 $this->ident = $a_ident;
92 }
93
94 function getIdent()
95 {
96 return $this->ident;
97 }
98
99 function setTitle($a_title)
100 {
101 $this->title = $a_title;
102 }
103
104 function getTitle()
105 {
106 return $this->title;
107 }
108
109 function setComment($a_comment)
110 {
111 if (preg_match("/(.*?)\=(.*)/", $a_comment, $matches))
112 {
113 // special comments written by ILIAS
114 switch ($matches[1])
115 {
116 case "ILIAS Version":
117 $this->ilias_version = $matches[2];
118 return;
119 break;
120 case "Questiontype":
121 $this->questiontype = $matches[2];
122 return;
123 break;
124 case "Author":
125 $this->author = $matches[2];
126 return;
127 break;
128 }
129 }
130 $this->comment = $a_comment;
131 }
132
133 function getComment()
134 {
135 return $this->comment;
136 }
137
138 function setDuration($a_duration)
139 {
140 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $a_duration, $matches))
141 {
142 $this->duration = array(
143 "h" => $matches[4],
144 "m" => $matches[5],
145 "s" => $matches[6]
146 );
147 }
148 }
149
150 function getDuration()
151 {
152 return $this->duration;
153 }
154
155 function setQuestiontext($a_questiontext)
156 {
157 $this->questiontext = $a_questiontext;
158 }
159
161 {
162 return $this->questiontext;
163 }
164
165 function addResprocessing($a_resprocessing)
166 {
167 array_push($this->resprocessing, $a_resprocessing);
168 }
169
170 function addItemfeedback($a_itemfeedback)
171 {
172 array_push($this->itemfeedback, $a_itemfeedback);
173 }
174
175 function setMaxattempts($a_maxattempts)
176 {
177 $this->maxattempts = $a_maxattempts;
178 }
179
180 function getMaxattempts()
181 {
182 return $this->maxattempts;
183 }
184
185 function setLabel($a_label)
186 {
187 $this->label = $a_label;
188 }
189
190 function getLabel()
191 {
192 return $this->label;
193 }
194
195 function setXmllang($a_xmllang)
196 {
197 $this->xmllang = $a_xmllang;
198 }
199
200 function getXmllang()
201 {
202 return $this->xmllang;
203 }
204
205 function setPresentation($a_presentation)
206 {
207 $this->presentation = $a_presentation;
208 }
209
211 {
212 return $this->presentation;
213 }
214
216 {
217 $result = array();
218 if ($this->presentation != NULL)
219 {
220 }
221 }
222
223 function setQuestiontype($a_questiontype)
224 {
225 $this->questiontype = $a_questiontype;
226 }
227
229 {
230 return $this->questiontype;
231 }
232
233 function addPresentationitem($a_presentationitem)
234 {
235 array_push($this->presentationitem, $a_presentationitem);
236 }
237
239 {
240 switch ($this->questiontype)
241 {
242 case "ORDERING QUESTION":
243 return QT_ORDERING;
244 case "KPRIM CHOICE QUESTION":
245 return QT_KPRIM_CHOICE;
246 case "LONG MENU QUESTION":
247 return QT_LONG_MENU;
248 case "SINGLE CHOICE QUESTION":
250 case "MULTIPLE CHOICE QUESTION":
251 break;
252 case "MATCHING QUESTION":
253 return QT_MATCHING;
254 case "CLOZE QUESTION":
255 return QT_CLOZE;
256 case "IMAGE MAP QUESTION":
257 return QT_IMAGEMAP;
258 case "JAVA APPLET QUESTION":
259 return QT_JAVAAPPLET;
260 case "TEXT QUESTION":
261 return QT_TEXT;
262 case "NUMERIC QUESTION":
263 return QT_NUMERIC;
264 case "TEXTSUBSET QUESTION":
265 return QT_TEXTSUBSET;
266 }
267 if (!$this->presentation) return QT_UNKNOWN;
268 foreach ($this->presentation->order as $entry)
269 {
270 switch ($entry["type"])
271 {
272 case "response":
273 $response = $this->presentation->response[$entry["index"]];
274 switch ($response->getResponsetype())
275 {
276 case RT_RESPONSE_LID:
277 switch ($response->getRCardinality())
278 {
280 return QT_ORDERING;
281 break;
284 break;
287 break;
288 }
289 break;
290 case RT_RESPONSE_XY:
291 return QT_IMAGEMAP;
292 break;
293 case RT_RESPONSE_STR:
294 switch ($response->getRCardinality())
295 {
297 return QT_TEXT;
298 break;
300 return QT_CLOZE;
301 break;
302 }
303 break;
304 case RT_RESPONSE_GRP:
305 return QT_MATCHING;
306 break;
307 default:
308 break;
309 }
310 break;
311 case "material":
312 $material = $this->presentation->material[$entry["index"]];
313 if (count($material->matapplet) > 0) return QT_JAVAAPPLET;
314 break;
315 }
316 }
317 if (strlen($this->questiontype) == 0)
318 {
319 return QT_UNKNOWN;
320 }
321 else
322 {
323 return $this->questiontype;
324 }
325 }
326
327 function setAuthor($a_author)
328 {
329 $this->author = $a_author;
330 }
331
332 function getAuthor()
333 {
334 return $this->author;
335 }
336
340 public function getIliasSourceVersion()
341 {
343 }
344
349 {
350 $this->iliasSourceVersion = $iliasSourceVersion;
351 }
352
356 public function getIliasSourceNic()
357 {
359 }
360
365 {
366 $this->iliasSourceNic = $iliasSourceNic;
367 }
368
369 function addSuggestedSolution($a_solution, $a_gap_index)
370 {
371 array_push($this->suggested_solutions, array("solution" => $a_solution, "gap_index" => $a_gap_index));
372 }
373
374 function addMetadata($a_metadata)
375 {
376 array_push($this->itemmetadata, $a_metadata);
377 }
378
379 function getMetadata()
380 {
381 return $this->itemmetadata;
382 }
383
384 function getMetadataEntry($a_label)
385 {
386 foreach ($this->itemmetadata as $metadata)
387 {
388 if (strcmp($metadata["label"], $a_label) == 0)
389 {
390 return $metadata["entry"];
391 }
392 }
393 return null;
394 }
395}
396?>
$result
const QT_CLOZE
const QT_IMAGEMAP
const QT_TEXTSUBSET
const QT_JAVAAPPLET
const QT_UNKNOWN
const QT_KPRIM_CHOICE
const QT_MULTIPLE_CHOICE_MR
const QT_MATCHING
const QT_ORDERING
const QT_NUMERIC
const QT_MULTIPLE_CHOICE_SR
const QT_LONG_MENU
const QT_TEXT
const RT_RESPONSE_LID
const RT_RESPONSE_XY
const R_CARDINALITY_SINGLE
const RT_RESPONSE_STR
const R_CARDINALITY_ORDERED
const RT_RESPONSE_GRP
const R_CARDINALITY_MULTIPLE
setPresentation($a_presentation)
addResprocessing($a_resprocessing)
setIliasSourceNic($iliasSourceNic)
setDuration($a_duration)
setTitle($a_title)
setIdent($a_ident)
setMaxattempts($a_maxattempts)
setIliasSourceVersion($iliasSourceVersion)
setComment($a_comment)
addSuggestedSolution($a_solution, $a_gap_index)
getMetadataEntry($a_label)
setXmllang($a_xmllang)
addMetadata($a_metadata)
setQuestiontext($a_questiontext)
addItemfeedback($a_itemfeedback)
setLabel($a_label)
addPresentationitem($a_presentationitem)
setQuestiontype($a_questiontype)
setAuthor($a_author)