ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilQuestionExporter Class Reference

Scorm 2004 Question Exporter. More...

+ Collaboration diagram for ilQuestionExporter:

Public Member Functions

 ilQuestionExporter ($a_preview_mode=false)
 Constructor @access public. More...
 
 exportQuestion ($a_ref_id, $a_image_path=null, $a_output_mode="presentation")
 

Static Public Member Functions

static indicateNewSco ()
 
static getMobs ()
 
static getFiles ()
 
static questionsJS (array $a_qids=null)
 

Data Fields

 $db
 
 $ilias
 
 $ref_id
 
 $inst_id
 
 $q_gui
 
 $tpl
 
 $json
 
 $json_decoded
 
 $preview_mode
 

Static Public Attributes

static $exported = array()
 
static $mobs = array()
 
static $media_files = array()
 

Private Member Functions

 setHeaderFooter ()
 
 assSingleChoice ()
 
 assMultipleChoice ()
 
 assKprimChoice ()
 
 assTextQuestion ()
 
 assClozeTest ()
 
 assLongMenu ()
 
 assOrderingQuestion ()
 
 assMatchingQuestion ()
 
 assImagemapQuestion ()
 
 assTextSubset ()
 
 assOrderingHorizontal ()
 
 assErrorText ()
 

Detailed Description

Scorm 2004 Question Exporter.

Author
Hendrik Holtmann holtm.nosp@m.ann@.nosp@m.me.co.nosp@m.m
Version
Id
class.ilQuestionExporter.php 12658 2006-11-29 08:51:48Z akill

Definition at line 16 of file class.ilQuestionExporter.php.

Member Function Documentation

◆ assClozeTest()

ilQuestionExporter::assClozeTest ( )
private

Definition at line 243 of file class.ilQuestionExporter.php.

243 {
244 $this->tpl->setCurrentBlock("clozequestion");
245 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
246 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
247 if ($this->preview_mode) {
248 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
249 }
250 $this->tpl->parseCurrentBlock();
251// $this->setHeaderFooter();
252 return $this->tpl->get();
253 }

◆ assErrorText()

ilQuestionExporter::assErrorText ( )
private

Definition at line 361 of file class.ilQuestionExporter.php.

361 {
362 $this->tpl->setCurrentBlock("errortext");
363 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
364 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
365 if ($this->preview_mode) {
366 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
367 }
368 $this->tpl->parseCurrentBlock();
369// $this->setHeaderFooter();
370 return $this->tpl->get();
371 }

◆ assImagemapQuestion()

ilQuestionExporter::assImagemapQuestion ( )
private

Definition at line 312 of file class.ilQuestionExporter.php.

312 {
313 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
314 array_push(self::$media_files,$this->q_gui->object->getImagePath().$this->q_gui->object->getImageFilename());
315 $this->tpl->setCurrentBlock("mapareas");
316 $areas = $this->json_decoded->answers;
317 //set areas in PHP cause of inteference between pure and highlighter
318 foreach ($areas as $area) {
319 $this->tpl->setVariable("VAL_TOOLTIP", htmlspecialchars($area->answertext));
320 $this->tpl->setVariable("VAL_COORDS", $area->coords);
321 $this->tpl->setVariable("VAL_ORDER", $area->order);
322 $this->tpl->setVariable("VAL_AREA", $area->area);
323 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
324 $this->tpl->parseCurrentBlock();
325 }
326 $this->tpl->setCurrentBlock("imagemapquestion");
327 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
328 if ($this->preview_mode) {
329 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
330 }
331 $this->tpl->parseCurrentBlock();
332// $this->setHeaderFooter();
333 return $this->tpl->get();
334 }

◆ assKprimChoice()

ilQuestionExporter::assKprimChoice ( )
private

Definition at line 186 of file class.ilQuestionExporter.php.

