ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 30 of file class.ilQuestionExporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilQuestionExporter::__construct (   $a_preview_mode = false)

Constructor @access public.

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

55 {
56 global $DIC;
57
58 $ilDB = $DIC->database();
59 $lng = $DIC->language();
60
61 $this->db = $ilDB;
62 $this->lng = $lng;
63
64 $this->lng->loadLanguageModule('assessment');
65
66 $this->inst_id = IL_INST_ID;
67
68 $this->preview_mode = $a_preview_mode;
69
70 $this->tpl = new ilTemplate("tpl.question_export.html", true, true, "components/ILIAS/COPage");
71
72 // fix for bug 5386, alex 29.10.2009
73 if (!$a_preview_mode) {
74 $this->tpl->setVariable("FORM_BEGIN", "<form onsubmit='return false;'>");
75 $this->tpl->setVariable("FORM_END", "</form>");
76 }
77 }
special template class to simplify handling of ITX/PEAR
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: shib_login.php:26

References $DIC, $ilDB, $lng, IL_INST_ID, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ assClozeTest()

ilQuestionExporter::assClozeTest ( )
private

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assErrorText()

ilQuestionExporter::assErrorText ( )
private

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ 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->getObject()->getImagePath() . $this->q_gui->getObject()->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 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assKprimChoice()

ilQuestionExporter::assKprimChoice ( )
private

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

