Completed
Pull Request — 1.11.x (#1339)
by José
73:57 queued 34:43
created
main/exercise/exercise.class.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
                     $label = get_lang('NextQuestion');
1967 1967
                     $class = 'btn btn-primary';
1968 1968
                 }
1969
-				$class .= ' question-validate-btn'; // used to select it with jquery
1969
+                $class .= ' question-validate-btn'; // used to select it with jquery
1970 1970
                 if ($this->type == ONE_PER_PAGE) {
1971 1971
                     if ($questionNum != 1) {
1972 1972
                         $prev_question = $questionNum - 2;
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
                         $all_label = get_lang('EndTest');
1992 1992
                         $class = 'btn btn-warning';
1993 1993
                     }
1994
-					$class .= ' question-validate-btn'; // used to select it with jquery
1994
+                    $class .= ' question-validate-btn'; // used to select it with jquery
1995 1995
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
1996 1996
                     $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
1997 1997
                     $html .= $all_button;
@@ -3774,7 +3774,7 @@  discard block
 block discarded – undo
3774 3774
 
3775 3775
         //Fixes multiple answer question in order to be exact
3776 3776
         //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
3777
-       /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) {
3777
+        /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) {
3778 3778
             $diff = @array_diff($answer_correct_array, $real_answers);
3779 3779
 
3780 3780
             // All good answers or nothing works like exact
@@ -5073,8 +5073,8 @@  discard block
 block discarded – undo
5073 5073
     }
5074 5074
 
5075 5075
     /**
5076
-    * @return string
5077
-    */
5076
+     * @return string
5077
+     */
5078 5078
     public function get_formated_title()
5079 5079
     {
5080 5080
         return api_html_entity_decode($this->selectTitle());
Please login to merge, or discard this patch.
main/exercise/exercise_submit.php 1 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
 }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 $time_control = false;
165 165
 if ($objExercise->expired_time != 0) {
166
-	$time_control = true;
166
+    $time_control = true;
167 167
 }
168 168
 
169 169
 // Generating the time control key for the user
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
173 173
 
174 174
 if ($time_control) {
175
-	// Get the expired time of the current exercise in track_e_exercises
176
-	$total_seconds = $objExercise->expired_time*60;
175
+    // Get the expired time of the current exercise in track_e_exercises
176
+    $total_seconds = $objExercise->expired_time*60;
177 177
 }
178 178
 
179 179
 $show_clock = true;
180 180
 $user_id = api_get_user_id();
181 181
 if ($objExercise->selectAttempts() > 0) {
182
-	$attempt_html = '';
182
+    $attempt_html = '';
183 183
     $attempt_count = Event::get_attempt_count(
184 184
         $user_id,
185 185
         $exerciseId,
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
         $learnpath_item_view_id
189 189
     );
190 190
 
191
-	if ($attempt_count >= $objExercise->selectAttempts()) {
192
-		$show_clock = false;
193
-		if (!api_is_allowed_to_edit(null,true)) {
191
+    if ($attempt_count >= $objExercise->selectAttempts()) {
192
+        $show_clock = false;
193
+        if (!api_is_allowed_to_edit(null,true)) {
194 194
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
195 195
 
196 196
                 // Showing latest attempt according with task BT#1628
@@ -229,31 +229,31 @@  discard block
 block discarded – undo
229 229
                             $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore'));
230 230
                         }
231 231
                     }
232
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
233
-					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
234
-				} else {
235
-					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
236
-				}
237
-			} else {
238
-				$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
239
-			}
240
-		} else {
241
-			$attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
242
-		}
232
+                    $score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
233
+                    $attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
234
+                } else {
235
+                    $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
236
+                }
237
+            } else {
238
+                $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
239
+            }
240
+        } else {
241
+            $attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
242
+        }
243 243
 
244
-		if ($origin == 'learnpath') {
245
-			Display :: display_reduced_header();
246
-		} else {
247
-			Display :: display_header(get_lang('Exercises'));
248
-		}
244
+        if ($origin == 'learnpath') {
245
+            Display :: display_reduced_header();
246
+        } else {
247
+            Display :: display_header(get_lang('Exercises'));
248
+        }
249 249
 
250
-		echo $attempt_html;
250
+        echo $attempt_html;
251 251
 
252 252
         if ($origin != 'learnpath') {
253 253
             Display:: display_footer();
254 254
         }
255
-		exit;
256
-	}
255
+        exit;
256
+    }
257 257
 }
258 258
 
