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>");
74 $type = $this->q_gui->object->getQuestionType();
75 if (method_exists($this,$type))
77 $this->q_gui->object->setExportImagePath($a_image_path);
78 $this->json = $this->q_gui->object->toJSON();
79 $this->json_decoded = json_decode($this->json);
80 self::$exported[$this->json_decoded->id] =
$this->json;
81 self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
82 return $this->$type();
84 return "Error: Question Type not implemented/Question editing not finished";
89 self::$exported = array();
91 self::$media_files = array();
97 for ($i=0;$i<count(
$mobs[$key]);$i++) {
98 array_push($allmobs,
$mobs[$key][$i]);
109 $exportstring =
'var questions = new Array();';
110 foreach (self::$exported as $key => $value) {
111 $exportstring .=
"questions[$key]= $value;";
113 return $exportstring;
118 $this->tpl->setCurrentBlock(
"common");
119 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
120 $this->tpl->setVariable(
"VAL_TYPE", $this->json_decoded->type);
121 $this->tpl->parseCurrentBlock();
126 $this->tpl->setCurrentBlock(
"singlechoice");
127 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
128 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
129 if ($this->preview_mode) {
130 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
132 if($this->json_decoded->path)
134 $this->tpl->setVariable(
"HANDLE_IMAGES",
135 "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
137 $this->tpl->parseCurrentBlock();
138 foreach ($this->json_decoded->answers as $answer) {
139 if ($answer->image!=
"") {
140 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
141 array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->image);
145 return $this->tpl->get();
149 $this->tpl->setCurrentBlock(
"multiplechoice");
150 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
151 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
152 if ($this->preview_mode) {
153 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
155 if($this->json_decoded->path)
157 $this->tpl->setVariable(
"HANDLE_IMAGES",
158 "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
160 $this->tpl->parseCurrentBlock();
161 foreach ($this->json_decoded->answers as $answer) {
162 if ($answer->image!=
"") {
163 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
164 array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->image);
168 return $this->tpl->get();
173 $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
174 $this->tpl->setCurrentBlock(
"textquestion");
175 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
176 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
177 $this->tpl->setVariable(
"VAL_MAXLENGTH", $maxlength);
178 if ($this->preview_mode) {
179 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
181 $this->tpl->parseCurrentBlock();
183 return $this->tpl->get();
187 $this->tpl->setCurrentBlock(
"clozequestion");
188 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
189 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
190 if ($this->preview_mode) {
191 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
193 $this->tpl->parseCurrentBlock();
195 return $this->tpl->get();
199 $this->tpl->setCurrentBlock(
"orderingquestion");
200 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
201 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
202 if ($this->preview_mode) {
203 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
205 if($this->q_gui->object->getOrderingType() ==
OQ_PICTURES)
207 $this->tpl->setVariable(
"VAL_SUBTYPE",
"_images");
208 $this->tpl->setVariable(
"HANDLE_IMAGES",
209 "ilias.questions.handleOrderingImages(".$this->json_decoded->id.
");");
211 foreach ($this->json_decoded->answers as $answer) {
212 if ($answer->answertext!=
"") {
213 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->answertext);
214 array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->answertext);
220 $this->tpl->setVariable(
"VAL_SUBTYPE",
"_terms");
222 $this->tpl->parseCurrentBlock();
224 return $this->tpl->get();
228 $this->tpl->setCurrentBlock(
"matchingquestion");
229 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
230 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
231 if ($this->preview_mode) {
232 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
234 $this->tpl->parseCurrentBlock();
236 return $this->tpl->get();
240 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
241 array_push(self::$media_files,$this->q_gui->object->getImagePath().$this->q_gui->object->getImageFilename());
242 $this->tpl->setCurrentBlock(
"mapareas");
243 $areas = $this->json_decoded->answers;
245 foreach ($areas as $area) {
246 $this->tpl->setVariable(
"VAL_COORDS", $area->coords);
247 $this->tpl->setVariable(
"VAL_ORDER", $area->order);
248 $this->tpl->setVariable(
"VAL_AREA", $area->area);
249 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
250 $this->tpl->parseCurrentBlock();
252 $this->tpl->setCurrentBlock(
"imagemapquestion");
253 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
254 if ($this->preview_mode) {
255 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
257 $this->tpl->parseCurrentBlock();
259 return $this->tpl->get();
263 $this->tpl->setCurrentBlock(
"textsubset");
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\"");
270 $this->tpl->parseCurrentBlock();
272 return $this->tpl->get();
276 $this->tpl->setCurrentBlock(
"orderinghorizontal");
277 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
278 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
279 if ($this->preview_mode) {
280 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
282 $this->tpl->parseCurrentBlock();
284 return $this->tpl->get();
288 $this->tpl->setCurrentBlock(
"errortext");
289 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
290 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
291 if ($this->preview_mode) {
292 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
294 $this->tpl->parseCurrentBlock();
296 return $this->tpl->get();