Completed
Push — 1.10.x ( 45b387...51aeba )
by Yannick
48:46
created
main/exercice/hotspot_lang_conversion.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
 $hotspot_lang_file = api_get_path(SYS_LANG_PATH);
15 15
 
16 16
 if(isset($_GET['lang'])) {
17
-	//$search = array('../','\\0','\\');
18
-	$lang = urldecode($_GET['lang']);
19
-	if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
20
-		//$lang = str_replace($search,$replace,urldecode($_GET['lang']));
21
-		if(file_exists($hotspot_lang_file . $lang . '/hotspot.inc.php'))
22
-			$hotspot_lang_file .= $lang . '/hotspot.inc.php';
23
-		else
24
-			$hotspot_lang_file .= 'english/hotspot.inc.php';
25
-	} else {
26
-		$hotspot_lang_file .= 'english/hotspot.inc.php';
27
-	}
17
+    //$search = array('../','\\0','\\');
18
+    $lang = urldecode($_GET['lang']);
19
+    if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
20
+        //$lang = str_replace($search,$replace,urldecode($_GET['lang']));
21
+        if(file_exists($hotspot_lang_file . $lang . '/hotspot.inc.php'))
22
+            $hotspot_lang_file .= $lang . '/hotspot.inc.php';
23
+        else
24
+            $hotspot_lang_file .= 'english/hotspot.inc.php';
25
+    } else {
26
+        $hotspot_lang_file .= 'english/hotspot.inc.php';
27
+    }
28 28
 } else {
29
-	$hotspot_lang_file .= 'english/hotspot.inc.php';
29
+    $hotspot_lang_file .= 'english/hotspot.inc.php';
30 30
 }
31 31
 
32 32
 $file = file($hotspot_lang_file);
@@ -35,23 +35,23 @@  discard block
 block discarded – undo
35 35
 
36 36
 foreach($file as $value)
37 37
 {
38
-	$explode = explode('=', $value);
38
+    $explode = explode('=', $value);
39 39
 
40
-	if(count($explode) > 1)
41
-	{
42
-		$explode[0] = trim($explode[0]);
43
-		$explode[0] = '&' . substr($explode[0], 1, strlen($explode[0]));
40
+    if(count($explode) > 1)
41
+    {
42
+        $explode[0] = trim($explode[0]);
43
+        $explode[0] = '&' . substr($explode[0], 1, strlen($explode[0]));
44 44
 
45
-		$explode[1] = trim($explode[1]);
46
-		$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
47
-		$explode[1] = str_replace('"', '', $explode[1]);
45
+        $explode[1] = trim($explode[1]);
46
+        $explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
47
+        $explode[1] = str_replace('"', '', $explode[1]);
48 48
 
49
-		$temp[] = $explode[0] . '=' . $explode[1];
50
-	}
49
+        $temp[] = $explode[0] . '=' . $explode[1];
50
+    }
51 51
 }
52 52
 
53 53
 foreach($temp as $value)
54 54
 {
55
-	echo $value . ' ';
55
+    echo $value . ' ';
56 56
 }
57 57
 ?>
Please login to merge, or discard this patch.
main/exercice/stats.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $result = $objExercise->read($exercise_id);
13 13
 
14 14
 if (!$result) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $sessionId = api_get_session_id();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 $data = array();
30 30
 // Question title 	# of students who tool it 	Lowest score 	Average 	Highest score 	Maximum score
31 31
 $headers = array(
32
-	get_lang('Question'),
32
+    get_lang('Question'),
33 33
     get_lang('QuestionType'),
34 34
     get_lang('NumberStudentWhoSelectedIt'),
35
-	get_lang('LowestScore'),
36
-	get_lang('AverageScore'),
37
-	get_lang('HighestScore'),
38
-	get_lang('Weighting')
35
+    get_lang('LowestScore'),
36
+    get_lang('AverageScore'),
37
+    get_lang('HighestScore'),
38
+    get_lang('Weighting')
39 39
 );
40 40
 
41 41
 if (!empty($question_list)) {
42
-	foreach ($question_list as $question_id) {
42
+    foreach ($question_list as $question_id) {
43 43
         $question_obj = Question::read($question_id);
44 44
 
45 45
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
74 74
         $data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
75 75
         $data[$question_id]['max_score'] = round($question_obj->weighting, 2);
76
-	}
76
+    }
77 77
 }
78 78
 
79 79
 // Format A table
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 $row = 0;
82 82
 $column = 0;