259 259
 if ($debug) {
@@ -277,26 +277,26 @@  discard block
 block discarded – undo
277 277
 
278 278
 if (empty($exercise_stat_info)) {
279 279
     if ($debug)  error_log('5  $exercise_stat_info is empty ');
280
-	$total_weight = 0;
281
-	$questionList = $objExercise->get_validated_question_list();
282
-	foreach ($questionListUncompressed as $question_id) {
283
-		$objQuestionTmp = Question::read($question_id);
284
-		$total_weight += floatval($objQuestionTmp->weighting);
285
-	}
280
+    $total_weight = 0;
281
+    $questionList = $objExercise->get_validated_question_list();
282
+    foreach ($questionListUncompressed as $question_id) {
283
+        $objQuestionTmp = Question::read($question_id);
284
+        $total_weight += floatval($objQuestionTmp->weighting);
285
+    }
286 286
 
287
-	if ($time_control) {
288
-		$expected_time = $current_timestamp + $total_seconds;
287
+    if ($time_control) {
288
+        $expected_time = $current_timestamp + $total_seconds;
289 289
 
290
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
291
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
290
+        if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
291
+        if ($debug)  error_log('5.2. $expected_time '.$expected_time);
292 292
 
293
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
294
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
293
+        $clock_expired_time 	= api_get_utc_datetime($expected_time);
294
+        if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
295 295
 
296
-		//Sessions  that contain the expired time
297
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
298
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
299
-	}
296
+        //Sessions  that contain the expired time
297
+        $_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
298
+        if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
299
+    }
300 300
 
301 301
     $exe_id = $objExercise->save_stat_track_exercise_info(
302 302
         $clock_expired_time,
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
     );
314 314
     if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
315 315
 } else {
316
-	$exe_id = $exercise_stat_info['exe_id'];
316
+    $exe_id = $exercise_stat_info['exe_id'];
317 317
     // Remember last question id position.
318 318
     $isFirstTime = Session::read('firstTime');
319 319
     if ($isFirstTime && $objExercise->type == ONE_PER_PAGE) {
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
373 373
 
374 374
 if (!empty($exercise_stat_info['questions_to_check'])) {
375
-	$my_remind_list = $exercise_stat_info['questions_to_check'];
376
-	$my_remind_list = explode(',', $my_remind_list);
377
-	$my_remind_list = array_filter($my_remind_list);
375
+    $my_remind_list = $exercise_stat_info['questions_to_check'];
376
+    $my_remind_list = explode(',', $my_remind_list);
377
+    $my_remind_list = array_filter($my_remind_list);
378 378
 }
379 379
 
380 380
 $params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq();
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 
383 383
 if ($reminder == 2 && empty($my_remind_list)) {
384 384
     if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
385
-	header('Location: exercise_reminder.php?'.$params);
386
-	exit;
385
+    header('Location: exercise_reminder.php?'.$params);
386
+    exit;
387 387
 }
388 388
 
389 389
 /*
@@ -391,56 +391,56 @@  discard block
 block discarded – undo
391 391
  * If the expired time is major that zero(0) then the expired time is compute on this time.
392 392
  */
393 393
 if ($time_control) {
394
-	if ($debug) error_log('7.1. Time control is enabled');
395
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
396
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
394
+    if ($debug) error_log('7.1. Time control is enabled');
395
+    if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
396
+    if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
397 397
 
398 398
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
399 399
         //Timer - Get expired_time for a student
400 400
         if (!empty($exercise_stat_info)) {
401
-        	if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
402
-	        $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
403
-			if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
404
-	        // Get the last attempt of an exercise
405
-	    	$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
401
+            if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
402
+            $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
403
+            if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
404
+            // Get the last attempt of an exercise
405
+            $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
406 406
 
407
-	    	/* This means that the user enters the exam but do not answer the
407
+            /* This means that the user enters the exam but do not answer the
408 408
 	    	   first question we get the date from the track_e_exercises not from
409 409
 	    	   the track_et_attempt see #2069 */
410
-	    	if (empty($last_attempt_date)) {
411
-	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
412
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
413
-	    	} else {
414
-	    		//Recalculate the time control due #2069
415
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
416
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
417
-	    	}
418
-	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
419
-
420
-	        //New expired time - it is due to the possible closure of session
421
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
422
-	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
423
-
424
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
425
-	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
426
-
427
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
428
-	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
429
-
430
-			// First we update the attempt to today
431
-			/* How the expired time is changed into "track_e_exercises" table,
410
+            if (empty($last_attempt_date)) {
411
+                $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
412
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
413
+            } else {
414
+                //Recalculate the time control due #2069
415
+                $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
416
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
417
+            }
418
+            if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
419
+
420
+            //New expired time - it is due to the possible closure of session
421
+            $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
422
+            if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
423
+
424
+            $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
425
+            if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
426
+
427
+            $clock_expired_time  = api_get_utc_datetime($expected_time);
428
+            if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
429
+
430
+            // First we update the attempt to today
431
+            /* How the expired time is changed into "track_e_exercises" table,
432 432
                then the last attempt for this student should be changed too */
433
-	        $sql = "UPDATE $exercise_attempt_table SET
433
+            $sql = "UPDATE $exercise_attempt_table SET
434 434
 	                tms = '".api_get_utc_datetime()."'
435 435
 	                WHERE
436 436
 	                    exe_id = '".$exercise_stat_info['exe_id']."' AND
437 437
 	                    tms = '".$last_attempt_date."' ";
438
-	        if ($debug) {error_log('7.10. $sql: '.$sql); }
439
-	        Database::query($sql);
438
+            if ($debug) {error_log('7.10. $sql: '.$sql); }
439
+            Database::query($sql);
440 440
 
441
-	        //Sessions  that contain the expired time
442
-	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
443
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
441
+            //Sessions  that contain the expired time
442
+            $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
443
+            if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
444 444
         }
445 445
     } else {
446 446
         $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
  * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock
458 458
  */
459 459
 if ($time_control) { //Sends the exercise form when the expired time is finished
460
-	$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
460
+    $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
461 461
 }
462 462
 
463 463
 // if the user has submitted the form
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
     // selects the list of question ID
471 471
     $questionList = $objExercise->get_validated_question_list();
472 472
     if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) {
473
-    	$questionList = explode(',', $exercise_stat_info['data_tracking']);
473
+        $questionList = explode(',', $exercise_stat_info['data_tracking']);
474 474
     }
475 475
     Session::write('questionList', $questionList);
476 476
     if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
477 477
 } else {
478
-	if (isset($objExercise) && isset($_SESSION['objExercise'])) {
479
-    	$questionList = $_SESSION['questionList'];
480
-	}
478
+    if (isset($objExercise) && isset($_SESSION['objExercise'])) {
479
+        $questionList = $_SESSION['questionList'];
480
+    }
481 481
 }
482 482
 
483 483
 if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 //Real question count
486 486
 $question_count = 0;
487 487
 if (!empty($questionList)) {
488
-	$question_count = count($questionList);
488
+    $question_count = count($questionList);
489 489
 }
490 490
 
491 491
 if ($formSent && isset($_POST)) {
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
                 //saving each question
528 528
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
529 529
                     $nro_question = $current_question; // - 1;
530
-                 	$questionId   = $key;
530
+                        $questionId   = $key;
531 531
                     // gets the student choice for this question
532 532
                     $choice = $exerciseResult[$questionId];
533 533
                     if (isset($exe_id)) {
534
-                    	// Manage the question and answer attempts
534
+                        // Manage the question and answer attempts
535 535
                         if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
536 536
                         $objExercise->manage_answer(
537 537
                             $exe_id,
@@ -620,58 +620,58 @@  discard block
 block discarded – undo
620 620
 }
621 621
 
622 622
 if ($question_count != 0) {
623
-	if (($objExercise->type == ALL_ON_ONE_PAGE ||
623
+    if (($objExercise->type == ALL_ON_ONE_PAGE ||
624 624
         $current_question > $question_count)
625 625
     ) {
626
-	    if (api_is_allowed_to_session_edit()) {
627
-	        // goes to the script that will show the result of the exercise
628
-	        if ($objExercise->type == ALL_ON_ONE_PAGE) {
629
-	            if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
630
-
631
-	            //We check if the user attempts before sending to the exercise_result.php
632
-	            if ($objExercise->selectAttempts() > 0) {
633
-	                $attempt_count = Event::get_attempt_count(
626
+        if (api_is_allowed_to_session_edit()) {
627
+            // goes to the script that will show the result of the exercise
628
+            if ($objExercise->type == ALL_ON_ONE_PAGE) {
629
+                if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
630
+
631
+                //We check if the user attempts before sending to the exercise_result.php
632
+                if ($objExercise->selectAttempts() > 0) {
633
+                    $attempt_count = Event::get_attempt_count(
634 634
                         api_get_user_id(),
635 635
                         $exerciseId,
636 636
                         $learnpath_id,
637 637
                         $learnpath_item_id,
638 638
                         $learnpath_item_view_id
639 639
                     );
640
-	                if ($attempt_count >= $objExercise->selectAttempts()) {
641
-	                    Display :: display_warning_message(
640
+                    if ($attempt_count >= $objExercise->selectAttempts()) {
641
+                        Display :: display_warning_message(
642 642
                             sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
643 643
                             false
644 644
                         );
645
-	                    if ($origin != 'learnpath') {
646
-	                        //so we are not in learnpath tool
647
-	                        echo '</div>'; //End glossary div
648
-	                        Display :: display_footer();
649
-	                    } else {
650
-	                        echo '</body></html>';
651
-	                    }
652
-	                    exit;
653
-	                }
654
-	            }
655
-	        } else {
656
-	            if ($objExercise->review_answers) {
657
-	            	header('Location: exercise_reminder.php?'.$params);
658
-	            	exit;
659
-	            } else {
645
+                        if ($origin != 'learnpath') {
646
+                            //so we are not in learnpath tool
647
+                            echo '</div>'; //End glossary div
648
+                            Display :: display_footer();
649
+                        } else {
650
+                            echo '</body></html>';
651
+                        }
652
+                        exit;
653
+                    }
654
+                }
655
+            } else {
656
+                if ($objExercise->review_answers) {
657
+                    header('Location: exercise_reminder.php?'.$params);
658
+                    exit;
659
+                } else {
660 660
                     header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
661 661
                     exit;
662
-	            }
663
-	        }
664
-	    } else {
665
-	        if ($debug) { error_log('Redirecting to exercise_submit.php'); }
666
-	        exit;
667
-	    }
668
-	}
662
+                }
663
+            }
664
+        } else {
665
+            if ($debug) { error_log('Redirecting to exercise_submit.php'); }
666
+            exit;
667
+        }
668
+    }
669 669
 } else {
670
-	$error = get_lang('ThereAreNoQuestionsForThisExercise');
671
-	// if we are in the case where user select random by category, but didn't choose the number of random question
672
-	if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
673
-		$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
674
-	}
670
+    $error = get_lang('ThereAreNoQuestionsForThisExercise');
671
+    // if we are in the case where user select random by category, but didn't choose the number of random question
672
+    if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
673
+        $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
674
+    }
675 675
 }
676 676
 
677 677
 if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
@@ -710,9 +710,9 @@  discard block
 block discarded – undo
710 710
 if (api_is_course_admin() && $origin != 'learnpath') {
711 711
     echo '<div class="actions">';
712 712
     if ($show_quiz_edition == false) {
713
-    	echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
713
+        echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
714 714
     } else {
715
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
715
+        echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
716 716
     }
717 717
     echo '</div>';
718 718
 }
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
756 756
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
757 757
             if ($origin != 'learnpath') {
758
-            	Display :: display_footer();
758
+                Display :: display_footer();
759 759
             }
760 760
             exit;
761 761
         } else {
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 if (isset($_custom['exercises_hidden_when_no_start_date']) &&
771 771
     $_custom['exercises_hidden_when_no_start_date']
772 772
 ) {
773
-	if (empty($objExercise->start_time)) {
773
+    if (empty($objExercise->start_time)) {
774 774
         Display:: display_warning_message(
775 775
             sprintf(
776 776
                 get_lang('ExerciseNoStartedYet'),
@@ -778,20 +778,20 @@  discard block
 block discarded – undo
778 778
                 $objExercise->selectAttempts()
779 779
             )
780 780
         );
781
-		if ($origin != 'learnpath') {
782
-			Display :: display_footer();
783
-		}
784
-	}
781
+        if ($origin != 'learnpath') {
782
+            Display :: display_footer();
783
+        }
784
+    }
785 785
 }
786 786
 
787 787
 //Timer control
788 788
 if ($time_control) {
789 789
     echo $objExercise->return_time_left_div();
790
-	echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
790
+    echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
791 791
 }
792 792
 
793 793
 if ($origin != 'learnpath') {
794
-   echo '<div id="highlight-plugin" class="glossary-content">';
794
+    echo '<div id="highlight-plugin" class="glossary-content">';
795 795
 }
796 796
 
797 797
 if ($reminder == 2)  {
@@ -803,53 +803,53 @@  discard block
 block discarded – undo
803 803
     $current_question = 1; //set by default the 1st question
804 804
 
805 805
     if (!empty($my_remind_list)) {
806
-    	//Checking which questions we are going to call from the remind list
807
-		for ($i = 0; $i < count($data_tracking); $i++) {
808
-			for($j = 0; $j < count($my_remind_list); $j++) {
809
-
810
-				if (!empty($remind_question_id)) {
811
-					if ($remind_question_id == $my_remind_list[$j]) {
812
-
813
-			        	if ($remind_question_id == $data_tracking[$i]) {
814
-			        		if (isset($my_remind_list[$j+1])) {
815
-			        			$remind_question_id = $my_remind_list[$j+1];
816
-			        			$current_question = $i + 1;
817
-			        		} else {
806
+        //Checking which questions we are going to call from the remind list
807
+        for ($i = 0; $i < count($data_tracking); $i++) {
808
+            for($j = 0; $j < count($my_remind_list); $j++) {
809
+
810
+                if (!empty($remind_question_id)) {
811
+                    if ($remind_question_id == $my_remind_list[$j]) {
812
+
813
+                        if ($remind_question_id == $data_tracking[$i]) {
814
+                            if (isset($my_remind_list[$j+1])) {
815
+                                $remind_question_id = $my_remind_list[$j+1];
816
+                                $current_question = $i + 1;
817
+                            } else {
818 818
                                 // We end the remind list we go to the exercise_reminder.php please
819
-			        			$remind_question_id = -1;
820
-			        			$current_question = $i + 1; // last question
821
-			        		}
822
-			        		break 2;
823
-			            }
824
-					}
825
-				} else {
826
-					if ($my_remind_list[$j] == $data_tracking[$i]) {
827
-						if (isset($my_remind_list[$j+1])) {
828
-							$remind_question_id = $my_remind_list[$j+1];
829
-							$current_question = $i + 1; // last question
830
-						} else {
819
+                                $remind_question_id = -1;
820
+                                $current_question = $i + 1; // last question
821
+                            }
822
+                            break 2;
823
+                        }
824
+                    }
825
+                } else {
826
+                    if ($my_remind_list[$j] == $data_tracking[$i]) {
827
+                        if (isset($my_remind_list[$j+1])) {
828
+                            $remind_question_id = $my_remind_list[$j+1];
829
+                            $current_question = $i + 1; // last question
830
+                        } else {
831 831
                             // We end the remind list we go to the exercise_reminder.php please
832
-							$remind_question_id = -1;
833
-							$current_question = $i + 1; // last question
834
-						}
835
-						break 2;
836
-					}
837
-				}
838
-			}
832
+                            $remind_question_id = -1;
833
+                            $current_question = $i + 1; // last question
834
+                        }
835
+                        break 2;
836
+                    }
837
+                }
838
+            }
839 839
         }
840 840
     } else {
841
-    	if ($objExercise->review_answers) {
841
+        if ($objExercise->review_answers) {
842 842
             if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
843
-	    	header("Location: exercise_reminder.php?$params");
844
-	    	exit;
845
-    	}
843
+            header("Location: exercise_reminder.php?$params");
844
+            exit;
845
+        }
846 846
     }
847 847
 }
848 848
 
849 849
 if ($objExercise->review_answers) {
850
-	$script_php = 'exercise_reminder.php';
850
+    $script_php = 'exercise_reminder.php';
851 851
 } else {
852
-	$script_php = 'exercise_result.php';
852
+    $script_php = 'exercise_result.php';
853 853
 }
854 854
 
855 855
 if (!empty($error)) {
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
          <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1090 1090
          <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1091 1091
 
1092
-	// Show list of questions
1092
+    // Show list of questions
1093 1093
     $i = 1;
1094 1094
     $attempt_list = array();
1095 1095
     if (isset($exe_id)) {
@@ -1149,10 +1149,10 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
         $attributes = array('id' =>'remind_list['.$questionId.']');
1151 1151
         if (in_array($questionId, $remind_list)) {
1152
-        	$is_remind_on = true;
1153
-        	$attributes['checked'] = 1;
1154
-        	$remind_question = true;
1155
-        	$remind_highlight = ' remind_highlight ';
1152
+            $is_remind_on = true;
1153
+            $attributes['checked'] = 1;
1154
+            $remind_question = true;
1155
+            $remind_highlight = ' remind_highlight ';
1156 1156
         }
1157 1157
 
1158 1158
         // Showing the exercise description
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
     }
1227 1227
     // end foreach()
1228 1228
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1229
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1230
-    	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1229
+        $exercise_actions =  $objExercise->show_button($questionId, $current_question);
1230
+        echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1231 1231
         echo '<br>';
1232 1232
     }
1233 1233
     echo '</form>';
Please login to merge, or discard this patch.
main/exercise/exercise_result.class.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 */
10 10
 class ExerciseResult
11 11
 {
12
-	private $results = array();
12
+    private $results = array();
13 13
     public $includeAllUsers = false;
14 14
     public $onlyBestAttempts = false;
15 15
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $exercise_id = 0,
47 47
         $hotpotato_name = null
48 48
     ) {
49
-		$return = array();
49
+        $return = array();
50 50
 
51 51
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
52 52
         $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
             $session_id_and .= " AND exe_exo_id = $exercise_id ";
67 67
         }
68 68
 
69
-		if (empty($user_id)) {
69
+        if (empty($user_id)) {
70 70
             $user_id_and = null;
71
-			$sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
71
+            $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
72 72
 			            official_code,
73 73
                         ce.title as extitle,
74 74
                         te.exe_result as exresult ,
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
                     te.status != 'incomplete' AND
92 92
                     te.c_id = ce.c_id $user_id_and  $session_id_and AND
93 93
                     ce.active <>-1";
94
-		} else {
94
+        } else {
95 95
             $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
96
-			// get only this user's results
96
+            // get only this user's results
97 97
             $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
98 98
                     official_code,
99 99
                     ce.title as extitle,
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
                         te.c_id = ce.c_id $user_id_and $session_id_and AND
120 120
                         ce.active <>-1 AND
121 121
                     ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
122
-		}
122
+        }
123 123
 
124
-		$results = array();
125
-		$resx = Database::query($sql);
124
+        $results = array();
125
+        $resx = Database::query($sql);
126 126
         $bestAttemptPerUser = array();
127
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
127
+        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
128 128
             if ($this->onlyBestAttempts) {
129 129
                 if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
130 130
                     $bestAttemptPerUser[$rowx['excruid']] = $rowx;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             } else {
137 137
                 $results[] = $rowx;
138 138
             }
139
-		}
139
+        }
140 140
 
141 141
         if ($this->onlyBestAttempts) {
142 142
             $results = $bestAttemptPerUser;
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
                     continue;
191 191
                 }
192 192
 
193
-				$return[$i] = array();
194
-				if (empty($user_id)) {
193
+                $return[$i] = array();
194
+                if (empty($user_id)) {
195 195
                     $return[$i]['official_code']   = $result['official_code'];
196 196
                     if (api_is_western_name_order()) {
197 197
                         $return[$i]['first_name']   = $results[$i]['userpart1'];
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
                         $return[$i]['first_name']   = $results[$i]['userpart2'];
201 201
                         $return[$i]['last_name']    = $results[$i]['userpart1'];
202 202
                     }
203
-					$return[$i]['user_id']      = $results[$i]['excruid'];
204
-					$return[$i]['email']        = $results[$i]['exemail'];
205
-				}
206
-				$return[$i]['title'] = $result['extitle'];
207
-				$return[$i]['start_date'] = api_get_local_time($result['exstart']);
203
+                    $return[$i]['user_id']      = $results[$i]['excruid'];
204
+                    $return[$i]['email']        = $results[$i]['exemail'];
205
+                }
206
+                $return[$i]['title'] = $result['extitle'];
207
+                $return[$i]['start_date'] = api_get_local_time($result['exstart']);
208 208
                 $return[$i]['end_date'] = api_get_local_time($result['exdate']);
209 209
                 $return[$i]['duration'] = $result['duration'];
210
-				$return[$i]['result'] = $result['exresult'];
211
-				$return[$i]['max'] = $result['exweight'];
210
+                $return[$i]['result'] = $result['exresult'];
211
+                $return[$i]['max'] = $result['exweight'];
212 212
                 $return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
213 213
                 $return[$i]['lp_id'] = $result['orig_lp_id'];
214 214
                 $return[$i]['lp_name'] = $result['lp_name'];
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 
222 222
                 $userWithResults[$result['excruid']] = 1;
223 223
                 $i++;
224
-			}
225
-		}
224
+            }
225
+        }
226 226
 
