@@ -28,10 +28,10 @@ |
||
28 | 28 | $content = ReadFileCont($full_file_path.$user_id.'.t.html'); |
29 | 29 | |
30 | 30 | if ($content == '') { |
31 | - $content = ReadFileCont($full_file_path); |
|
31 | + $content = ReadFileCont($full_file_path); |
|
32 | 32 | // Do not move this like: |
33 | - $mit = "function Finish(){"; |
|
34 | - $js_content = " |
|
33 | + $mit = "function Finish(){"; |
|
34 | + $js_content = " |
|
35 | 35 | // Code added - start |
36 | 36 | var SaveScoreVariable = 0; |
37 | 37 | function mySaveScore() { |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $filename |
|
16 | - */ |
|
17 | - function mime_content_type($filename) { |
|
18 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
19 | - } |
|
14 | + /** |
|
15 | + * @param string $filename |
|
16 | + */ |
|
17 | + function mime_content_type($filename) { |
|
18 | + return DocumentManager::file_get_mime_type((string)$filename); |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | case MCUA : |
35 | 35 | $answer = new AikenAnswerMultipleChoice($this->id); |
36 | - return $answer; |
|
36 | + return $answer; |
|
37 | 37 | default : |
38 | 38 | $answer = null; |
39 | 39 | break; |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | } |
43 | 43 | function createAnswersForm($form) |
44 | 44 | { |
45 | - return true; |
|
45 | + return true; |
|
46 | 46 | } |
47 | 47 | function processAnswersCreation($form) |
48 | 48 | { |
49 | - return true; |
|
49 | + return true; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 |
@@ -281,7 +281,7 @@ |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -74,10 +74,10 @@ |
||
74 | 74 | Display::display_introduction_section( |
75 | 75 | TOOL_QUIZ, |
76 | 76 | array( |
77 | - 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', |
|
77 | + 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', |
|
78 | 78 | 'CreateDocumentDir' => '../../..'.api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/', |
79 | - 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/' |
|
80 | - ) |
|
79 | + 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/' |
|
80 | + ) |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Display Forms or dialog box(if needed) |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param Ims2Question $question Ims2Question object we want to export. |
36 | 36 | */ |
37 | - function ImsAssessmentItem($question) |
|
38 | - { |
|
37 | + function ImsAssessmentItem($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 | /** |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | function export_presentation() |
194 | 194 | { |
195 | 195 | $out = "<presentation_material><flow_mat><material>\n" |
196 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | - . "</material></flow_mat></presentation_material>\n"; |
|
196 | + . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | + . "</material></flow_mat></presentation_material>\n"; |
|
198 | 198 | return $out; |
199 | 199 | } |
200 | 200 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | $out = ''; |
209 | 209 | if ($n = $this->exercise->getShuffle()) { |
210 | 210 | $out.= "<selection_ordering>" |
211 | - . " <selection>\n" |
|
212 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | - . " </selection>\n" |
|
214 | - . ' <order order_type="Random" />' |
|
215 | - . "\n</selection_ordering>\n"; |
|
211 | + . " <selection>\n" |
|
212 | + . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | + . " </selection>\n" |
|
214 | + . ' <order order_type="Random" />' |
|
215 | + . "\n</selection_ordering>\n"; |
|
216 | 216 | } else { |
217 | 217 | $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
218 | - . " <selection />\n" |
|
219 | - . "</selection_ordering>\n"; |
|
218 | + . " <selection />\n" |
|
219 | + . "</selection_ordering>\n"; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | return $out; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $out = ""; |
232 | 232 | foreach ($this->exercise->selectQuestionList() as $q) { |
233 | - $out .= export_question_qti($q, false); |
|
233 | + $out .= export_question_qti($q, false); |
|
234 | 234 | } |
235 | 235 | return $out; |
236 | 236 | } |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | $head = $foot = ""; |
248 | 248 | if ($standalone) { |
249 | 249 | $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
250 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | - . "<questestinterop>\n"; |
|
250 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | + . "<questestinterop>\n"; |
|
252 | 252 | $foot = "</questestinterop>\n"; |
253 | 253 | } |
254 | 254 | $out = $head |
255 | - . $this->start_section() |
|
256 | - . $this->export_duration() |
|
257 | - . $this->export_presentation() |
|
258 | - . $this->export_ordering() |
|
259 | - . $this->export_questions() |
|
260 | - . $this->end_section() |
|
261 | - . $foot; |
|
255 | + . $this->start_section() |
|
256 | + . $this->export_duration() |
|
257 | + . $this->export_presentation() |
|
258 | + . $this->export_ordering() |
|
259 | + . $this->export_questions() |
|
260 | + . $this->end_section() |
|
261 | + . $foot; |
|
262 | 262 | |
263 | 263 | return $out; |
264 | 264 | } |
@@ -304,97 +304,97 @@ discard block |
||
304 | 304 | * @param $question The Question object we want to export. |
305 | 305 | * @author Anamd Tihon |
306 | 306 | */ |
307 | - function ImsItem($question) |
|
308 | - { |
|
307 | + function ImsItem($question) |
|
308 | + { |
|
309 | 309 | $this->question = $question; |
310 | 310 | $this->answer = $question->answer; |
311 | 311 | $this->questionIdent = "QST_" . $question->selectId() ; |
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Start the XML flow. |
|
316 | - * |
|
317 | - * This opens the <item> block, with correct attributes. |
|
318 | - * |
|
319 | - * @author Amand Tihon <[email protected]> |
|
320 | - */ |
|
321 | - function start_item() |
|
322 | - { |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Start the XML flow. |
|
316 | + * |
|
317 | + * This opens the <item> block, with correct attributes. |
|
318 | + * |
|
319 | + * @author Amand Tihon <[email protected]> |
|
320 | + */ |
|
321 | + function start_item() |
|
322 | + { |
|
323 | 323 | return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * End the XML flow, closing the </item> tag. |
|
328 | - * |
|
329 | - * @author Amand Tihon <[email protected]> |
|
330 | - */ |
|
331 | - function end_item() |
|
332 | - { |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * End the XML flow, closing the </item> tag. |
|
328 | + * |
|
329 | + * @author Amand Tihon <[email protected]> |
|
330 | + */ |
|
331 | + function end_item() |
|
332 | + { |
|
333 | 333 | return "</item>\n"; |
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Create the opening, with the question itself. |
|
338 | - * |
|
339 | - * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | - * In between, the export_responses from the subclass should have been called. |
|
341 | - * |
|
342 | - * @author Amand Tihon <[email protected]> |
|
343 | - */ |
|
344 | - function start_presentation() |
|
345 | - { |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Create the opening, with the question itself. |
|
338 | + * |
|
339 | + * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | + * In between, the export_responses from the subclass should have been called. |
|
341 | + * |
|
342 | + * @author Amand Tihon <[email protected]> |
|
343 | + */ |
|
344 | + function start_presentation() |
|
345 | + { |
|
346 | 346 | return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
347 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * End the </presentation> part, opened by export_header. |
|
352 | - * |
|
353 | - * @author Amand Tihon <[email protected]> |
|
354 | - */ |
|
355 | - function end_presentation() |
|
356 | - { |
|
347 | + . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * End the </presentation> part, opened by export_header. |
|
352 | + * |
|
353 | + * @author Amand Tihon <[email protected]> |
|
354 | + */ |
|
355 | + function end_presentation() |
|
356 | + { |
|
357 | 357 | return "</flow></presentation>\n"; |
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | - * |
|
363 | - * @author Amand Tihon <[email protected]> |
|
364 | - */ |
|
365 | - function start_processing() |
|
366 | - { |
|
358 | + } |
|
359 | + |
|
360 | + /** |
|
361 | + * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | + * |
|
363 | + * @author Amand Tihon <[email protected]> |
|
364 | + */ |
|
365 | + function start_processing() |
|
366 | + { |
|
367 | 367 | return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * End the response processing part. |
|
372 | - * |
|
373 | - * @author Amand Tihon <[email protected]> |
|
374 | - */ |
|
375 | - function end_processing() |
|
376 | - { |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * End the response processing part. |
|
372 | + * |
|
373 | + * @author Amand Tihon <[email protected]> |
|
374 | + */ |
|
375 | + function end_processing() |
|
376 | + { |
|
377 | 377 | return "</resprocessing>\n"; |
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Export the question as an IMS/QTI Item. |
|
382 | - * |
|
383 | - * This is a default behaviour, some classes may want to override this. |
|
384 | - * |
|
385 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | - * @return string string, the XML flow for an Item. |
|
387 | - * @author Amand Tihon <[email protected]> |
|
388 | - */ |
|
389 | - function export($standalone = False) |
|
390 | - { |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Export the question as an IMS/QTI Item. |
|
382 | + * |
|
383 | + * This is a default behaviour, some classes may want to override this. |
|
384 | + * |
|
385 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | + * @return string string, the XML flow for an Item. |
|
387 | + * @author Amand Tihon <[email protected]> |
|
388 | + */ |
|
389 | + function export($standalone = False) |
|
390 | + { |
|
391 | 391 | global $charset; |
392 | 392 | $head = $foot = ""; |
393 | 393 | |
394 | 394 | if ($standalone) { |
395 | 395 | $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
396 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | - . "<questestinterop>\n"; |
|
396 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | + . "<questestinterop>\n"; |
|
398 | 398 | $foot = "</questestinterop>\n"; |
399 | 399 | } |
400 | 400 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | . $this->answer->imsExportFeedback($this->questionIdent) |
410 | 410 | . $this->end_item() |
411 | 411 | . $foot; |
412 | - } |
|
412 | + } |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | $question->type = $qst->type; |
448 | 448 | $question->question = $qst->question; |
449 | 449 | $question->description = $qst->description; |
450 | - $question->weighting=$qst->weighting; |
|
451 | - $question->position=$qst->position; |
|
452 | - $question->picture=$qst->picture; |
|
450 | + $question->weighting=$qst->weighting; |
|
451 | + $question->position=$qst->position; |
|
452 | + $question->picture=$qst->picture; |
|
453 | 453 | $ims = new ImsAssessmentItem($question); |
454 | 454 | |
455 | 455 | return $ims->export($standalone); |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | |
56 | 56 | function createAnswersForm($form) |
57 | 57 | { |
58 | - return true; |
|
58 | + return true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | function processAnswersCreation($form) |
62 | 62 | { |
63 | - return true; |
|
63 | + return true; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | - $this->answerList = $this->getAnswersList(true); |
|
79 | + $this->answerList = $this->getAnswersList(true); |
|
80 | 80 | $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
81 | 81 | $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
82 | - if (is_array($this->answerList)) { |
|
83 | - foreach ($this->answerList as $current_answer) { |
|
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
82 | + if (is_array($this->answerList)) { |
|
83 | + foreach ($this->answerList as $current_answer) { |
|
84 | + $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | - if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
86 | + if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | + $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | - } |
|
91 | - $out .= '</simpleChoice>'. "\n"; |
|
92 | - } |
|
93 | - } |
|
90 | + } |
|
91 | + $out .= '</simpleChoice>'. "\n"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | $out .= ' </choiceInteraction>'. "\n"; |
95 | 95 | |
96 | 96 | return $out; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function imsExportResponsesDeclaration($questionIdent) |
104 | 104 | { |
105 | - $this->answerList = $this->getAnswersList(true); |
|
106 | - $type = $this->getQuestionType(); |
|
105 | + $this->answerList = $this->getAnswersList(true); |
|
106 | + $type = $this->getQuestionType(); |
|
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | 109 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | 113 | $out .= ' <correctResponse>'. "\n"; |
114 | - if (is_array($this->answerList)) { |
|
115 | - foreach($this->answerList as $current_answer) { |
|
116 | - if ($current_answer['correct']) { |
|
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
114 | + if (is_array($this->answerList)) { |
|
115 | + foreach($this->answerList as $current_answer) { |
|
116 | + if ($current_answer['correct']) { |
|
117 | + $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $out .= ' </correctResponse>'. "\n"; |
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | 125 | $out .= ' <mapping>'. "\n"; |
126 | - if (is_array($this->answerList)) { |
|
127 | - foreach($this->answerList as $current_answer) { |
|
128 | - if (isset($current_answer['grade'])) { |
|
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
126 | + if (is_array($this->answerList)) { |
|
127 | + foreach($this->answerList as $current_answer) { |
|
128 | + if (isset($current_answer['grade'])) { |
|
129 | + $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | $out .= ' </mapping>'. "\n"; |
134 | 134 | $out .= ' </responseDeclaration>'. "\n"; |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 152 | { |
153 | - $this->answerList = $this->getAnswersList(true); |
|
153 | + $this->answerList = $this->getAnswersList(true); |
|
154 | 154 | $text = ''; |
155 | 155 | $text .= $this->answerText; |
156 | 156 | if (is_array($this->answerList)) { |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function imsExportResponsesDeclaration($questionIdent) |
173 | 173 | { |
174 | - $this->answerList = $this->getAnswersList(true); |
|
175 | - $this->gradeList = $this->getGradesList(); |
|
174 | + $this->answerList = $this->getAnswersList(true); |
|
175 | + $this->gradeList = $this->getGradesList(); |
|
176 | 176 | $out = ''; |
177 | - if (is_array($this->answerList)) { |
|
178 | - foreach ($this->answerList as $answer) { |
|
179 | - $answerKey = $answer['id']; |
|
180 | - $answer = $answer['answer']; |
|
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
177 | + if (is_array($this->answerList)) { |
|
178 | + foreach ($this->answerList as $answer) { |
|
179 | + $answerKey = $answer['id']; |
|
180 | + $answer = $answer['answer']; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | + $out .= ' <correctResponse>'. "\n"; |
|
183 | 183 | $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
184 | - $out .= ' </correctResponse>'. "\n"; |
|
185 | - if (isset($this->gradeList[$answerKey])) { |
|
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
189 | - } |
|
190 | - |
|
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $out; |
|
184 | + $out .= ' </correctResponse>'. "\n"; |
|
185 | + if (isset($this->gradeList[$answerKey])) { |
|
186 | + $out .= ' <mapping>'. "\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | + $out .= ' </mapping>'. "\n"; |
|
189 | + } |
|
190 | + |
|
191 | + $out .= ' </responseDeclaration>'. "\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $out; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 209 | { |
210 | - $this->answerList = $this->getAnswersList(true); |
|
211 | - $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
210 | + $this->answerList = $this->getAnswersList(true); |
|
211 | + $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | //add left column |
219 | 219 | |
220 | 220 | $out .= ' <simpleMatchSet>'. "\n"; |
221 | - if (is_array($this->leftList)) { |
|
222 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | - $out .= ' |
|
221 | + if (is_array($this->leftList)) { |
|
222 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | + $out .= ' |
|
224 | 224 | <simpleAssociableChoice identifier="left_'.$leftKey.'" > |
225 | 225 | <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]> |
226 | 226 | </simpleAssociableChoice>'. "\n"; |
227 | - } |
|
228 | - } |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | $out .= ' </simpleMatchSet>'. "\n"; |
231 | 231 | |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | - if (is_array($this->rightList)) { |
|
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | - $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
238 | + if (is_array($this->rightList)) { |
|
239 | + foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | + $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | - $i++; |
|
244 | - } |
|
245 | - } |
|
243 | + $i++; |
|
244 | + } |
|
245 | + } |
|
246 | 246 | $out .= ' </simpleMatchSet>'. "\n"; |
247 | 247 | $out .= '</matchInteraction>'. "\n"; |
248 | 248 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | - $this->answerList = $this->getAnswersList(true); |
|
257 | + $this->answerList = $this->getAnswersList(true); |
|
258 | 258 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
259 | 259 | $out .= ' <correctResponse>' . "\n"; |
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | - if (is_array($this->leftList)) { |
|
263 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | - $i=0; |
|
265 | - foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | - if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | - |
|
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | - } |
|
271 | - $i++; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
262 | + if (is_array($this->leftList)) { |
|
263 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | + $i=0; |
|
265 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | + if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | + $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | + |
|
269 | + $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | + } |
|
271 | + $i++; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $out .= ' </correctResponse>'. "\n"; |
276 | 276 | $out .= ' <mapping>' . "\n"; |
277 | 277 | if (is_array($gradeArray)) { |
278 | - foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | - } |
|
278 | + foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | $out .= ' </mapping>' . "\n"; |
283 | 283 | $out .= ' </responseDeclaration>'. "\n"; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 300 | { |
301 | - $this->answerList = $this->getAnswersList(true); |
|
302 | - $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | - $mimetype = mime_content_type($questionMedia); |
|
304 | - if(empty($mimetype)){ |
|
305 | - $mimetype = 'image/jpeg'; |
|
306 | - } |
|
307 | - |
|
308 | - $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | - $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | - $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | - $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
301 | + $this->answerList = $this->getAnswersList(true); |
|
302 | + $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | + $mimetype = mime_content_type($questionMedia); |
|
304 | + if(empty($mimetype)){ |
|
305 | + $mimetype = 'image/jpeg'; |
|
306 | + } |
|
307 | + |
|
308 | + $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | + $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | + $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | + $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
312 | 312 | if (is_array($this->answerList)) { |
313 | - foreach ($this->answerList as $key=>$answer) { |
|
314 | - $key = $answer['id']; |
|
315 | - $answerTxt = $answer['answer']; |
|
316 | - $len = api_strlen($answerTxt); |
|
317 | - //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | - $coords = ''; |
|
319 | - $type = 'default'; |
|
320 | - switch($answer['hotspot_type']){ |
|
321 | - case 'square': |
|
322 | - $type = 'rect'; |
|
323 | - $res = array(); |
|
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | - break; |
|
327 | - case 'circle': |
|
328 | - $type = 'circle'; |
|
329 | - $res = array(); |
|
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | - break; |
|
333 | - case 'poly': |
|
334 | - $type = 'poly'; |
|
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | - break; |
|
337 | - case 'delineation' : |
|
338 | - $type = 'delineation'; |
|
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | - break; |
|
341 | - } |
|
342 | - $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | - } |
|
313 | + foreach ($this->answerList as $key=>$answer) { |
|
314 | + $key = $answer['id']; |
|
315 | + $answerTxt = $answer['answer']; |
|
316 | + $len = api_strlen($answerTxt); |
|
317 | + //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | + $coords = ''; |
|
319 | + $type = 'default'; |
|
320 | + switch($answer['hotspot_type']){ |
|
321 | + case 'square': |
|
322 | + $type = 'rect'; |
|
323 | + $res = array(); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | + break; |
|
327 | + case 'circle': |
|
328 | + $type = 'circle'; |
|
329 | + $res = array(); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | + break; |
|
333 | + case 'poly': |
|
334 | + $type = 'poly'; |
|
335 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | + break; |
|
337 | + case 'delineation' : |
|
338 | + $type = 'delineation'; |
|
339 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | + break; |
|
341 | + } |
|
342 | + $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | + } |
|
344 | 344 | } |
345 | 345 | $text .= ' </graphicOrderInteraction>'."\n"; |
346 | 346 | $out = $text; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function imsExportResponsesDeclaration($questionIdent) |
355 | 355 | { |
356 | - $this->answerList = $this->getAnswersList(true); |
|
357 | - $this->gradeList = $this->getGradesList(); |
|
356 | + $this->answerList = $this->getAnswersList(true); |
|
357 | + $this->gradeList = $this->getGradesList(); |
|
358 | 358 | $out = ''; |
359 | 359 | $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
360 | 360 | $out .= ' <correctResponse>'. "\n"; |
361 | 361 | |
362 | - if (is_array($this->answerList)) { |
|
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | - $answerKey = $answer['id']; |
|
365 | - $answer = $answer['answer']; |
|
366 | - $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | - } |
|
368 | - } |
|
362 | + if (is_array($this->answerList)) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | + $answerKey = $answer['id']; |
|
365 | + $answer = $answer['answer']; |
|
366 | + $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $out .= ' </correctResponse>'. "\n"; |
370 | 370 | $out .= ' </responseDeclaration>'. "\n"; |
371 | 371 | |
372 | - return $out; |
|
372 | + return $out; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | 386 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | - { |
|
388 | - return ''; |
|
389 | - } |
|
387 | + { |
|
388 | + return ''; |
|
389 | + } |
|
390 | 390 | /** |
391 | 391 | * |
392 | 392 | */ |
393 | 393 | public function imsExportResponsesDeclaration($questionIdent) |
394 | 394 | { |
395 | - return ''; |
|
395 | + return ''; |
|
396 | 396 | } |
397 | 397 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | //Event::event_download($doc_url); |
24 | 24 | if (isset($_course['path'])) { |
25 | 25 | $course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
26 | - $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
26 | + $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
27 | 27 | } else { |
28 | 28 | $course_path = api_get_path(SYS_COURSE_PATH).$cid.'/document'; |
29 | - $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
29 | + $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if(!is_file($full_file_name)) { |
33 | - exit; |
|
33 | + exit; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if (!Security::check_abs_path($full_file_name, $course_path.'/')) { |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | $extension=strtolower($extension[sizeof($extension)-1]); |
42 | 42 | |
43 | 43 | switch($extension) { |
44 | - case 'gz': $content_type='application/x-gzip'; break; |
|
45 | - case 'zip': $content_type='application/zip'; break; |
|
46 | - case 'pdf': $content_type='application/pdf'; break; |
|
47 | - case 'png': $content_type='image/png'; break; |
|
48 | - case 'gif': $content_type='image/gif'; break; |
|
49 | - case 'jpg': $content_type='image/jpeg'; break; |
|
50 | - case 'txt': $content_type='text/plain'; break; |
|
51 | - case 'htm': $content_type='text/html'; break; |
|
52 | - case 'html': $content_type='text/html'; break; |
|
53 | - default: $content_type='application/octet-stream'; break; |
|
44 | + case 'gz': $content_type='application/x-gzip'; break; |
|
45 | + case 'zip': $content_type='application/zip'; break; |
|
46 | + case 'pdf': $content_type='application/pdf'; break; |
|
47 | + case 'png': $content_type='image/png'; break; |
|
48 | + case 'gif': $content_type='image/gif'; break; |
|
49 | + case 'jpg': $content_type='image/jpeg'; break; |
|
50 | + case 'txt': $content_type='text/plain'; break; |
|
51 | + case 'htm': $content_type='text/html'; break; |
|
52 | + case 'html': $content_type='text/html'; break; |
|
53 | + default: $content_type='application/octet-stream'; break; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | header('Content-disposition: filename='.$filename); |
@@ -68,23 +68,23 @@ discard block |
||
68 | 68 | */ |
69 | 69 | |
70 | 70 | if ($content_type == 'text/html') { |
71 | - $directory_name = dirname($full_file_name); |
|
71 | + $directory_name = dirname($full_file_name); |
|
72 | 72 | |
73 | - $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name); |
|
73 | + $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name); |
|
74 | 74 | |
75 | - if($dir[strlen($dir)-1] != '/') { |
|
76 | - $dir.='/'; |
|
77 | - } |
|
75 | + if($dir[strlen($dir)-1] != '/') { |
|
76 | + $dir.='/'; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - //Parse whole file at one |
|
81 | - $fp = fopen($full_file_name, "r"); |
|
82 | - $file_content = fread ($fp, filesize ($full_file_name)); |
|
83 | - fclose($fp); |
|
84 | - //$file_content = api_replace_parameter($dir, $file_content, "src"); |
|
85 | - //$file_content = api_replace_parameter($dir, $file_content, "href"); |
|
80 | + //Parse whole file at one |
|
81 | + $fp = fopen($full_file_name, "r"); |
|
82 | + $file_content = fread ($fp, filesize ($full_file_name)); |
|
83 | + fclose($fp); |
|
84 | + //$file_content = api_replace_parameter($dir, $file_content, "src"); |
|
85 | + //$file_content = api_replace_parameter($dir, $file_content, "href"); |
|
86 | 86 | |
87 | - /* |
|
87 | + /* |
|
88 | 88 | //parse line per line |
89 | 89 | $file_content_array = file($full_file_name); |
90 | 90 | |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | $exercisePath = api_get_self(); |
101 | - $exfile = explode('/',$exercisePath); |
|
102 | - $exfile = $exfile[sizeof($exfile)-1]; |
|
103 | - $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile)); |
|
104 | - $exercisePath = $exercisePath; |
|
101 | + $exfile = explode('/',$exercisePath); |
|
102 | + $exfile = $exfile[sizeof($exfile)-1]; |
|
103 | + $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile)); |
|
104 | + $exercisePath = $exercisePath; |
|
105 | 105 | |
106 | - $content = $file_content; |
|
107 | - $mit = "function Finish(){"; |
|
106 | + $content = $file_content; |
|
107 | + $mit = "function Finish(){"; |
|
108 | 108 | |
109 | - $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". |
|
110 | - "function mySaveScore() // This function included by Dokeos System\n". |
|
109 | + $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". |
|
110 | + "function mySaveScore() // This function included by Dokeos System\n". |
|
111 | 111 | "{\n". |
112 | 112 | " if (SaveScoreVariable==0)\n". |
113 | 113 | " {\n". |
@@ -125,23 +125,23 @@ discard block |
||
125 | 125 | "// Must be included \n". |
126 | 126 | "function Finish(){\n". |
127 | 127 | " mySaveScore();"; |
128 | - $newcontent = str_replace($mit,$js_content,$content); |
|
128 | + $newcontent = str_replace($mit,$js_content,$content); |
|
129 | 129 | |
130 | - $prehref="javascript:void(0);"; |
|
131 | - $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; |
|
132 | - $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
130 | + $prehref="javascript:void(0);"; |
|
131 | + $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; |
|
132 | + $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
133 | 133 | |
134 | 134 | |
135 | - $prehref="class=\"GridNum\" onclick="; |
|
136 | - $posthref="class=\"GridNum\" onMouseover="; |
|
137 | - $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
135 | + $prehref="class=\"GridNum\" onclick="; |
|
136 | + $posthref="class=\"GridNum\" onMouseover="; |
|
137 | + $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
138 | 138 | |
139 | 139 | |
140 | - header('Content-length: '.strlen($newcontent)); |
|
141 | - // Dipsp. |
|
142 | - echo $newcontent; |
|
140 | + header('Content-length: '.strlen($newcontent)); |
|
141 | + // Dipsp. |
|
142 | + echo $newcontent; |
|
143 | 143 | |
144 | - exit(); |
|
144 | + exit(); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | //normal case, all non-html files |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | $label = get_lang('NextQuestion'); |
1967 | 1967 | $class = 'btn btn-primary'; |
1968 | 1968 | } |
1969 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1969 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1970 | 1970 | if ($this->type == ONE_PER_PAGE) { |
1971 | 1971 | if ($questionNum != 1) { |
1972 | 1972 | $prev_question = $questionNum - 2; |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | $all_label = get_lang('EndTest'); |
1992 | 1992 | $class = 'btn btn-warning'; |
1993 | 1993 | } |
1994 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1994 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | 1996 | $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
1997 | 1997 | $html .= $all_button; |
@@ -3774,7 +3774,7 @@ discard block |
||
3774 | 3774 | |
3775 | 3775 | //Fixes multiple answer question in order to be exact |
3776 | 3776 | //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
3777 | - /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3777 | + /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3778 | 3778 | $diff = @array_diff($answer_correct_array, $real_answers); |
3779 | 3779 | |
3780 | 3780 | // All good answers or nothing works like exact |
@@ -5073,8 +5073,8 @@ discard block |
||
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
5076 | - * @return string |
|
5077 | - */ |
|
5076 | + * @return string |
|
5077 | + */ |
|
5078 | 5078 | public function get_formated_title() |
5079 | 5079 | { |
5080 | 5080 | return api_html_entity_decode($this->selectTitle()); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if (!$objExercise->read($exerciseId) || |
124 | 124 | (!$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath') |
125 | 125 | ) { |
126 | - if ($debug) {error_log('1.1. Error while reading the exercise'); }; |
|
126 | + if ($debug) {error_log('1.1. Error while reading the exercise'); }; |
|
127 | 127 | unset ($objExercise); |
128 | 128 | $error = get_lang('ExerciseNotFound'); |
129 | 129 | } else { |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | } |
137 | 137 | //2. Checking if $objExercise is set |
138 | 138 | if (!isset($objExercise) && isset($exerciseInSession)) { |
139 | - if ($debug) { error_log('2. Loading $objExercise from session'); }; |
|
139 | + if ($debug) { error_log('2. Loading $objExercise from session'); }; |
|
140 | 140 | $objExercise = $exerciseInSession; |
141 | 141 | } |
142 | 142 | |
143 | 143 | //3. $objExercise is not set, then return to the exercise list |
144 | 144 | if (!is_object($objExercise)) { |
145 | - if ($debug) {error_log('3. $objExercise was not set, kill the script'); }; |
|
145 | + if ($debug) {error_log('3. $objExercise was not set, kill the script'); }; |
|
146 | 146 | header('Location: exercise.php'); |
147 | 147 | exit; |
148 | 148 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | $time_control = false; |
165 | 165 | if ($objExercise->expired_time != 0) { |
166 | - $time_control = true; |
|
166 | + $time_control = true; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Generating the time control key for the user |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp; |
173 | 173 | |
174 | 174 | if ($time_control) { |
175 | - // Get the expired time of the current exercise in track_e_exercises |
|
176 | - $total_seconds = $objExercise->expired_time*60; |
|
175 | + // Get the expired time of the current exercise in track_e_exercises |
|
176 | + $total_seconds = $objExercise->expired_time*60; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $show_clock = true; |
180 | 180 | $user_id = api_get_user_id(); |
181 | 181 | if ($objExercise->selectAttempts() > 0) { |
182 | - $attempt_html = ''; |
|
182 | + $attempt_html = ''; |
|
183 | 183 | $attempt_count = Event::get_attempt_count( |
184 | 184 | $user_id, |
185 | 185 | $exerciseId, |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | $learnpath_item_view_id |
189 | 189 | ); |
190 | 190 | |
191 | - if ($attempt_count >= $objExercise->selectAttempts()) { |
|
192 | - $show_clock = false; |
|
193 | - if (!api_is_allowed_to_edit(null,true)) { |
|
191 | + if ($attempt_count >= $objExercise->selectAttempts()) { |
|
192 | + $show_clock = false; |
|
193 | + if (!api_is_allowed_to_edit(null,true)) { |
|
194 | 194 | if ($objExercise->results_disabled == 0 && $origin != 'learnpath') { |
195 | 195 | |
196 | 196 | // Showing latest attempt according with task BT#1628 |
@@ -229,31 +229,31 @@ discard block |
||
229 | 229 | $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore')); |
230 | 230 | } |
231 | 231 | } |
232 | - $score = ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']); |
|
233 | - $attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score')); |
|
234 | - } else { |
|
235 | - $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false); |
|
236 | - } |
|
237 | - } else { |
|
238 | - $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false); |
|
239 | - } |
|
240 | - } else { |
|
241 | - $attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false); |
|
242 | - } |
|
232 | + $score = ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']); |
|
233 | + $attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score')); |
|
234 | + } else { |
|
235 | + $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false); |
|
236 | + } |
|
237 | + } else { |
|
238 | + $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false); |
|
239 | + } |
|
240 | + } else { |
|
241 | + $attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false); |
|
242 | + } |
|
243 | 243 | |
244 | - if ($origin == 'learnpath') { |
|
245 | - Display :: display_reduced_header(); |
|
246 | - } else { |
|
247 | - Display :: display_header(get_lang('Exercises')); |
|
248 | - } |
|
244 | + if ($origin == 'learnpath') { |
|
245 | + Display :: display_reduced_header(); |
|
246 | + } else { |
|
247 | + Display :: display_header(get_lang('Exercises')); |
|
248 | + } |
|
249 | 249 | |
250 | - echo $attempt_html; |
|
250 | + echo $attempt_html; |
|
251 | 251 | |
252 | 252 | if ($origin != 'learnpath') { |
253 | 253 | Display:: display_footer(); |
254 | 254 | } |
255 | - exit; |
|
256 | - } |
|
255 | + exit; |
|
256 | + } |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if ($debug) { |
@@ -277,26 +277,26 @@ discard block |
||
277 | 277 | |
278 | 278 | if (empty($exercise_stat_info)) { |
279 | 279 | if ($debug) error_log('5 $exercise_stat_info is empty '); |
280 | - $total_weight = 0; |
|
281 | - $questionList = $objExercise->get_validated_question_list(); |
|
282 | - foreach ($questionListUncompressed as $question_id) { |
|
283 | - $objQuestionTmp = Question::read($question_id); |
|
284 | - $total_weight += floatval($objQuestionTmp->weighting); |
|
285 | - } |
|
280 | + $total_weight = 0; |
|
281 | + $questionList = $objExercise->get_validated_question_list(); |
|
282 | + foreach ($questionListUncompressed as $question_id) { |
|
283 | + $objQuestionTmp = Question::read($question_id); |
|
284 | + $total_weight += floatval($objQuestionTmp->weighting); |
|
285 | + } |
|
286 | 286 | |
287 | - if ($time_control) { |
|
288 | - $expected_time = $current_timestamp + $total_seconds; |
|
287 | + if ($time_control) { |
|
288 | + $expected_time = $current_timestamp + $total_seconds; |
|
289 | 289 | |
290 | - if ($debug) error_log('5.1. $current_timestamp '.$current_timestamp); |
|
291 | - if ($debug) error_log('5.2. $expected_time '.$expected_time); |
|
290 | + if ($debug) error_log('5.1. $current_timestamp '.$current_timestamp); |
|
291 | + if ($debug) error_log('5.2. $expected_time '.$expected_time); |
|
292 | 292 | |
293 | - $clock_expired_time = api_get_utc_datetime($expected_time); |
|
294 | - if ($debug) error_log('5.3. $expected_time '.$clock_expired_time); |
|
293 | + $clock_expired_time = api_get_utc_datetime($expected_time); |
|
294 | + if ($debug) error_log('5.3. $expected_time '.$clock_expired_time); |
|
295 | 295 | |
296 | - //Sessions that contain the expired time |
|
297 | - $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
298 | - if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); }; |
|
299 | - } |
|
296 | + //Sessions that contain the expired time |
|
297 | + $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
298 | + if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); }; |
|
299 | + } |
|
300 | 300 | |
301 | 301 | $exe_id = $objExercise->save_stat_track_exercise_info( |
302 | 302 | $clock_expired_time, |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | ); |
314 | 314 | if ($debug) error_log("5.5 exercise_stat_info[] exists getting exe_id $exe_id"); |
315 | 315 | } else { |
316 | - $exe_id = $exercise_stat_info['exe_id']; |
|
316 | + $exe_id = $exercise_stat_info['exe_id']; |
|
317 | 317 | // Remember last question id position. |
318 | 318 | $isFirstTime = Session::read('firstTime'); |
319 | 319 | if ($isFirstTime && $objExercise->type == ONE_PER_PAGE) { |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); }; |
373 | 373 | |
374 | 374 | if (!empty($exercise_stat_info['questions_to_check'])) { |
375 | - $my_remind_list = $exercise_stat_info['questions_to_check']; |
|
376 | - $my_remind_list = explode(',', $my_remind_list); |
|
377 | - $my_remind_list = array_filter($my_remind_list); |
|
375 | + $my_remind_list = $exercise_stat_info['questions_to_check']; |
|
376 | + $my_remind_list = explode(',', $my_remind_list); |
|
377 | + $my_remind_list = array_filter($my_remind_list); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | $params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq(); |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | |
383 | 383 | if ($reminder == 2 && empty($my_remind_list)) { |
384 | 384 | if ($debug) { error_log("6.2 calling the exercise_reminder.php "); }; |
385 | - header('Location: exercise_reminder.php?'.$params); |
|
386 | - exit; |
|
385 | + header('Location: exercise_reminder.php?'.$params); |
|
386 | + exit; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /* |
@@ -391,56 +391,56 @@ discard block |
||
391 | 391 | * If the expired time is major that zero(0) then the expired time is compute on this time. |
392 | 392 | */ |
393 | 393 | if ($time_control) { |
394 | - if ($debug) error_log('7.1. Time control is enabled'); |
|
395 | - if ($debug) error_log('7.2. $current_expired_time_key '.$current_expired_time_key); |
|
396 | - if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key] '.$_SESSION['expired_time'][$current_expired_time_key]); |
|
394 | + if ($debug) error_log('7.1. Time control is enabled'); |
|
395 | + if ($debug) error_log('7.2. $current_expired_time_key '.$current_expired_time_key); |
|
396 | + if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key] '.$_SESSION['expired_time'][$current_expired_time_key]); |
|
397 | 397 | |
398 | 398 | if (!isset($_SESSION['expired_time'][$current_expired_time_key])) { |
399 | 399 | //Timer - Get expired_time for a student |
400 | 400 | if (!empty($exercise_stat_info)) { |
401 | - if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); }; |
|
402 | - $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control']; |
|
403 | - if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); } |
|
404 | - // Get the last attempt of an exercise |
|
405 | - $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']); |
|
401 | + if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); }; |
|
402 | + $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control']; |
|
403 | + if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); } |
|
404 | + // Get the last attempt of an exercise |
|
405 | + $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']); |
|
406 | 406 | |
407 | - /* This means that the user enters the exam but do not answer the |
|
407 | + /* This means that the user enters the exam but do not answer the |
|
408 | 408 | first question we get the date from the track_e_exercises not from |
409 | 409 | the track_et_attempt see #2069 */ |
410 | - if (empty($last_attempt_date)) { |
|
411 | - $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC'); |
|
412 | - $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff); |
|
413 | - } else { |
|
414 | - //Recalculate the time control due #2069 |
|
415 | - $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC'); |
|
416 | - $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff); |
|
417 | - } |
|
418 | - if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); } |
|
419 | - |
|
420 | - //New expired time - it is due to the possible closure of session |
|
421 | - $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC'); |
|
422 | - if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); } |
|
423 | - |
|
424 | - $expected_time = $current_timestamp + $new_expired_time_in_seconds; |
|
425 | - if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); } |
|
426 | - |
|
427 | - $clock_expired_time = api_get_utc_datetime($expected_time); |
|
428 | - if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); } |
|
429 | - |
|
430 | - // First we update the attempt to today |
|
431 | - /* How the expired time is changed into "track_e_exercises" table, |
|
410 | + if (empty($last_attempt_date)) { |
|
411 | + $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC'); |
|
412 | + $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff); |
|
413 | + } else { |
|
414 | + //Recalculate the time control due #2069 |
|
415 | + $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC'); |
|
416 | + $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff); |
|
417 | + } |
|
418 | + if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); } |
|
419 | + |
|
420 | + //New expired time - it is due to the possible closure of session |
|
421 | + $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC'); |
|
422 | + if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); } |
|
423 | + |
|
424 | + $expected_time = $current_timestamp + $new_expired_time_in_seconds; |
|
425 | + if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); } |
|
426 | + |
|
427 | + $clock_expired_time = api_get_utc_datetime($expected_time); |
|
428 | + if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); } |
|
429 | + |
|
430 | + // First we update the attempt to today |
|
431 | + /* How the expired time is changed into "track_e_exercises" table, |
|
432 | 432 | then the last attempt for this student should be changed too */ |
433 | - $sql = "UPDATE $exercise_attempt_table SET |
|
433 | + $sql = "UPDATE $exercise_attempt_table SET |
|
434 | 434 | tms = '".api_get_utc_datetime()."' |
435 | 435 | WHERE |
436 | 436 | exe_id = '".$exercise_stat_info['exe_id']."' AND |
437 | 437 | tms = '".$last_attempt_date."' "; |
438 | - if ($debug) {error_log('7.10. $sql: '.$sql); } |
|
439 | - Database::query($sql); |
|
438 | + if ($debug) {error_log('7.10. $sql: '.$sql); } |
|
439 | + Database::query($sql); |
|
440 | 440 | |
441 | - //Sessions that contain the expired time |
|
442 | - $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
443 | - if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); }; |
|
441 | + //Sessions that contain the expired time |
|
442 | + $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
443 | + if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); }; |
|
444 | 444 | } |
445 | 445 | } else { |
446 | 446 | $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key]; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock |
458 | 458 | */ |
459 | 459 | if ($time_control) { //Sends the exercise form when the expired time is finished |
460 | - $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left); |
|
460 | + $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | // if the user has submitted the form |
@@ -470,14 +470,14 @@ discard block |
||
470 | 470 | // selects the list of question ID |
471 | 471 | $questionList = $objExercise->get_validated_question_list(); |
472 | 472 | if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) { |
473 | - $questionList = explode(',', $exercise_stat_info['data_tracking']); |
|
473 | + $questionList = explode(',', $exercise_stat_info['data_tracking']); |
|
474 | 474 | } |
475 | 475 | Session::write('questionList', $questionList); |
476 | 476 | if ($debug > 0) { error_log('$_SESSION[questionList] was set'); } |
477 | 477 | } else { |
478 | - if (isset($objExercise) && isset($_SESSION['objExercise'])) { |
|
479 | - $questionList = $_SESSION['questionList']; |
|
480 | - } |
|
478 | + if (isset($objExercise) && isset($_SESSION['objExercise'])) { |
|
479 | + $questionList = $_SESSION['questionList']; |
|
480 | + } |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1)); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | //Real question count |
486 | 486 | $question_count = 0; |
487 | 487 | if (!empty($questionList)) { |
488 | - $question_count = count($questionList); |
|
488 | + $question_count = count($questionList); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | if ($formSent && isset($_POST)) { |
@@ -527,11 +527,11 @@ discard block |
||
527 | 527 | //saving each question |
528 | 528 | if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) { |
529 | 529 | $nro_question = $current_question; // - 1; |
530 | - $questionId = $key; |
|
530 | + $questionId = $key; |
|
531 | 531 | // gets the student choice for this question |
532 | 532 | $choice = $exerciseResult[$questionId]; |
533 | 533 | if (isset($exe_id)) { |
534 | - // Manage the question and answer attempts |
|
534 | + // Manage the question and answer attempts |
|
535 | 535 | if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); } |
536 | 536 | $objExercise->manage_answer( |
537 | 537 | $exe_id, |
@@ -620,58 +620,58 @@ discard block |
||
620 | 620 | } |
621 | 621 | |
622 | 622 | if ($question_count != 0) { |
623 | - if (($objExercise->type == ALL_ON_ONE_PAGE || |
|
623 | + if (($objExercise->type == ALL_ON_ONE_PAGE || |
|
624 | 624 | $current_question > $question_count) |
625 | 625 | ) { |
626 | - if (api_is_allowed_to_session_edit()) { |
|
627 | - // goes to the script that will show the result of the exercise |
|
628 | - if ($objExercise->type == ALL_ON_ONE_PAGE) { |
|
629 | - if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); } |
|
630 | - |
|
631 | - //We check if the user attempts before sending to the exercise_result.php |
|
632 | - if ($objExercise->selectAttempts() > 0) { |
|
633 | - $attempt_count = Event::get_attempt_count( |
|
626 | + if (api_is_allowed_to_session_edit()) { |
|
627 | + // goes to the script that will show the result of the exercise |
|
628 | + if ($objExercise->type == ALL_ON_ONE_PAGE) { |
|
629 | + if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); } |
|
630 | + |
|
631 | + //We check if the user attempts before sending to the exercise_result.php |
|
632 | + if ($objExercise->selectAttempts() > 0) { |
|
633 | + $attempt_count = Event::get_attempt_count( |
|
634 | 634 | api_get_user_id(), |
635 | 635 | $exerciseId, |
636 | 636 | $learnpath_id, |
637 | 637 | $learnpath_item_id, |
638 | 638 | $learnpath_item_view_id |
639 | 639 | ); |
640 | - if ($attempt_count >= $objExercise->selectAttempts()) { |
|
641 | - Display :: display_warning_message( |
|
640 | + if ($attempt_count >= $objExercise->selectAttempts()) { |
|
641 | + Display :: display_warning_message( |
|
642 | 642 | sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), |
643 | 643 | false |
644 | 644 | ); |
645 | - if ($origin != 'learnpath') { |
|
646 | - //so we are not in learnpath tool |
|
647 | - echo '</div>'; //End glossary div |
|
648 | - Display :: display_footer(); |
|
649 | - } else { |
|
650 | - echo '</body></html>'; |
|
651 | - } |
|
652 | - exit; |
|
653 | - } |
|
654 | - } |
|
655 | - } else { |
|
656 | - if ($objExercise->review_answers) { |
|
657 | - header('Location: exercise_reminder.php?'.$params); |
|
658 | - exit; |
|
659 | - } else { |
|
645 | + if ($origin != 'learnpath') { |
|
646 | + //so we are not in learnpath tool |
|
647 | + echo '</div>'; //End glossary div |
|
648 | + Display :: display_footer(); |
|
649 | + } else { |
|
650 | + echo '</body></html>'; |
|
651 | + } |
|
652 | + exit; |
|
653 | + } |
|
654 | + } |
|
655 | + } else { |
|
656 | + if ($objExercise->review_answers) { |
|
657 | + header('Location: exercise_reminder.php?'.$params); |
|
658 | + exit; |
|
659 | + } else { |
|
660 | 660 | header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id"); |
661 | 661 | exit; |
662 | - } |
|
663 | - } |
|
664 | - } else { |
|
665 | - if ($debug) { error_log('Redirecting to exercise_submit.php'); } |
|
666 | - exit; |
|
667 | - } |
|
668 | - } |
|
662 | + } |
|
663 | + } |
|
664 | + } else { |
|
665 | + if ($debug) { error_log('Redirecting to exercise_submit.php'); } |
|
666 | + exit; |
|
667 | + } |
|
668 | + } |
|
669 | 669 | } else { |
670 | - $error = get_lang('ThereAreNoQuestionsForThisExercise'); |
|
671 | - // if we are in the case where user select random by category, but didn't choose the number of random question |
|
672 | - if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) { |
|
673 | - $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion'); |
|
674 | - } |
|
670 | + $error = get_lang('ThereAreNoQuestionsForThisExercise'); |
|
671 | + // if we are in the case where user select random by category, but didn't choose the number of random question |
|
672 | + if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) { |
|
673 | + $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion'); |
|
674 | + } |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') { |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | if (api_is_course_admin() && $origin != 'learnpath') { |
711 | 711 | echo '<div class="actions">'; |
712 | 712 | if ($show_quiz_edition == false) { |
713 | - echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
713 | + echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
714 | 714 | } else { |
715 | - echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
715 | + echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
716 | 716 | } |
717 | 717 | echo '</div>'; |
718 | 718 | } |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet'); |
756 | 756 | Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts())); |
757 | 757 | if ($origin != 'learnpath') { |
758 | - Display :: display_footer(); |
|
758 | + Display :: display_footer(); |
|
759 | 759 | } |
760 | 760 | exit; |
761 | 761 | } else { |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | if (isset($_custom['exercises_hidden_when_no_start_date']) && |
771 | 771 | $_custom['exercises_hidden_when_no_start_date'] |
772 | 772 | ) { |
773 | - if (empty($objExercise->start_time)) { |
|
773 | + if (empty($objExercise->start_time)) { |
|
774 | 774 | Display:: display_warning_message( |
775 | 775 | sprintf( |
776 | 776 | get_lang('ExerciseNoStartedYet'), |
@@ -778,20 +778,20 @@ discard block |
||
778 | 778 | $objExercise->selectAttempts() |
779 | 779 | ) |
780 | 780 | ); |
781 | - if ($origin != 'learnpath') { |
|
782 | - Display :: display_footer(); |
|
783 | - } |
|
784 | - } |
|
781 | + if ($origin != 'learnpath') { |
|
782 | + Display :: display_footer(); |
|
783 | + } |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | //Timer control |
788 | 788 | if ($time_control) { |
789 | 789 | echo $objExercise->return_time_left_div(); |
790 | - echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>'; |
|
790 | + echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>'; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | if ($origin != 'learnpath') { |
794 | - echo '<div id="highlight-plugin" class="glossary-content">'; |
|
794 | + echo '<div id="highlight-plugin" class="glossary-content">'; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | if ($reminder == 2) { |
@@ -803,53 +803,53 @@ discard block |
||
803 | 803 | $current_question = 1; //set by default the 1st question |
804 | 804 | |
805 | 805 | if (!empty($my_remind_list)) { |
806 | - //Checking which questions we are going to call from the remind list |
|
807 | - for ($i = 0; $i < count($data_tracking); $i++) { |
|
808 | - for($j = 0; $j < count($my_remind_list); $j++) { |
|
809 | - |
|
810 | - if (!empty($remind_question_id)) { |
|
811 | - if ($remind_question_id == $my_remind_list[$j]) { |
|
812 | - |
|
813 | - if ($remind_question_id == $data_tracking[$i]) { |
|
814 | - if (isset($my_remind_list[$j+1])) { |
|
815 | - $remind_question_id = $my_remind_list[$j+1]; |
|
816 | - $current_question = $i + 1; |
|
817 | - } else { |
|
806 | + //Checking which questions we are going to call from the remind list |
|
807 | + for ($i = 0; $i < count($data_tracking); $i++) { |
|
808 | + for($j = 0; $j < count($my_remind_list); $j++) { |
|
809 | + |
|
810 | + if (!empty($remind_question_id)) { |
|
811 | + if ($remind_question_id == $my_remind_list[$j]) { |
|
812 | + |
|
813 | + if ($remind_question_id == $data_tracking[$i]) { |
|
814 | + if (isset($my_remind_list[$j+1])) { |
|
815 | + $remind_question_id = $my_remind_list[$j+1]; |
|
816 | + $current_question = $i + 1; |
|
817 | + } else { |
|
818 | 818 | // We end the remind list we go to the exercise_reminder.php please |
819 | - $remind_question_id = -1; |
|
820 | - $current_question = $i + 1; // last question |
|
821 | - } |
|
822 | - break 2; |
|
823 | - } |
|
824 | - } |
|
825 | - } else { |
|
826 | - if ($my_remind_list[$j] == $data_tracking[$i]) { |
|
827 | - if (isset($my_remind_list[$j+1])) { |
|
828 | - $remind_question_id = $my_remind_list[$j+1]; |
|
829 | - $current_question = $i + 1; // last question |
|
830 | - } else { |
|
819 | + $remind_question_id = -1; |
|
820 | + $current_question = $i + 1; // last question |
|
821 | + } |
|
822 | + break 2; |
|
823 | + } |
|
824 | + } |
|
825 | + } else { |
|
826 | + if ($my_remind_list[$j] == $data_tracking[$i]) { |
|
827 | + if (isset($my_remind_list[$j+1])) { |
|
828 | + $remind_question_id = $my_remind_list[$j+1]; |
|
829 | + $current_question = $i + 1; // last question |
|
830 | + } else { |
|
831 | 831 | // We end the remind list we go to the exercise_reminder.php please |
832 | - $remind_question_id = -1; |
|
833 | - $current_question = $i + 1; // last question |
|
834 | - } |
|
835 | - break 2; |
|
836 | - } |
|
837 | - } |
|
838 | - } |
|
832 | + $remind_question_id = -1; |
|
833 | + $current_question = $i + 1; // last question |
|
834 | + } |
|
835 | + break 2; |
|
836 | + } |
|
837 | + } |
|
838 | + } |
|
839 | 839 | } |
840 | 840 | } else { |
841 | - if ($objExercise->review_answers) { |
|
841 | + if ($objExercise->review_answers) { |
|
842 | 842 | if ($debug) { error_log('. redirecting to exercise_reminder.php '); } |
843 | - header("Location: exercise_reminder.php?$params"); |
|
844 | - exit; |
|
845 | - } |
|
843 | + header("Location: exercise_reminder.php?$params"); |
|
844 | + exit; |
|
845 | + } |
|
846 | 846 | } |
847 | 847 | } |
848 | 848 | |
849 | 849 | if ($objExercise->review_answers) { |
850 | - $script_php = 'exercise_reminder.php'; |
|
850 | + $script_php = 'exercise_reminder.php'; |
|
851 | 851 | } else { |
852 | - $script_php = 'exercise_result.php'; |
|
852 | + $script_php = 'exercise_result.php'; |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | if (!empty($error)) { |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | <input type="hidden" name="learnpath_item_id" value="'.$learnpath_item_id . '" /> |
1090 | 1090 | <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />'; |
1091 | 1091 | |
1092 | - // Show list of questions |
|
1092 | + // Show list of questions |
|
1093 | 1093 | $i = 1; |
1094 | 1094 | $attempt_list = array(); |
1095 | 1095 | if (isset($exe_id)) { |
@@ -1149,10 +1149,10 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | $attributes = array('id' =>'remind_list['.$questionId.']'); |
1151 | 1151 | if (in_array($questionId, $remind_list)) { |
1152 | - $is_remind_on = true; |
|
1153 | - $attributes['checked'] = 1; |
|
1154 | - $remind_question = true; |
|
1155 | - $remind_highlight = ' remind_highlight '; |
|
1152 | + $is_remind_on = true; |
|
1153 | + $attributes['checked'] = 1; |
|
1154 | + $remind_question = true; |
|
1155 | + $remind_highlight = ' remind_highlight '; |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | // Showing the exercise description |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | } |
1227 | 1227 | // end foreach() |
1228 | 1228 | if ($objExercise->type == ALL_ON_ONE_PAGE) { |
1229 | - $exercise_actions = $objExercise->show_button($questionId, $current_question); |
|
1230 | - echo Display::div($exercise_actions, array('class'=>'exercise_actions')); |
|
1229 | + $exercise_actions = $objExercise->show_button($questionId, $current_question); |
|
1230 | + echo Display::div($exercise_actions, array('class'=>'exercise_actions')); |
|
1231 | 1231 | echo '<br>'; |
1232 | 1232 | } |
1233 | 1233 | echo '</form>'; |