5 require_once(
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
39 $this->ref_id =& $a_ref_id;
44 $this->inst_id = IL_INST_ID;
46 $this->preview_mode = $a_preview_mode;
48 $this->tpl =
new ilTemplate(
"tpl.question_export.html",
true,
true,
"Modules/Scorm2004");
53 $this->tpl->setVariable(
"FORM_BEGIN",
"<form onsubmit='return false;'>");
54 $this->tpl->setVariable(
"FORM_END",
"</form>");
73 $type = $this->q_gui->object->getQuestionType();
74 if (method_exists($this,
$type))
76 $this->json = $this->q_gui->object->toJSON();
77 $this->json_decoded = json_decode($this->json);
78 self::$exported[$this->json_decoded->id] =
$this->json;
79 self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
80 return $this->
$type();
82 return "Error: Question Type not implemented/Question editing not finished";
87 self::$exported = array();
89 self::$media_files = array();
95 for ($i=0;$i<count(
$mobs[$key]);$i++) {
96 array_push($allmobs,
$mobs[$key][$i]);
107 $exportstring =
'var questions = new Array();';
108 foreach (self::$exported as $key => $value) {
109 $exportstring .=
"questions[$key]= $value;";
111 return $exportstring;
116 $this->tpl->setCurrentBlock(
"common");
117 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
118 $this->tpl->setVariable(
"VAL_TYPE", $this->json_decoded->type);
119 $this->tpl->parseCurrentBlock();
124 $this->tpl->setCurrentBlock(
"singlechoice");
125 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
126 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
127 if ($this->preview_mode) {
128 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
130 $this->tpl->parseCurrentBlock();
131 foreach ($this->json_decoded->answers as $answer) {
132 if ($answer->image!=
"") {
133 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
137 return $this->tpl->get();
141 $this->tpl->setCurrentBlock(
"multiplechoice");
142 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
143 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
144 if ($this->preview_mode) {
145 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
147 $this->tpl->parseCurrentBlock();
148 foreach ($this->json_decoded->answers as $answer) {
149 if ($answer->image!=
"") {
150 array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
154 return $this->tpl->get();
159 $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
160 $this->tpl->setCurrentBlock(
"textquestion");
161 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
162 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
163 $this->tpl->setVariable(
"VAL_MAXLENGTH", $maxlength);
164 if ($this->preview_mode) {
165 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
167 $this->tpl->parseCurrentBlock();
169 return $this->tpl->get();
173 $this->tpl->setCurrentBlock(
"clozequestion");
174 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
175 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
176 if ($this->preview_mode) {
177 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
179 $this->tpl->parseCurrentBlock();
181 return $this->tpl->get();
185 $this->tpl->setCurrentBlock(
"orderingquestion");
186 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
187 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
188 if ($this->preview_mode) {
189 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
191 $this->tpl->parseCurrentBlock();
193 return $this->tpl->get();
197 $this->tpl->setCurrentBlock(
"matchingquestion");
198 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
199 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
200 if ($this->preview_mode) {
201 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
203 $this->tpl->parseCurrentBlock();
205 return $this->tpl->get();
209 $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
210 array_push(self::$media_files,$this->q_gui->object->getImagePath().$this->q_gui->object->getImageFilename());
211 $this->tpl->setCurrentBlock(
"mapareas");
212 $areas = $this->json_decoded->answers;
214 foreach ($areas as $area) {
215 $this->tpl->setVariable(
"VAL_COORDS", $area->coords);
216 $this->tpl->setVariable(
"VAL_ORDER", $area->order);
217 $this->tpl->setVariable(
"VAL_AREA", $area->area);
218 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
219 $this->tpl->parseCurrentBlock();
221 $this->tpl->setCurrentBlock(
"imagemapquestion");
222 $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
223 if ($this->preview_mode) {
224 $this->tpl->setVariable(
"VAL_NO_DISPLAY",
"style=\"display:none\"");
226 $this->tpl->parseCurrentBlock();
228 return $this->tpl->get();