227 227
         if ($this->includeAllUsers) {
228 228
             $latestId = count($return);
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
             }
266 266
         }
267 267
 
268
-		$this->results = $return;
268
+        $this->results = $return;
269 269
 
270
-		return true;
271
-	}
270
+        return true;
271
+    }
272 272
 
273
-	/**
274
-	 * Exports the complete report as a CSV file
275
-	 * @param	string		Document path inside the document tool
276
-	 * @param	integer		Optional user ID
277
-	 * @param	boolean		Whether to include user fields or not
278
-	 * @return	boolean		False on error
279
-	 */
273
+    /**
274
+     * Exports the complete report as a CSV file
275
+     * @param	string		Document path inside the document tool
276
+     * @param	integer		Optional user ID
277
+     * @param	boolean		Whether to include user fields or not
278
+     * @return	boolean		False on error
279
+     */
280 280
     public function exportCompleteReportCSV(
281 281
         $document_path = '',
282 282
         $user_id = null,
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $exercise_id = 0,
286 286
         $hotpotato_name = null
287 287
     ) {
288
-		global $charset;
289
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
-
291
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
292
-		if(!empty($user_id)) {
293
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
-		}
295
-		$data = '';
288
+        global $charset;
289
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
+
291
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
292
+        if(!empty($user_id)) {
293
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
+        }
295
+        $data = '';
296 296
         if (api_is_western_name_order()) {
297 297
             if(!empty($this->results[0]['first_name'])) {
298 298
                 $data .= get_lang('FirstName').';';
@@ -316,28 +316,28 @@  discard block
 block discarded – undo
316 316
         $data .= get_lang('Email').';';
317 317
         $data .= get_lang('Groups').';';
318 318
 
319
-		if ($export_user_fields) {
320
-			//show user fields section with a big th colspan that spans over all fields
321
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
-			$num = count($extra_user_fields);
323
-			foreach($extra_user_fields as $field) {
324
-				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
-			}
326
-		}
327
-
328
-		$data .= get_lang('Title').';';
329
-		$data .= get_lang('StartDate').';';
319
+        if ($export_user_fields) {
320
+            //show user fields section with a big th colspan that spans over all fields
321
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
+            $num = count($extra_user_fields);
323
+            foreach($extra_user_fields as $field) {
324
+                $data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
+            }
326
+        }
327
+
328
+        $data .= get_lang('Title').';';
329
+        $data .= get_lang('StartDate').';';
330 330
         $data .= get_lang('EndDate').';';
331 331
         $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
332
-		$data .= get_lang('Score').';';
333
-		$data .= get_lang('Total').';';
332
+        $data .= get_lang('Score').';';
333
+        $data .= get_lang('Total').';';
334 334
         $data .= get_lang('Status').';';
335 335
         $data .= get_lang('ToolLearnpath').';';
336 336
         $data .= get_lang('UserIsCurrentlySubscribed').';';
337
-		$data .= "\n";
337
+        $data .= "\n";
338 338
 
339
-		//results
340
-		foreach ($this->results as $row) {
339
+        //results
340
+        foreach ($this->results as $row) {
341 341
 
342 342
             if (api_is_western_name_order()) {
343 343
                 $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
@@ -354,51 +354,51 @@  discard block
 block discarded – undo
354 354
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355 355
             $data .= str_replace("\r\n",'  ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
356 356
 
357
-			if ($export_user_fields) {
358
-				//show user fields data, if any, for this user
359
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
-				foreach($user_fields_values as $value) {
361
-					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
-				}
363
-			}
357
+            if ($export_user_fields) {
358
+                //show user fields data, if any, for this user
359
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
+                foreach($user_fields_values as $value) {
361
+                    $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
+                }
363
+            }
364 364
 
365
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
-			$data .= str_replace("\r\n",'  ',$row['start_date']).';';
365
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
+            $data .= str_replace("\r\n",'  ',$row['start_date']).';';
367 367
             $data .= str_replace("\r\n",'  ',$row['end_date']).';';
368 368
             $data .= str_replace("\r\n",'  ',$row['duration']).';';
369
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
370
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
369
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
370
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
371 371
             $data .= str_replace("\r\n",'  ',$row['status']).';';
372 372
             $data .= str_replace("\r\n",'  ',$row['lp_name']).';';
373 373
             $data .= str_replace("\r\n",'  ',$row['is_user_subscribed']).';';
374
-			$data .= "\n";
375
-		}
376
-
377
-		//output the results
378
-		$len = strlen($data);
379
-		header('Content-type: application/octet-stream');
380
-		header('Content-Type: application/force-download');
381
-		header('Content-length: '.$len);
382
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
-			header('Content-Disposition: filename= '.$filename);
384
-		} else {
385
-			header('Content-Disposition: attachment; filename= '.$filename);
386
-		}
387
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
-			header('Pragma: ');
389
-			header('Cache-Control: ');
390
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
-		}
392
-		header('Content-Description: '.$filename);
393
-		header('Content-transfer-encoding: binary');
394
-		echo $data;
395
-		return true;
396
-	}
397
-
398
-	/**
399
-	 * Exports the complete report as an XLS file
400
-	 * @return	boolean		False on error
401
-	 */
374
+            $data .= "\n";
375
+        }
376
+
377
+        //output the results
378
+        $len = strlen($data);
379
+        header('Content-type: application/octet-stream');
380
+        header('Content-Type: application/force-download');
381
+        header('Content-length: '.$len);
382
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
+            header('Content-Disposition: filename= '.$filename);
384
+        } else {
385
+            header('Content-Disposition: attachment; filename= '.$filename);
386
+        }
387
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
+            header('Pragma: ');
389
+            header('Cache-Control: ');
390
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
+        }
392
+        header('Content-Description: '.$filename);
393
+        header('Content-transfer-encoding: binary');
394
+        echo $data;
395
+        return true;
396
+    }
397
+
398
+    /**
399
+     * Exports the complete report as an XLS file
400
+     * @return	boolean		False on error
401
+     */
402 402
     public function exportCompleteReportXLS(
403 403
         $document_path = '',
404 404
         $user_id = null,
@@ -407,35 +407,35 @@  discard block
 block discarded – undo
407 407
         $exercise_id = 0,
408 408
         $hotpotato_name = null
409 409
     ) {
410
-		global $charset;
411
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
413
-		if (!empty($user_id)) {
414
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
-		}
410
+        global $charset;
411
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
413
+        if (!empty($user_id)) {
414
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
+        }
416 416
 
417 417
         $spreadsheet = new PHPExcel();
418 418
         $spreadsheet->setActiveSheetIndex(0);
419 419
         $worksheet = $spreadsheet->getActiveSheet();
420 420
 
421
-		$line = 0;
422
-		$column = 0; //skip the first column (row titles)
421
+        $line = 0;
422
+        $column = 0; //skip the first column (row titles)
423 423
 
424
-		// check if exists column 'user'
425
-		$with_column_user = false;
426
-		foreach ($this->results as $result) {
427
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
-				$with_column_user = true;
429
-				break;
430
-			}
431
-		}
424
+        // check if exists column 'user'
425
+        $with_column_user = false;
426
+        foreach ($this->results as $result) {
427
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
+                $with_column_user = true;
429
+                break;
430
+            }
431
+        }
432 432
 
