ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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_MULTIPLE_CHOICE_SR", "assSingleChoice");
27define ("QT_MULTIPLE_CHOICE_MR", "assMultipleChoice");
28define ("QT_CLOZE", "assClozeTest");
29define ("QT_MATCHING", "assMatchingQuestion");
30define ("QT_ORDERING", "assOrderingQuestion");
31define ("QT_IMAGEMAP", "assImagemapQuestion");
32define ("QT_JAVAAPPLET", "assJavaApplet");
33define ("QT_TEXT", "assTextQuestion");
34define ("QT_NUMERIC", "assNumeric");
35define ("QT_TEXTSUBSET", "assTextSubset");
36
46{
47 var $ident;
48 var $title;
50 var $label;
52
65
67 protected $iliasSourceNic;
68
69 function ilQTIItem()
70 {
71 $this->response = array();
72 $this->resprocessing = array();
73 $this->itemfeedback = array();
74 $this->presentation = NULL;
75 $this->presentationitem = array();
76 $this->suggested_solutions = array();
77 $this->itemmetadata = array();
78
79 $this->iliasSourceVersion = null;
80 $this->iliasSourceNic = null;
81 }
82
83 function setIdent($a_ident)
84 {
85 $this->ident = $a_ident;
86 }
87
88 function getIdent()
89 {
90 return $this->ident;
91 }
92
93 function setTitle($a_title)
94 {
95 $this->title = $a_title;
96 }
97
98 function getTitle()
99 {
100 return $this->title;
101 }
102
103 function setComment($a_comment)
104 {
105 if (preg_match("/(.*?)\=(.*)/", $a_comment, $matches))
106 {
107 // special comments written by ILIAS
108 switch ($matches[1])
109 {
110 case "ILIAS Version":
111 $this->ilias_version = $matches[2];
112 return;
113 break;
114 case "Questiontype":
115 $this->questiontype = $matches[2];
116 return;
117 break;
118 case "Author":
119 $this->author = $matches[2];
120 return;
121 break;
122 }
123 }
124 $this->comment = $a_comment;
125 }
126
127 function getComment()
128 {
129 return $this->comment;
130 }
131
132 function setDuration($a_duration)
133 {
134 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $a_duration, $matches))
135 {
136 $this->duration = array(
137 "h" => $matches[4],
138 "m" => $matches[5],
139 "s" => $matches[6]
140 );
141 }
142 }
143
144 function getDuration()
145 {
146 return $this->duration;
147 }
148
149 function setQuestiontext($a_questiontext)
150 {
151 $this->questiontext = $a_questiontext;
152 }
153
155 {
156 return $this->questiontext;
157 }
158
159 function addResprocessing($a_resprocessing)
160 {
161 array_push($this->resprocessing, $a_resprocessing);
162 }
163
164 function addItemfeedback($a_itemfeedback)
165 {
166 array_push($this->itemfeedback, $a_itemfeedback);
167 }
168
169 function setMaxattempts($a_maxattempts)
170 {
171 $this->maxattempts = $a_maxattempts;
172 }
173
174 function getMaxattempts()
175 {
176 return $this->maxattempts;
177 }
178
179 function setLabel($a_label)
180 {
181 $this->label = $a_label;
182 }
183
184 function getLabel()
185 {
186 return $this->label;
187 }
188
189 function setXmllang($a_xmllang)
190 {
191 $this->xmllang = $a_xmllang;
192 }
193
194 function getXmllang()
195 {
196 return $this->xmllang;
197 }
198
199 function setPresentation($a_presentation)
200 {
201 $this->presentation = $a_presentation;
202 }
203
205 {
206 return $this->presentation;
207 }
208
210 {
211 $result = array();
212 if ($this->presentation != NULL)
213 {
214 }
215 }
216
217 function setQuestiontype($a_questiontype)
218 {
219 $this->questiontype = $a_questiontype;
220 }
221
223 {
224 return $this->questiontype;
225 }
226
227 function addPresentationitem($a_presentationitem)
228 {
229 array_push($this->presentationitem, $a_presentationitem);
230 }
231
233 {
234 switch ($this->questiontype)
235 {
236 case "ORDERING QUESTION":
237 return QT_ORDERING;
238 case "KPRIM CHOICE QUESTION":
239 return QT_KPRIM_CHOICE;
240 case "SINGLE CHOICE QUESTION":
242 case "MULTIPLE CHOICE QUESTION":
243 break;
244 case "MATCHING QUESTION":
245 return QT_MATCHING;
246 case "CLOZE QUESTION":
247 return QT_CLOZE;
248 case "IMAGE MAP QUESTION":
249 return QT_IMAGEMAP;
250 case "JAVA APPLET QUESTION":
251 return QT_JAVAAPPLET;
252 case "TEXT QUESTION":
253 return QT_TEXT;
254 case "NUMERIC QUESTION":
255 return QT_NUMERIC;
256 case "TEXTSUBSET QUESTION":
257 return QT_TEXTSUBSET;
258 }
259 if (!$this->presentation) return QT_UNKNOWN;
260 foreach ($this->presentation->order as $entry)
261 {
262 switch ($entry["type"])
263 {
264 case "response":
265 $response = $this->presentation->response[$entry["index"]];
266 switch ($response->getResponsetype())
267 {
268 case RT_RESPONSE_LID:
269 switch ($response->getRCardinality())
270 {
272 return QT_ORDERING;
273 break;
276 break;
279 break;
280 }
281 break;
282 case RT_RESPONSE_XY:
283 return QT_IMAGEMAP;
284 break;
285 case RT_RESPONSE_STR:
286 switch ($response->getRCardinality())
287 {
289 return QT_TEXT;
290 break;
292 return QT_CLOZE;
293 break;
294 }
295 break;
296 case RT_RESPONSE_GRP:
297 return QT_MATCHING;
298 break;
299 default:
300 break;
301 }
302 break;
303 case "material":
304 $material = $this->presentation->material[$entry["index"]];
305 if (count($material->matapplet) > 0) return QT_JAVAAPPLET;
306 break;
307 }
308 }
309 if (strlen($this->questiontype) == 0)
310 {
311 return QT_UNKNOWN;
312 }
313 else
314 {
315 return $this->questiontype;
316 }
317 }
318
319 function setAuthor($a_author)
320 {
321 $this->author = $a_author;
322 }
323
324 function getAuthor()
325 {
326 return $this->author;
327 }
328
332 public function getIliasSourceVersion()
333 {
335 }
336
341 {
342 $this->iliasSourceVersion = $iliasSourceVersion;
343 }
344
348 public function getIliasSourceNic()
349 {
351 }
352
357 {
358 $this->iliasSourceNic = $iliasSourceNic;
359 }
360
361 function addSuggestedSolution($a_solution, $a_gap_index)
362 {
363 array_push($this->suggested_solutions, array("solution" => $a_solution, "gap_index" => $a_gap_index));
364 }
365
366 function addMetadata($a_metadata)
367 {
368 array_push($this->itemmetadata, $a_metadata);
369 }
370
371 function getMetadata()
372 {
373 return $this->itemmetadata;
374 }
375
376 function getMetadataEntry($a_label)
377 {
378 foreach ($this->itemmetadata as $metadata)
379 {
380 if (strcmp($metadata["label"], $a_label) == 0)
381 {
382 return $metadata["entry"];
383 }
384 }
385 return null;
386 }
387}
388?>
$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_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)