Completed
Push — 1.11.x ( 78f130...f6f5c2 )
by José
50:40 queued 24:26
created
main/exercise/showinframes.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
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() {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 $time = time();
15 15
 $doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
16 16
 $cid = api_get_course_id();
17
-$document_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
18
-$document_web_path = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/document';
17
+$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
18
+$document_web_path = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document';
19 19
 $origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
20 20
 $learnpath_id = isset($_REQUEST['learnpath_id']) ? $_REQUEST['learnpath_id'] : null;
21 21
 $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? $_REQUEST['learnpath_item_id'] : null;
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
         if (SaveScoreVariable==0) {
39 39
             SaveScoreVariable = 1;
40 40
             if (C.ie) {
41
-                document.location.href = '" . api_get_path(WEB_CODE_PATH) . "exercise/savescores.php?lp_view_id=$lpViewId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
41
+                document.location.href = '" . api_get_path(WEB_CODE_PATH)."exercise/savescores.php?lp_view_id=$lpViewId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
42 42
             } else {
43
-                window.location.href = '" . api_get_path(WEB_CODE_PATH) . "exercise/savescores.php?lp_view_id=$lpViewId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
43
+                window.location.href = '" . api_get_path(WEB_CODE_PATH)."exercise/savescores.php?lp_view_id=$lpViewId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
44 44
             }
45 45
         }
46 46
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 $my_file = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($my_file));
70 70
 
71 71
 $title = GetQuizName($my_file, $documentPath);
72
-if ($title =='') {
72
+if ($title == '') {
73 73
     $title = basename($my_file);
74 74
 }
75 75
 $nameTools = $title;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     });
87 87
 </script>';
88 88
 
89
-$interbreadcrumb[]= array ("url"=>"./exercise.php", "name"=> get_lang('Exercises'));
89
+$interbreadcrumb[] = array("url"=>"./exercise.php", "name"=> get_lang('Exercises'));
90 90
 if ($origin == 'learnpath') {
91 91
     Display::display_reduced_header($nameTools, "Exercise");
92 92
 } else {
Please login to merge, or discard this patch.
main/exercise/freeanswer.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@
 block discarded – undo
60 60
             $score['revised'] = false;
61 61
         }
62 62
         $header = parent::return_header($feedback_type, $counter, $score);
63
-        $header .= '<table class="' . $this->question_table_class . '" >
63
+        $header .= '<table class="'.$this->question_table_class.'" >
64 64
         <tr>
65
-        <th>' . get_lang("Answer") . '</th>
65
+        <th>' . get_lang("Answer").'</th>
66 66
         </tr>';
67 67
 
68 68
         return $header;
Please login to merge, or discard this patch.
main/exercise/export/aiken/aiken_classes.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @package chamilo.exercise
8 8
  */
9 9
 
10
-if ( count( get_included_files() ) == 1 ) die( '---' );
10
+if (count(get_included_files()) == 1) die('---');
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13 13
 	function mime_content_type($filename) {
14
-		return DocumentManager::file_get_mime_type((string)$filename);
14
+		return DocumentManager::file_get_mime_type((string) $filename);
15 15
 	}
16 16
 }