433 433
         $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
434 434
 
435
-		if ($with_column_user) {
435
+        if ($with_column_user) {
436 436
             if (api_is_western_name_order()) {
437
-    			$worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName'));
438
-    			$column++;
437
+                $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName'));
438
+                $column++;
439 439
                 $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('LastName'));
440 440
                 $column++;
441 441
             } else {
@@ -451,43 +451,43 @@  discard block
 block discarded – undo
451 451
             }
452 452
 
453 453
             $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email'));
454
-		    $column++;
455
-		}
454
+            $column++;
455
+        }
456 456
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Groups'));
457
-	    $column++;
458
-
459
-		if ($export_user_fields) {
460
-			//show user fields section with a big th colspan that spans over all fields
461
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462
-
463
-			//show the fields names for user fields
464
-			foreach ($extra_user_fields as $field) {
465
-				$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
466
-				$column++;
467
-			}
468
-		}
469
-
470
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
471
-		$column++;
472
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
457
+        $column++;
458
+
459
+        if ($export_user_fields) {
460
+            //show user fields section with a big th colspan that spans over all fields
461
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462
+
463
+            //show the fields names for user fields
464
+            foreach ($extra_user_fields as $field) {
465
+                $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
466
+                $column++;
467
+            }
468
+        }
469
+
470
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
471
+        $column++;
472
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
473 473
         $column++;
