@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param Ims2Question $question Ims2Question object we want to export. |
36 | 36 | */ |
37 | - function __construct($question) |
|
38 | - { |
|
37 | + function __construct($question) |
|
38 | + { |
|
39 | 39 | $this->question = $question; |
40 | 40 | $this->answer = $this->question->setAnswer(); |
41 | 41 | $this->questionIdent = "QST_" . $question->id ; |
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Start the XML flow. |
|
46 | - * |
|
47 | - * This opens the <item> block, with correct attributes. |
|
48 | - * |
|
49 | - */ |
|
50 | - function start_item() |
|
51 | - { |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Start the XML flow. |
|
46 | + * |
|
47 | + * This opens the <item> block, with correct attributes. |
|
48 | + * |
|
49 | + */ |
|
50 | + function start_item() |
|
51 | + { |
|
52 | 52 | $string = '<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" |
53 | 53 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
54 | 54 | xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 imsqti_v2p1.xsd" |
@@ -56,55 +56,55 @@ discard block |
||
56 | 56 | title="'.htmlspecialchars(formatExerciseQtiTitle($this->question->selectTitle())).'">'."\n"; |
57 | 57 | |
58 | 58 | return $string; |
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * End the XML flow, closing the </item> tag. |
|
63 | - * |
|
64 | - */ |
|
65 | - function end_item() |
|
66 | - { |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * End the XML flow, closing the </item> tag. |
|
63 | + * |
|
64 | + */ |
|
65 | + function end_item() |
|
66 | + { |
|
67 | 67 | return "</assessmentItem>\n"; |
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Start the itemBody |
|
72 | - * |
|
73 | - */ |
|
74 | - function start_item_body() |
|
75 | - { |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Start the itemBody |
|
72 | + * |
|
73 | + */ |
|
74 | + function start_item_body() |
|
75 | + { |
|
76 | 76 | return ' <itemBody>' . "\n"; |
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * End the itemBody part. |
|
81 | - * |
|
82 | - */ |
|
83 | - function end_item_body() |
|
84 | - { |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * End the itemBody part. |
|
81 | + * |
|
82 | + */ |
|
83 | + function end_item_body() |
|
84 | + { |
|
85 | 85 | return " </itemBody>\n"; |
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * add the response processing template used. |
|
90 | - * |
|
91 | - */ |
|
92 | - |
|
93 | - function add_response_processing() |
|
94 | - { |
|
95 | - return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Export the question as an IMS/QTI Item. |
|
100 | - * |
|
101 | - * This is a default behaviour, some classes may want to override this. |
|
102 | - * |
|
103 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | - * @return string string, the XML flow for an Item. |
|
105 | - */ |
|
106 | - function export($standalone = false) |
|
107 | - { |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * add the response processing template used. |
|
90 | + * |
|
91 | + */ |
|
92 | + |
|
93 | + function add_response_processing() |
|
94 | + { |
|
95 | + return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Export the question as an IMS/QTI Item. |
|
100 | + * |
|
101 | + * This is a default behaviour, some classes may want to override this. |
|
102 | + * |
|
103 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | + * @return string string, the XML flow for an Item. |
|
105 | + */ |
|
106 | + function export($standalone = false) |
|
107 | + { |
|
108 | 108 | $head = $foot = ""; |
109 | 109 | |
110 | 110 | if ($standalone) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | .$foot; |
132 | 132 | |
133 | 133 | return $res; |
134 | - } |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | function export_presentation() |
195 | 195 | { |
196 | 196 | $out = "<presentation_material><flow_mat><material>\n" |
197 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
198 | - . "</material></flow_mat></presentation_material>\n"; |
|
197 | + . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
198 | + . "</material></flow_mat></presentation_material>\n"; |
|
199 | 199 | return $out; |
200 | 200 | } |
201 | 201 | |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | $out = ''; |
210 | 210 | if ($n = $this->exercise->getShuffle()) { |
211 | 211 | $out.= "<selection_ordering>" |
212 | - . " <selection>\n" |
|
213 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
214 | - . " </selection>\n" |
|
215 | - . ' <order order_type="Random" />' |
|
216 | - . "\n</selection_ordering>\n"; |
|
212 | + . " <selection>\n" |
|
213 | + . " <selection_number>" . $n . "</selection_number>\n" |
|
214 | + . " </selection>\n" |
|
215 | + . ' <order order_type="Random" />' |
|
216 | + . "\n</selection_ordering>\n"; |
|
217 | 217 | } else { |
218 | 218 | $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
219 | - . " <selection />\n" |
|
220 | - . "</selection_ordering>\n"; |
|
219 | + . " <selection />\n" |
|
220 | + . "</selection_ordering>\n"; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | return $out; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | { |
232 | 232 | $out = ""; |
233 | 233 | foreach ($this->exercise->selectQuestionList() as $q) { |
234 | - $out .= export_question_qti($q, false); |
|
234 | + $out .= export_question_qti($q, false); |
|
235 | 235 | } |
236 | 236 | return $out; |
237 | 237 | } |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | $head = $foot = ""; |
249 | 249 | if ($standalone) { |
250 | 250 | $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
251 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
252 | - . "<questestinterop>\n"; |
|
251 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
252 | + . "<questestinterop>\n"; |
|
253 | 253 | $foot = "</questestinterop>\n"; |
254 | 254 | } |
255 | 255 | $out = $head |
256 | - . $this->start_section() |
|
257 | - . $this->export_duration() |
|
258 | - . $this->export_presentation() |
|
259 | - . $this->export_ordering() |
|
260 | - . $this->export_questions() |
|
261 | - . $this->end_section() |
|
262 | - . $foot; |
|
256 | + . $this->start_section() |
|
257 | + . $this->export_duration() |
|
258 | + . $this->export_presentation() |
|
259 | + . $this->export_ordering() |
|
260 | + . $this->export_questions() |
|
261 | + . $this->end_section() |
|
262 | + . $foot; |
|
263 | 263 | |
264 | 264 | return $out; |
265 | 265 | } |
@@ -306,97 +306,97 @@ discard block |
||
306 | 306 | * @return ImsItem |
307 | 307 | * @author Anamd Tihon |
308 | 308 | */ |
309 | - function __construct($question) |
|
310 | - { |
|
309 | + function __construct($question) |
|
310 | + { |
|
311 | 311 | $this->question = $question; |
312 | 312 | $this->answer = $question->answer; |
313 | 313 | $this->questionIdent = "QST_" . $question->selectId() ; |
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Start the XML flow. |
|
318 | - * |
|
319 | - * This opens the <item> block, with correct attributes. |
|
320 | - * |
|
321 | - * @author Amand Tihon <[email protected]> |
|
322 | - */ |
|
323 | - function start_item() |
|
324 | - { |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Start the XML flow. |
|
318 | + * |
|
319 | + * This opens the <item> block, with correct attributes. |
|
320 | + * |
|
321 | + * @author Amand Tihon <[email protected]> |
|
322 | + */ |
|
323 | + function start_item() |
|
324 | + { |
|
325 | 325 | return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * End the XML flow, closing the </item> tag. |
|
330 | - * |
|
331 | - * @author Amand Tihon <[email protected]> |
|
332 | - */ |
|
333 | - function end_item() |
|
334 | - { |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * End the XML flow, closing the </item> tag. |
|
330 | + * |
|
331 | + * @author Amand Tihon <[email protected]> |
|
332 | + */ |
|
333 | + function end_item() |
|
334 | + { |
|
335 | 335 | return "</item>\n"; |
336 | - } |
|
337 | - |
|
338 | - /** |
|
339 | - * Create the opening, with the question itself. |
|
340 | - * |
|
341 | - * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
342 | - * In between, the export_responses from the subclass should have been called. |
|
343 | - * |
|
344 | - * @author Amand Tihon <[email protected]> |
|
345 | - */ |
|
346 | - function start_presentation() |
|
347 | - { |
|
336 | + } |
|
337 | + |
|
338 | + /** |
|
339 | + * Create the opening, with the question itself. |
|
340 | + * |
|
341 | + * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
342 | + * In between, the export_responses from the subclass should have been called. |
|
343 | + * |
|
344 | + * @author Amand Tihon <[email protected]> |
|
345 | + */ |
|
346 | + function start_presentation() |
|
347 | + { |
|
348 | 348 | return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
349 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * End the </presentation> part, opened by export_header. |
|
354 | - * |
|
355 | - * @author Amand Tihon <[email protected]> |
|
356 | - */ |
|
357 | - function end_presentation() |
|
358 | - { |
|
349 | + . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * End the </presentation> part, opened by export_header. |
|
354 | + * |
|
355 | + * @author Amand Tihon <[email protected]> |
|
356 | + */ |
|
357 | + function end_presentation() |
|
358 | + { |
|
359 | 359 | return "</flow></presentation>\n"; |
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
364 | - * |
|
365 | - * @author Amand Tihon <[email protected]> |
|
366 | - */ |
|
367 | - function start_processing() |
|
368 | - { |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
364 | + * |
|
365 | + * @author Amand Tihon <[email protected]> |
|
366 | + */ |
|
367 | + function start_processing() |
|
368 | + { |
|
369 | 369 | return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * End the response processing part. |
|
374 | - * |
|
375 | - * @author Amand Tihon <[email protected]> |
|
376 | - */ |
|
377 | - function end_processing() |
|
378 | - { |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * End the response processing part. |
|
374 | + * |
|
375 | + * @author Amand Tihon <[email protected]> |
|
376 | + */ |
|
377 | + function end_processing() |
|
378 | + { |
|
379 | 379 | return "</resprocessing>\n"; |
380 | - } |
|
381 | - |
|
382 | - /** |
|
383 | - * Export the question as an IMS/QTI Item. |
|
384 | - * |
|
385 | - * This is a default behaviour, some classes may want to override this. |
|
386 | - * |
|
387 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
388 | - * @return string string, the XML flow for an Item. |
|
389 | - * @author Amand Tihon <[email protected]> |
|
390 | - */ |
|
391 | - function export($standalone = False) |
|
392 | - { |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * Export the question as an IMS/QTI Item. |
|
384 | + * |
|
385 | + * This is a default behaviour, some classes may want to override this. |
|
386 | + * |
|
387 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
388 | + * @return string string, the XML flow for an Item. |
|
389 | + * @author Amand Tihon <[email protected]> |
|
390 | + */ |
|
391 | + function export($standalone = False) |
|
392 | + { |
|
393 | 393 | global $charset; |
394 | 394 | $head = $foot = ""; |
395 | 395 | |
396 | 396 | if ($standalone) { |
397 | 397 | $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
398 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
399 | - . "<questestinterop>\n"; |
|
398 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
399 | + . "<questestinterop>\n"; |
|
400 | 400 | $foot = "</questestinterop>\n"; |
401 | 401 | } |
402 | 402 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | . $this->answer->imsExportFeedback($this->questionIdent) |
412 | 412 | . $this->end_item() |
413 | 413 | . $foot; |
414 | - } |
|
414 | + } |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | $question->type = $qst->type; |
451 | 451 | $question->question = $qst->question; |
452 | 452 | $question->description = $qst->description; |
453 | - $question->weighting=$qst->weighting; |
|
454 | - $question->position=$qst->position; |
|
455 | - $question->picture=$qst->picture; |
|
453 | + $question->weighting=$qst->weighting; |
|
454 | + $question->position=$qst->position; |
|
455 | + $question->picture=$qst->picture; |
|
456 | 456 | $ims = new ImsAssessmentItem($question); |
457 | 457 | |
458 | 458 | return $ims->export($standalone); |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | public $new_destination; // id of the next question if feedback option is set to Directfeedback |
38 | 38 | public $course; //Course information |
39 | 39 | public $iid; |
40 | - public $questionJSId; |
|
41 | - public $standalone; |
|
40 | + public $questionJSId; |
|
41 | + public $standalone; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * constructor of the class |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | return []; |
160 | 160 | } |
161 | 161 | |
162 | - /** |
|
163 | - * returns all answer ids from this question Id |
|
164 | - * |
|
165 | - * @author Yoselyn Castillo |
|
166 | - * @return array - $id (answer ids) |
|
167 | - */ |
|
162 | + /** |
|
163 | + * returns all answer ids from this question Id |
|
164 | + * |
|
165 | + * @author Yoselyn Castillo |
|
166 | + * @return array - $id (answer ids) |
|
167 | + */ |
|
168 | 168 | public function selectAnswerId() |
169 | 169 | { |
170 | 170 | $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | return $id; |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Reads answer information from the data base ordered by parameter |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function readOrderedBy($field, $order='ASC') |
197 | 197 | { |
198 | - $field = Database::escape_string($field); |
|
199 | - if (empty($field)) { |
|
200 | - $field = 'position'; |
|
201 | - } |
|
198 | + $field = Database::escape_string($field); |
|
199 | + if (empty($field)) { |
|
200 | + $field = 'position'; |
|
201 | + } |
|
202 | 202 | |
203 | - if ($order != 'ASC' && $order!='DESC') { |
|
204 | - $order = 'ASC'; |
|
205 | - } |
|
203 | + if ($order != 'ASC' && $order!='DESC') { |
|
204 | + $order = 'ASC'; |
|
205 | + } |
|
206 | 206 | |
207 | - $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
208 | - $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
209 | - $questionId = intval($this->questionId); |
|
207 | + $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
208 | + $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
209 | + $questionId = intval($this->questionId); |
|
210 | 210 | |
211 | - $sql = "SELECT type FROM $TBL_QUIZ |
|
211 | + $sql = "SELECT type FROM $TBL_QUIZ |
|
212 | 212 | WHERE c_id = {$this->course_id} AND id = $questionId"; |
213 | - $result_question = Database::query($sql); |
|
214 | - $questionType = Database::fetch_array($result_question); |
|
213 | + $result_question = Database::query($sql); |
|
214 | + $questionType = Database::fetch_array($result_question); |
|
215 | 215 | |
216 | 216 | if ($questionType['type'] == DRAGGABLE) { |
217 | 217 | // Random is done by submit.js.tpl |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | return true; |
221 | 221 | } |
222 | 222 | |
223 | - $sql = "SELECT |
|
223 | + $sql = "SELECT |
|
224 | 224 | answer, |
225 | 225 | correct, |
226 | 226 | comment, |
@@ -236,16 +236,16 @@ discard block |
||
236 | 236 | c_id = {$this->course_id} AND |
237 | 237 | question_id='".$questionId."' |
238 | 238 | ORDER BY $field $order"; |
239 | - $result=Database::query($sql); |
|
240 | - |
|
241 | - $i = 1; |
|
242 | - // while a record is found |
|
243 | - $doubt_data = null; |
|
244 | - while ($object = Database::fetch_object($result)) { |
|
245 | - if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { |
|
246 | - $doubt_data = $object; |
|
239 | + $result=Database::query($sql); |
|
240 | + |
|
241 | + $i = 1; |
|
242 | + // while a record is found |
|
243 | + $doubt_data = null; |
|
244 | + while ($object = Database::fetch_object($result)) { |
|
245 | + if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { |
|
246 | + $doubt_data = $object; |
|
247 | 247 | continue; |
248 | - } |
|
248 | + } |
|
249 | 249 | $this->answer[$i] = $object->answer; |
250 | 250 | $this->correct[$i] = $object->correct; |
251 | 251 | $this->comment[$i] = $object->comment; |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | $this->autoId[$i] = $object->id_auto; |
258 | 258 | $this->iid[$i] = $object->iid; |
259 | 259 | $i++; |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | - if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { |
|
262 | + if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { |
|
263 | 263 | $this->answer[$i] = $doubt_data->answer; |
264 | 264 | $this->correct[$i] = $doubt_data->correct; |
265 | 265 | $this->comment[$i] = $doubt_data->comment; |
@@ -271,88 +271,88 @@ discard block |
||
271 | 271 | $this->autoId[$i] = $doubt_data->id_auto; |
272 | 272 | $this->iid[$i] = $doubt_data->iid; |
273 | 273 | $i++; |
274 | - } |
|
274 | + } |
|
275 | 275 | $this->nbrAnswers = $i-1; |
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * returns the autoincrement id identificator |
|
280 | - * |
|
281 | - * @author Juan Carlos Ra�a |
|
282 | - * @return integer - answer num |
|
283 | - */ |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * returns the autoincrement id identificator |
|
280 | + * |
|
281 | + * @author Juan Carlos Ra�a |
|
282 | + * @return integer - answer num |
|
283 | + */ |
|
284 | 284 | public function selectAutoId($id) |
285 | 285 | { |
286 | - return isset($this->autoId[$id]) ? $this->autoId[$id] : 0; |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * returns the number of answers in this question |
|
291 | - * |
|
292 | - * @author Olivier Brouckaert |
|
293 | - * @return integer - number of answers |
|
294 | - */ |
|
295 | - public function selectNbrAnswers() |
|
286 | + return isset($this->autoId[$id]) ? $this->autoId[$id] : 0; |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * returns the number of answers in this question |
|
291 | + * |
|
292 | + * @author Olivier Brouckaert |
|
293 | + * @return integer - number of answers |
|
294 | + */ |
|
295 | + public function selectNbrAnswers() |
|
296 | 296 | { |
297 | - return $this->nbrAnswers; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * returns the question ID which the answers belong to |
|
302 | - * |
|
303 | - * @author Olivier Brouckaert |
|
304 | - * @return integer - the question ID |
|
305 | - */ |
|
306 | - public function selectQuestionId() |
|
297 | + return $this->nbrAnswers; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * returns the question ID which the answers belong to |
|
302 | + * |
|
303 | + * @author Olivier Brouckaert |
|
304 | + * @return integer - the question ID |
|
305 | + */ |
|
306 | + public function selectQuestionId() |
|
307 | 307 | { |
308 | - return $this->questionId; |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * returns the question ID of the destination question |
|
313 | - * |
|
314 | - * @author Julio Montoya |
|
315 | - * @param integer $id |
|
316 | - * @return integer - the question ID |
|
317 | - */ |
|
318 | - public function selectDestination($id) |
|
308 | + return $this->questionId; |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * returns the question ID of the destination question |
|
313 | + * |
|
314 | + * @author Julio Montoya |
|
315 | + * @param integer $id |
|
316 | + * @return integer - the question ID |
|
317 | + */ |
|
318 | + public function selectDestination($id) |
|
319 | 319 | { |
320 | - return isset($this->destination[$id]) ? $this->destination[$id] : null; |
|
321 | - } |
|
320 | + return isset($this->destination[$id]) ? $this->destination[$id] : null; |
|
321 | + } |
|
322 | 322 | |
323 | 323 | /** |
324 | - * returns the answer title |
|
325 | - * |
|
326 | - * @author Olivier Brouckaert |
|
327 | - * @param - integer $id - answer ID |
|
328 | - * @return string - answer title |
|
329 | - */ |
|
330 | - public function selectAnswer($id) |
|
331 | - { |
|
332 | - return isset($this->answer[$id]) ? $this->answer[$id] : null; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * return array answer by id else return a bool |
|
337 | - * @param integer $auto_id |
|
338 | - */ |
|
339 | - public function selectAnswerByAutoId($auto_id) |
|
340 | - { |
|
341 | - $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
342 | - |
|
343 | - $auto_id = intval($auto_id); |
|
344 | - $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER |
|
324 | + * returns the answer title |
|
325 | + * |
|
326 | + * @author Olivier Brouckaert |
|
327 | + * @param - integer $id - answer ID |
|
328 | + * @return string - answer title |
|
329 | + */ |
|
330 | + public function selectAnswer($id) |
|
331 | + { |
|
332 | + return isset($this->answer[$id]) ? $this->answer[$id] : null; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * return array answer by id else return a bool |
|
337 | + * @param integer $auto_id |
|
338 | + */ |
|
339 | + public function selectAnswerByAutoId($auto_id) |
|
340 | + { |
|
341 | + $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
342 | + |
|
343 | + $auto_id = intval($auto_id); |
|
344 | + $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER |
|
345 | 345 | WHERE c_id = {$this->course_id} AND id_auto='$auto_id'"; |
346 | - $rs = Database::query($sql); |
|
346 | + $rs = Database::query($sql); |
|
347 | 347 | |
348 | - if (Database::num_rows($rs) > 0) { |
|
349 | - $row = Database::fetch_array($rs, 'ASSOC'); |
|
348 | + if (Database::num_rows($rs) > 0) { |
|
349 | + $row = Database::fetch_array($rs, 'ASSOC'); |
|
350 | 350 | |
351 | - return $row; |
|
352 | - } |
|
351 | + return $row; |
|
352 | + } |
|
353 | 353 | |
354 | - return false; |
|
355 | - } |
|
354 | + return false; |
|
355 | + } |
|
356 | 356 | |
357 | 357 | /** |
358 | 358 | * returns the answer title from an answer's position |
@@ -361,18 +361,18 @@ discard block |
||
361 | 361 | * @param - integer $id - answer ID |
362 | 362 | * @return bool - answer title |
363 | 363 | */ |
364 | - public function selectAnswerIdByPosition($pos) |
|
365 | - { |
|
366 | - foreach ($this->position as $k => $v) { |
|
367 | - if ($v != $pos) { |
|
368 | - continue; |
|
369 | - } |
|
364 | + public function selectAnswerIdByPosition($pos) |
|
365 | + { |
|
366 | + foreach ($this->position as $k => $v) { |
|
367 | + if ($v != $pos) { |
|
368 | + continue; |
|
369 | + } |
|
370 | 370 | |
371 | - return $k; |
|
372 | - } |
|
371 | + return $k; |
|
372 | + } |
|
373 | 373 | |
374 | - return false; |
|
375 | - } |
|
374 | + return false; |
|
375 | + } |
|
376 | 376 | |
377 | 377 | /** |
378 | 378 | * Returns a list of answers |
@@ -381,18 +381,18 @@ discard block |
||
381 | 381 | * of (id, answer, comment, grade) and grade=weighting |
382 | 382 | */ |
383 | 383 | public function getAnswersList($decode = false) |
384 | - { |
|
385 | - $list = array(); |
|
386 | - for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
387 | - if (!empty($this->answer[$i])) { |
|
388 | - |
|
389 | - //Avoid problems when parsing elements with accents |
|
390 | - if ($decode) { |
|
391 | - $this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); |
|
392 | - $this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); |
|
393 | - } |
|
394 | - |
|
395 | - $list[] = array( |
|
384 | + { |
|
385 | + $list = array(); |
|
386 | + for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
387 | + if (!empty($this->answer[$i])) { |
|
388 | + |
|
389 | + //Avoid problems when parsing elements with accents |
|
390 | + if ($decode) { |
|
391 | + $this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); |
|
392 | + $this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); |
|
393 | + } |
|
394 | + |
|
395 | + $list[] = array( |
|
396 | 396 | 'id' => $i, |
397 | 397 | 'answer' => $this->answer[$i], |
398 | 398 | 'comment' => $this->comment[$i], |
@@ -401,137 +401,137 @@ discard block |
||
401 | 401 | 'hotspot_type' => $this->hotspot_type[$i], |
402 | 402 | 'correct' => $this->correct[$i], |
403 | 403 | 'destination' => $this->destination[$i] |
404 | - ); |
|
404 | + ); |
|
405 | + } |
|
405 | 406 | } |
406 | - } |
|
407 | 407 | |
408 | - return $list; |
|
409 | - } |
|
408 | + return $list; |
|
409 | + } |
|
410 | 410 | |
411 | - /** |
|
412 | - * Returns a list of grades |
|
413 | - * @author Yannick Warnier <[email protected]> |
|
414 | - * @return array List of grades where grade=weighting (?) |
|
415 | - */ |
|
411 | + /** |
|
412 | + * Returns a list of grades |
|
413 | + * @author Yannick Warnier <[email protected]> |
|
414 | + * @return array List of grades where grade=weighting (?) |
|
415 | + */ |
|
416 | 416 | public function getGradesList() |
417 | - { |
|
418 | - $list = array(); |
|
419 | - for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
420 | - if(!empty($this->answer[$i])){ |
|
421 | - $list[$i] = $this->weighting[$i]; |
|
422 | - } |
|
423 | - } |
|
424 | - return $list; |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * Returns the question type |
|
429 | - * @author Yannick Warnier <[email protected]> |
|
430 | - * @return integer The type of the question this answer is bound to |
|
431 | - */ |
|
417 | + { |
|
418 | + $list = array(); |
|
419 | + for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
420 | + if(!empty($this->answer[$i])){ |
|
421 | + $list[$i] = $this->weighting[$i]; |
|
422 | + } |
|
423 | + } |
|
424 | + return $list; |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * Returns the question type |
|
429 | + * @author Yannick Warnier <[email protected]> |
|
430 | + * @return integer The type of the question this answer is bound to |
|
431 | + */ |
|
432 | 432 | public function getQuestionType() |
433 | - { |
|
434 | - $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
435 | - $sql = "SELECT type FROM $TBL_QUESTIONS |
|
433 | + { |
|
434 | + $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
435 | + $sql = "SELECT type FROM $TBL_QUESTIONS |
|
436 | 436 | WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'"; |
437 | - $res = Database::query($sql); |
|
438 | - if (Database::num_rows($res)<=0){ |
|
439 | - return null; |
|
440 | - } |
|
441 | - $row = Database::fetch_array($res); |
|
442 | - |
|
443 | - return $row['type']; |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - /** |
|
448 | - * tells if answer is correct or not |
|
449 | - * |
|
450 | - * @author Olivier Brouckaert |
|
451 | - * @param - integer $id - answer ID |
|
452 | - * @return integer - 0 if bad answer, not 0 if good answer |
|
453 | - */ |
|
437 | + $res = Database::query($sql); |
|
438 | + if (Database::num_rows($res)<=0){ |
|
439 | + return null; |
|
440 | + } |
|
441 | + $row = Database::fetch_array($res); |
|
442 | + |
|
443 | + return $row['type']; |
|
444 | + } |
|
445 | + |
|
446 | + |
|
447 | + /** |
|
448 | + * tells if answer is correct or not |
|
449 | + * |
|
450 | + * @author Olivier Brouckaert |
|
451 | + * @param - integer $id - answer ID |
|
452 | + * @return integer - 0 if bad answer, not 0 if good answer |
|
453 | + */ |
|
454 | 454 | public function isCorrect($id) |
455 | - { |
|
456 | - return isset($this->correct[$id]) ? $this->correct[$id] : null; |
|
457 | - } |
|
458 | - |
|
459 | - /** |
|
460 | - * returns answer comment |
|
461 | - * |
|
462 | - * @author Olivier Brouckaert |
|
463 | - * @param - integer $id - answer ID |
|
464 | - * @return string - answer comment |
|
465 | - */ |
|
455 | + { |
|
456 | + return isset($this->correct[$id]) ? $this->correct[$id] : null; |
|
457 | + } |
|
458 | + |
|
459 | + /** |
|
460 | + * returns answer comment |
|
461 | + * |
|
462 | + * @author Olivier Brouckaert |
|
463 | + * @param - integer $id - answer ID |
|
464 | + * @return string - answer comment |
|
465 | + */ |
|
466 | 466 | public function selectComment($id) |
467 | - { |
|
467 | + { |
|
468 | 468 | return isset($this->comment[$id]) ? $this->comment[$id] : null; |
469 | - } |
|
470 | - |
|
471 | - /** |
|
472 | - * returns answer weighting |
|
473 | - * |
|
474 | - * @author Olivier Brouckaert |
|
475 | - * @param - integer $id - answer ID |
|
476 | - * @param integer $id |
|
477 | - * @return integer - answer weighting |
|
478 | - */ |
|
469 | + } |
|
470 | + |
|
471 | + /** |
|
472 | + * returns answer weighting |
|
473 | + * |
|
474 | + * @author Olivier Brouckaert |
|
475 | + * @param - integer $id - answer ID |
|
476 | + * @param integer $id |
|
477 | + * @return integer - answer weighting |
|
478 | + */ |
|
479 | 479 | public function selectWeighting($id) |
480 | - { |
|
481 | - return isset($this->weighting[$id]) ? $this->weighting[$id] : null; |
|
482 | - } |
|
483 | - |
|
484 | - /** |
|
485 | - * returns answer position |
|
486 | - * |
|
487 | - * @author Olivier Brouckaert |
|
488 | - * @param - integer $id - answer ID |
|
489 | - * @return integer - answer position |
|
490 | - */ |
|
491 | - function selectPosition($id) |
|
492 | - { |
|
493 | - return isset($this->position[$id]) ? $this->position[$id] : null; |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * returns answer hotspot coordinates |
|
498 | - * |
|
499 | - * @author Olivier Brouckaert |
|
500 | - * @param integer Answer ID |
|
501 | - * @param integer $id |
|
502 | - * @return integer Answer position |
|
503 | - */ |
|
480 | + { |
|
481 | + return isset($this->weighting[$id]) ? $this->weighting[$id] : null; |
|
482 | + } |
|
483 | + |
|
484 | + /** |
|
485 | + * returns answer position |
|
486 | + * |
|
487 | + * @author Olivier Brouckaert |
|
488 | + * @param - integer $id - answer ID |
|
489 | + * @return integer - answer position |
|
490 | + */ |
|
491 | + function selectPosition($id) |
|
492 | + { |
|
493 | + return isset($this->position[$id]) ? $this->position[$id] : null; |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * returns answer hotspot coordinates |
|
498 | + * |
|
499 | + * @author Olivier Brouckaert |
|
500 | + * @param integer Answer ID |
|
501 | + * @param integer $id |
|
502 | + * @return integer Answer position |
|
503 | + */ |
|
504 | 504 | public function selectHotspotCoordinates($id) |
505 | - { |
|
506 | - return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; |
|
507 | - } |
|
508 | - |
|
509 | - /** |
|
510 | - * returns answer hotspot type |
|
511 | - * |
|
512 | - * @author Toon Keppens |
|
513 | - * @param integer Answer ID |
|
514 | - * @param integer $id |
|
515 | - * @return integer Answer position |
|
516 | - */ |
|
505 | + { |
|
506 | + return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; |
|
507 | + } |
|
508 | + |
|
509 | + /** |
|
510 | + * returns answer hotspot type |
|
511 | + * |
|
512 | + * @author Toon Keppens |
|
513 | + * @param integer Answer ID |
|
514 | + * @param integer $id |
|
515 | + * @return integer Answer position |
|
516 | + */ |
|
517 | 517 | public function selectHotspotType($id) |
518 | - { |
|
519 | - return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * Creates a new answer |
|
524 | - * |
|
525 | - * @author Olivier Brouckaert |
|
526 | - * @param string $answer answer title |
|
527 | - * @param integer $correct 0 if bad answer, not 0 if good answer |
|
528 | - * @param string $comment answer comment |
|
529 | - * @param integer $weighting answer weighting |
|
530 | - * @param integer $position answer position |
|
531 | - * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) |
|
532 | - * @param integer $new_hotspot_type Type for hotspot exercises (optional) |
|
518 | + { |
|
519 | + return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * Creates a new answer |
|
524 | + * |
|
525 | + * @author Olivier Brouckaert |
|
526 | + * @param string $answer answer title |
|
527 | + * @param integer $correct 0 if bad answer, not 0 if good answer |
|
528 | + * @param string $comment answer comment |
|
529 | + * @param integer $weighting answer weighting |
|
530 | + * @param integer $position answer position |
|
531 | + * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) |
|
532 | + * @param integer $new_hotspot_type Type for hotspot exercises (optional) |
|
533 | 533 | * @param string $destination |
534 | - */ |
|
534 | + */ |
|
535 | 535 | public function createAnswer( |
536 | 536 | $answer, |
537 | 537 | $correct, |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $new_hotspot_type = null, |
543 | 543 | $destination = '' |
544 | 544 | ) { |
545 | - $this->new_nbrAnswers++; |
|
545 | + $this->new_nbrAnswers++; |
|
546 | 546 | $id = $this->new_nbrAnswers; |
547 | 547 | $this->new_answer[$id] = $answer; |
548 | 548 | $this->new_correct[$id] = $correct; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates; |
553 | 553 | $this->new_hotspot_type[$id] = $new_hotspot_type; |
554 | 554 | $this->new_destination[$id] = $destination; |
555 | - } |
|
555 | + } |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Updates an answer |
@@ -595,32 +595,32 @@ discard block |
||
595 | 595 | |
596 | 596 | $em->merge($quizAnswer); |
597 | 597 | $em->flush(); |
598 | - } |
|
598 | + } |
|
599 | 599 | |
600 | - /** |
|
601 | - * Records answers into the data base |
|
602 | - * |
|
603 | - * @author Olivier Brouckaert |
|
604 | - */ |
|
600 | + /** |
|
601 | + * Records answers into the data base |
|
602 | + * |
|
603 | + * @author Olivier Brouckaert |
|
604 | + */ |
|
605 | 605 | public function save() |
606 | 606 | { |
607 | - $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
607 | + $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
608 | 608 | $em = Database::getManager(); |
609 | - $questionId = intval($this->questionId); |
|
609 | + $questionId = intval($this->questionId); |
|
610 | 610 | |
611 | - $c_id = $this->course['real_id']; |
|
611 | + $c_id = $this->course['real_id']; |
|
612 | 612 | $correctList = []; |
613 | 613 | $answerList = []; |
614 | 614 | |
615 | - for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
616 | - $answer = $this->new_answer[$i]; |
|
617 | - $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : ''; |
|
618 | - $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : ''; |
|
619 | - $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : ''; |
|
620 | - $position = isset($this->new_position[$i]) ? $this->new_position[$i] : ''; |
|
621 | - $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : ''; |
|
622 | - $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : ''; |
|
623 | - $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : ''; |
|
615 | + for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
616 | + $answer = $this->new_answer[$i]; |
|
617 | + $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : ''; |
|
618 | + $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : ''; |
|
619 | + $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : ''; |
|
620 | + $position = isset($this->new_position[$i]) ? $this->new_position[$i] : ''; |
|
621 | + $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : ''; |
|
622 | + $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : ''; |
|
623 | + $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : ''; |
|
624 | 624 | $autoId = $this->selectAutoId($i); |
625 | 625 | $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0; |
626 | 626 | |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | |
664 | 664 | $correctAnswerId = $answer->selectAnswerIdByPosition($correct); |
665 | 665 | |
666 | - // Continue to avoid matching question bug if $correctAnswerId returns false |
|
667 | - // See : https://support.chamilo.org/issues/8334 |
|
668 | - if ($questionType == MATCHING && !$correctAnswerId) { |
|
669 | - continue; |
|
670 | - } |
|
666 | + // Continue to avoid matching question bug if $correctAnswerId returns false |
|
667 | + // See : https://support.chamilo.org/issues/8334 |
|
668 | + if ($questionType == MATCHING && !$correctAnswerId) { |
|
669 | + continue; |
|
670 | + } |
|
671 | 671 | |
672 | 672 | $correctAnswerAutoId = $answer->selectAutoId($correct); |
673 | 673 | |
@@ -734,28 +734,28 @@ discard block |
||
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
737 | - // moves $new_* arrays |
|
738 | - $this->answer = $this->new_answer; |
|
739 | - $this->correct = $this->new_correct; |
|
740 | - $this->comment = $this->new_comment; |
|
741 | - $this->weighting = $this->new_weighting; |
|
742 | - $this->position = $this->new_position; |
|
743 | - $this->hotspot_coordinates = $this->new_hotspot_coordinates; |
|
744 | - $this->hotspot_type = $this->new_hotspot_type; |
|
745 | - $this->nbrAnswers = $this->new_nbrAnswers; |
|
746 | - $this->destination = $this->new_destination; |
|
747 | - |
|
748 | - $this->cancel(); |
|
749 | - } |
|
750 | - |
|
751 | - /** |
|
752 | - * Duplicates answers by copying them into another question |
|
753 | - * |
|
754 | - * @author Olivier Brouckaert |
|
755 | - * @param int question id |
|
737 | + // moves $new_* arrays |
|
738 | + $this->answer = $this->new_answer; |
|
739 | + $this->correct = $this->new_correct; |
|
740 | + $this->comment = $this->new_comment; |
|
741 | + $this->weighting = $this->new_weighting; |
|
742 | + $this->position = $this->new_position; |
|
743 | + $this->hotspot_coordinates = $this->new_hotspot_coordinates; |
|
744 | + $this->hotspot_type = $this->new_hotspot_type; |
|
745 | + $this->nbrAnswers = $this->new_nbrAnswers; |
|
746 | + $this->destination = $this->new_destination; |
|
747 | + |
|
748 | + $this->cancel(); |
|
749 | + } |
|
750 | + |
|
751 | + /** |
|
752 | + * Duplicates answers by copying them into another question |
|
753 | + * |
|
754 | + * @author Olivier Brouckaert |
|
755 | + * @param int question id |
|
756 | 756 | * @param array destination course info (result of the function api_get_course_info() ) |
757 | 757 | * @param string $newQuestionId |
758 | - */ |
|
758 | + */ |
|
759 | 759 | public function duplicate($newQuestionId, $course_info = null) |
760 | 760 | { |
761 | 761 | if (empty($course_info)) { |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | |
776 | 776 | if (!empty($origin_options)) { |
777 | 777 | foreach ($origin_options as $item) { |
778 | - $new_option_list[] = $item['id']; |
|
778 | + $new_option_list[] = $item['id']; |
|
779 | 779 | } |
780 | 780 | } |
781 | 781 | |
@@ -789,12 +789,12 @@ discard block |
||
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | - // if at least one answer |
|
793 | - if ($this->nbrAnswers) { |
|
794 | - // inserts new answers into data base |
|
795 | - $c_id = $course_info['real_id']; |
|
792 | + // if at least one answer |
|
793 | + if ($this->nbrAnswers) { |
|
794 | + // inserts new answers into data base |
|
795 | + $c_id = $course_info['real_id']; |
|
796 | 796 | |
797 | - for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
797 | + for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
798 | 798 | if ($this->course['id'] != $course_info['id']) { |
799 | 799 | $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
800 | 800 | $this->answer[$i], |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | ); |
809 | 809 | } |
810 | 810 | |
811 | - $correct = $this->correct[$i]; |
|
811 | + $correct = $this->correct[$i]; |
|
812 | 812 | |
813 | 813 | if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || |
814 | 814 | self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE |
@@ -840,9 +840,9 @@ discard block |
||
840 | 840 | |
841 | 841 | $em->merge($quizAnswer); |
842 | 842 | $em->flush(); |
843 | - } |
|
843 | + } |
|
844 | 844 | } |
845 | - } |
|
845 | + } |
|
846 | 846 | |
847 | 847 | /** |
848 | 848 | * Get the necessary JavaScript for some answers |
@@ -860,25 +860,25 @@ discard block |
||
860 | 860 | </script>"; |
861 | 861 | } |
862 | 862 | |
863 | - /** |
|
864 | - * Check if a answer is correct by an answer auto id |
|
865 | - * @param $needle int The answer auto id |
|
866 | - * @return bool |
|
867 | - */ |
|
868 | - public function isCorrectByAutoId($needle) |
|
869 | - { |
|
870 | - $key = 0; |
|
871 | - |
|
872 | - foreach ($this->autoId as $autoIdKey => $autoId) { |
|
873 | - if ($autoId == $needle) { |
|
874 | - $key = $autoIdKey; |
|
875 | - } |
|
876 | - } |
|
877 | - |
|
878 | - if (!$key) { |
|
879 | - return false; |
|
880 | - } |
|
881 | - |
|
882 | - return $this->isCorrect($key) ? true : false; |
|
883 | - } |
|
863 | + /** |
|
864 | + * Check if a answer is correct by an answer auto id |
|
865 | + * @param $needle int The answer auto id |
|
866 | + * @return bool |
|
867 | + */ |
|
868 | + public function isCorrectByAutoId($needle) |
|
869 | + { |
|
870 | + $key = 0; |
|
871 | + |
|
872 | + foreach ($this->autoId as $autoIdKey => $autoId) { |
|
873 | + if ($autoId == $needle) { |
|
874 | + $key = $autoIdKey; |
|
875 | + } |
|
876 | + } |
|
877 | + |
|
878 | + if (!$key) { |
|
879 | + return false; |
|
880 | + } |
|
881 | + |
|
882 | + return $this->isCorrect($key) ? true : false; |
|
883 | + } |
|
884 | 884 | } |
@@ -101,7 +101,7 @@ |
||
101 | 101 | "categories.php?action=delete&id={$row['id']}" |
102 | 102 | ); |
103 | 103 | |
104 | - return $result; |
|
104 | + return $result; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | Display::display_header($plugin->get_lang('MyTickets')); |
@@ -101,7 +101,7 @@ |
||
101 | 101 | "categories.php?action=delete&id={$row['id']}" |
102 | 102 | ); |
103 | 103 | |
104 | - return $result; |
|
104 | + return $result; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | Display::display_header($plugin->get_lang('MyTickets')); |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | public $name; |
16 | 16 | public $description; |
17 | 17 | |
18 | - /** |
|
19 | - * Constructor of the class Category |
|
18 | + /** |
|
19 | + * Constructor of the class Category |
|
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
52 | + /** |
|
53 | 53 | * add TestCategory in the database if name doesn't already exists |
54 | - */ |
|
54 | + */ |
|
55 | 55 | public function addCategoryInBDD() |
56 | 56 | { |
57 | 57 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $category = $this->getCategory($id); |
111 | 111 | |
112 | 112 | if ($category) { |
113 | - $sql = "DELETE FROM $table |
|
113 | + $sql = "DELETE FROM $table |
|
114 | 114 | WHERE id= $id AND c_id=".$course_id; |
115 | 115 | Database::query($sql); |
116 | 116 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | return false; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
137 | + /** |
|
138 | 138 | * Modify category name or description of category with id=in_id |
139 | - */ |
|
139 | + */ |
|
140 | 140 | public function modifyCategory() |
141 | 141 | { |
142 | 142 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -167,30 +167,30 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | return false; |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
172 | + /** |
|
173 | 173 | * Gets the number of question of category id=in_id |
174 | - */ |
|
174 | + */ |
|
175 | 175 | public function getCategoryQuestionsNumber() |
176 | 176 | { |
177 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
178 | - $in_id = intval($this->id); |
|
179 | - $sql = "SELECT count(*) AS nb |
|
177 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
178 | + $in_id = intval($this->id); |
|
179 | + $sql = "SELECT count(*) AS nb |
|
180 | 180 | FROM $table |
181 | 181 | WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); |
182 | - $res = Database::query($sql); |
|
183 | - $row = Database::fetch_array($res); |
|
182 | + $res = Database::query($sql); |
|
183 | + $row = Database::fetch_array($res); |
|
184 | 184 | |
185 | - return $row['nb']; |
|
186 | - } |
|
185 | + return $row['nb']; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
188 | + /** |
|
189 | 189 | * Return an array of all Category objects in the database |
190 | - * If in_field=="" Return an array of all category objects in the database |
|
191 | - * Otherwise, return an array of all in_field value |
|
192 | - * in the database (in_field = id or name or description) |
|
193 | - * |
|
190 | + * If in_field=="" Return an array of all category objects in the database |
|
191 | + * Otherwise, return an array of all in_field value |
|
192 | + * in the database (in_field = id or name or description) |
|
193 | + * |
|
194 | 194 | * @param string $in_field |
195 | 195 | * @param int $courseId |
196 | 196 | * @return array |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | * @param int exercise |
494 | 494 | * @param array $check_in_question_list |
495 | 495 | * @param array $categoriesAddedInExercise |
496 | - * |
|
497 | - * @param int $exerciseId |
|
498 | - * @return array |
|
499 | - */ |
|
496 | + * |
|
497 | + * @param int $exerciseId |
|
498 | + * @return array |
|
499 | + */ |
|
500 | 500 | static function getQuestionsByCat( |
501 | 501 | $exerciseId, |
502 | 502 | $check_in_question_list = array(), |
@@ -622,9 +622,9 @@ discard block |
||
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
625 | - * Display signs [+] and/or (>0) after question title if question has options |
|
626 | - * scoreAlwaysPositive and/or uncheckedMayScore |
|
627 | - */ |
|
625 | + * Display signs [+] and/or (>0) after question title if question has options |
|
626 | + * scoreAlwaysPositive and/or uncheckedMayScore |
|
627 | + */ |
|
628 | 628 | public function displayQuestionOption($in_objQuestion) |
629 | 629 | { |
630 | 630 | if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * key of $tabCategoryQuestions are the category id (0 for not in a category) |
641 | 641 | * value is the array of question id of this category |
642 | 642 | * Sort question by Category |
643 | - */ |
|
643 | + */ |
|
644 | 644 | public static function sortTabByBracketLabel($in_tab) |
645 | 645 | { |
646 | 646 | $tabResult = array(); |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * count the number of questions in all categories, and return the max |
694 | 694 | * @param int $exerciseId |
695 | 695 | * @author - hubert borderiou |
696 | - */ |
|
696 | + */ |
|
697 | 697 | public static function getNumberMaxQuestionByCat($exerciseId) |
698 | 698 | { |
699 | 699 | $res_num_max = 0; |
@@ -8,19 +8,19 @@ |
||
8 | 8 | */ |
9 | 9 | class DataForm extends FormValidator |
10 | 10 | { |
11 | - const TYPE_IMPORT = 1; |
|
12 | - const TYPE_EXPORT = 2; |
|
13 | - const TYPE_EXPORT_PDF = 3; |
|
11 | + const TYPE_IMPORT = 1; |
|
12 | + const TYPE_EXPORT = 2; |
|
13 | + const TYPE_EXPORT_PDF = 3; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Builds a form containing form items based on a given parameter |
|
17 | - * @param int form_type 1=import, 2=export |
|
18 | - * @param obj cat_obj the category object |
|
19 | - * @param obj res_obj the result object |
|
20 | - * @param string form name |
|
21 | - * @param method |
|
22 | - * @param action |
|
23 | - */ |
|
15 | + /** |
|
16 | + * Builds a form containing form items based on a given parameter |
|
17 | + * @param int form_type 1=import, 2=export |
|
18 | + * @param obj cat_obj the category object |
|
19 | + * @param obj res_obj the result object |
|
20 | + * @param string form name |
|
21 | + * @param method |
|
22 | + * @param action |
|
23 | + */ |
|
24 | 24 | public function __construct($form_type, $form_name, $method = 'post', $action = null, $target = '', $locked_status) |
25 | 25 | { |
26 | 26 | parent:: __construct($form_name, $method, $action, $target); |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $htmlHeadXtra[] = '<style> |
71 | 71 | body { background: none;} |
72 | 72 | </style>'; |
73 | - Display::display_reduced_header(); |
|
73 | + Display::display_reduced_header(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $message = Session::read('attempt_remaining'); |
@@ -289,7 +289,7 @@ |
||
289 | 289 | echo '<div class="actions" >'; |
290 | 290 | echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'ticket/new_ticket.php?project_id='.$projectId.'">' . |
291 | 291 | Display::return_icon('add.png', get_lang('Add'), '', '32') . |
292 | - '</a>'; |
|
292 | + '</a>'; |
|
293 | 293 | echo '</div>'; |
294 | 294 | } |
295 | 295 | } |
@@ -433,7 +433,7 @@ |
||
433 | 433 | $form->addElement( |
434 | 434 | 'checkbox', |
435 | 435 | 'confirmation', |
436 | - null, |
|
436 | + null, |
|
437 | 437 | $plugin->get_lang('RequestConfirmation') |
438 | 438 | ); |
439 | 439 | } |