187 {
188 global $tpl;
189 $tpl->addCss('Modules/Test/templates/default/ta.css');
190
191 $this->tpl->setCurrentBlock("kprimchoice");
192
193 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
194 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
195
196 if( $this->preview_mode )
197 {
198 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
199 }
200
201 if( $this->json_decoded->path )
202 {
203 $this->tpl->setVariable("HANDLE_IMAGES",
204 "ilias.questions.handleMCImages(".$this->json_decoded->id.");");
205 }
206
207 $this->tpl->setVariable('OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
208 $this->tpl->setVariable('OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
209
210 $this->tpl->setVariable('VALUE_TRUE', 1);
211 $this->tpl->setVariable('VALUE_FALSE', 0);
212
213 $this->tpl->parseCurrentBlock();
214
215 foreach( $this->json_decoded->answers as $answer )
216 {
217 if( $answer->image != "" )
218 {
219 self::$media_files[] = $answer->getImageFsPath();
220 self::$media_files[] = $answer->getThumbFsPath();
221 }
222 }
223
224 // $this->setHeaderFooter();
225
226 return $this->tpl->get();
227 }

References $tpl.

◆ assLongMenu()

ilQuestionExporter::assLongMenu ( )
private

Definition at line 255 of file class.ilQuestionExporter.php.

255 {
256 $this->tpl->setCurrentBlock("longmenu");
257 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
258 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
259 if ($this->preview_mode) {
260 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
261 }
262 $this->tpl->parseCurrentBlock();
263// $this->setHeaderFooter();
264 return $this->tpl->get();
265 }

◆ assMatchingQuestion()

ilQuestionExporter::assMatchingQuestion ( )
private

Definition at line 296 of file class.ilQuestionExporter.php.

296 {
297 global $tpl;
298 $tpl->addJavaScript('Modules/TestQuestionPool/js/ilMatchingQuestion.js');
299 $tpl->addCss('Modules/TestQuestionPool/templates/default/test_javascript.css');
300 $this->tpl->setCurrentBlock("matchingquestion");
301 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
302 $this->tpl->setVariable("BTN_LABEL_RESET", $this->lng->txt("reset_terms"));
303 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
304 if ($this->preview_mode) {
305 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
306 }
307 $this->tpl->parseCurrentBlock();
308// $this->setHeaderFooter();
309 return $this->tpl->get();
310 }

References $tpl.

◆ assMultipleChoice()

ilQuestionExporter::assMultipleChoice ( )
private

Definition at line 162 of file class.ilQuestionExporter.php.

162 {
163 $this->tpl->setCurrentBlock("multiplechoice");
164 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
165 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
166 if ($this->preview_mode) {
167 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
168 }
169 if($this->json_decoded->path)
170 {
171 $this->tpl->setVariable("HANDLE_IMAGES",
172 "ilias.questions.handleMCImages(".$this->json_decoded->id.");");
173 }
174 $this->tpl->parseCurrentBlock();
175 foreach ($this->json_decoded->answers as $answer) {
176 if ($answer->image!="") {
177 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
178 array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->image);
179 }
180 }
181// $this->setHeaderFooter();
182 return $this->tpl->get();
183 }

◆ assOrderingHorizontal()

ilQuestionExporter::assOrderingHorizontal ( )
private

Definition at line 349 of file class.ilQuestionExporter.php.

349 {
350 $this->tpl->setCurrentBlock("orderinghorizontal");
351 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
352 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
353 if ($this->preview_mode) {
354 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
355 }
356 $this->tpl->parseCurrentBlock();
357// $this->setHeaderFooter();
358 return $this->tpl->get();
359 }

◆ assOrderingQuestion()

ilQuestionExporter::assOrderingQuestion ( )
private

Definition at line 267 of file class.ilQuestionExporter.php.

267 {
268 $this->tpl->setCurrentBlock("orderingquestion");
269 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
270 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
271 if ($this->preview_mode) {
272 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
273 }
274 if($this->q_gui->object->getOrderingType() == OQ_PICTURES)
275 {
276 $this->tpl->setVariable("VAL_SUBTYPE", "_images");
277 $this->tpl->setVariable("HANDLE_IMAGES",
278 "ilias.questions.handleOrderingImages(".$this->json_decoded->id.");");
279
280 foreach ($this->json_decoded->answers as $answer) {
281 if ($answer->answertext!="") {
282 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->answertext);
283 array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->answertext);
284 }
285 }
286 }
287 else
288 {
289 $this->tpl->setVariable("VAL_SUBTYPE", "_terms");
290 }
291 $this->tpl->parseCurrentBlock();
292// $this->setHeaderFooter();
293 return $this->tpl->get();
294 }
const OQ_PICTURES
Ordering question constants.