474 474
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate'));
475 475
         $column++;
476 476
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
477
-		$column++;
478
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
479
-		$column++;
480
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
481
-		$column++;
477
+        $column++;
478
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
479
+        $column++;
480
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
481
+        $column++;
482 482
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status'));
483
-		$column++;
483
+        $column++;
484 484
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ToolLearnpath'));
485 485
         $column++;
486 486
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('UserIsCurrentlySubscribed'));
487
-		$line++;
487
+        $line++;
488 488
 
489
-		foreach ($this->results as $row) {
490
-			$column = 0;
489
+        foreach ($this->results as $row) {
490
+            $column = 0;
491 491
 
492 492
             if ($with_column_user) {
493 493
                 if (api_is_western_name_order()) {
@@ -509,22 +509,22 @@  discard block
 block discarded – undo
509 509
 
510 510
                 $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
511 511
                 $column++;
512
-			}
512
+            }
513 513
 
514 514
             $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
515 515
             $column++;
516 516
 
517
-			if ($export_user_fields) {
518
-				//show user fields data, if any, for this user
519
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
520
-				foreach($user_fields_values as $value) {
521
-					$worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
522
-					$column++;
523
-				}
524
-			}
525
-
526
-			$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
527
-			$column++;
517
+            if ($export_user_fields) {
518
+                //show user fields data, if any, for this user
519
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
520
+                foreach($user_fields_values as $value) {
521
+                    $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
522
+                    $column++;
523
+                }
524
+            }
525
+
526
+            $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
527
+            $column++;
528 528
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']);
529 529
             $column++;
530 530
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']);
@@ -540,14 +540,14 @@  discard block
 block discarded – undo
540 540
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['lp_name']);
541 541
             $column++;
542 542
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['is_user_subscribed']);
543
-			$line++;
544
-		}
543
+            $line++;
544
+        }
545 545
 
