5 require_once(
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
40 $this->ref_id =& $a_ref_id;
45 $this->inst_id = IL_INST_ID;
47 $this->preview_mode = $a_preview_mode;
49 $this->tpl =
new ilTemplate(
"tpl.question_export.html",
true,
true,
"Modules/Scorm2004");
54 $this->tpl->setVariable(
"FORM_BEGIN",
"<form onsubmit='return false;'>");
55 $this->tpl->setVariable(
"FORM_END",
"</form>");
61 public function exportQuestion($a_ref_id, $a_image_path = null, $a_output_mode =
"presentation") {
74 $type = $this->q_gui->object->getQuestionType();
75 if (method_exists($this,$type))
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);
82 self::$exported[$this->json_decoded->id] =
$this->json;
83 self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
84 return $this->$type();
86 return "Error: Question Type not implemented/Question editing not finished";
91 self::$exported = array();
93 self::$media_files = array();
99 for ($i=0;$i<count(
$mobs[$key]);$i++) {
100 array_push($allmobs,
$mobs[$key][$i]);
107 return self::$media_files;
111 $exportstring =
'var questions = new Array();';
112 foreach (self::$exported as $key => $value) {
113 $exportstring .=
"questions[$key]= $value;";
115 return $exportstring;
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();
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\"");
134 if($this->json_decoded->path)
136 $this->tpl->setVariable(
"HANDLE_IMAGES",
137 "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
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))
145 array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->image);
150 return $this->tpl->get();
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\"");
160 if($this->json_decoded->path)
162 $this->tpl->setVariable(
"HANDLE_IMAGES",
163 "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
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);
173 return $this->tpl->get();
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\"");
186 $this->tpl->parseCurrentBlock();
188 return $this->tpl->get();
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\"");
198 $this->tpl->parseCurrentBlock();
200 return $this->tpl->get();
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\"");
210 if($this->q_gui->object->getOrderingType() ==
OQ_PICTURES)
212 $this->tpl->setVariable(
"VAL_SUBTYPE",
"_images");
213 $this->tpl->setVariable(
"HANDLE_IMAGES",
214 "ilias.questions.handleOrderingImages(".$this->json_decoded->id.
");");
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);
225 $this->tpl->setVariable(
"VAL_SUBTYPE",
"_terms");
227 $this->tpl->parseCurrentBlock();
229 return $this->tpl->get();
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\"");
239 $this->tpl->parseCurrentBlock();
241 return $this->tpl->get();
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;
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();
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\"");
262 $this->tpl->parseCurrentBlock();
264 return $this->tpl->get();
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\"");
275 $this->tpl->parseCurrentBlock();
277 return $this->tpl->get();
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\"");
287 $this->tpl->parseCurrentBlock();
289 return $this->tpl->get();
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\"");
299 $this->tpl->parseCurrentBlock();
301 return $this->tpl->get();
Scorm 2004 Question Exporter.
exportQuestion($a_ref_id, $a_image_path=null, $a_output_mode="presentation")
ilQuestionExporter($a_preview_mode=false)
Constructor public.
_extractObjIdOfTarget($a_target)
Extract object id out of target.
const OQ_PICTURES
Ordering question constants.
_extractInstOfTarget($a_target)
Extract installation id out of target.
special template class to simplify handling of ITX/PEAR
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...