ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilQuestionExporter Class Reference

Scorm 2004 Question Exporter. More...

+ Collaboration diagram for ilQuestionExporter:

Public Member Functions

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

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 ()
 
 assTextQuestion ()
 
 assClozeTest ()
 
 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 191 of file class.ilQuestionExporter.php.

191  {
192  $this->tpl->setCurrentBlock("clozequestion");
193  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
194  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
195  if ($this->preview_mode) {
196  $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
197  }
198  $this->tpl->parseCurrentBlock();
199 // $this->setHeaderFooter();
200  return $this->tpl->get();
201  }

◆ assErrorText()

ilQuestionExporter::assErrorText ( )
private

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

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

◆ assImagemapQuestion()

ilQuestionExporter::assImagemapQuestion ( )
private

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

244  {
245  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
246  array_push(self::$media_files,$this->q_gui->object->getImagePath().$this->q_gui->object->getImageFilename());
247  $this->tpl->setCurrentBlock("mapareas");
248  $areas = $this->json_decoded->answers;
249  //set areas in PHP cause of inteference between pure and highlighter
250  foreach ($areas as $area) {
251  $this->tpl->setVariable("VAL_COORDS", $area->coords);
252  $this->tpl->setVariable("VAL_ORDER", $area->order);
253  $this->tpl->setVariable("VAL_AREA", $area->area);
254  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
255  $this->tpl->parseCurrentBlock();
256  }
257  $this->tpl->setCurrentBlock("imagemapquestion");
258  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
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 232 of file class.ilQuestionExporter.php.

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

◆ assMultipleChoice()

ilQuestionExporter::assMultipleChoice ( )
private

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

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

◆ assOrderingHorizontal()

ilQuestionExporter::assOrderingHorizontal ( )
private

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

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

◆ assOrderingQuestion()

ilQuestionExporter::assOrderingQuestion ( )
private

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

References OQ_PICTURES.

203  {
204  $this->tpl->setCurrentBlock("orderingquestion");
205  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
206  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
207  if ($this->preview_mode) {
208  $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
209  }
210  if($this->q_gui->object->getOrderingType() == OQ_PICTURES)
211  {
212  $this->tpl->setVariable("VAL_SUBTYPE", "_images");
213  $this->tpl->setVariable("HANDLE_IMAGES",
214  "ilias.questions.handleOrderingImages(".$this->json_decoded->id.");");
215 
216  foreach ($this->json_decoded->answers as $answer) {
217  if ($answer->answertext!="") {
218  array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->answertext);
219  array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->answertext);
220  }
221  }
222  }
223  else
224  {
225  $this->tpl->setVariable("VAL_SUBTYPE", "_terms");
226  }
227  $this->tpl->parseCurrentBlock();
228 // $this->setHeaderFooter();
229  return $this->tpl->get();
230  }
const OQ_PICTURES
Ordering question constants.

◆ assSingleChoice()

ilQuestionExporter::assSingleChoice ( )
private

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

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

◆ assTextQuestion()

ilQuestionExporter::assTextQuestion ( )
private

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

177  {
178  $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
179  $this->tpl->setCurrentBlock("textquestion");
180  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
181  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
182  $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
183  if ($this->preview_mode) {
184  $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
185  }
186  $this->tpl->parseCurrentBlock();
187 // $this->setHeaderFooter();
188  return $this->tpl->get();
189  }

◆ assTextSubset()

ilQuestionExporter::assTextSubset ( )
private

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

267  {
268  $this->tpl->setCurrentBlock("textsubset");
269  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
270  $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
271  $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
272  if ($this->preview_mode) {
273  $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
274  }
275  $this->tpl->parseCurrentBlock();
276 // $this->setHeaderFooter();
277  return $this->tpl->get();
278  }

◆ exportQuestion()

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

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

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

61  {
62 
63  if ($a_ref_id != "")
64  {
66  if (!($inst_id > 0))
67  {
68  $q_id = ilInternalLink::_extractObjIdOfTarget($a_ref_id);
69  }
70  }
71 
72  $this->q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id);
73 
74  $type = $this->q_gui->object->getQuestionType();
75  if (method_exists($this,$type))
76  {
77  $this->q_gui->object->setExportImagePath($a_image_path);
78  $this->q_gui->object->feedbackOBJ->setPageObjectOutputMode($a_output_mode);
79  $this->json = $this->q_gui->object->toJSON();
80  $this->json_decoded = json_decode($this->json);
81 
82  self::$exported[$this->json_decoded->id] = $this->json;
83  self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
84  return $this->$type();
85  } else {
86  return "Error: Question Type not implemented/Question editing not finished";
87  }
88  }
$mobs
& _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 106 of file class.ilQuestionExporter.php.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

106  {
107  return self::$media_files;
108  }
+ Here is the caller graph for this function:

◆ getMobs()

static ilQuestionExporter::getMobs ( )
static

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

References $mobs, and $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

96  {
97  $allmobs = array();
98  foreach (self::$mobs as $key => $value) {
99  for ($i=0;$i<count($mobs[$key]);$i++) {
100  array_push($allmobs,$mobs[$key][$i]);
101  }
102  }
103  return $allmobs;
104  }
$mobs
+ Here is the caller graph for this function:

◆ ilQuestionExporter()

ilQuestionExporter::ilQuestionExporter (   $a_preview_mode = false)

Constructor public.

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

References $ilias, and $lng.

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

◆ indicateNewSco()

static ilQuestionExporter::indicateNewSco ( )
static

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

References $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

90  {
91  self::$exported = array();
92  self::$mobs = array();
93  self::$media_files = array();
94  }
$mobs
+ Here is the caller graph for this function:

◆ questionsJS()

static ilQuestionExporter::questionsJS ( )
static

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

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

110  {
111  $exportstring ='var questions = new Array();';
112  foreach (self::$exported as $key => $value) {
113  $exportstring .= "questions[$key]= $value;";
114  }
115  return $exportstring;
116  }
+ Here is the caller graph for this function:

◆ setHeaderFooter()

ilQuestionExporter::setHeaderFooter ( )
private

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

119  {
120  $this->tpl->setCurrentBlock("common");
121  $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
122  $this->tpl->setVariable("VAL_TYPE", $this->json_decoded->type);
123  $this->tpl->parseCurrentBlock();
124  }

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.

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

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


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