546 546
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
547 547
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
548 548
         $writer->save($file);
549 549
         DocumentManager::file_send_for_download($file, true, $filename);
550 550
 
551
-		return true;
552
-	}
551
+        return true;
552
+    }
553 553
 }
Please login to merge, or discard this patch.
main/exercise/hotspot_actionscript.as.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
 // Query db for answers
32 32
 if ($answer_type==HOT_SPOT_DELINEATION) {
33
-	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
33
+    $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
34 34
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY id";
35 35
 } else {
36
-	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
36
+    $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
37 37
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id";
38 38
 }
39 39
 $result = Database::query($sql);
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     $hotSpot['id'] = $hotspot['id'];
75 75
     $hotSpot['answer'] = $hotspot['answer'];
76 76
 
77
-	// Square or rectancle
78
-	if ($hotspot['hotspot_type'] == 'square' )
79
-	{
77
+    // Square or rectancle
78
+    if ($hotspot['hotspot_type'] == 'square' )
79
+    {
80 80
         $hotSpot['type'] = 'square';
81
-	}
82
-	// Circle or ovale
83
-	if ($hotspot['hotspot_type'] == 'circle')
84
-	{
81
+    }
82
+    // Circle or ovale
83
+    if ($hotspot['hotspot_type'] == 'circle')
84
+    {
85 85
         $hotSpot['type'] = 'circle';
86
-	}
87
-	// Polygon
88
-	if ($hotspot['hotspot_type'] == 'poly')
89
-	{
86
+    }
87
+    // Polygon
88
+    if ($hotspot['hotspot_type'] == 'poly')
89
+    {
90 90
         $hotSpot['type'] = 'poly';
91
-	}
92
-	// Delineation
93
-	if ($hotspot['hotspot_type'] == 'delineation')
94
-	{
91
+    }
92
+    // Delineation
93
+    if ($hotspot['hotspot_type'] == 'delineation')
94
+    {
95 95
         $hotSpot['type'] = 'delineation';
96
-	}
97
-	// No error
98
-	if ($hotspot['hotspot_type'] == 'noerror')
99
-	{
96
+    }
97
+    // No error
98
+    if ($hotspot['hotspot_type'] == 'noerror')
99
+    {
100 100
         $hotSpot['type'] = 'noerror';
101
-	}
101
+    }
102 102
 