17 17
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     function setAnswer()
27 27
     {
28
-        switch($this->type)
28
+        switch ($this->type)
29 29
         {
30 30
             case MCUA :
31 31
                 $answer = new AikenAnswerMultipleChoice($this->id);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@
 block discarded – undo
7 7
  * @package chamilo.exercise
8 8
  */
9 9
 
10
-if ( count( get_included_files() ) == 1 ) die( '---' );
10
+if ( count( get_included_files() ) == 1 ) {
11
+    die( '---' );
12
+}
11 13
 
12 14
 if (!function_exists('mime_content_type')) {
13 15
 	function mime_content_type($filename) {
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13 13
 
14
-	/**
15
-	 * @param string $filename
14
+    /**
15
+     * @param string $filename
16 16
      * @return string
17
-	 */
18
-	function mime_content_type($filename) {
19
-		return DocumentManager::file_get_mime_type((string)$filename);
20
-	}
17
+     */
18
+    function mime_content_type($filename) {
19
+        return DocumentManager::file_get_mime_type((string)$filename);
20
+    }
21 21
 }
22 22
 
23 23
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         {
35 35
             case MCUA :
36 36
                 $answer = new AikenAnswerMultipleChoice($this->id);
37
-            	return $answer;
37
+                return $answer;
38 38
             default :
39 39
                 $answer = null;
40 40
                 break;
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     }
44 44
     function createAnswersForm($form)
45 45
     {
46
-    	return true;
46
+        return true;
47 47
     }
48 48
     function processAnswersCreation($form)
49 49
     {
50
-    	return true;
50
+        return true;
51 51
     }
52 52
 }
53 53
 
Please login to merge, or discard this patch.
main/exercise/export/aiken/aiken_import.inc.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -281,7 +281,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * Security check
12 12
  */
13
-if (count(get_included_files()) == 1)
13
+if (count(get_included_files()) == 1) {
14 14
     die('---');
15
+}
15 16
 
16 17
 /**
17 18
  * Creates a temporary directory
@@ -21,8 +22,9 @@  discard block
 block discarded – undo
21 22
  * @return string
22 23
  */
23 24
 function tempdir($dir, $prefix = 'tmp', $mode = 0777) {
24
-    if (substr($dir, -1) != '/')
25
-        $dir .= '/';
25
+    if (substr($dir, -1) != '/') {
26
+            $dir .= '/';
27
+    }
26 28
 
27 29
     do {
28 30
         $path = $dir . $prefix . mt_rand(0, 9999999);
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $dir .= '/';
26 26
 
27 27
     do {
28
-        $path = $dir . $prefix . mt_rand(0, 9999999);
28
+        $path = $dir.$prefix.mt_rand(0, 9999999);
29 29
     } while (!mkdir($path, $mode));
30 30
 
31 31
     return $path;
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 {
40 40
     $name_tools = get_lang('ImportAikenQuiz');
41 41
     $form  = '<div class="actions">';
42
-    $form .= '<a href="exercise.php?show=test&'.api_get_cidreq().'">' .
43
-        Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
42
+    $form .= '<a href="exercise.php?show=test&'.api_get_cidreq().'">'.
43
+        Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>';
44 44
     $form .= '</div>';
45 45
     $form_validator = new FormValidator(
46 46
         'aiken_upload',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 function aiken_import_exercise($file)
94 94
 {
95 95
     global $exercise_info;
96
-    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'aiken';
96
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'aiken';
97 97
     $baseWorkDir = $archive_path;
98 98
 
99 99
     if (!is_dir($baseWorkDir)) {
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 
131 131
     // Parse every subdirectory to search txt question files
132 132
     while (false !== ($file = readdir($exerciseHandle))) {
133
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
133
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
134 134
             //find each manifest for each question repository found
135
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
135
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
136 136
             while (false !== ($questionFile = readdir($questionHandle))) {
137 137
                 if (preg_match('/.txt$/i', $questionFile)) {
138 138
                     $result = aiken_parse_file(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         }
217 217
 
218 218
         // Delete the temp dir where the exercise was unzipped
219
-        my_delete($baseWorkDir . $uploadPath);
219
+        my_delete($baseWorkDir.$uploadPath);
220 220
         $operation = $last_exercise_id;
221 221
     }
222 222
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) {
240 240
     global $questionTempDir;
241 241
 
242
-    $questionTempDir = $exercisePath . '/' . $file . '/';
243
-    $questionFilePath = $questionTempDir . $questionFile;
242
+    $questionTempDir = $exercisePath.'/'.$file.'/';
243
+    $questionFilePath = $questionTempDir.$questionFile;
244 244
 
245 245
     if (!is_file($questionFilePath)) {
246 246
         return 'FileNotFound';
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
     $answers_array = array();
253 253
     $new_question = true;
254 254
     foreach ($data as $line => $info) {
255
-        if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/',$info)) {
255
+        if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) {
256 256
             // double empty line
257 257
             continue;
258 258
         }
259 259
         $new_question = false;
260 260
         //make sure it is transformed from iso-8859-1 to utf-8 if in that form
261
-        if (!mb_check_encoding($info,'utf-8') && mb_check_encoding($info,'iso-8859-1')) {
261
+        if (!mb_check_encoding($info, 'utf-8') && mb_check_encoding($info, 'iso-8859-1')) {
262 262
             $info = utf8_encode($info);
263 263
         }
264 264
         $exercise_info['question'][$question_index]['type'] = 'MCUA';
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) {
291 291
             //TAGS for chamilo >= 1.10 (Spanish e-ducativa format)
292 292
             $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]);
293
-        } elseif (preg_match('/^(\r)?\n/',$info)) {
293
+        } elseif (preg_match('/^(\r)?\n/', $info)) {
294 294
             //moving to next question (tolerate \r\n or just \n)
295 295
             if (empty($exercise_info['question'][$question_index]['correct_answers'])) {
296 296
                 error_log('Aiken: Error in question index '.$question_index.': no correct answer defined');
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                     $exercise_info['question'][$question_index]['title'] = $info;
311 311
                 } else {
312 312
                     //Question itself (use a 100-chars long title and a larger description)
313
-                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)) . '...';
313
+                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...';
314 314
                     $exercise_info['question'][$question_index]['description'] = $info;
315 315
                 }
316 316
             } else {
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
     }
321 321
     $total_questions = count($exercise_info['question']);
322 322
     $total_weight = (!empty($_POST['total_weight'])) ? intval($_POST['total_weight']) : 20;
323
-    foreach  ($exercise_info['question'] as $key => $question) {
323
+    foreach ($exercise_info['question'] as $key => $question) {
324 324
         $exercise_info['question'][$key]['weighting'][current(array_keys($exercise_info['question'][$key]['weighting']))] = $total_weight / $total_questions;
325 325
     }
326 326
     return true;
Please login to merge, or discard this patch.
main/exercise/export/exercise_import.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
 $interbredcrump[] = array('url' => '../exercise.php', 'name' => get_lang('Exercises'));
30 30
 
31 31
 // EXECUTE COMMAND
32
-$cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import');
32
+$cmd = (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show_import');
33 33
 
34 34
 switch ($cmd) {
35 35
     case 'show_import' :
36 36
     {
37 37
         $display = '<p>'
38
-        .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.') . '<br>'
38
+        .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'<br>'
39 39
         .            '</p>'
40 40
         .            '<form enctype="multipart/form-data" action="" method="post">'
41 41
         .            '<input name="cmd" type="hidden" value="import" />'
42 42
         .            '<input name="uploadedExercise" type="file" /><br><br>'
43
-        .            get_lang('Import exercise') . ' : '
44
-        .            '<input value="' . get_lang('Ok') . '" type="submit" /> '
45
-        .            claro_html_button( $_SERVER['PHP_SELF'], get_lang('Cancel'))
43
+        .            get_lang('Import exercise').' : '
44
+        .            '<input value="'.get_lang('Ok').'" type="submit" /> '
45
+        .            claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel'))
46 46
         .            '<br><br>'
47
-        .            '<small>' . get_lang('Max file size') . ' :  2&nbsp;MB</small>'
47
+        .            '<small>'.get_lang('Max file size').' :  2&nbsp;MB</small>'
48 48
         .            '</form>';
49 49
     }
50 50
     break;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 
69 69
 // DISPLAY
70
-include api_get_path(SYS_INC_PATH) . '/header.inc.php';
70
+include api_get_path(SYS_INC_PATH).'/header.inc.php';
71 71
 
72 72
 // Tool introduction
73 73
 // TODO: These settings to be checked when it is possible.
@@ -91,4 +91,4 @@  discard block
 block discarded – undo
91 91
     echo $display;
92 92
 }
93 93
 
94
-include api_get_path(SYS_INC_PATH) . '/footer.inc.php';
94
+include api_get_path(SYS_INC_PATH).'/footer.inc.php';
Please login to merge, or discard this patch.
main/exercise/export/qti2/qti2_export.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 /**
9 9
  * Code
10 10
  */
11
-require dirname(__FILE__) . '/qti2_classes.php';
11
+require dirname(__FILE__).'/qti2_classes.php';
12 12
 /**
13 13
  * Classes
14 14
 */
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      {
39 39
         $this->question = $question;
40 40
         $this->answer = $this->question->setAnswer();
41
-        $this->questionIdent = "QST_" . $question->id ;
41
+        $this->questionIdent = "QST_".$question->id;
42 42
      }
43 43
 
44 44
      /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       */
74 74
      function start_item_body()
75 75
      {
76
-        return '  <itemBody>' . "\n";
76
+        return '  <itemBody>'."\n";
77 77
      }
78 78
 
79 79
      /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
       function add_response_processing()
94 94
       {
95
-          return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
95
+          return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>'."\n";
96 96
       }
97 97
 
98 98
      /**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $head = $foot = "";
109 109
 
110 110
         if ($standalone) {
111
-            $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
111
+            $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n";
112 112
         }
113 113
         //TODO understand why answer might be a non-object sometimes
114 114
         if (!is_object($this->answer)) {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
     function start_section()
166 166
     {
167
-        $out = '<section ident="EXO_' . $this->exercise->selectId() . '" title="' .cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())) . '">' . "\n";
167
+        $out = '<section ident="EXO_'.$this->exercise->selectId().'" title="'.cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())).'">'."\n";
168 168
         return $out;
169 169
     }
170 170
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             // return exercise duration in ISO8601 format.
181 181
             $minutes = floor($max_time / 60);
182 182
             $seconds = $max_time % 60;
183
-            return '<duration>PT' . $minutes . 'M' . $seconds . "S</duration>\n";
183
+            return '<duration>PT'.$minutes.'M'.$seconds."S</duration>\n";
184 184
         } else {
185 185
             return '';
186 186
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
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"
196
+             . "  <mattext><![CDATA[".formatExerciseQtiDescription($this->exercise->selectDescription())."]]></mattext>\n"
197 197
              . "</material></flow_mat></presentation_material>\n";
198 198
         return $out;
199 199
     }
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
     {
208 208
         $out = '';
209 209
         if ($n = $this->exercise->getShuffle()) {
210
-            $out.= "<selection_ordering>"
210
+            $out .= "<selection_ordering>"
211 211
                  . "  <selection>\n"
212
-                 . "    <selection_number>" . $n . "</selection_number>\n"
212
+                 . "    <selection_number>".$n."</selection_number>\n"
213 213
                  . "  </selection>\n"
214 214
                  . '  <order order_type="Random" />'
215 215
                  . "\n</selection_ordering>\n";
216 216
         } else {
217
-            $out.= '<selection_ordering sequence_type="Normal">' . "\n"
217
+            $out .= '<selection_ordering sequence_type="Normal">'."\n"
218 218
                  . "  <selection />\n"
219 219
                  . "</selection_ordering>\n";
220 220
         }
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
     {
247 247
         $head = $foot = "";
248 248
         if ($standalone) {
249
-            $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n"
250
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
249
+            $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>'."\n"
250
+                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"
251 251
                   . "<questestinterop>\n";
252 252
             $foot = "</questestinterop>\n";
253 253
         }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      {
309 309
         $this->question = $question;
310 310
         $this->answer = $question->answer;
311
-        $this->questionIdent = "QST_" . $question->selectId() ;
311
+        $this->questionIdent = "QST_".$question->selectId();
312 312
      }
313 313
 
314 314
      /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
       */
321 321
       function start_item()
322 322
       {
323
-        return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n";
323
+        return '<item title="'.cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())).'" ident="'.$this->questionIdent.'">'."\n";
324 324
       }
325 325
 
326 326
       /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
       */
344 344
      function start_presentation()
345 345
      {
346
-        return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n"
347
-             . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n";
346
+        return '<presentation label="'.$this->questionIdent.'"><flow>'."\n"
347
+             . '<material><mattext>'.formatExerciseQtiDescription($this->question->selectDescription())."</mattext></material>\n";
348 348
      }
349 349
 
350 350
      /**
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
       */
365 365
      function start_processing()
366 366
      {
367
-        return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n";
367
+        return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>'."\n";
368 368
      }
369 369
 
370 370
      /**
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
         $head = $foot = "";
393 393
 
394 394
         if ($standalone) {
395
-            $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n"
396
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
395
+            $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n"
396
+                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"
397 397
                   . "<questestinterop>\n";
398 398
             $foot = "</questestinterop>\n";
399 399
         }
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
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);
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
131 131
             .$foot;
132 132
 
133 133
         return $res;
134
-     }
134
+        }
135 135
 }
136 136
 
137 137
 /**
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
main/exercise/Hpdownload.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 session_cache_limiter('public');
13 13
 
14 14
 require_once '../inc/global.inc.php';
15
-$this_section=SECTION_COURSES;
15
+$this_section = SECTION_COURSES;
16 16
 
17 17
 $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
18 18
 
19
-$doc_url=str_replace(array('../','\\..','\\0','..\\'),array('','','',''),urldecode($_GET['doc_url']));
20
-$filename=basename($doc_url);
19
+$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($_GET['doc_url']));
20
+$filename = basename($doc_url);
21 21
 
22 22
 // launch event
23 23
 //Event::event_download($doc_url);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	$full_file_name = $course_path.Security::remove_XSS($doc_url);
30 30
 }
31 31
 
32
-if(!is_file($full_file_name)) {
32
+if (!is_file($full_file_name)) {
33 33
 	exit;
34 34
 }
35 35
 
@@ -37,26 +37,26 @@  discard block
 block discarded – undo
37 37
     exit;
38 38
 }
39 39
 
40
-$extension=explode('.',$filename);
41
-$extension=strtolower($extension[sizeof($extension)-1]);
42
-
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;
40
+$extension = explode('.', $filename);
41
+$extension = strtolower($extension[sizeof($extension) - 1]);
42
+
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;
54 54
 }
55 55
 
56 56
 header('Content-disposition: filename='.$filename);
57 57
 header('Content-Type: '.$content_type);
58
-header('Expires: '.gmdate('D, d M Y H:i:s',time()+10).' GMT');
59
-header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()+10).' GMT');
58
+header('Expires: '.gmdate('D, d M Y H:i:s', time() + 10).' GMT');
59
+header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + 10).' GMT');
60 60
 
61 61
 /*
62 62
 	Dynamic parsing section
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 if ($content_type == 'text/html') {
71 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.='/';
75
+	if ($dir[strlen($dir) - 1] != '/') {
76
+		$dir .= '/';
77 77
 	}
78 78
 
79 79
 
80 80
 	//Parse whole file at one
81 81
 	$fp = fopen($full_file_name, "r");
82
-	$file_content = fread ($fp, filesize ($full_file_name));
82
+	$file_content = fread($fp, filesize($full_file_name));
83 83
 	fclose($fp);
84 84
 	//$file_content = api_replace_parameter($dir, $file_content, "src");
85 85
 	//$file_content = api_replace_parameter($dir, $file_content, "href");
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
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));
101
+  	$exfile = explode('/', $exercisePath);
102
+  	$exfile = $exfile[sizeof($exfile) - 1];
103
+  	$exercisePath = substr($exercisePath, 0, strpos($exercisePath, $exfile));
104 104
   	$exercisePath = $exercisePath;
105 105
 
106 106
 		$content = $file_content;
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
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 140
 		header('Content-length: '.strlen($newcontent));
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 //normal case, all non-html files
148 148
 //header('Content-length: '.filesize($full_file_name));
149
-$fp=fopen($full_file_name,'rb');
149
+$fp = fopen($full_file_name, 'rb');
150 150
 fpassthru($fp);
151 151
 fclose($fp);
152 152
 ?>
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,30 +68,30 @@  discard block
 block discarded – undo
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);
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 84
     $exercisePath = api_get_self();
85
-  	$exfile = explode('/',$exercisePath);
86
-  	$exfile = $exfile[sizeof($exfile)-1];
87
-  	$exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
88
-  	$exercisePath = $exercisePath;
85
+        $exfile = explode('/',$exercisePath);
86
+        $exfile = $exfile[sizeof($exfile)-1];
87
+        $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
88
+        $exercisePath = $exercisePath;
89 89
 
90
-		$content = $file_content;
91
-		$mit = "function Finish(){";
90
+        $content = $file_content;
91
+        $mit = "function Finish(){";
92 92
 
93
-		$js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
94
-		"function mySaveScore() // This function included by Dokeos System\n".
93
+        $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
94
+        "function mySaveScore() // This function included by Dokeos System\n".
95 95
 "{\n".
96 96
 "   if (SaveScoreVariable==0)\n".
97 97
 "		{\n".
@@ -109,23 +109,23 @@  discard block
 block discarded – undo
109 109
 "// Must be included \n".
110 110
 "function Finish(){\n".
111 111
 " mySaveScore();";
112
-		$newcontent = str_replace($mit,$js_content,$content);
112
+        $newcontent = str_replace($mit,$js_content,$content);
113 113
 
114
-		$prehref="javascript:void(0);";
115
-		$posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
116
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
114
+        $prehref="javascript:void(0);";
115
+        $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
116
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
117 117
 
118 118
 
119
-		$prehref="class=\"GridNum\" onclick=";
120
-		$posthref="class=\"GridNum\" onMouseover=";
121
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
119
+        $prehref="class=\"GridNum\" onclick=";
120
+        $posthref="class=\"GridNum\" onMouseover=";
121
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
122 122
 
123 123
 
124
-		header('Content-length: '.strlen($newcontent));
125
-		// Dipsp.
126
-		echo $newcontent;
124
+        header('Content-length: '.strlen($newcontent));
125
+        // Dipsp.
126
+        echo $newcontent;
127 127
 
128
-	exit();
128
+    exit();
129 129
 }
130 130
 
131 131
 //normal case, all non-html files
Please login to merge, or discard this patch.
main/exercise/exercise_submit.php 3 patches
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -269,7 +269,9 @@  discard block
 block discarded – undo
269 269
 $clock_expired_time = null;
270 270
 
271 271
 if (empty($exercise_stat_info)) {
272
-    if ($debug)  error_log('5  $exercise_stat_info is empty ');
272
+    if ($debug) {
273
+        error_log('5  $exercise_stat_info is empty ');
274
+    }
273 275
 	$total_weight = 0;
274 276
 	$questionList = $objExercise->get_validated_question_list();
275 277
 	foreach ($questionListUncompressed as $question_id) {
@@ -280,11 +282,17 @@  discard block
 block discarded – undo
280 282
 	if ($time_control) {
281 283
 		$expected_time = $current_timestamp + $total_seconds;
282 284
 
283
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
284
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
285
+		if ($debug) {
286
+		    error_log('5.1. $current_timestamp '.$current_timestamp);
287
+		}
288
+		if ($debug) {
289
+		    error_log('5.2. $expected_time '.$expected_time);
290
+		}
285 291
 
286 292
 		$clock_expired_time 	= api_get_utc_datetime($expected_time);
287
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
293
+		if ($debug) {
294
+		    error_log('5.3. $expected_time '.$clock_expired_time);
295
+		}
288 296
 
289 297
 		//Sessions  that contain the expired time
290 298
 		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
@@ -304,8 +312,10 @@  discard block
 block discarded – undo
304 312
         $learnpath_item_id,
305 313
         $learnpath_item_view_id
306 314
     );
307
-    if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
308
-} else {
315
+    if ($debug) {
316
+        error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
317
+    }
318
+    } else {
309 319
 	$exe_id = $exercise_stat_info['exe_id'];
310 320
     // Remember last question id position.
311 321
     $isFirstTime = Session::read('firstTime');
@@ -327,8 +337,10 @@  discard block
 block discarded – undo
327 337
         }
328 338
     }
329 339
 
330
-    if ($debug)  error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
331
-}
340
+    if ($debug) {
341
+        error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
342
+    }
343
+    }
332 344
 
333 345
 $questionListInSession = Session::read('questionList');
334 346
 
@@ -384,9 +396,15 @@  discard block
 block discarded – undo
384 396
  * If the expired time is major that zero(0) then the expired time is compute on this time.
385 397
  */
386 398
 if ($time_control) {
387
-	if ($debug) error_log('7.1. Time control is enabled');
388
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
389
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
399
+	if ($debug) {
400
+	    error_log('7.1. Time control is enabled');
401
+	}
402
+	if ($debug) {
403
+	    error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
404
+	}
405
+	if ($debug) {
406
+	    error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
407
+	}
390 408
 
391 409
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
392 410
         //Timer - Get expired_time for a student
@@ -473,7 +491,9 @@  discard block
 block discarded – undo
473 491
 	}
474 492
 }
475 493
 
476
-if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
494
+if ($debug) {
495
+    error_log('8. Question list loaded '.print_r($questionList, 1));
496
+}
477 497
 
478 498
 //Real question count
479 499
 $question_count = 0;
Please login to merge, or discard this patch.
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 $time_control = false;
166 166
 if ($objExercise->expired_time != 0) {
167
-	$time_control = true;
167
+    $time_control = true;
168 168
 }
169 169
 
170 170
 // Generating the time control key for the user
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
174 174
 
175 175
 if ($time_control) {
176
-	// Get the expired time of the current exercise in track_e_exercises
177
-	$total_seconds = $objExercise->expired_time*60;
176
+    // Get the expired time of the current exercise in track_e_exercises
177
+    $total_seconds = $objExercise->expired_time*60;
178 178
 }
179 179
 
180 180
 $show_clock = true;
181 181
 $user_id = api_get_user_id();
182 182
 if ($objExercise->selectAttempts() > 0) {
183
-	$attempt_html = '';
183
+    $attempt_html = '';
184 184
     $attempt_count = Event::get_attempt_count(
185 185
         $user_id,
186 186
         $exerciseId,
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
         $learnpath_item_view_id
190 190
     );
191 191
 
192
-	if ($attempt_count >= $objExercise->selectAttempts()) {
193
-		$show_clock = false;
194
-		if (!api_is_allowed_to_edit(null,true)) {
192
+    if ($attempt_count >= $objExercise->selectAttempts()) {
193
+        $show_clock = false;
194
+        if (!api_is_allowed_to_edit(null,true)) {
195 195
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
196 196
 
197 197
                 // Showing latest attempt according with task BT#1628
@@ -230,31 +230,31 @@  discard block
 block discarded – undo
230 230
                             $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore'));
231 231
                         }
232 232
                     }
233
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
234
-					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
235
-				} else {
236
-					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
237
-				}
238
-			} else {
239
-				$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
240
-			}
241
-		} else {
242
-			$attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
243
-		}
233
+                    $score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
234
+                    $attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
235
+                } else {
236
+                    $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
237
+                }
238
+            } else {
239
+                $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
240
+            }
241
+        } else {
242
+            $attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
243
+        }
244 244
 
245
-		if ($origin == 'learnpath') {
246
-			Display :: display_reduced_header();
247
-		} else {
248
-			Display :: display_header(get_lang('Exercises'));
249
-		}
245
+        if ($origin == 'learnpath') {
246
+            Display :: display_reduced_header();
247
+        } else {
248
+            Display :: display_header(get_lang('Exercises'));
249
+        }
250 250
 
251
-		echo $attempt_html;
251
+        echo $attempt_html;
252 252
 
253 253
         if ($origin != 'learnpath') {
254 254
             Display:: display_footer();
255 255
         }
256
-		exit;
257
-	}
256
+        exit;
257
+    }
258 258
 }
