58 $ilDB = $DIC->database();
59 $lng = $DIC->language();
64 $this->
lng->loadLanguageModule(
'assessment');
68 $this->preview_mode = $a_preview_mode;
70 $this->tpl =
new ilTemplate(
"tpl.question_export.html",
true,
true,
"components/ILIAS/COPage");
73 if (!$a_preview_mode) {
74 $this->tpl->setVariable(
"FORM_BEGIN",
"<form onsubmit='return false;'>");
75 $this->tpl->setVariable(
"FORM_END",
"</form>");
82 if ($a_ref_id !=
"") {
91 if (!is_object($this->q_gui->getObject())) {
92 return "Error: Question not found.";
95 $type = $this->q_gui->getObject()->getQuestionType();
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();
105 return "Error: Question Type not implemented/Question editing not finished";
111 self::$exported = array();
112 self::$mobs = array();
113 self::$media_files = 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]);
129 return self::$media_files;
135 if (!is_array($a_qids)) {
136 $exportstring =
'var questions = new Array();';
138 foreach (self::$exported as $key => $value) {
139 if (!is_array($a_qids) || in_array($key, $a_qids)) {
140 $exportstring .=
"questions[$key]= $value;";
143 return $exportstring;
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();
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\"");
162 if ($this->json_decoded->path ??
false) {
163 $this->tpl->setVariable(
165 "ilias.questions.handleMCImages(" . $this->json_decoded->id .
");" 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);
178 return $this->tpl->get();
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)
193 $this->tpl->setVariable(
'SELECTION_LIMIT_VALUE', $this->json_decoded->selection_limit);
195 $this->tpl->setVariable(
'SELECTION_LIMIT_VALUE',
'null');
197 if ($this->preview_mode) {
198 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
200 if (isset($this->json_decoded->path)) {
201 $this->tpl->setVariable(
203 "ilias.questions.handleMCImages(" . $this->json_decoded->id .
");" 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);
214 return $this->tpl->get();
220 $this->tpl->setCurrentBlock(
"kprimchoice");
222 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->
lng->txt(
"cont_submit_answers"));
223 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
225 if ($this->preview_mode) {
226 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
229 if ($this->json_decoded->path ??
false) {
230 $this->tpl->setVariable(
232 "ilias.questions.handleKprimImages(" . $this->json_decoded->id .
");" 236 $this->tpl->setVariable(
'OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
237 $this->tpl->setVariable(
'OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
239 $this->tpl->setVariable(
'VALUE_TRUE', 1);
240 $this->tpl->setVariable(
'VALUE_FALSE', 0);
242 $this->tpl->parseCurrentBlock();
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;
258 return $this->tpl->get();
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\"");
271 $this->tpl->parseCurrentBlock();
273 return $this->tpl->get();
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\"");
284 $this->tpl->parseCurrentBlock();
286 return $this->tpl->get();
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\"");
297 $this->tpl->parseCurrentBlock();
299 return $this->tpl->get();
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\"");
311 $this->tpl->setVariable(
"VAL_SUBTYPE",
"_images");
312 $this->tpl->setVariable(
314 "ilias.questions.handleOrderingImages(" . $this->json_decoded->id .
");" 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);
324 $this->tpl->setVariable(
"VAL_SUBTYPE",
"_terms");
326 $this->tpl->parseCurrentBlock();
328 return $this->tpl->get();
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\"");
340 $this->tpl->parseCurrentBlock();
342 return $this->tpl->get();
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;
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();
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\"");
365 $this->tpl->parseCurrentBlock();
367 return $this->tpl->get();
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\"");
378 $this->tpl->parseCurrentBlock();
380 return $this->tpl->get();
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\"");
391 $this->tpl->parseCurrentBlock();
393 return $this->tpl->get();
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\"");
404 $this->tpl->parseCurrentBlock();
406 return $this->tpl->get();
Scorm 2004 Question Exporter.
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exportQuestion($a_ref_id, $a_image_path=null, $a_output_mode="presentation")
static questionsJS(?array $a_qids=null)
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
static _extractInstOfTarget(string $a_target)
Extract installation id out of target.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct($a_preview_mode=false)
Constructor public.