103
-	// This is a good answer, count + 1 for nmbr of clicks
104
-	if ($hotspot['hotspot_type'] > 0)
105
-	{
106
-		$nmbrTries++;
107
-	}
103
+    // This is a good answer, count + 1 for nmbr of clicks
104
+    if ($hotspot['hotspot_type'] > 0)
105
+    {
106
+        $nmbrTries++;
107
+    }
108 108
 
109 109
     $hotSpot['coord'] = $hotspot['hotspot_coordinates'];
110 110
 
Please login to merge, or discard this patch.
main/lp/lp_move_item.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@
 block discarded – undo
47 47
 " .
48 48
 "\n" .
49 49
 '$().ready(function() {'."\n" .
50
-  'if ($(\'#previous\')) {'."\n" .
50
+    'if ($(\'#previous\')) {'."\n" .
51 51
     'if(\'parent is\'+$(\'#idParent\').val()) {'.
52
-      'load_cbo($(\'#idParent\').val());'."\n" .
53
-  '}}'."\n" .
52
+        'load_cbo($(\'#idParent\').val());'."\n" .
53
+    '}}'."\n" .
54 54
 '});</script>'."\n" ;
55 55
 
56 56
 /* Constants and variables */
Please login to merge, or discard this patch.
main/lp/lp_build.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
 // Using the resource linker as a tool for adding resources to the learning path.