83 83
 foreach ($headers as $header) {
84
-	$table->setHeaderContents($row, $column, $header);
85
-	$column++;
84
+    $table->setHeaderContents($row, $column, $header);
85
+    $column++;
86 86
 }
87 87
 $row++;
88 88
 foreach ($data as $row_table) {
89
-	$column = 0;
90
-	foreach ($row_table as $cell) {
91
-		$table->setCellContents($row, $column, $cell);
92
-		$table->updateCellAttributes($row, $column, 'align="center"');
93
-		$column++;
94
-	}
95
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
-	$row++;
89
+    $column = 0;
90
+    foreach ($row_table as $cell) {
91
+        $table->setCellContents($row, $column, $cell);
92
+        $table->updateCellAttributes($row, $column, 'align="center"');
93
+        $column++;
94
+    }
95
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
+    $row++;
97 97
 }
98 98
 $content = $table->toHtml();
99 99
 
100 100
 // Format B
101 101
 
102 102
 $headers = array(
103
-	get_lang('Question'),
104
-	get_lang('Answer'),
105
-	get_lang('Correct'),
106
-	get_lang('NumberStudentWhoSelectedIt')
103
+    get_lang('Question'),
104
+    get_lang('Answer'),
105
+    get_lang('Correct'),
106
+    get_lang('NumberStudentWhoSelectedIt')
107 107
 );
108 108
 
109 109
 $data = array();
110 110
 
111 111
 if (!empty($question_list)) {
112 112
     $id = 0;
113
-	foreach ($question_list as $question_id) {
114
-		$question_obj = Question::read($question_id);
113
+    foreach ($question_list as $question_id) {
114
+        $question_obj = Question::read($question_id);
115 115
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
116 116
             $question_id,
117 117
             $exercise_id,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         );
121 121
 
122 122
         $answer = new Answer($question_id);
123
-		$answer_count = $answer->selectNbrAnswers();
123
+        $answer_count = $answer->selectNbrAnswers();
124 124
 
125 125
         for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
126 126
             $answer_info = $answer->selectAnswer($answer_id);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
                         $correct = '';
176 176
 
177 177
                         for ($i = 1; $i <= $answer_count; $i++) {
178
-                             $is_correct_i = $answer->isCorrect($i);
179
-                             if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
-                                 $correct = $answer->selectAnswer($i);
181
-                                 break;
182
-                             }
178
+                                $is_correct_i = $answer->isCorrect($i);
179
+                                if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
+                                    $correct = $answer->selectAnswer($i);
181
+                                    break;
182
+                                }
183 183
                         }
184 184
                         $data[$id]['answer'] = $correct;
185 185
                         $data[$id]['correct'] = $answer_info;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             }
246 246
             $id++;
247 247
         }
248
-	}
248
+    }
249 249
 }
250 250
 
251 251
 // Format A table
@@ -253,19 +253,19 @@  discard block
 block discarded – undo
253 253
 $row = 0;
254 254
 $column = 0;
255 255
 foreach ($headers as $header) {
256
-	$table->setHeaderContents($row, $column, $header);
257
-	$column++;
256
+    $table->setHeaderContents($row, $column, $header);
257
+    $column++;
258 258
 }
259 259
 $row++;
260 260
 foreach ($data as $row_table) {
261
-	$column = 0;
262
-	foreach ($row_table as $cell) {
263
-		$table->setCellContents($row, $column, $cell);
264
-		$table->updateCellAttributes($row, $column, 'align="center"');
265
-		$column++;
266
-	}
267
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
-	$row++;
261
+    $column = 0;
262
+    foreach ($row_table as $cell) {
263
+        $table->setCellContents($row, $column, $cell);
264
+        $table->updateCellAttributes($row, $column, 'align="center"');
265
+        $column++;
266
+    }
267
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
+    $row++;
269 269
 }
270 270
 $content .= $table->toHtml();
271 271
 
Please login to merge, or discard this patch.
main/exercice/multiple_answer_true_false.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
     }
242 242
 
243 243
     /**
244
-	 * abstract function which creates the form to create / edit the answers of the question
245
-	 * @param FormValidator $form
246
-	 */
244
+     * abstract function which creates the form to create / edit the answers of the question
245
+     * @param FormValidator $form
246
+     */
247 247
     public function processAnswersCreation($form)
248 248
     {
249
-		$questionWeighting = $nbrGoodAnswers = 0;
250
-		$objAnswer = new Answer($this->id);
249
+        $questionWeighting = $nbrGoodAnswers = 0;
250
+        $objAnswer = new Answer($this->id);
251 251
         $nb_answers = $form->getSubmitValue('nb_answers');
252 252
         //$options_count    = $form->getSubmitValue('options_count');
253 253
         $course_id = api_get_course_int_id();
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                     $course_id,
270 270
                     $i
271 271
                 );