References OQ_PICTURES.

◆ assSingleChoice()

ilQuestionExporter::assSingleChoice ( )
private

Definition at line 135 of file class.ilQuestionExporter.php.

136 {
137 $this->tpl->setCurrentBlock("singlechoice");
138 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
139 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
140 if ($this->preview_mode) {
141 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
142 }
143 if($this->json_decoded->path)
144 {
145 $this->tpl->setVariable("HANDLE_IMAGES",
146 "ilias.questions.handleMCImages(".$this->json_decoded->id.");");
147 }
148 $this->tpl->parseCurrentBlock();
149 foreach ($this->json_decoded->answers as $answer) {
150 if ($answer->image!="") {
151 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
152 if (is_file($this->q_gui->object->getImagePath()."thumb.".$answer->image))
153 {
154 array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->image);
155 }
156 }
157 }
158// $this->setHeaderFooter();
159 return $this->tpl->get();
160 }

◆ assTextQuestion()

ilQuestionExporter::assTextQuestion ( )
private

Definition at line 229 of file class.ilQuestionExporter.php.

229 {
230 $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
231 $this->tpl->setCurrentBlock("textquestion");
232 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
233 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
234 $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
235 if ($this->preview_mode) {
236 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
237 }
238 $this->tpl->parseCurrentBlock();
239// $this->setHeaderFooter();
240 return $this->tpl->get();
241 }

◆ assTextSubset()

ilQuestionExporter::assTextSubset ( )
private

Definition at line 336 of file class.ilQuestionExporter.php.

336 {
337 $this->tpl->setCurrentBlock("textsubset");
338 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
339 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
340 $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
341 if ($this->preview_mode) {
342 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
343 }
344 $this->tpl->parseCurrentBlock();
345// $this->setHeaderFooter();
346 return $this->tpl->get();
347 }

◆ exportQuestion()

ilQuestionExporter::exportQuestion (   $a_ref_id,
  $a_image_path = null,
  $a_output_mode = "presentation" 
)

Definition at line 61 of file class.ilQuestionExporter.php.

61 {
62
63 if ($a_ref_id != "")
64 {
66 if (!($inst_id > 0))
67 {
69 }
70 }
71
72 $this->q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
73
74 if (!is_object($this->q_gui->object))
75 {
76 return "Error: Question not found.";
77 }
78
79 $type = $this->q_gui->object->getQuestionType();
80 if (method_exists($this,$type))
81 {
82 $this->q_gui->object->setExportImagePath($a_image_path);
83 $this->q_gui->object->feedbackOBJ->setPageObjectOutputMode($a_output_mode);
84 $this->json = $this->q_gui->object->toJSON();
85 $this->json_decoded = json_decode($this->json);
86 self::$exported[$this->json_decoded->id] = $this->json;
87 self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
88 return $this->$type();
89 } else {
90 return "Error: Question Type not implemented/Question editing not finished";
91 }
92 }
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
$mobs

References $inst_id, $json, $mobs, ilInternalLink\_extractInstOfTarget(), ilInternalLink\_extractObjIdOfTarget(), and assQuestionGUI\_getQuestionGUI().

+ Here is the call graph for this function:

◆ getFiles()

static ilQuestionExporter::getFiles ( )
static

Definition at line 110 of file class.ilQuestionExporter.php.

110 {
111 return self::$media_files;
112 }

References $media_files.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

+ Here is the caller graph for this function:

◆ getMobs()

static ilQuestionExporter::getMobs ( )
static

Definition at line 100 of file class.ilQuestionExporter.php.

100 {
101 $allmobs = array();
102 foreach (self::$mobs as $key => $value) {
103 for ($i=0;$i<count($mobs[$key]);$i++) {
104 array_push($allmobs,$mobs[$key][$i]);
105 }
106 }
107 return $allmobs;
108 }