37 37
 if ($action=="add" and $type=="learnpathitem") {
38
-     $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
38
+        $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
39 39
 }
40 40
 if ((!$is_allowed_to_edit) || ($isStudentView)) {
41 41
     error_log('New LP - User not authorized in lp_build.php');
Please login to merge, or discard this patch.
main/lp/lp_ajax_save_item.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -458,7 +458,7 @@
 block discarded – undo
458 458
     }
459 459
 
460 460
     if ($myLP->get_type() == 2) {
461
-         $return .= "update_stats();";
461
+            $return .= "update_stats();";
462 462
     }
463 463
 
464 464
     // To be sure progress is updated.
Please login to merge, or discard this patch.
main/lp/scorm_api.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -458,8 +458,8 @@
 block discarded – undo
458 458
     } else if(param == 'cmi.core.student_name'){
459 459
         // ---- cmi.core.student_name
460 460
         <?php
461
-          $who = addslashes($user['complete_name']);
462
-          echo "result='$who';";
461
+            $who = addslashes($user['complete_name']);
462
+            echo "result='$who';";
463 463
         ?>
464 464
     } else if(param == 'cmi.core.lesson_location'){
465 465
         // ---- cmi.core.lesson_location
Please login to merge, or discard this patch.
main/lp/content_makers.inc.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
     'Accent',
14 14
     'Accenture',
15 15
     'ADLNet',
16
-      'Articulate',
17
-      'ATutor',
18
-      'Blackboard',
19
-      'Calfat',
20
-      'Captivate',
16
+        'Articulate',
17
+        'ATutor',
18
+        'Blackboard',
19
+        'Calfat',
20
+        'Captivate',
21 21
     'Chamilo',
22 22
     'Chamilo 2',
23 23
     'Claroline',
Please login to merge, or discard this patch.