219 {
220 $this->tpl->setCurrentBlock("kprimchoice");
221
222 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
223 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
224
225 if ($this->preview_mode) {
226 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
227 }
228
229 if ($this->json_decoded->path ?? false) {
230 $this->tpl->setVariable(
231 "HANDLE_IMAGES",
232 "ilias.questions.handleKprimImages(" . $this->json_decoded->id . ");"
233 );
234 }
235
236 $this->tpl->setVariable('OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
237 $this->tpl->setVariable('OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
238
239 $this->tpl->setVariable('VALUE_TRUE', 1);
240 $this->tpl->setVariable('VALUE_FALSE', 0);
241
242 $this->tpl->parseCurrentBlock();
243
244 foreach ($this->json_decoded->answers as $answer) {
245 if (is_object($answer->image)) {
246 self::$media_files[] = $answer->getImageFsPath();
247 self::$media_files[] = $answer->getThumbFsPath();
248 } elseif (is_string($answer->image)) {
249 self::$media_files[] = $this->q_gui->getObject()->getImagePath() . $answer->image;
250 if (is_file($this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image)) {
251 self::$media_files[] = $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image;
252 }
253 }
254 }
255
256 // $this->setHeaderFooter();
257
258 return $this->tpl->get();
259 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assLongMenu()

ilQuestionExporter::assLongMenu ( )
private

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assMatchingQuestion()

ilQuestionExporter::assMatchingQuestion ( )
private

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

332 {
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 ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assMultipleChoice()

ilQuestionExporter::assMultipleChoice ( )
private

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

182 {
183 $this->tpl->setCurrentBlock("multiplechoice");
184 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
185 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
186 if ($this->json_decoded->selection_limit) {
187 $this->tpl->setVariable('SELECTION_LIMIT_HINT', sprintf(
188 $this->lng->txt('ass_mc_sel_lim_hint'),
189 $this->json_decoded->selection_limit,
190 count($this->json_decoded->answers)
191 ));
192
193 $this->tpl->setVariable('SELECTION_LIMIT_VALUE', $this->json_decoded->selection_limit);
194 } else {
195 $this->tpl->setVariable('SELECTION_LIMIT_VALUE', 'null');
196 }
197 if ($this->preview_mode) {
198 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
199 }
200 if (isset($this->json_decoded->path)) {
201 $this->tpl->setVariable(
202 "HANDLE_IMAGES",
203 "ilias.questions.handleMCImages(" . $this->json_decoded->id . ");"
204 );
205 }
206 $this->tpl->parseCurrentBlock();
207 foreach ($this->json_decoded->answers as $answer) {
208 if ($answer->image != "") {
209 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . $answer->image);
210 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image);
211 }
212 }
213 // $this->setHeaderFooter();
214 return $this->tpl->get();
215 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assOrderingHorizontal()

ilQuestionExporter::assOrderingHorizontal ( )
private

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assOrderingQuestion()

ilQuestionExporter::assOrderingQuestion ( )
private

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

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

References ILIAS\Repository\lng(), and assOrderingQuestion\OQ_PICTURES.

+ Here is the call graph for this function:

◆ assSingleChoice()

ilQuestionExporter::assSingleChoice ( )
private

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

155 {
156 $this->tpl->setCurrentBlock("singlechoice");
157 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
158 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
159 if ($this->preview_mode) {
160 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
161 }
162 if ($this->json_decoded->path ?? false) {
163 $this->tpl->setVariable(
164 "HANDLE_IMAGES",
165 "ilias.questions.handleMCImages(" . $this->json_decoded->id . ");"
166 );
167 }
168 $this->tpl->parseCurrentBlock();
169 foreach ($this->json_decoded->answers as $answer) {
170 if ($answer->image != "") {
171 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . $answer->image);
172 if (is_file($this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image)) {
173 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image);
174 }
175 }
176 }
177 // $this->setHeaderFooter();
178 return $this->tpl->get();
179 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assTextQuestion()

ilQuestionExporter::assTextQuestion ( )
private

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ 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 if ($this->preview_mode) {
376 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
377 }
378 $this->tpl->parseCurrentBlock();
379 // $this->setHeaderFooter();
380 return $this->tpl->get();
381 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ exportQuestion()

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

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

81 {
82 if ($a_ref_id != "") {
84 if (!($inst_id > 0)) {
86 }
87 }
88
89 $this->q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
90
91 if (!is_object($this->q_gui->getObject())) {
92 return "Error: Question not found.";
93 }
94
95 $type = $this->q_gui->getObject()->getQuestionType();
96 if($this->q_gui->getObject() instanceof QuestionLMExportable) {
97 $this->q_gui->getObject()->setExportImagePath($a_image_path);
98 $this->q_gui->getObject()->feedbackOBJ->setPageObjectOutputMode($a_output_mode);
99 $this->json = $this->q_gui->getObject()->toJSON();
100 $this->json_decoded = json_decode($this->json);
101 self::$exported[$this->json_decoded->id] = $this->json;
102 self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
103 return $this->$type();
104 } else {
105 return "Error: Question Type not implemented/Question editing not finished";
106 }
107 }
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.

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

+ Here is the call graph for this function:

◆ getFiles()

static ilQuestionExporter::getFiles ( )
static

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

128 {
129 return self::$media_files;
130 }

References $media_files.

◆ getMobs()

static ilQuestionExporter::getMobs ( )
static

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

117 {
118 $allmobs = array();
119 foreach (self::$mobs as $key => $value) {
120 for ($i = 0;$i < count(self::$mobs[$key]);$i++) {
121 array_push($allmobs, self::$mobs[$key][$i]);
122 }
123 }
124 return $allmobs;
125 }

◆ indicateNewSco()

static ilQuestionExporter::indicateNewSco ( )
static

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

110 {
111 self::$exported = array();
112 self::$mobs = array();
113 self::$media_files = array();
114 }

◆ questionsJS()

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

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

133 {
134 $exportstring = '';
135 if (!is_array($a_qids)) {
136 $exportstring = 'var questions = new Array();';
137 }
138 foreach (self::$exported as $key => $value) {
139 if (!is_array($a_qids) || in_array($key, $a_qids)) {
140 $exportstring .= "questions[$key]= $value;";
141 }
142 }
143 return $exportstring;
144 }

Referenced by ilPCQuestion\modifyPageContentPostXsl().

+ Here is the caller graph for this function:

◆ setHeaderFooter()

ilQuestionExporter::setHeaderFooter ( )
private

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

147 {
148 $this->tpl->setCurrentBlock("common");
149 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
150 $this->tpl->setVariable("VAL_TYPE", $this->json_decoded->type);
151 $this->tpl->parseCurrentBlock();
152 }

Field Documentation

◆ $db

ilQuestionExporter::$db

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

◆ $exported

ilQuestionExporter::$exported = array()
static

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

◆ $inst_id

ilQuestionExporter::$inst_id

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

Referenced by exportQuestion().

◆ $json

ilQuestionExporter::$json

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

Referenced by exportQuestion().

◆ $json_decoded

ilQuestionExporter::$json_decoded

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

◆ $lng

ilQuestionExporter::$lng
protected

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

Referenced by __construct().

◆ $media_files

ilQuestionExporter::$media_files = array()
static

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

Referenced by getFiles().

◆ $mobs

ilQuestionExporter::$mobs = array()
static

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

◆ $preview_mode

ilQuestionExporter::$preview_mode

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

◆ $q_gui

ilQuestionExporter::$q_gui

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

◆ $ref_id

ilQuestionExporter::$ref_id

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

◆ $tpl

ilQuestionExporter::$tpl

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


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