References $mobs, and $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

+ Here is the caller graph for this function:

◆ ilQuestionExporter()

ilQuestionExporter::ilQuestionExporter (   $a_preview_mode = false)

Constructor @access public.

Definition at line 36 of file class.ilQuestionExporter.php.

37 {
38 global $ilDB, $ilias, $lng;
39
40 $this->ref_id =& $a_ref_id;
41
42 $this->db =& $ilDB;
43 $this->lng = $lng;
44
45 $this->inst_id = IL_INST_ID;
46
47 $this->preview_mode = $a_preview_mode;
48
49 $this->tpl = new ilTemplate("tpl.question_export.html", true, true, "Modules/Scorm2004");
50
51 // fix for bug 5386, alex 29.10.2009
52 if (!$a_preview_mode)
53 {
54 $this->tpl->setVariable("FORM_BEGIN", "<form onsubmit='return false;'>");
55 $this->tpl->setVariable("FORM_END", "</form>");
56 }
57
58 }
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:40
global $ilDB

References $ilDB, $ilias, and $lng.

◆ indicateNewSco()

static ilQuestionExporter::indicateNewSco ( )
static

Definition at line 94 of file class.ilQuestionExporter.php.

94 {
95 self::$exported = array();
96 self::$mobs = array();
97 self::$media_files = array();
98 }

References $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

+ Here is the caller graph for this function:

◆ questionsJS()

static ilQuestionExporter::questionsJS ( array  $a_qids = null)
static

Definition at line 114 of file class.ilQuestionExporter.php.

114 {
115 $exportstring = '';
116 if(!is_array($a_qids)) {
117 $exportstring ='var questions = new Array();';
118 }
119 foreach (self::$exported as $key => $value) {
120 if(!is_array($a_qids) || in_array($key, $a_qids)) {
121 $exportstring .= "questions[$key]= $value;";
122 }
123 }
124 return $exportstring;
125 }

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

+ Here is the caller graph for this function:

◆ setHeaderFooter()

ilQuestionExporter::setHeaderFooter ( )
private

Definition at line 127 of file class.ilQuestionExporter.php.

128 {
129 $this->tpl->setCurrentBlock("common");
130 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
131 $this->tpl->setVariable("VAL_TYPE", $this->json_decoded->type);
132 $this->tpl->parseCurrentBlock();
133 }

Field Documentation

◆ $db

ilQuestionExporter::$db

Definition at line 22 of file class.ilQuestionExporter.php.

◆ $exported

ilQuestionExporter::$exported = array()
static

Definition at line 18 of file class.ilQuestionExporter.php.

◆ $ilias

ilQuestionExporter::$ilias

Definition at line 23 of file class.ilQuestionExporter.php.

Referenced by ilQuestionExporter().

◆ $inst_id

ilQuestionExporter::$inst_id

Definition at line 25 of file class.ilQuestionExporter.php.

Referenced by exportQuestion().

◆ $json

ilQuestionExporter::$json

Definition at line 28 of file class.ilQuestionExporter.php.

Referenced by exportQuestion().

◆ $json_decoded

ilQuestionExporter::$json_decoded

Definition at line 29 of file class.ilQuestionExporter.php.

◆ $media_files

ilQuestionExporter::$media_files = array()
static

Definition at line 20 of file class.ilQuestionExporter.php.

Referenced by getFiles().

◆ $mobs

ilQuestionExporter::$mobs = array()
static

Definition at line 19 of file class.ilQuestionExporter.php.

Referenced by getMobs().

◆ $preview_mode

ilQuestionExporter::$preview_mode

Definition at line 30 of file class.ilQuestionExporter.php.

◆ $q_gui

ilQuestionExporter::$q_gui

Definition at line 26 of file class.ilQuestionExporter.php.

◆ $ref_id

ilQuestionExporter::$ref_id

Definition at line 24 of file class.ilQuestionExporter.php.

◆ $tpl

ilQuestionExporter::$tpl

Definition at line 27 of file class.ilQuestionExporter.php.

Referenced by assKprimChoice(), and assMatchingQuestion().


The documentation for this class was generated from the following file: