ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilQuestionExporter Class Reference

Scorm 2004 Question Exporter. More...

+ Collaboration diagram for ilQuestionExporter:

Public Member Functions

 __construct ($a_preview_mode=false)
 Constructor 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 public.

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

References $DIC, $ilDB, and $lng.

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  }
global $DIC
Definition: saml.php:7
special template class to simplify handling of ITX/PEAR
global $ilDB

Member Function Documentation

◆ assClozeTest()

ilQuestionExporter::assClozeTest ( )
private

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

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

◆ assErrorText()

ilQuestionExporter::assErrorText ( )
private

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

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

◆ assImagemapQuestion()

ilQuestionExporter::assImagemapQuestion ( )
private

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

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

◆ assKprimChoice()

ilQuestionExporter::assKprimChoice ( )
private

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

References $DIC.

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

◆ assLongMenu()

ilQuestionExporter::assLongMenu ( )
private

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

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

◆ assMatchingQuestion()

ilQuestionExporter::assMatchingQuestion ( )
private

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

References $DIC.

331  {
332  global $DIC;
333  $main_tpl = $DIC["tpl"];
334 
335  $main_tpl->addJavaScript('Modules/TestQuestionPool/js/ilMatchingQuestion.js');
336  $main_tpl->addCss('Modules/TestQuestionPool/templates/default/test_javascript.css');
337  $this->tpl->setCurrentBlock("matchingquestion");
338  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
339  $this->tpl->setVariable("BTN_LABEL_RESET", $this->lng->txt("reset_terms"));
340  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
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  }
global $DIC
Definition: saml.php:7

◆ assMultipleChoice()

ilQuestionExporter::assMultipleChoice ( )
private

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

References $GLOBALS.

168  {
169  // do not! use $GLOBALS['DIC']["tpl"]
170  // or $DIC->ui()->mainTemplate()
171  // at this point because LMs does init an own main template
172  // and currently replaces only $GLOBALS["tpl"] with the new one
173  $main_tpl = $GLOBALS["tpl"];
174  $this->q_gui->populateJavascriptFilesRequiredForWorkForm($main_tpl);
175  $main_tpl->addCss('Modules/Test/templates/default/ta.css');
176 
177  $this->tpl->setCurrentBlock("multiplechoice");
178  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
179  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
180  if ($this->json_decoded->selection_limit) {
181  $this->tpl->setVariable('SELECTION_LIMIT_HINT', sprintf(
182  $this->lng->txt('ass_mc_sel_lim_hint'),
183  $this->json_decoded->selection_limit,
184  count($this->json_decoded->answers)
185  ));
186 
187  $this->tpl->setVariable('SELECTION_LIMIT_VALUE', $this->json_decoded->selection_limit);
188  } else {
189  $this->tpl->setVariable('SELECTION_LIMIT_VALUE', 'null');
190  }
191  if ($this->preview_mode) {
192  $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
193  }
194  if ($this->json_decoded->path) {
195  $this->tpl->setVariable(
196  "HANDLE_IMAGES",
197  "ilias.questions.handleMCImages(" . $this->json_decoded->id . ");"
198  );
199  }
200  $this->tpl->parseCurrentBlock();
201  foreach ($this->json_decoded->answers as $answer) {
202  if ($answer->image != "") {
203  array_push(self::$media_files, $this->q_gui->object->getImagePath() . $answer->image);
204  array_push(self::$media_files, $this->q_gui->object->getImagePath() . "thumb." . $answer->image);
205  }
206  }
207  // $this->setHeaderFooter();
208  return $this->tpl->get();
209  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ assOrderingHorizontal()

ilQuestionExporter::assOrderingHorizontal ( )
private

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

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

◆ assOrderingQuestion()

ilQuestionExporter::assOrderingQuestion ( )
private

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

References OQ_PICTURES.

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

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

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

◆ assTextSubset()

ilQuestionExporter::assTextSubset ( )
private

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

375  {
376  $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
377  $this->tpl->setCurrentBlock("textsubset");
378  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
379  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
380  if ($this->preview_mode) {
381  $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
382  }
383  $this->tpl->parseCurrentBlock();
384  // $this->setHeaderFooter();
385  return $this->tpl->get();
386  }

◆ exportQuestion()

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

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

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

67  {
68  if ($a_ref_id != "") {
70  if (!($inst_id > 0)) {
71  $q_id = ilInternalLink::_extractObjIdOfTarget($a_ref_id);
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  }
$type
$mobs
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...
+ Here is the call graph for this function:

◆ getFiles()

static ilQuestionExporter::getFiles ( )
static

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

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

114  {
115  return self::$media_files;
116  }
+ Here is the caller graph for this function:

◆ getMobs()

static ilQuestionExporter::getMobs ( )
static

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

References $i, $key, and $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

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  }
$mobs
$i
Definition: disco.tpl.php:19
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ indicateNewSco()

static ilQuestionExporter::indicateNewSco ( )
static

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

References $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

96  {
97  self::$exported = array();
98  self::$mobs = array();
99  self::$media_files = array();
100  }
$mobs
+ 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.

References $key.

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

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  }
$key
Definition: croninfo.php:18
+ 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.

◆ $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: