ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilQuestionExporter Class Reference

Scorm 2004 Question Exporter. More...

+ Collaboration diagram for ilQuestionExporter:

Public Member Functions

 __construct ($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
 
 $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()
 

Protected Attributes

 $lng
 

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.

Constructor & Destructor Documentation

◆ __construct()

ilQuestionExporter::__construct (   $a_preview_mode = false)

Constructor @access public.

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

41 {
42 global $DIC;
43
44 $ilDB = $DIC->database();
45 $lng = $DIC->language();
46
47 $this->db = $ilDB;
48 $this->lng = $lng;
49
50 $this->lng->loadLanguageModule('assessment');
51
52 $this->inst_id = IL_INST_ID;
53
54 $this->preview_mode = $a_preview_mode;
55
56 $this->tpl = new ilTemplate("tpl.question_export.html", true, true, "Modules/Scorm2004");
57
58 // fix for bug 5386, alex 29.10.2009
59 if (!$a_preview_mode) {
60 $this->tpl->setVariable("FORM_BEGIN", "<form onsubmit='return false;'>");
61 $this->tpl->setVariable("FORM_END", "</form>");
62 }
63 }
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, $ilDB, and $lng.

Member Function Documentation

◆ assClozeTest()

ilQuestionExporter::assClozeTest ( )
private

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

272 {
273 $this->tpl->setCurrentBlock("clozequestion");
274 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
275 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
276 if ($this->preview_mode) {
277 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
278 }
279 $this->tpl->parseCurrentBlock();
280 // $this->setHeaderFooter();
281 return $this->tpl->get();
282 }

◆ assErrorText()

ilQuestionExporter::assErrorText ( )
private

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

398 {
399 $this->tpl->setCurrentBlock("errortext");
400 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
401 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
402 if ($this->preview_mode) {
403 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
404 }
405 $this->tpl->parseCurrentBlock();
406 // $this->setHeaderFooter();
407 return $this->tpl->get();
408 }

◆ assImagemapQuestion()

ilQuestionExporter::assImagemapQuestion ( )
private

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

346 {
347 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
348 array_push(self::$media_files, $this->q_gui->object->getImagePath() . $this->q_gui->object->getImageFilename());
349 $this->tpl->setCurrentBlock("mapareas");
350 $areas = $this->json_decoded->answers;
351 //set areas in PHP cause of inteference between pure and highlighter
352 foreach ($areas as $area) {
353 $this->tpl->setVariable("VAL_TOOLTIP", htmlspecialchars($area->answertext));
354 $this->tpl->setVariable("VAL_COORDS", $area->coords);
355 $this->tpl->setVariable("VAL_ORDER", $area->order);
356 $this->tpl->setVariable("VAL_AREA", $area->area);
357 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
358 $this->tpl->parseCurrentBlock();
359 }
360 $this->tpl->setCurrentBlock("imagemapquestion");
361 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
362 if ($this->preview_mode) {
363 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
364 }
365 $this->tpl->parseCurrentBlock();
366 // $this->setHeaderFooter();
367 return $this->tpl->get();
368 }

◆ assKprimChoice()

ilQuestionExporter::assKprimChoice ( )
private

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

209 {
210 global $DIC;
211 $main_tpl = $DIC["tpl"];
212
213 $main_tpl->addCss('Modules/Test/templates/default/ta.css');
214
215 $this->tpl->setCurrentBlock("kprimchoice");
216
217 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
218 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
219
220 if ($this->preview_mode) {
221 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
222 }
223
224 if ($this->json_decoded->path) {
225 $this->tpl->setVariable(
226 "HANDLE_IMAGES",
227 "ilias.questions.handleKprimImages(" . $this->json_decoded->id . ");"
228 );
229 }
230
231 $this->tpl->setVariable('OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
232 $this->tpl->setVariable('OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
233
234 $this->tpl->setVariable('VALUE_TRUE', 1);
235 $this->tpl->setVariable('VALUE_FALSE', 0);
236
237 $this->tpl->parseCurrentBlock();
238
239 foreach ($this->json_decoded->answers as $answer) {
240 if (is_object($answer->image)) {
241 self::$media_files[] = $answer->getImageFsPath();
242 self::$media_files[] = $answer->getThumbFsPath();
243 } elseif (is_string($answer->image)) {
244 self::$media_files[] = $this->q_gui->object->getImagePath() . $answer->image;
245 if (is_file($this->q_gui->object->getImagePath() . "thumb." . $answer->image)) {
246 self::$media_files[] = $this->q_gui->object->getImagePath() . "thumb." . $answer->image;
247 }
248 }
249 }
250
251 // $this->setHeaderFooter();
252
253 return $this->tpl->get();
254 }

References $DIC.

◆ assLongMenu()

ilQuestionExporter::assLongMenu ( )
private

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

285 {
286 $this->tpl->setCurrentBlock("longmenu");
287 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
288 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
289 if ($this->preview_mode) {
290 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
291 }
292 $this->tpl->parseCurrentBlock();
293 // $this->setHeaderFooter();
294 return $this->tpl->get();
295 }

◆ assMatchingQuestion()

ilQuestionExporter::assMatchingQuestion ( )
private

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

327 {
328 global $DIC;
329 $main_tpl = $DIC["tpl"];
330
331 $main_tpl->addJavaScript('Modules/TestQuestionPool/js/ilMatchingQuestion.js');
332 $main_tpl->addCss('Modules/TestQuestionPool/templates/default/test_javascript.css');
333 $this->tpl->setCurrentBlock("matchingquestion");
334 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
335 $this->tpl->setVariable("BTN_LABEL_RESET", $this->lng->txt("reset_terms"));
336 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
337 if ($this->preview_mode) {
338 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
339 }
340 $this->tpl->parseCurrentBlock();
341 // $this->setHeaderFooter();
342 return $this->tpl->get();
343 }

References $DIC.

◆ assMultipleChoice()

ilQuestionExporter::assMultipleChoice ( )
private

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

168 {
169 $main_tpl = $GLOBALS["tpl"];
170 $this->q_gui->populateJavascriptFilesRequiredForWorkForm($main_tpl);
171 $main_tpl->addCss('Modules/Test/templates/default/ta.css');
172
173 $this->tpl->setCurrentBlock("multiplechoice");
174 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
175 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
176 if ($this->json_decoded->selection_limit) {
177 $this->tpl->setVariable('SELECTION_LIMIT_HINT', sprintf(
178 $this->lng->txt('ass_mc_sel_lim_hint'),
179 $this->json_decoded->selection_limit,
180 count($this->json_decoded->answers)
181 ));
182
183 $this->tpl->setVariable('SELECTION_LIMIT_VALUE', $this->json_decoded->selection_limit);
184 } else {
185 $this->tpl->setVariable('SELECTION_LIMIT_VALUE', 'null');
186 }
187 if ($this->preview_mode) {
188 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
189 }
190 if ($this->json_decoded->path) {
191 $this->tpl->setVariable(
192 "HANDLE_IMAGES",
193 "ilias.questions.handleMCImages(" . $this->json_decoded->id . ");"
194 );
195 }
196 $this->tpl->parseCurrentBlock();
197 foreach ($this->json_decoded->answers as $answer) {
198 if ($answer->image!="") {
199 array_push(self::$media_files, $this->q_gui->object->getImagePath() . $answer->image);
200 array_push(self::$media_files, $this->q_gui->object->getImagePath() . "thumb." . $answer->image);
201 }
202 }
203 // $this->setHeaderFooter();
204 return $this->tpl->get();
205 }
sprintf('%.4f', $callTime)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, and sprintf.

◆ assOrderingHorizontal()

ilQuestionExporter::assOrderingHorizontal ( )
private

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

385 {
386 $this->tpl->setCurrentBlock("orderinghorizontal");
387 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
388 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
389 if ($this->preview_mode) {
390 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
391 }
392 $this->tpl->parseCurrentBlock();
393 // $this->setHeaderFooter();
394 return $this->tpl->get();
395 }

◆ assOrderingQuestion()

ilQuestionExporter::assOrderingQuestion ( )
private

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

298 {
299 $this->tpl->setCurrentBlock("orderingquestion");
300 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
301 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
302 if ($this->preview_mode) {
303 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
304 }
305 if ($this->q_gui->object->getOrderingType() == OQ_PICTURES) {
306 $this->tpl->setVariable("VAL_SUBTYPE", "_images");
307 $this->tpl->setVariable(
308 "HANDLE_IMAGES",
309 "ilias.questions.handleOrderingImages(" . $this->json_decoded->id . ");"
310 );
311
312 foreach ($this->json_decoded->answers as $answer) {
313 if ($answer->answertext!="") {
314 array_push(self::$media_files, $this->q_gui->object->getImagePath() . $answer->answertext);
315 array_push(self::$media_files, $this->q_gui->object->getImagePath() . "thumb." . $answer->answertext);
316 }
317 }
318 } else {
319 $this->tpl->setVariable("VAL_SUBTYPE", "_terms");
320 }
321 $this->tpl->parseCurrentBlock();
322 // $this->setHeaderFooter();
323 return $this->tpl->get();
324 }
const OQ_PICTURES
Ordering question constants.

References OQ_PICTURES.

◆ assSingleChoice()

ilQuestionExporter::assSingleChoice ( )
private

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

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

◆ assTextQuestion()

ilQuestionExporter::assTextQuestion ( )
private

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

257 {
258 $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
259 $this->tpl->setCurrentBlock("textquestion");
260 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
261 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
262 $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
263 if ($this->preview_mode) {
264 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
265 }
266 $this->tpl->parseCurrentBlock();
267 // $this->setHeaderFooter();
268 return $this->tpl->get();
269 }

◆ assTextSubset()

ilQuestionExporter::assTextSubset ( )
private

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

371 {
372 $this->tpl->setCurrentBlock("textsubset");
373 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
374 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
375 $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
376 if ($this->preview_mode) {
377 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
378 }
379 $this->tpl->parseCurrentBlock();
380 // $this->setHeaderFooter();
381 return $this->tpl->get();
382 }

◆ exportQuestion()

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

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

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

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

+ Here is the call graph for this function:

◆ getFiles()

static ilQuestionExporter::getFiles ( )
static

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

114 {
115 return self::$media_files;
116 }

References $media_files.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

+ Here is the caller graph for this function:

◆ getMobs()

static ilQuestionExporter::getMobs ( )
static

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

103 {
104 $allmobs = array();
105 foreach (self::$mobs as $key => $value) {
106 for ($i=0;$i<count(self::$mobs[$key]);$i++) {
107 array_push($allmobs, self::$mobs[$key][$i]);
108 }
109 }
110 return $allmobs;
111 }
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19

References $i, $key, and $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

+ Here is the caller graph for this function:

◆ indicateNewSco()

static ilQuestionExporter::indicateNewSco ( )
static

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

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

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 118 of file class.ilQuestionExporter.php.

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

References $key.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects(), ilPCQuestion\modifyPageContentPostXsl(), and ilSCORM2004ScoGUI\sco_preview().

+ Here is the caller graph for this function:

◆ setHeaderFooter()

ilQuestionExporter::setHeaderFooter ( )
private

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

133 {
134 $this->tpl->setCurrentBlock("common");
135 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
136 $this->tpl->setVariable("VAL_TYPE", $this->json_decoded->type);
137 $this->tpl->parseCurrentBlock();
138 }

Field Documentation

◆ $db

ilQuestionExporter::$db

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

◆ $exported

ilQuestionExporter::$exported = array()
static

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

◆ $inst_id

ilQuestionExporter::$inst_id

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

Referenced by exportQuestion().

◆ $json

ilQuestionExporter::$json

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

Referenced by exportQuestion().

◆ $json_decoded

ilQuestionExporter::$json_decoded

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

◆ $lng

ilQuestionExporter::$lng
protected

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

Referenced by __construct().

◆ $media_files

ilQuestionExporter::$media_files = array()
static

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

Referenced by getFiles().

◆ $mobs

ilQuestionExporter::$mobs = array()
static

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

◆ $preview_mode

ilQuestionExporter::$preview_mode

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

◆ $q_gui

ilQuestionExporter::$q_gui

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

◆ $ref_id

ilQuestionExporter::$ref_id

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

◆ $tpl

ilQuestionExporter::$tpl

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


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