272
-               $correct[$i] = $last_id;
272
+                $correct[$i] = $last_id;
273 273
             }
274 274
         }
275 275
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
         $sorted_by_position = array();
282 282
         foreach ($new_options as $item) {
283
-        	$sorted_by_position[$item['position']] = $item;
283
+            $sorted_by_position[$item['position']] = $item;
284 284
         }
285 285
 
286 286
         /* Saving quiz_question.extra values that has the correct scores of
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         }
294 294
         $this->setExtra(implode(':', $extra_values));
295 295
 
296
-		for ($i = 1; $i <= $nb_answers; $i++) {
296
+        for ($i = 1; $i <= $nb_answers; $i++) {
297 297
             $answer = trim($form->getSubmitValue('answer['.$i.']'));
298 298
             $comment = trim($form->getSubmitValue('comment['.$i.']'));
299 299
             $goodAnswer = trim($form->getSubmitValue('correct['.$i.']'));
@@ -302,18 +302,18 @@  discard block
 block discarded – undo
302 302
                 // change the default values from the form 1 and 2 by the correct "option id" registered
303 303
                 $goodAnswer = $sorted_by_position[$goodAnswer]['id'];
304 304
             }
305
-    	    $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
305
+            $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
306 306
 
307
-        	$objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i);
307
+            $objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i);
308 308
         }
309 309
 
310
-    	// saves the answers into the data base
310
+        // saves the answers into the data base
311 311
         $objAnswer->save();
312 312
 
313 313
         // sets the total weighting of the question
314 314
         $this->updateWeighting($questionWeighting);
315 315
         $this->save();
316
-	}
316
+    }
317 317
 
318 318
     /**
319 319
      * @param int $feedback_type
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
     function return_header($feedback_type = null, $counter = null, $score = null)
325 325
     {
326 326
         $header = parent::return_header($feedback_type, $counter, $score);
327
-  	    $header .= '<table class="'.$this->question_table_class .'">
327
+            $header .= '<table class="'.$this->question_table_class .'">
328 328
 		<tr>
329 329
 			<th>'.get_lang("Choice").'</th>
330 330
 			<th>'. get_lang("ExpectedChoice").'</th>
331 331
 			<th>'. get_lang("Answer").'</th>';
332
-			if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
333
-				$header .= '<th>'.get_lang("Comment").'</th>';
334
-			} else {
335
-				$header .= '<th>&nbsp;</th>';
336
-			}
332
+            if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
333
+                $header .= '<th>'.get_lang("Comment").'</th>';
334
+            } else {
335
+                $header .= '<th>&nbsp;</th>';
336
+            }
337 337
         $header .= '</tr>';
338 338
         return $header;
339
-	}
339
+    }
340 340
 }
Please login to merge, or discard this patch.
main/exercice/hotspot_save.inc.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@
 block discarded – undo
15 15
 $answerId 	= intval($_GET['answerId']);
16 16
 
17 17
 if ($_GET['type'] == "square" || $_GET['type'] == "circle") {
18
-	$hotspot_type = $_GET['type'];
19
-	$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
18
+    $hotspot_type = $_GET['type'];
19
+    $hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
20 20
 }
21 21
 if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] == "oar") {
22
-	$hotspot_type = $_GET['type'];
23
-	$tmp_coord = explode(",",$_GET['co']);
24
-	$i = 0;
25
-	$hotspot_coordinates = "";
26
-	foreach ($tmp_coord as $coord) {
27
-		if ($i%2 == 0) {
28
-			$delimiter = ";";
29
-		} else {
30
-			$delimiter = "|";
31
-		}
32
-		$hotspot_coordinates .= $coord.$delimiter;
33
-		$i++;
34
-	}
35
-	$hotspot_coordinates = api_substr($hotspot_coordinates,0,-2);
22
+    $hotspot_type = $_GET['type'];
23
+    $tmp_coord = explode(",",$_GET['co']);
24
+    $i = 0;
25
+    $hotspot_coordinates = "";
26
+    foreach ($tmp_coord as $coord) {
27
+        if ($i%2 == 0) {
28
+            $delimiter = ";";
29
+        } else {
30
+            $delimiter = "|";
31
+        }
32
+        $hotspot_coordinates .= $coord.$delimiter;
33
+        $i++;
34
+    }
35
+    $hotspot_coordinates = api_substr($hotspot_coordinates,0,-2);
36 36
 }
37 37
 $course_id = api_get_course_int_id();
38 38
 $sql = "UPDATE $TBL_ANSWER SET
Please login to merge, or discard this patch.
main/exercice/question_create.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,17 +51,17 @@
 block discarded – undo
51 51
 $result = Database::query($sql);
52 52
 $exercises['-'] = '-'.get_lang('SelectExercise').'-';
53 53
 while ($row = Database :: fetch_array($result)) {
54
-	$exercises[$row['id']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
54
+    $exercises[$row['id']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
55 55
 }
56 56
 $form->addElement('select', 'exercise', get_lang('Exercise'), $exercises);
57 57
 
58 58
 // generate default content
59 59
 $form->addElement(
60
-	'checkbox',
61
-	'is_content',
62
-	null,
63
-	get_lang('GenerateDefaultContent'),
64
-	array('checked' => true)
60
+    'checkbox',
61
+    'is_content',
62
+    null,
63
+    get_lang('GenerateDefaultContent'),
64
+    array('checked' => true)
65 65
 );
66 66
 
67 67
 // the submit button
Please login to merge, or discard this patch.
main/exercice/hotspot_updatescore.inc.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@
 block discarded – undo
17 17
 $hotspotId	  = $_GET['hotspotId'];
18 18
 $exerciseId   = $objExcercise->selectId();
19 19
 if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
20
-	$hit = 0;
21
-	$answerId = $hotspotId;
20
+    $hit = 0;
21
+    $answerId = $hotspotId;
22 22
 
23
-	// remove from session
24
-	unset($_SESSION['exerciseResult'][$questionId][$answerId]);
23
+    // remove from session
24
+    unset($_SESSION['exerciseResult'][$questionId][$answerId]);
25 25
 
26
-	// Save clicking order
27
-	//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
28
-	//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
26
+    // Save clicking order
27
+    //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
28
+    //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
29 29
 } else { // user clicked ON a hotspot
30
-	$hit = 1;
31
-	$answerId = $hotspotId;
30
+    $hit = 1;
31
+    $answerId = $hotspotId;
32 32
 
33
-	// Save into session
34
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
33
+    // Save into session
34
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
35 35
 
36
-	// Save clicking order
37
-	//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
38
-	//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
36
+    // Save clicking order
37
+    //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
38
+    //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
39 39
 }
40 40
 
41 41
 //round-up the coordinates
Please login to merge, or discard this patch.
main/exercice/hotspot_admin.inc.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -907,10 +907,10 @@
 block discarded – undo
907 907
                                         <?php } else { ?>
908 908
                                             <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
909 909
                                                    <?php
910
-                                               }
911
-                                           }
912
-                                           if ($answerType == HOT_SPOT) {
913
-                                               ?>
910
+                                                }
911
+                                            }
912
+                                            if ($answerType == HOT_SPOT) {
913
+                                                ?>
914 914
                                         <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
915 915
                                         <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
916 916
                                         <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" />
Please login to merge, or discard this patch.
main/exercice/hotspot_savescore.inc.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,15 +17,15 @@
 block discarded – undo
17 17
 $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
18 18
 if ($_GET['answerId'] == "0") // click is NOT on a hotspot
19 19
 {
20
-	$hit = 0;
21
-	$answerId = NULL;
20
+    $hit = 0;
21
+    $answerId = NULL;
22 22
 }
23 23
 else // user clicked ON a hotspot
24 24
 {
25
-	$hit = 1;
26
-	$answerId = api_substr($_GET['answerId'],22,2);
27
-	// Save into session
28
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
25
+    $hit = 1;
26
+    $answerId = api_substr($_GET['answerId'],22,2);
27
+    // Save into session
28
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
29 29
 }
30 30
 //round-up the coordinates
31 31
 $coords = explode('/',$coordinates);
Please login to merge, or discard this patch.
main/exercice/fill_blanks.class.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -729,43 +729,43 @@  discard block
 block discarded – undo
729 729
     }
730 730
     
731 731
     /**
732
-    * Return an array of student state answers for fill the blank questions
733
-    * for each students that answered the question
734
-    * -2  : didn't answer
735
-    * -1  : student answer is wrong
736
-    *  0  : student answer is correct
737
-    * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
738
-    *
739
-    * @param $testId
740
-    * @param $questionId
741
-    * @param $studentsIdList
742
-    * @param $startDate
743
-    * @param $endDate
744
-    * @param bool $useLastAnswerredAttempt
745
-    * @return array
746
-    * (
747
-    *     [student_id] => Array
748
-    *         (
749
-    *             [first fill the blank for question] => -1
750
-    *             [second fill the blank for question] => 2
751
-    *             [third fill the blank for question] => -1
752
-    *         )
753
-    * )
754
-    */
732
+     * Return an array of student state answers for fill the blank questions
733
+     * for each students that answered the question
734
+     * -2  : didn't answer
735
+     * -1  : student answer is wrong
736
+     *  0  : student answer is correct
737
+     * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
738
+     *
739
+     * @param $testId
740
+     * @param $questionId
741
+     * @param $studentsIdList
742
+     * @param $startDate
743
+     * @param $endDate
744
+     * @param bool $useLastAnswerredAttempt
745
+     * @return array
746
+     * (
747
+     *     [student_id] => Array
748
+     *         (
749
+     *             [first fill the blank for question] => -1
750
+     *             [second fill the blank for question] => 2
751
+     *             [third fill the blank for question] => -1
752
+     *         )
753
+     * )
754
+     */
755 755
     public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) {
756 756
 
757
-       $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
758
-       $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
759
-       $courseId = api_get_course_int_id();
757
+        $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
758
+        $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
759
+        $courseId = api_get_course_int_id();
760 760
 
761
-       require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
761
+        require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
762 762
 
763
-       // request to have all the answers of student for this question
764
-       // student may have doing it several time
765
-       // student may have not answered the bracket id, in this case, is result of the answer is empty
763
+        // request to have all the answers of student for this question
764
+        // student may have doing it several time
765
+        // student may have not answered the bracket id, in this case, is result of the answer is empty
766 766
 
767
-       // we got the less recent attempt first
768
-       $sql = '
767
+        // we got the less recent attempt first
768
+        $sql = '
769 769
            SELECT * FROM '.$tblTrackEAttempt.' tea
770 770
 
771 771
            LEFT JOIN '.$tblTrackEExercise.' tee
@@ -781,49 +781,49 @@  discard block
 block discarded – undo
781 781
            ORDER BY user_id, tea.exe_id;
782 782
        ';
783 783
 
784
-       $res = Database::query($sql);
785
-       $tabUserResult = array();
786
-       $bracketNumber = 0;
787
-       // foreach attempts for all students starting with his older attempt
788
-       while ($data = Database::fetch_array($res)) {
789
-           $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
784
+        $res = Database::query($sql);
785
+        $tabUserResult = array();
786
+        $bracketNumber = 0;
787
+        // foreach attempts for all students starting with his older attempt
788
+        while ($data = Database::fetch_array($res)) {
789
+            $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
790 790
 
791
-           // for each bracket to find in this question
792
-           foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
791
+            // for each bracket to find in this question
792
+            foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
793 793
 
794
-               if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
795
-                   // student has answered this bracket, cool
796
-                   switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
797
-                       case self::FILL_THE_BLANK_MENU :
794
+                if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
795
+                    // student has answered this bracket, cool
796
+                    switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
797
+                        case self::FILL_THE_BLANK_MENU :
798 798
                            // get the indice of the choosen answer in the menu
799 799
                            // we know that the right answer is the first entry of the menu, ie 0
800 800
                            // (remember, menu entries are shuffled when taking the test)
801 801
                            $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]);
802
-                           break;
803
-                       default :
802
+                            break;
803
+                        default :
804 804
                            if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
805
-                               $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
806
-                           } else {
807
-                               $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
808
-                           }
809
-                   }
810
-               } else {
811
-                   // student didn't answer this bracket
812
-                   if ($useLastAnswerredAttempt) {
813
-                       // if we take into account the last answered attempt
814
-                       if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
815
-                           $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
816
-                       }
817
-                   } else {
818
-                       // we take the last attempt, even if the student answer the question before
819
-                       $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
820
-                   }
821
-               }
822
-           }
823
-
824
-
825
-       }
826
-       return $tabUserResult;
805
+                                $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
806
+                            } else {
807
+                                $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
808
+                            }
809
+                    }
810
+                } else {
811
+                    // student didn't answer this bracket
812
+                    if ($useLastAnswerredAttempt) {
813
+                        // if we take into account the last answered attempt
814
+                        if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
815
+                            $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
816
+                        }
817
+                    } else {
818
+                        // we take the last attempt, even if the student answer the question before
819
+                        $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
820
+                    }
821
+                }
822
+            }
823
+
824
+
825
+        }
826
+        return $tabUserResult;
827 827
     }
828 828
 
829 829
 
Please login to merge, or discard this patch.