ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public $ident;
54 public $title;
56 public $label;
57 public $xmllang;
58
59 public $comment;
61 public $author;
63 public $duration;
71
73 protected $iliasSourceNic;
74
75 public function __construct()
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 public function setIdent($a_ident)
90 {
91 $this->ident = $a_ident;
92 }
93
94 public function getIdent()
95 {
96 return $this->ident;
97 }
98
99 public function setTitle($a_title)
100 {
101 $this->title = $a_title;
102 }
103
104 public function getTitle()
105 {
106 return $this->title;
107 }
108
109 public function setComment($a_comment)
110 {
111 if (preg_match("/(.*?)\=(.*)/", $a_comment, $matches)) {
112 // special comments written by ILIAS
113 switch ($matches[1]) {
114 case "ILIAS Version":
115 $this->ilias_version = $matches[2];
116 return;
117 break;
118 case "Questiontype":
119 $this->questiontype = $matches[2];
120 return;
121 break;
122 case "Author":
123 $this->author = $matches[2];
124 return;
125 break;
126 }
127 }
128 $this->comment = $a_comment;
129 }
130
131 public function getComment()
132 {
133 return $this->comment;
134 }
135
136 public function setDuration($a_duration)
137 {
138 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $a_duration, $matches)) {
139 $this->duration = array(
140 "h" => $matches[4],
141 "m" => $matches[5],
142 "s" => $matches[6]
143 );
144 }
145 }
146
147 public function getDuration()
148 {
149 return $this->duration;
150 }
151
152 public function setQuestiontext($a_questiontext)
153 {
154 $this->questiontext = $a_questiontext;
155 }
156
157 public function getQuestiontext()
158 {
159 return $this->questiontext;
160 }
161
162 public function addResprocessing($a_resprocessing)
163 {
164 array_push($this->resprocessing, $a_resprocessing);
165 }
166
167 public function addItemfeedback($a_itemfeedback)
168 {
169 array_push($this->itemfeedback, $a_itemfeedback);
170 }
171
172 public function setMaxattempts($a_maxattempts)
173 {
174 $this->maxattempts = $a_maxattempts;
175 }
176
177 public function getMaxattempts()
178 {
179 return $this->maxattempts;
180 }
181
182 public function setLabel($a_label)
183 {
184 $this->label = $a_label;
185 }
186
187 public function getLabel()
188 {
189 return $this->label;
190 }
191
192 public function setXmllang($a_xmllang)
193 {
194 $this->xmllang = $a_xmllang;
195 }
196
197 public function getXmllang()
198 {
199 return $this->xmllang;
200 }
201
202 public function setPresentation($a_presentation)
203 {
204 $this->presentation = $a_presentation;
205 }
206
207 public function getPresentation()
208 {
209 return $this->presentation;
210 }
211
212 public function collectResponses()
213 {
214 $result = array();
215 if ($this->presentation != null) {
216 }
217 }
218
219 public function setQuestiontype($a_questiontype)
220 {
221 $this->questiontype = $a_questiontype;
222 }
223
224 public function getQuestiontype()
225 {
226 return $this->questiontype;
227 }
228
229 public function addPresentationitem($a_presentationitem)
230 {
231 array_push($this->presentationitem, $a_presentationitem);
232 }
233
234 public function determineQuestionType()
235 {
236 switch ($this->questiontype) {
237 case "ORDERING QUESTION":
238 return QT_ORDERING;
239 case "KPRIM CHOICE QUESTION":
240 return QT_KPRIM_CHOICE;
241 case "LONG MENU QUESTION":
242 return QT_LONG_MENU;
243 case "SINGLE CHOICE QUESTION":
245 case "MULTIPLE CHOICE QUESTION":
246 break;
247 case "MATCHING QUESTION":
248 return QT_MATCHING;
249 case "CLOZE QUESTION":
250 return QT_CLOZE;
251 case "IMAGE MAP QUESTION":
252 return QT_IMAGEMAP;
253 case "JAVA APPLET QUESTION":
254 return QT_JAVAAPPLET;
255 case "TEXT QUESTION":
256 return QT_TEXT;
257 case "NUMERIC QUESTION":
258 return QT_NUMERIC;
259 case "TEXTSUBSET QUESTION":
260 return QT_TEXTSUBSET;
261 }
262 if (!$this->presentation) {
263 return QT_UNKNOWN;
264 }
265 foreach ($this->presentation->order as $entry) {
266 switch ($entry["type"]) {
267 case "response":
268 $response = $this->presentation->response[$entry["index"]];
269 switch ($response->getResponsetype()) {
270 case RT_RESPONSE_LID:
271 switch ($response->getRCardinality()) {
273 return QT_ORDERING;
274 break;
277 break;
280 break;
281 }
282 break;
283 case RT_RESPONSE_XY:
284 return QT_IMAGEMAP;
285 break;
286 case RT_RESPONSE_STR:
287 switch ($response->getRCardinality()) {
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 (is_array($material->matapplet) && count($material->matapplet) > 0) {
306 return QT_JAVAAPPLET;
307 }
308 break;
309 }
310 }
311 if (strlen($this->questiontype) == 0) {
312 return QT_UNKNOWN;
313 } else {
314 return $this->questiontype;
315 }
316 }
317
318 public function setAuthor($a_author)
319 {
320 $this->author = $a_author;
321 }
322
323 public function getAuthor()
324 {
325 return $this->author;
326 }
327
331 public function getIliasSourceVersion()
332 {
334 }
335
340 {
341 $this->iliasSourceVersion = $iliasSourceVersion;
342 }
343
347 public function getIliasSourceNic()
348 {
350 }
351
356 {
357 $this->iliasSourceNic = $iliasSourceNic;
358 }
359
360 public function addSuggestedSolution($a_solution, $a_gap_index)
361 {
362 array_push($this->suggested_solutions, array("solution" => $a_solution, "gap_index" => $a_gap_index));
363 }
364
365 public function addMetadata($a_metadata)
366 {
367 array_push($this->itemmetadata, $a_metadata);
368 }
369
370 public function getMetadata()
371 {
372 return $this->itemmetadata;
373 }
374
375 public function getMetadataEntry($a_label)
376 {
377 foreach ($this->itemmetadata as $metadata) {
378 if (strcmp($metadata["label"], $a_label) == 0) {
379 return $metadata["entry"];
380 }
381 }
382 return null;
383 }
384}
$result
$metadata['__DYNAMIC:1__']
An exception for terminatinating execution or to throw for unit testing.
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)
comment()
Definition: comment.php:2
$response