259 259
 
260 260
 if ($debug) {
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 
279 279
 if (empty($exercise_stat_info)) {
280 280
     if ($debug)  error_log('5  $exercise_stat_info is empty ');
281
-	$total_weight = 0;
282
-	$questionList = $objExercise->get_validated_question_list();
283
-	foreach ($questionListUncompressed as $question_id) {
284
-		$objQuestionTmp = Question::read($question_id);
285
-		$total_weight += floatval($objQuestionTmp->weighting);
286
-	}
281
+    $total_weight = 0;
282
+    $questionList = $objExercise->get_validated_question_list();
283
+    foreach ($questionListUncompressed as $question_id) {
284
+        $objQuestionTmp = Question::read($question_id);
285
+        $total_weight += floatval($objQuestionTmp->weighting);
286
+    }
287 287
 
288
-	if ($time_control) {
289
-		$expected_time = $current_timestamp + $total_seconds;
288
+    if ($time_control) {
289
+        $expected_time = $current_timestamp + $total_seconds;
290 290
 
291
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
292
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
291
+        if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
292
+        if ($debug)  error_log('5.2. $expected_time '.$expected_time);
293 293
 
294
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
295
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
294
+        $clock_expired_time 	= api_get_utc_datetime($expected_time);
295
+        if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
296 296
 
297
-		//Sessions  that contain the expired time
298
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
299
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
300
-	}
297
+        //Sessions  that contain the expired time
298
+        $_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
299
+        if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
300
+    }
301 301
 
302 302
     $exe_id = $objExercise->save_stat_track_exercise_info(
303 303
         $clock_expired_time,
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
     );
315 315
     if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
316 316
 } else {
317
-	$exe_id = $exercise_stat_info['exe_id'];
317
+    $exe_id = $exercise_stat_info['exe_id'];
318 318
     // Remember last question id position.
319 319
     $isFirstTime = Session::read('firstTime');
320 320
     if ($isFirstTime && $objExercise->type == ONE_PER_PAGE) {
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
374 374
 
375 375
 if (!empty($exercise_stat_info['questions_to_check'])) {
376
-	$my_remind_list = $exercise_stat_info['questions_to_check'];
377
-	$my_remind_list = explode(',', $my_remind_list);
378
-	$my_remind_list = array_filter($my_remind_list);
376
+    $my_remind_list = $exercise_stat_info['questions_to_check'];
377
+    $my_remind_list = explode(',', $my_remind_list);
378
+    $my_remind_list = array_filter($my_remind_list);
379 379
 }
380 380
 
381 381
 $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();
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 
384 384
 if ($reminder == 2 && empty($my_remind_list)) {
385 385
     if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
386
-	header('Location: exercise_reminder.php?'.$params);
387
-	exit;
386
+    header('Location: exercise_reminder.php?'.$params);
387
+    exit;
388 388
 }
389 389
 
390 390
 /*
@@ -392,56 +392,56 @@  discard block
 block discarded – undo
392 392
  * If the expired time is major that zero(0) then the expired time is compute on this time.
393 393
  */
394 394
 if ($time_control) {
395
-	if ($debug) error_log('7.1. Time control is enabled');
396
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
397
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
395
+    if ($debug) error_log('7.1. Time control is enabled');
396
+    if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
397
+    if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
398 398
 
399 399
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
400 400
         //Timer - Get expired_time for a student
401 401
         if (!empty($exercise_stat_info)) {
402
-        	if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
403
-	        $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
404
-			if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
405
-	        // Get the last attempt of an exercise
406
-	    	$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
402
+            if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
403
+            $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
404
+            if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
405
+            // Get the last attempt of an exercise
406
+            $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
407 407
 
408
-	    	/* This means that the user enters the exam but do not answer the
408
+            /* This means that the user enters the exam but do not answer the
409 409
 	    	   first question we get the date from the track_e_exercises not from
410 410
 	    	   the track_et_attempt see #2069 */
411
-	    	if (empty($last_attempt_date)) {
412
-	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
413
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
414
-	    	} else {
415
-	    		//Recalculate the time control due #2069
416
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
417
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
418
-	    	}
419
-	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
420
-
421
-	        //New expired time - it is due to the possible closure of session
422
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
423
-	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
424
-
425
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
426
-	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
427
-
428
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
429
-	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
430
-
431
-			// First we update the attempt to today
432
-			/* How the expired time is changed into "track_e_exercises" table,
411
+            if (empty($last_attempt_date)) {
412
+                $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
413
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
414
+            } else {
415
+                //Recalculate the time control due #2069
416
+                $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
417
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
418
+            }
419
+            if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
420
+
421
+            //New expired time - it is due to the possible closure of session
422
+            $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
423
+            if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
424
+
425
+            $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
426
+            if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
427
+
428
+            $clock_expired_time  = api_get_utc_datetime($expected_time);
429
+            if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
430
+
431
+            // First we update the attempt to today
432
+            /* How the expired time is changed into "track_e_exercises" table,
433 433
                then the last attempt for this student should be changed too */
434
-	        $sql = "UPDATE $exercise_attempt_table SET
434
+            $sql = "UPDATE $exercise_attempt_table SET
435 435
 	                tms = '".api_get_utc_datetime()."'
436 436
 	                WHERE
437 437
 	                    exe_id = '".$exercise_stat_info['exe_id']."' AND
438 438
 	                    tms = '".$last_attempt_date."' ";
439
-	        if ($debug) {error_log('7.10. $sql: '.$sql); }
440
-	        Database::query($sql);
439
+            if ($debug) {error_log('7.10. $sql: '.$sql); }
440
+            Database::query($sql);
441 441
 
442
-	        //Sessions  that contain the expired time
443
-	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
444
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
442
+            //Sessions  that contain the expired time
443
+            $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
444
+            if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
445 445
         }
446 446
     } else {
447 447
         $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
  * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock
459 459
  */
460 460
 if ($time_control) { //Sends the exercise form when the expired time is finished
461
-	$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
461
+    $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
462 462
 }
463 463
 
464 464
 // if the user has submitted the form
@@ -471,14 +471,14 @@  discard block
 block discarded – undo
471 471
     // selects the list of question ID
472 472
     $questionList = $objExercise->get_validated_question_list();
473 473
     if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) {
474
-    	$questionList = explode(',', $exercise_stat_info['data_tracking']);
474
+        $questionList = explode(',', $exercise_stat_info['data_tracking']);
475 475
     }
476 476
     Session::write('questionList', $questionList);
477 477
     if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
478 478
 } else {
479
-	if (isset($objExercise) && isset($_SESSION['objExercise'])) {
480
-    	$questionList = $_SESSION['questionList'];
481
-	}
479
+    if (isset($objExercise) && isset($_SESSION['objExercise'])) {
480
+        $questionList = $_SESSION['questionList'];
481
+    }
482 482
 }
483 483
 
484 484
 if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 //Real question count
487 487
 $question_count = 0;
488 488
 if (!empty($questionList)) {
489
-	$question_count = count($questionList);
489
+    $question_count = count($questionList);
490 490
 }
491 491
 
492 492
 if ($current_question > $question_count) {
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
                 //saving each question
533 533
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
534 534
                     $nro_question = $current_question; // - 1;
535
-                 	$questionId = $key;
535
+                        $questionId = $key;
536 536
                     // gets the student choice for this question
537 537
                     $choice = $exerciseResult[$questionId];
538 538
                     if (isset($exe_id)) {
539
-                    	// Manage the question and answer attempts
539
+                        // Manage the question and answer attempts
540 540
                         if ($debug) {
541 541
                             error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1));
542 542
                         }
@@ -627,58 +627,58 @@  discard block
 block discarded – undo
627 627
 }
628 628
 
629 629
 if ($question_count != 0) {
630
-	if (($objExercise->type == ALL_ON_ONE_PAGE ||
630
+    if (($objExercise->type == ALL_ON_ONE_PAGE ||
631 631
         $current_question > $question_count)
632 632
     ) {
633
-	    if (api_is_allowed_to_session_edit()) {
634
-	        // goes to the script that will show the result of the exercise
635
-	        if ($objExercise->type == ALL_ON_ONE_PAGE) {
636
-	            if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
637
-
638
-	            //We check if the user attempts before sending to the exercise_result.php
639
-	            if ($objExercise->selectAttempts() > 0) {
640
-	                $attempt_count = Event::get_attempt_count(
633
+        if (api_is_allowed_to_session_edit()) {
634
+            // goes to the script that will show the result of the exercise
635
+            if ($objExercise->type == ALL_ON_ONE_PAGE) {
636
+                if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
637
+
638
+                //We check if the user attempts before sending to the exercise_result.php
639
+                if ($objExercise->selectAttempts() > 0) {
640
+                    $attempt_count = Event::get_attempt_count(
641 641
                         api_get_user_id(),
642 642
                         $exerciseId,
643 643
                         $learnpath_id,
644 644
                         $learnpath_item_id,
645 645
                         $learnpath_item_view_id
646 646
                     );
647
-	                if ($attempt_count >= $objExercise->selectAttempts()) {
648
-	                    Display :: display_warning_message(
647
+                    if ($attempt_count >= $objExercise->selectAttempts()) {
648
+                        Display :: display_warning_message(
649 649
                             sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
650 650
                             false
651 651
                         );
652
-	                    if ($origin != 'learnpath') {
653
-	                        //so we are not in learnpath tool
654
-	                        echo '</div>'; //End glossary div
655
-	                        Display :: display_footer();
656
-	                    } else {
657
-	                        echo '</body></html>';
658
-	                    }
659
-	                    exit;
660
-	                }
661
-	            }
662
-	        } else {
663
-	            if ($objExercise->review_answers) {
664
-	            	header('Location: exercise_reminder.php?'.$params);
665
-	            	exit;
666
-	            } else {
652
+                        if ($origin != 'learnpath') {
653
+                            //so we are not in learnpath tool
654
+                            echo '</div>'; //End glossary div
655
+                            Display :: display_footer();
656
+                        } else {
657
+                            echo '</body></html>';
658
+                        }
659
+                        exit;
660
+                    }
661
+                }
662
+            } else {
663
+                if ($objExercise->review_answers) {
664
+                    header('Location: exercise_reminder.php?'.$params);
665
+                    exit;
666
+                } else {
667 667
                     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");
668 668
                     exit;
669
-	            }
670
-	        }
671
-	    } else {
672
-	        if ($debug) { error_log('Redirecting to exercise_submit.php'); }
673
-	        exit;
674
-	    }
675
-	}
669
+                }
670
+            }
671
+        } else {
672
+            if ($debug) { error_log('Redirecting to exercise_submit.php'); }
673
+            exit;
674
+        }
675
+    }
676 676
 } else {
677
-	$error = get_lang('ThereAreNoQuestionsForThisExercise');
678
-	// if we are in the case where user select random by category, but didn't choose the number of random question
679
-	if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
680
-		$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
681
-	}
677
+    $error = get_lang('ThereAreNoQuestionsForThisExercise');
678
+    // if we are in the case where user select random by category, but didn't choose the number of random question
679
+    if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
680
+        $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
681
+    }
682 682
 }
683 683
 
684 684
 if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
 if (api_is_course_admin() && $origin != 'learnpath') {
718 718
     echo '<div class="actions">';
719 719
     if ($show_quiz_edition == false) {
720
-    	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>';
720
+        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>';
721 721
     } else {
722
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
722
+        echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
723 723
     }
724 724
     echo '</div>';
725 725
 }
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
763 763
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
764 764
             if ($origin != 'learnpath') {
765
-            	Display :: display_footer();
765
+                Display :: display_footer();
766 766
             }
767 767
             exit;
768 768
         } else {
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 if (isset($_custom['exercises_hidden_when_no_start_date']) &&
778 778
     $_custom['exercises_hidden_when_no_start_date']
779 779
 ) {
780
-	if (empty($objExercise->start_time)) {
780
+    if (empty($objExercise->start_time)) {
781 781
         Display:: display_warning_message(
782 782
             sprintf(
783 783
                 get_lang('ExerciseNoStartedYet'),
@@ -785,20 +785,20 @@  discard block
 block discarded – undo
785 785
                 $objExercise->selectAttempts()
786 786
             )
787 787
         );
788
-		if ($origin != 'learnpath') {
789
-			Display :: display_footer();
790
-		}
791
-	}
788
+        if ($origin != 'learnpath') {
789
+            Display :: display_footer();
790
+        }
791
+    }
792 792
 }
793 793
 
794 794
 //Timer control
795 795
 if ($time_control) {
796 796
     echo $objExercise->return_time_left_div();
797
-	echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
797
+    echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
798 798
 }
799 799
 
800 800
 if ($origin != 'learnpath') {
801
-   echo '<div id="highlight-plugin" class="glossary-content">';
801
+    echo '<div id="highlight-plugin" class="glossary-content">';
802 802
 }
803 803
 
804 804
 if ($reminder == 2)  {
@@ -810,53 +810,53 @@  discard block
 block discarded – undo
810 810
     $current_question = 1; //set by default the 1st question
811 811
 
812 812
     if (!empty($my_remind_list)) {
813
-    	//Checking which questions we are going to call from the remind list
814
-		for ($i = 0; $i < count($data_tracking); $i++) {
815
-			for($j = 0; $j < count($my_remind_list); $j++) {
816
-
817
-				if (!empty($remind_question_id)) {
818
-					if ($remind_question_id == $my_remind_list[$j]) {
819
-
820
-			        	if ($remind_question_id == $data_tracking[$i]) {
821
-			        		if (isset($my_remind_list[$j+1])) {
822
-			        			$remind_question_id = $my_remind_list[$j+1];
823
-			        			$current_question = $i + 1;
824
-			        		} else {
813
+        //Checking which questions we are going to call from the remind list
814
+        for ($i = 0; $i < count($data_tracking); $i++) {
815
+            for($j = 0; $j < count($my_remind_list); $j++) {
816
+
817
+                if (!empty($remind_question_id)) {
818
+                    if ($remind_question_id == $my_remind_list[$j]) {
819
+
820
+                        if ($remind_question_id == $data_tracking[$i]) {
821
+                            if (isset($my_remind_list[$j+1])) {
822
+                                $remind_question_id = $my_remind_list[$j+1];
823
+                                $current_question = $i + 1;
824
+                            } else {
825 825
                                 // We end the remind list we go to the exercise_reminder.php please
826
-			        			$remind_question_id = -1;
827
-			        			$current_question = $i + 1; // last question
828
-			        		}
829
-			        		break 2;
830
-			            }
831
-					}
832
-				} else {
833
-					if ($my_remind_list[$j] == $data_tracking[$i]) {
834
-						if (isset($my_remind_list[$j+1])) {
835
-							$remind_question_id = $my_remind_list[$j+1];
836
-							$current_question = $i + 1; // last question
837
-						} else {
826
+                                $remind_question_id = -1;
827
+                                $current_question = $i + 1; // last question
828
+                            }
829
+                            break 2;
830
+                        }
831
+                    }
832
+                } else {
833
+                    if ($my_remind_list[$j] == $data_tracking[$i]) {
834
+                        if (isset($my_remind_list[$j+1])) {
835
+                            $remind_question_id = $my_remind_list[$j+1];
836
+                            $current_question = $i + 1; // last question
837
+                        } else {
838 838
                             // We end the remind list we go to the exercise_reminder.php please
839
-							$remind_question_id = -1;
840
-							$current_question = $i + 1; // last question
841
-						}
842
-						break 2;
843
-					}
844
-				}
845
-			}
839
+                            $remind_question_id = -1;
840
+                            $current_question = $i + 1; // last question
841
+                        }
842
+                        break 2;
843
+                    }
844
+                }
845
+            }
846 846
         }
847 847
     } else {
848
-    	if ($objExercise->review_answers) {
848
+        if ($objExercise->review_answers) {
849 849
             if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
850
-	    	header("Location: exercise_reminder.php?$params");
851
-	    	exit;
852
-    	}
850
+            header("Location: exercise_reminder.php?$params");
851
+            exit;
852
+        }
853 853
     }
854 854
 }
855 855
 
856 856
 if ($objExercise->review_answers) {
857
-	$script_php = 'exercise_reminder.php';
857
+    $script_php = 'exercise_reminder.php';
858 858
 } else {
859
-	$script_php = 'exercise_result.php';
859
+    $script_php = 'exercise_result.php';
860 860
 }
861 861
 
862 862
 if (!empty($error)) {
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
          <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1097 1097
          <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1098 1098
 
1099
-	// Show list of questions
1099
+    // Show list of questions
1100 1100
     $i = 1;
1101 1101
     $attempt_list = array();
1102 1102
     if (isset($exe_id)) {
@@ -1156,10 +1156,10 @@  discard block
 block discarded – undo
1156 1156
 
1157 1157
         $attributes = array('id' =>'remind_list['.$questionId.']');
1158 1158
         if (in_array($questionId, $remind_list)) {
1159
-        	$is_remind_on = true;
1160
-        	$attributes['checked'] = 1;
1161
-        	$remind_question = true;
1162
-        	$remind_highlight = ' remind_highlight ';
1159
+            $is_remind_on = true;
1160
+            $attributes['checked'] = 1;
1161
+            $remind_question = true;
1162
+            $remind_highlight = ' remind_highlight ';
1163 1163
         }
1164 1164
 
1165 1165
         // Showing the exercise description
@@ -1233,8 +1233,8 @@  discard block
 block discarded – undo
1233 1233
     }
1234 1234
     // end foreach()
1235 1235
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1236
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1237
-    	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1236
+        $exercise_actions =  $objExercise->show_button($questionId, $current_question);
1237
+        echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1238 1238
         echo '<br>';
1239 1239
     }
1240 1240
     echo '</form>';
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 */
30 30
 
31 31
 require_once __DIR__.'/../inc/global.inc.php';
32
-$current_course_tool  = TOOL_QUIZ;
32
+$current_course_tool = TOOL_QUIZ;
33 33
 $this_section = SECTION_COURSES;
34 34
 $debug = false;
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 $origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : '';
40 40
 
41
-$is_allowedToEdit = api_is_allowed_to_edit(null,true);
41
+$is_allowedToEdit = api_is_allowed_to_edit(null, true);
42 42
 $glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
43 43
 
44 44
 $showGlossary = in_array($glossaryExtraTools, array('true', 'exercise', 'exercise_and_lp'));
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
61 61
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
62 62
 $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
63
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
64
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
63
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
64
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
65 65
 
66 66
 if (api_get_setting('enable_record_audio') === 'true') {
67
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'rtc/RecordRTC.js"></script>';
68
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'wami-recorder/recorder.js"></script>';
69
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'wami-recorder/gui.js"></script>';
70
-    $htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'swfobject/swfobject.js"></script>';
67
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
68
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
69
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
70
+    $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
71 71
 }
72 72
 
73 73
 $template = new Template();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
 $learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;
78 78
 $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : 0;
79
-$learnpath_item_view_id	= isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
79
+$learnpath_item_view_id = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
80 80
 
81 81
 $reminder = isset($_REQUEST['reminder']) ? intval($_REQUEST['reminder']) : 0;
82 82
 $remind_question_id = isset($_REQUEST['remind_question_id']) ? intval($_REQUEST['remind_question_id']) : 0;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 /*  Teacher takes an exam and want to see a preview,
104 104
     we delete the objExercise from the session in order to get the latest
105 105
     changes in the exercise */
106
-if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1 ) {
106
+if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1) {
107 107
     Session::erase('objExercise');
108 108
 }
109 109
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 if ($time_control) {
176 176
 	// Get the expired time of the current exercise in track_e_exercises
177
-	$total_seconds = $objExercise->expired_time*60;
177
+	$total_seconds = $objExercise->expired_time * 60;
178 178
 }
179 179
 
180 180
 $show_clock = true;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 	if ($attempt_count >= $objExercise->selectAttempts()) {
193 193
 		$show_clock = false;
194
-		if (!api_is_allowed_to_edit(null,true)) {
194
+		if (!api_is_allowed_to_edit(null, true)) {
195 195
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
196 196
 
197 197
                 // Showing latest attempt according with task BT#1628
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                     );
222 222
 
223 223
                     if (!empty($last_attempt_info['question_list'])) {
224
-                        foreach($last_attempt_info['question_list'] as $questions) {
224
+                        foreach ($last_attempt_info['question_list'] as $questions) {
225 225
                             foreach ($questions as $question_data) {
226 226
                                 $question_id = $question_data['question_id'];
227 227
                                 $marks       = $question_data['marks'];
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                             }
233 233
                         }
234 234
                     }
235
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
235
+					$score = ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
236 236
 					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
237 237
 				} else {
238 238
 					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
294 294
 		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
295 295
 
296
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
296
+		$clock_expired_time = api_get_utc_datetime($expected_time);
297 297
 		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
298 298
 
299 299
 		//Sessions  that contain the expired time
300
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
301
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
300
+		$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
301
+		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
302 302
 	}
303 303
 
304 304
     $exe_id = $objExercise->save_stat_track_exercise_info(
@@ -412,22 +412,22 @@  discard block
 block discarded – undo
412 412
 	    	   the track_et_attempt see #2069 */
413 413
 	    	if (empty($last_attempt_date)) {
414 414
 	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
415
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
415
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'], 'UTC') + $diff);
416 416
 	    	} else {
417 417
 	    		//Recalculate the time control due #2069
418
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
419
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
418
+	    		$diff = $current_timestamp - api_strtotime($last_attempt_date, 'UTC');
419
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff);
420 420
 	    	}
421 421
 	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
422 422
 
423 423
 	        //New expired time - it is due to the possible closure of session
424
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
424
+	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date, 'UTC');
425 425
 	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
426 426
 
427
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
427
+	        $expected_time = $current_timestamp + $new_expired_time_in_seconds;
428 428
 	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
429 429
 
430
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
430
+	        $clock_expired_time = api_get_utc_datetime($expected_time);
431 431
 	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
432 432
 
433 433
 			// First we update the attempt to today
@@ -443,17 +443,17 @@  discard block
 block discarded – undo
443 443
 
444 444
 	        //Sessions  that contain the expired time
445 445
 	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
446
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
446
+	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
447 447
         }
448 448
     } else {
449
-        $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
449
+        $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
450 450
     }
451 451
 } else {
452 452
     if ($debug) { error_log("7 No time control"); };
453 453
 }
