ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilQuestionExporter Class Reference

Scorm 2004 Question Exporter. More...

+ Collaboration diagram for ilQuestionExporter:

Public Member Functions

 __construct (bool $a_preview_mode=false)
 Constructor @access public. More...
 
 exportQuestion ($a_ref_id, $a_image_path=null, $a_output_mode="presentation")
 

Static Public Member Functions

static questionsJS (?array $a_qids=null)
 

Data Fields

ilDBInterface $db
 
int $ref_id
 
int $inst_id
 
assQuestionGUI $q_gui
 
ilTemplate $tpl
 
string $json
 
mixed $json_decoded
 
bool $preview_mode
 

Static Public Attributes

static array $exported = []
 
static array $mobs = []
 
static array $media_files = []
 

Protected Attributes

ilLanguage $lng
 

Private Member Functions

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

Constructor & Destructor Documentation

◆ __construct()

ilQuestionExporter::__construct ( bool  $a_preview_mode = false)

Constructor @access public.

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

55 {
56 global $DIC;
57
58 $ilDB = $DIC->database();
59 $lng = $DIC->language();
60
61 $this->db = $ilDB;
62 $this->lng = $lng;
63
64 $this->lng->loadLanguageModule('assessment');
65
66 $this->inst_id = IL_INST_ID;
67
68 $this->preview_mode = $a_preview_mode;
69
70 $this->tpl = new ilTemplate("tpl.question_export.html", true, true, "components/ILIAS/COPage");
71
72 // fix for bug 5386, alex 29.10.2009
73 if (!$a_preview_mode) {
74 $this->tpl->setVariable("FORM_BEGIN", "<form onsubmit='return false;'>");
75 $this->tpl->setVariable("FORM_END", "</form>");
76 }
77 }
special template class to simplify handling of ITX/PEAR
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: shib_login.php:26

References $DIC, $ilDB, $lng, IL_INST_ID, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ assClozeTest()

ilQuestionExporter::assClozeTest ( )
private

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

240 : string
241 {
242 $this->tpl->setCurrentBlock("clozequestion");
243 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
244 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
245 if ($this->preview_mode) {
246 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
247 }
248 $this->tpl->parseCurrentBlock();
249 return $this->tpl->get();
250 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assErrorText()

ilQuestionExporter::assErrorText ( )
private

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

353 : string
354 {
355 $this->tpl->setCurrentBlock("errortext");
356 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
357 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
358 if ($this->preview_mode) {
359 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
360 }
361 $this->tpl->parseCurrentBlock();
362 return $this->tpl->get();
363 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assImagemapQuestion()

ilQuestionExporter::assImagemapQuestion ( )
private

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

305 : string
306 {
307 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
308 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . $this->q_gui->getObject()->getImageFilename());
309 $this->tpl->setCurrentBlock("mapareas");
310 $areas = $this->json_decoded->answers;
311 //set areas in PHP cause of inteference between pure and highlighter
312 foreach ($areas as $area) {
313 $this->tpl->setVariable("VAL_TOOLTIP", htmlspecialchars($area->answertext));
314 $this->tpl->setVariable("VAL_COORDS", $area->coords);
315 $this->tpl->setVariable("VAL_ORDER", $area->order);
316 $this->tpl->setVariable("VAL_AREA", $area->area);
317 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
318 $this->tpl->parseCurrentBlock();
319 }
320 $this->tpl->setCurrentBlock("imagemapquestion");
321 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
322 if ($this->preview_mode) {
323 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
324 }
325 $this->tpl->parseCurrentBlock();
326 return $this->tpl->get();
327 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assKprimChoice()

ilQuestionExporter::assKprimChoice ( )
private

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

185 : string
186 {
187 $this->tpl->setCurrentBlock("kprimchoice");
188
189 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
190 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
191
192 if ($this->preview_mode) {
193 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
194 }
195
196 if ($this->json_decoded->path ?? false) {
197 $this->tpl->setVariable(
198 "HANDLE_IMAGES",
199 "ilias.questions.handleKprimImages(" . $this->json_decoded->id . ");"
200 );
201 }
202
203 $this->tpl->setVariable('OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
204 $this->tpl->setVariable('OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
205
206 $this->tpl->setVariable('VALUE_TRUE', 1);
207 $this->tpl->setVariable('VALUE_FALSE', 0);
208
209 $this->tpl->parseCurrentBlock();
210
211 foreach ($this->json_decoded->answers as $answer) {
212 if (is_object($answer->image)) {
213 self::$media_files[] = $answer->getImageFsPath();
214 self::$media_files[] = $answer->getThumbFsPath();
215 } elseif (is_string($answer->image)) {
216 self::$media_files[] = $this->q_gui->getObject()->getImagePath() . $answer->image;
217 if (is_file($this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image)) {
218 self::$media_files[] = $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image;
219 }
220 }
221 }
222
223 return $this->tpl->get();
224 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assLongMenu()

ilQuestionExporter::assLongMenu ( )
private

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

252 : string
253 {
254 $this->tpl->setCurrentBlock("longmenu");
255 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
256 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
257 if ($this->preview_mode) {
258 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
259 }
260 $this->tpl->parseCurrentBlock();
261 return $this->tpl->get();
262 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assMatchingQuestion()

ilQuestionExporter::assMatchingQuestion ( )
private

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assMultipleChoice()

ilQuestionExporter::assMultipleChoice ( )
private

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

149 : string
150 {
151 $this->tpl->setCurrentBlock("multiplechoice");
152 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
153 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
154 if ($this->json_decoded->selection_limit) {
155 $this->tpl->setVariable('SELECTION_LIMIT_HINT', sprintf(
156 $this->lng->txt('ass_mc_sel_lim_hint'),
157 $this->json_decoded->selection_limit,
158 count($this->json_decoded->answers)
159 ));
160
161 $this->tpl->setVariable('SELECTION_LIMIT_VALUE', $this->json_decoded->selection_limit);
162 } else {
163 $this->tpl->setVariable('SELECTION_LIMIT_VALUE', 'null');
164 }
165 if ($this->preview_mode) {
166 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
167 }
168 if (isset($this->json_decoded->path)) {
169 $this->tpl->setVariable(
170 "HANDLE_IMAGES",
171 "ilias.questions.handleMCImages(" . $this->json_decoded->id . ");"
172 );
173 }
174 $this->tpl->parseCurrentBlock();
175 foreach ($this->json_decoded->answers as $answer) {
176 if ($answer->image != "") {
177 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . $answer->image);
178 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image);
179 }
180 }
181 return $this->tpl->get();
182 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assOrderingHorizontal()

ilQuestionExporter::assOrderingHorizontal ( )
private

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

341 : string
342 {
343 $this->tpl->setCurrentBlock("orderinghorizontal");
344 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
345 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
346 if ($this->preview_mode) {
347 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
348 }
349 $this->tpl->parseCurrentBlock();
350 return $this->tpl->get();
351 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assOrderingQuestion()

ilQuestionExporter::assOrderingQuestion ( )
private

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

264 : string
265 {
266 $this->tpl->setCurrentBlock("orderingquestion");
267 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
268 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
269 if ($this->preview_mode) {
270 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
271 }
272 if ($this->q_gui->getObject()->getOrderingType() == assOrderingQuestion::OQ_PICTURES) {
273 $this->tpl->setVariable("VAL_SUBTYPE", "_images");
274 $this->tpl->setVariable(
275 "HANDLE_IMAGES",
276 "ilias.questions.handleOrderingImages(" . $this->json_decoded->id . ");"
277 );
278
279 foreach ($this->json_decoded->answers as $answer) {
280 if ($answer->answertext != "") {
281 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . $answer->answertext);
282 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->answertext);
283 }
284 }
285 } else {
286 $this->tpl->setVariable("VAL_SUBTYPE", "_terms");
287 }
288 $this->tpl->parseCurrentBlock();
289 return $this->tpl->get();
290 }

References ILIAS\Repository\lng(), and assOrderingQuestion\OQ_PICTURES.

+ Here is the call graph for this function:

◆ assSingleChoice()

ilQuestionExporter::assSingleChoice ( )
private

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

123 : string
124 {
125 $this->tpl->setCurrentBlock("singlechoice");
126 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
127 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
128 if ($this->preview_mode) {
129 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
130 }
131 if ($this->json_decoded->path ?? false) {
132 $this->tpl->setVariable(
133 "HANDLE_IMAGES",
134 "ilias.questions.handleMCImages(" . $this->json_decoded->id . ");"
135 );
136 }
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->getObject()->getImagePath() . $answer->image);
141 if (is_file($this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image)) {
142 array_push(self::$media_files, $this->q_gui->getObject()->getImagePath() . "thumb." . $answer->image);
143 }
144 }
145 }
146 return $this->tpl->get();
147 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assTextQuestion()

ilQuestionExporter::assTextQuestion ( )
private

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

226 : string
227 {
228 $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
229 $this->tpl->setCurrentBlock("textquestion");
230 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
231 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
232 $this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
233 if ($this->preview_mode) {
234 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
235 }
236 $this->tpl->parseCurrentBlock();
237 return $this->tpl->get();
238 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assTextSubset()

ilQuestionExporter::assTextSubset ( )
private

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

329 : string
330 {
331 $this->tpl->setCurrentBlock("textsubset");
332 $this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
333 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
334 if ($this->preview_mode) {
335 $this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
336 }
337 $this->tpl->parseCurrentBlock();
338 return $this->tpl->get();
339 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ exportQuestion()

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

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

81 {
82 if ($a_ref_id != "") {
84 if (!($inst_id > 0)) {
86 }
87 }
88
89 $this->q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
90
91 if (!is_object($this->q_gui->getObject())) {
92 return "Error: Question not found.";
93 }
94
95 $type = $this->q_gui->getObject()->getQuestionType();
96 if ($this->q_gui->getObject() instanceof QuestionLMExportable) {
97 $this->q_gui->getObject()->setExportImagePath($a_image_path);
98 $this->q_gui->getObject()->feedbackOBJ->setPageObjectOutputMode($a_output_mode);
99 $this->json = $this->q_gui->getObject()->toJSON();
100 $this->json_decoded = json_decode($this->json);
101 self::$exported[$this->json_decoded->id] = $this->json;
102 self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
103 return $this->$type();
104 } else {
105 return "Error: Question Type not implemented/Question editing not finished";
106 }
107 }
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.

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

+ Here is the call graph for this function:

◆ questionsJS()

static ilQuestionExporter::questionsJS ( ?array  $a_qids = null)
static

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

109 : string
110 {
111 $exportstring = '';
112 if (!is_array($a_qids)) {
113 $exportstring = 'var questions = new Array();';
114 }
115 foreach (self::$exported as $key => $value) {
116 if (!is_array($a_qids) || in_array($key, $a_qids)) {
117 $exportstring .= "questions[$key]= $value;";
118 }
119 }
120 return $exportstring;
121 }

Referenced by ilPCQuestion\modifyPageContentPostXsl().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilQuestionExporter::$db

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

◆ $exported

array ilQuestionExporter::$exported = []
static

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

◆ $inst_id

int ilQuestionExporter::$inst_id

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

Referenced by exportQuestion().

◆ $json

string ilQuestionExporter::$json

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

Referenced by exportQuestion().

◆ $json_decoded

mixed ilQuestionExporter::$json_decoded

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

◆ $lng

ilLanguage ilQuestionExporter::$lng
protected

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

Referenced by __construct().

◆ $media_files

array ilQuestionExporter::$media_files = []
static

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

◆ $mobs

array ilQuestionExporter::$mobs = []
static

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

◆ $preview_mode

bool ilQuestionExporter::$preview_mode

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

◆ $q_gui

assQuestionGUI ilQuestionExporter::$q_gui

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

◆ $ref_id

int ilQuestionExporter::$ref_id

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

◆ $tpl

ilTemplate ilQuestionExporter::$tpl

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


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