454 454
 
455 455
 // Get time left for expiring time
456
-$time_left = api_strtotime($clock_expired_time,'UTC') - time();
456
+$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
457 457
 
458 458
 /*
459 459
  * The time control feature is enable here - this feature is enable for a jquery plugin called epiclock
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 
507 507
     //Only for hotspot
508 508
     if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) {
509
-        $hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
509
+        $hotspot_id = (int) ($_REQUEST['hidden_hotspot_id']);
510 510
         $choice     = array($hotspot_id => '');
511 511
     }
512 512
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
                     if (isset($exe_id)) {
541 541
                     	// Manage the question and answer attempts
542 542
                         if ($debug) {
543
-                            error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1));
543
+                            error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice, 1));
544 544
                         }
545 545
                         $objExercise->manage_answer(
546 546
                             $exe_id,
@@ -560,13 +560,13 @@  discard block
 block discarded – undo
560 560
             }
561 561
         }
562 562
         if ($debug) { error_log('9.3.  $choice is an array - end'); }
563
-        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult,1)); }
563
+        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult, 1)); }
564 564
     }
565 565
 
566 566
     // the script "exercise_result.php" will take the variable $exerciseResult from the session
567 567
     Session::write('exerciseResult', $exerciseResult);
568 568
     Session::write('remind_list', $remind_list);
569
-    Session::write('exerciseResultCoordinates',$exerciseResultCoordinates);
569
+    Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
570 570
 
571 571
     // if all questions on one page OR if it is the last question (only for an exercise with one question per page)
572 572
     if ($objExercise->type == ALL_ON_ONE_PAGE || $current_question >= $question_count) {
@@ -692,15 +692,15 @@  discard block
 block discarded – undo
692 692
 }
693 693
 
694 694
 if (!empty ($gradebook) && $gradebook == 'view') {
695
-    $interbreadcrumb[] = array ('url' => '../gradebook/' . Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
695
+    $interbreadcrumb[] = array('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('ToolGradebook'));
696 696
 }
697 697
 
698
-$interbreadcrumb[] = array ("url" => "exercise.php?".api_get_cidreq(),	"name" => get_lang('Exercises'));
699
-$interbreadcrumb[] = array ("url" => "#", "name" => $objExercise->name);
698
+$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
699
+$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
700 700
 
701 701
 if ($origin != 'learnpath') { //so we are not in learnpath tool
702
-    Display :: display_header(null,'Exercises');
703
-    if (!api_is_allowed_to_session_edit() ) {
702
+    Display :: display_header(null, 'Exercises');
703
+    if (!api_is_allowed_to_session_edit()) {
704 704
         Display :: display_warning_message(get_lang('SessionIsReadOnly'));
705 705
     }
706 706
 } else {
@@ -719,9 +719,9 @@  discard block
 block discarded – undo
719 719
 if (api_is_course_admin() && $origin != 'learnpath') {
720 720
     echo '<div class="actions">';
721 721
     if ($show_quiz_edition == false) {
722
-    	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>';
722
+    	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>';
723 723
     } else {
724
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
724
+    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
725 725
     }
726 726
     echo '</div>';
727 727
 }
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
     }
761 761
 
762 762
     if (!$permission_to_start || $exercise_timeover) {
763
-        if (!api_is_allowed_to_edit(null,true)) {
763
+        if (!api_is_allowed_to_edit(null, true)) {
764 764
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
765 765
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
766 766
             if ($origin != 'learnpath') {
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
    echo '<div id="highlight-plugin" class="glossary-content">';
804 804
 }
805 805
 
806
-if ($reminder == 2)  {
806
+if ($reminder == 2) {
807 807
     if ($debug) { error_log(' $reminder == 2'); }
808 808
 
809 809
     $data_tracking  = $exercise_stat_info['data_tracking'];
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
     if (!empty($my_remind_list)) {
815 815
     	//Checking which questions we are going to call from the remind list
816 816
 		for ($i = 0; $i < count($data_tracking); $i++) {
817
-			for($j = 0; $j < count($my_remind_list); $j++) {
817
+			for ($j = 0; $j < count($my_remind_list); $j++) {
818 818
 
819 819
 				if (!empty($remind_question_id)) {
820 820
 					if ($remind_question_id == $my_remind_list[$j]) {
821 821
 
822 822
 			        	if ($remind_question_id == $data_tracking[$i]) {
823
-			        		if (isset($my_remind_list[$j+1])) {
824
-			        			$remind_question_id = $my_remind_list[$j+1];
823
+			        		if (isset($my_remind_list[$j + 1])) {
824
+			        			$remind_question_id = $my_remind_list[$j + 1];
825 825
 			        			$current_question = $i + 1;
826 826
 			        		} else {
827 827
                                 // We end the remind list we go to the exercise_reminder.php please
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 					}
834 834
 				} else {
835 835
 					if ($my_remind_list[$j] == $data_tracking[$i]) {
836
-						if (isset($my_remind_list[$j+1])) {
837
-							$remind_question_id = $my_remind_list[$j+1];
836
+						if (isset($my_remind_list[$j + 1])) {
837
+							$remind_question_id = $my_remind_list[$j + 1];
838 838
 							$current_question = $i + 1; // last question
839 839
 						} else {
840 840
                             // We end the remind list we go to the exercise_reminder.php please
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
     Display :: display_error_message($error, false);
866 866
 } else {
867 867
     if (!empty ($exercise_sound)) {
868
-        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . Security::remove_XSS($exercise_sound) . "\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
868
+        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound')."\" /></a>";
869 869
     }
870 870
     // Get number of hotspot questions for javascript validation
871 871
     $number_of_hotspot_questions = 0;
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
     }
897 897
 
898 898
     if ($number_of_hotspot_questions > 0) {
899
-        $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\"";
899
+        $onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
900 900
     }
901 901
 
902 902
     echo '<script>
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                 ICON_SIZE_SMALL,
911 911
                 false,
912 912
                 true
913
-            ) . '\';
913
+            ).'\';
914 914
 
915 915
             // Block form submition on enter
916 916
             $(".block_on_enter").keypress(function(event) {
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
             } else {
963 963
                 url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
964 964
             }
965
-            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
965
+            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
966 966
             window.location = url;
967 967
         }
968 968
 
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 
995 995
             // Only for the first time
996 996
 
997
-            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin') . '\');
997
+            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
998 998
             $.ajax({
999 999
                 type:"post",
1000 1000
                 async: false,
@@ -1002,9 +1002,9 @@  discard block
 block discarded – undo
1002 1002
                 data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
1003 1003
                 success: function(return_value) {
1004 1004
                     if (return_value == "ok") {
1005
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
1005
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
1006 1006
                     } else if (return_value == "error") {
1007
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
1007
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
1008 1008
                     } else if (return_value == "one_per_page") {
1009 1009
                         var url = "";
1010 1010
                         if ('.$reminder.' == 1 ) {
@@ -1019,13 +1019,13 @@  discard block
 block discarded – undo
1019 1019
                             url = url_extra;
1020 1020
                         }
1021 1021
 
1022
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
1022
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
1023 1023
 
1024 1024
                         window.location = url;
1025 1025
                     }
1026 1026
                 },
1027 1027
                 error: function() {
1028
-                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
1028
+                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
1029 1029
                 }
1030 1030
             });
1031 1031
             return false;
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 
1059 1059
             free_answers = $.param(free_answers);
1060 1060
 
1061
-            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin') . '\');
1061
+            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
1062 1062
 
1063 1063
             $.ajax({
1064 1064
                 type:"post",
@@ -1067,14 +1067,14 @@  discard block
 block discarded – undo
1067 1067
                 data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
1068 1068
                 success: function(return_value) {
1069 1069
                     if (return_value == "ok") {
1070
-                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
1070
+                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
1071 1071
                         if (validate == "validate") {
1072 1072
                             window.location = "'.$script_php.'?'.$params.'";
1073 1073
                         } else {
1074
-                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
1074
+                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
1075 1075
                         }
1076 1076
                     } else {
1077
-                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif') . '\');
1077
+                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif').'\');
1078 1078
                     }
1079 1079
                 }
1080 1080
             });
@@ -1087,16 +1087,16 @@  discard block
 block discarded – undo
1087 1087
         }
1088 1088
     </script>';
1089 1089
 
1090
-    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId .'" name="frm_exercise" '.$onsubmit.'>
1090
+    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId.'" name="frm_exercise" '.$onsubmit.'>
1091 1091
          <input type="hidden" name="formSent"				value="1" />
1092
-         <input type="hidden" name="exerciseId" 			value="'.$exerciseId . '" />
1092
+         <input type="hidden" name="exerciseId" 			value="'.$exerciseId.'" />
1093 1093
          <input type="hidden" name="num" 					value="'.$current_question.'" id="num_current_id" />
1094 1094
          <input type="hidden" name="num_answer"             value="'.$currentAnswer.'" id="num_current_answer_id" />
1095
-         <input type="hidden" name="exe_id" 				value="'.$exe_id . '" />
1096
-         <input type="hidden" name="origin" 				value="'.$origin . '" />
1097
-         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id . '" />
1098
-         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1099
-         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1095
+         <input type="hidden" name="exe_id" 				value="'.$exe_id.'" />
1096
+         <input type="hidden" name="origin" 				value="'.$origin.'" />
1097
+         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id.'" />
1098
+         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id.'" />
1099
+         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id.'" />';
1100 1100
 
1101 1101
 	// Show list of questions
1102 1102
     $i = 1;
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
         $attempt_list = Event::getAllExerciseEventByExeId($exe_id);
1106 1106
     }
1107 1107
 
1108
-    $remind_list  = array();
1108
+    $remind_list = array();
1109 1109
     if (isset($exercise_stat_info['questions_to_check']) && !empty($exercise_stat_info['questions_to_check'])) {
1110 1110
         $remind_list = explode(',', $exercise_stat_info['questions_to_check']);
1111 1111
     }
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
             $remind_highlight = 'no_remind_highlight';
1154 1154
         }
1155 1155
 
1156
-        $exercise_actions  = '';
1156
+        $exercise_actions = '';
1157 1157
         $is_remind_on = false;
1158 1158
 
1159 1159
         $attributes = array('id' =>'remind_list['.$questionId.']');
@@ -1165,8 +1165,8 @@  discard block
 block discarded – undo
1165 1165
         }
1166 1166
 
1167 1167
         // Showing the exercise description
1168
-        if (!empty($objExercise->description)){
1169
-            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i==1)) {
1168
+        if (!empty($objExercise->description)) {
1169
+            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i == 1)) {
1170 1170
                 echo Display::panelCollapse('<span>'.
1171 1171
                     get_lang('ExerciseDescriptionLabel').'</span>',
1172 1172
                     $objExercise->description,
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
             case ALL_ON_ONE_PAGE :
1203 1203
                 $button  = '<a href="javascript://" class="btn btn-info" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
1204 1204
                 $button .= '<span id="save_for_now_'.$questionId.'"></span>&nbsp;';
1205
-                $exercise_actions  .= Display::div($button, array('class'=>'exercise_save_now_button'));
1205
+                $exercise_actions .= Display::div($button, array('class'=>'exercise_save_now_button'));
1206 1206
                 break;
1207 1207
         }
1208 1208
 
@@ -1212,13 +1212,13 @@  discard block
 block discarded – undo
1212 1212
                 'label',
1213 1213
                 Display::input(
1214 1214
                     'checkbox',
1215
-                    'remind_list[' . $questionId . ']',
1215
+                    'remind_list['.$questionId.']',
1216 1216
                     '',
1217 1217
                     $attributes
1218
-                ) . get_lang('ReviewQuestionLater'),
1218
+                ).get_lang('ReviewQuestionLater'),
1219 1219
                 array(
1220 1220
                     'class' => 'checkbox',
1221
-                    'for' => 'remind_list[' . $questionId . ']'
1221
+                    'for' => 'remind_list['.$questionId.']'
1222 1222
                 )
1223 1223
             );
1224 1224
             $exercise_actions .= Display::div($remind_question_div, array('class'=>'exercise_save_now_button'));
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
     }
1236 1236
     // end foreach()
1237 1237
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1238
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1238
+    	$exercise_actions = $objExercise->show_button($questionId, $current_question);
1239 1239
     	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1240 1240
         echo '<br>';
1241 1241
     }
Please login to merge, or discard this patch.
main/exercise/UniqueAnswerImage.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -40,22 +40,22 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
42 42
             //Scenario
43
-            $commentTitle = '<th>' . get_lang('Comment') . '</th>';
44
-            $feedbackTitle = '<th>' . get_lang('Scenario') . '</th>';
43
+            $commentTitle = '<th>'.get_lang('Comment').'</th>';
44
+            $feedbackTitle = '<th>'.get_lang('Scenario').'</th>';
45 45
         } else {
46
-            $commentTitle = '<th >' . get_lang('Comment') . '</th>';
46
+            $commentTitle = '<th >'.get_lang('Comment').'</th>';
47 47
         }
48 48
 
49 49
         $html = '<div class="alert alert-success" role="alert">'.get_lang('UniqueAnswerImagePreferredSize200x150').'</div>';
50 50
         $html .= '<table class="table table-striped table-hover">
51 51
             <thead>
52 52
                 <tr style="text-align: center;">
53
-                    <th width="10">' . get_lang('Number') . '</th>
54
-                    <th>' . get_lang('True') . '</th>
55
-                    <th>' . get_lang('Answer') . '</th>
56
-                        ' . $commentTitle . '
57
-                        ' . $feedbackTitle . '
58
-                    <th width="15">' . get_lang('Weighting') . '</th>
53
+                    <th width="10">' . get_lang('Number').'</th>
54
+                    <th>' . get_lang('True').'</th>
55
+                    <th>' . get_lang('Answer').'</th>
56
+                        ' . $commentTitle.'
57
+                        ' . $feedbackTitle.'
58
+                    <th width="15">' . get_lang('Weighting').'</th>
59 59
                 </tr>
60 60
             </thead>
61 61
             <tbody>';
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 }
91 91
 
92 92
                 $question = Question::read($questionid);
93
-                $selectQuestion[$questionid] = 'Q' . $key . ' :' . cut(
93
+                $selectQuestion[$questionid] = 'Q'.$key.' :'.cut(
94 94
                     $question->selectTitle(), 20
95 95
                 );
96 96
             }
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
                     $correct = $i;
124 124
                 }
125 125
 
126
-                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
127
-                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
128
-                $defaults['weighting[' . $i . ']'] = float_format(
126
+                $defaults['answer['.$i.']'] = $answer->answer[$i];
127
+                $defaults['comment['.$i.']'] = $answer->comment[$i];
128
+                $defaults['weighting['.$i.']'] = float_format(
129 129
                     $answer->weighting[$i], 1
130 130
                 );
131 131
 
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
                     $urlResult = $url;
149 149
                 }
150 150
 
151
-                $tempScenario['url' . $i] = $urlResult;
152
-                $tempScenario['try' . $i] = $tryResult;
153
-                $tempScenario['lp' . $i] = $lp;
154
-                $tempScenario['destination' . $i] = $listDestination;
151
+                $tempScenario['url'.$i] = $urlResult;
152
+                $tempScenario['try'.$i] = $tryResult;
153
+                $tempScenario['lp'.$i] = $lp;
154
+                $tempScenario['destination'.$i] = $listDestination;
155 155
             } else {
156 156
                 $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1');
157 157
                 $defaults['weighting[1]'] = 10;
158 158
                 $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
159 159
                 $defaults['weighting[2]'] = 0;
160 160
 
161
-                $tempScenario['destination' . $i] = array('0');
162
-                $tempScenario['lp' . $i] = array('0');
161
+                $tempScenario['destination'.$i] = array('0');
162
+                $tempScenario['lp'.$i] = array('0');
163 163
             }
164 164
 
165 165
             $defaults['scenario'] = $tempScenario;
@@ -172,50 +172,50 @@  discard block
 block discarded – undo
172 172
             );
173 173
             $renderer->setElementTemplate(
174 174
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
175
-                'counter[' . $i . ']'
175
+                'counter['.$i.']'
176 176
             );
177 177
             $renderer->setElementTemplate(
178 178
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
179
-                'answer[' . $i . ']'
179
+                'answer['.$i.']'
180 180
             );
181 181
             $renderer->setElementTemplate(
182 182
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
183
-                'comment[' . $i . ']'
183
+                'comment['.$i.']'
184 184
             );
185 185
             $renderer->setElementTemplate(
186 186
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
187
-                'weighting[' . $i . ']'
187
+                'weighting['.$i.']'
188 188
             );
189 189
 
190
-            $answerNumber = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"');
190
+            $answerNumber = $form->addElement('text', 'counter['.$i.']', null, ' value = "'.$i.'"');
191 191
             $answerNumber->freeze();
192 192
 
193 193
             $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox"');
194
-            $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editorConfig);
194
+            $form->addHtmlEditor('answer['.$i.']', null, null, true, $editorConfig);
195 195
 
196
-            $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
196
+            $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
197 197
 
198 198
             if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
199
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editorConfig);
199
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
200 200
                 // Direct feedback
201 201
                 //Adding extra feedback fields
202 202
                 $group = array();
203
-                $group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain'));
204
-                $group['lp' . $i] = $form->createElement(
203
+                $group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain'));
204
+                $group['lp'.$i] = $form->createElement(
205 205
                     'select',
206
-                    'lp' . $i,
207
-                    get_lang('SeeTheory') . ': ',
206
+                    'lp'.$i,
207
+                    get_lang('SeeTheory').': ',
208 208
                     $selectLpId
209 209
                 );
210
-                $group['destination' . $i] = $form->createElement(
210
+                $group['destination'.$i] = $form->createElement(
211 211
                     'select',
212
-                    'destination' . $i,
213
-                    get_lang('GoToQuestion') . ': ',
212
+                    'destination'.$i,
213
+                    get_lang('GoToQuestion').': ',
214 214
                     $selectQuestion
215 215
                 );
216
-                $group['url' . $i] = $form->createElement(
217
-                    'text', 'url' . $i,
218
-                    get_lang('Other') . ': ',
216
+                $group['url'.$i] = $form->createElement(
217
+                    'text', 'url'.$i,
218
+                    get_lang('Other').': ',
219 219
                     array(
220 220
                         'class' => 'col-md-2',
221 221
                         'placeholder' => get_lang('Other')
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
                     'scenario'
229 229
                 );
230 230
             } else {
231
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editorConfig);
231
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
232 232
             }
233
-            $form->addText('weighting[' . $i . ']', null, null, array('class' => "col-md-1", 'value' => '0'));
233
+            $form->addText('weighting['.$i.']', null, null, array('class' => "col-md-1", 'value' => '0'));
234 234
             $form->addHtml('</tr>');
235 235
         }
236 236
 
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
         $numberAnswers = $form->getSubmitValue('nb_answers');
280 280
 
281 281
         for ($i = 1; $i <= $numberAnswers; $i++) {
282
-            $answer = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('answer[' . $i . ']')));
283
-            $comment = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('comment[' . $i . ']')));
284
-            $weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
282
+            $answer = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('answer['.$i.']')));
283
+            $comment = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('comment['.$i.']')));
284
+            $weighting = trim($form->getSubmitValue('weighting['.$i.']'));
285 285
 
286 286
             $scenario = $form->getSubmitValue('scenario');
287 287
 
288 288
             //$listDestination = $form -> getSubmitValue('destination'.$i);
289 289
             //$destinationStr = $form -> getSubmitValue('destination'.$i);
290 290
 
291
-            $try = $scenario['try' . $i];
292
-            $lp = $scenario['lp' . $i];
293
-            $destination = $scenario['destination' . $i];
294
-            $url = trim($scenario['url' . $i]);
291
+            $try = $scenario['try'.$i];
292
+            $lp = $scenario['lp'.$i];
293
+            $destination = $scenario['destination'.$i];
294
+            $url = trim($scenario['url'.$i]);
295 295
 
296 296
             /*
297 297
               How we are going to parse the destination value
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             }
341 341
 
342 342
             //1@@1;2;@@2;4;4;@@http://www.chamilo.org
343
-            $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
343
+            $dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
344 344
 
345 345
             $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i, null, null, $dest);
346 346
         }
Please login to merge, or discard this patch.