Completed
Push — 1.10.x ( 52e3a4...954719 )
by
unknown
48:07
created
main/exercice/exercise_submit.php 3 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     if (!$objExercise->read($exerciseId) ||
117 117
         (!$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath')
118 118
     ) {
119
-    	if ($debug) {error_log('1.1. Error while reading the exercise'); };
119
+        if ($debug) {error_log('1.1. Error while reading the exercise'); };
120 120
         unset ($objExercise);
121 121
         $error = get_lang('ExerciseNotFound');
122 122
     } else {
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 }
130 130
 //2. Checking if $objExercise is set
131 131
 if (!isset($objExercise) && isset($exerciseInSession)) {
132
-	if ($debug) { error_log('2. Loading $objExercise from session'); };
132
+    if ($debug) { error_log('2. Loading $objExercise from session'); };
133 133
     $objExercise = $exerciseInSession;
134 134
 }
135 135
 
136 136
 //3. $objExercise is not set, then return to the exercise list
137 137
 if (!is_object($objExercise)) {
138
-	if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
138
+    if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
139 139
     header('Location: exercise.php');
140 140
     exit;
141 141
 }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 $time_control = false;
158 158
 if ($objExercise->expired_time != 0) {
159
-	$time_control = true;
159
+    $time_control = true;
160 160
 }
161 161
 
162 162
 // Generating the time control key for the user
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
166 166
 
167 167
 if ($time_control) {
168
-	// Get the expired time of the current exercise in track_e_exercises
169
-	$total_seconds = $objExercise->expired_time*60;
168
+    // Get the expired time of the current exercise in track_e_exercises
169
+    $total_seconds = $objExercise->expired_time*60;
170 170
 }
171 171
 
172 172
 $show_clock = true;
173 173
 $user_id = api_get_user_id();
174 174
 if ($objExercise->selectAttempts() > 0) {
175
-	$attempt_html = '';
175
+    $attempt_html = '';
176 176
     $attempt_count = Event::get_attempt_count(
177 177
         $user_id,
178 178
         $exerciseId,
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
         $learnpath_item_view_id
182 182
     );
183 183
 
184
-	if ($attempt_count >= $objExercise->selectAttempts()) {
185
-		$show_clock = false;
186
-		if (!api_is_allowed_to_edit(null,true)) {
184
+    if ($attempt_count >= $objExercise->selectAttempts()) {
185
+        $show_clock = false;
186
+        if (!api_is_allowed_to_edit(null,true)) {
187 187
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
188 188
 
189 189
                 // Showing latest attempt according with task BT#1628
@@ -222,31 +222,31 @@  discard block
 block discarded – undo
222 222
                             $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore'));
223 223
                         }
224 224
                     }
225
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
226
-					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
227
-				} else {
228
-					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
229
-				}
230
-			} else {
231
-				$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
232
-			}
233
-		} else {
234
-			$attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
235
-		}
225
+                    $score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
226
+                    $attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
227
+                } else {
228
+                    $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
229
+                }
230
+            } else {
231
+                $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
232
+            }
233
+        } else {
234
+            $attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
235
+        }
236 236
 
237
-		if ($origin == 'learnpath') {
238
-			Display :: display_reduced_header();
239
-		} else {
240
-			Display :: display_header(get_lang('Exercises'));
241
-		}
237
+        if ($origin == 'learnpath') {
238
+            Display :: display_reduced_header();
239
+        } else {
240
+            Display :: display_header(get_lang('Exercises'));
241
+        }
242 242
 
243
-		echo $attempt_html;
243
+        echo $attempt_html;
244 244
 
245 245
         if ($origin != 'learnpath') {
246 246
             Display:: display_footer();
247 247
         }
248
-		exit;
249
-	}
248
+        exit;
249
+    }
250 250
 }
251 251
 
252 252
 if ($debug) {
@@ -270,26 +270,26 @@  discard block
 block discarded – undo
270 270
 
271 271
 if (empty($exercise_stat_info)) {
272 272
     if ($debug)  error_log('5  $exercise_stat_info is empty ');
273
-	$total_weight = 0;
274
-	$questionList = $objExercise->get_validated_question_list();
275
-	foreach ($questionListUncompressed as $question_id) {
276
-		$objQuestionTmp = Question::read($question_id);
277
-		$total_weight += floatval($objQuestionTmp->weighting);
278
-	}
273
+    $total_weight = 0;
274
+    $questionList = $objExercise->get_validated_question_list();
275
+    foreach ($questionListUncompressed as $question_id) {
276
+        $objQuestionTmp = Question::read($question_id);
277
+        $total_weight += floatval($objQuestionTmp->weighting);
278
+    }
279 279
 
280
-	if ($time_control) {
281
-		$expected_time = $current_timestamp + $total_seconds;
280
+    if ($time_control) {
281
+        $expected_time = $current_timestamp + $total_seconds;
282 282
 
283
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
284
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
283
+        if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
284
+        if ($debug)  error_log('5.2. $expected_time '.$expected_time);
285 285
 
286
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
287
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
286
+        $clock_expired_time 	= api_get_utc_datetime($expected_time);
287
+        if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
288 288
 
289
-		//Sessions  that contain the expired time
290
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
291
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
292
-	}
289
+        //Sessions  that contain the expired time
290
+        $_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
291
+        if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
292
+    }
293 293
 
294 294
     $exe_id = $objExercise->save_stat_track_exercise_info(
295 295
         $clock_expired_time,
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     );
307 307
     if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
308 308
 } else {
309
-	$exe_id = $exercise_stat_info['exe_id'];
309
+    $exe_id = $exercise_stat_info['exe_id'];
310 310
     // Remember last question id position.
311 311
     $isFirstTime = Session::read('firstTime');
312 312
     if ($isFirstTime && $objExercise->type == ONE_PER_PAGE) {
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
366 366
 
367 367
 if (!empty($exercise_stat_info['questions_to_check'])) {
368
-	$my_remind_list = $exercise_stat_info['questions_to_check'];
369
-	$my_remind_list = explode(',', $my_remind_list);
370
-	$my_remind_list = array_filter($my_remind_list);
368
+    $my_remind_list = $exercise_stat_info['questions_to_check'];
369
+    $my_remind_list = explode(',', $my_remind_list);
370
+    $my_remind_list = array_filter($my_remind_list);
371 371
 }
372 372
 
373 373
 $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();
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 
376 376
 if ($reminder == 2 && empty($my_remind_list)) {
377 377
     if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
378
-	header('Location: exercise_reminder.php?'.$params);
379
-	exit;
378
+    header('Location: exercise_reminder.php?'.$params);
379
+    exit;
380 380
 }
381 381
 
382 382
 /*
@@ -384,56 +384,56 @@  discard block
 block discarded – undo
384 384
  * If the expired time is major that zero(0) then the expired time is compute on this time.
385 385
  */
386 386
 if ($time_control) {
387
-	if ($debug) error_log('7.1. Time control is enabled');
388
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
389
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
387
+    if ($debug) error_log('7.1. Time control is enabled');
388
+    if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
389
+    if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
390 390
 
391 391
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
392 392
         //Timer - Get expired_time for a student
393 393
         if (!empty($exercise_stat_info)) {
394
-        	if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
395
-	        $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
396
-			if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
397
-	        // Get the last attempt of an exercise
398
-	    	$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
394
+            if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
395
+            $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
396
+            if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
397
+            // Get the last attempt of an exercise
398
+            $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
399 399
 
400
-	    	/* This means that the user enters the exam but do not answer the
400
+            /* This means that the user enters the exam but do not answer the
401 401
 	    	   first question we get the date from the track_e_exercises not from
402 402
 	    	   the track_et_attempt see #2069 */
403
-	    	if (empty($last_attempt_date)) {
404
-	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
405
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
406
-	    	} else {
407
-	    		//Recalculate the time control due #2069
408
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
409
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
410
-	    	}
411
-	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
412
-
413
-	        //New expired time - it is due to the possible closure of session
414
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
415
-	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
416
-
417
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
418
-	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
419
-
420
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
421
-	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
422
-
423
-			// First we update the attempt to today
424
-			/* How the expired time is changed into "track_e_exercises" table,
403
+            if (empty($last_attempt_date)) {
404
+                $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
405
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
406
+            } else {
407
+                //Recalculate the time control due #2069
408
+                $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
409
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
410
+            }
411
+            if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
412
+
413
+            //New expired time - it is due to the possible closure of session
414
+            $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
415
+            if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
416
+
417
+            $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
418
+            if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
419
+
420
+            $clock_expired_time  = api_get_utc_datetime($expected_time);
421
+            if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
422
+
423
+            // First we update the attempt to today
424
+            /* How the expired time is changed into "track_e_exercises" table,
425 425
                then the last attempt for this student should be changed too */
426
-	        $sql = "UPDATE $exercise_attempt_table SET
426
+            $sql = "UPDATE $exercise_attempt_table SET
427 427
 	                tms = '".api_get_utc_datetime()."'
428 428
 	                WHERE
429 429
 	                    exe_id = '".$exercise_stat_info['exe_id']."' AND
430 430
 	                    tms = '".$last_attempt_date."' ";
431
-	        if ($debug) {error_log('7.10. $sql: '.$sql); }
432
-	        Database::query($sql);
431
+            if ($debug) {error_log('7.10. $sql: '.$sql); }
432
+            Database::query($sql);
433 433
 
434
-	        //Sessions  that contain the expired time
435
-	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
436
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
434
+            //Sessions  that contain the expired time
435
+            $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
436
+            if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
437 437
         }
438 438
     } else {
439 439
         $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
  * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock
451 451
  */
452 452
 if ($time_control) { //Sends the exercise form when the expired time is finished
453
-	$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
453
+    $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
454 454
 }
455 455
 
456 456
 // if the user has submitted the form
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
     // selects the list of question ID
464 464
     $questionList = $objExercise->get_validated_question_list();
465 465
     if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) {
466
-    	$questionList = explode(',', $exercise_stat_info['data_tracking']);
466
+        $questionList = explode(',', $exercise_stat_info['data_tracking']);
467 467
     }
468 468
     Session::write('questionList', $questionList);
469 469
     if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
470 470
 } else {
471
-	if (isset($objExercise) && isset($_SESSION['objExercise'])) {
472
-    	$questionList = $_SESSION['questionList'];
473
-	}
471
+    if (isset($objExercise) && isset($_SESSION['objExercise'])) {
472
+        $questionList = $_SESSION['questionList'];
473
+    }
474 474
 }
475 475
 
476 476
 if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 //Real question count
479 479
 $question_count = 0;
480 480
 if (!empty($questionList)) {
481
-	$question_count = count($questionList);
481
+    $question_count = count($questionList);
482 482
 }
483 483
 
484 484
 if ($formSent && isset($_POST)) {
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
                 //saving each question
521 521
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
522 522
                     $nro_question = $current_question; // - 1;
523
-                 	$questionId   = $key;
523
+                        $questionId   = $key;
524 524
                     // gets the student choice for this question
525 525
                     $choice = $exerciseResult[$questionId];
526 526
                     if (isset($exe_id)) {
527
-                    	// Manage the question and answer attempts
527
+                        // Manage the question and answer attempts
528 528
                         if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
529 529
                         $objExercise->manage_answer(
530 530
                             $exe_id,
@@ -613,58 +613,58 @@  discard block
 block discarded – undo
613 613
 }
614 614
 
615 615
 if ($question_count != 0) {
616
-	if (($objExercise->type == ALL_ON_ONE_PAGE ||
616
+    if (($objExercise->type == ALL_ON_ONE_PAGE ||
617 617
         $current_question > $question_count)
618 618
     ) {
619
-	    if (api_is_allowed_to_session_edit()) {
620
-	        // goes to the script that will show the result of the exercise
621
-	        if ($objExercise->type == ALL_ON_ONE_PAGE) {
622
-	            if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
623
-
624
-	            //We check if the user attempts before sending to the exercise_result.php
625
-	            if ($objExercise->selectAttempts() > 0) {
626
-	                $attempt_count = Event::get_attempt_count(
619
+        if (api_is_allowed_to_session_edit()) {
620
+            // goes to the script that will show the result of the exercise
621
+            if ($objExercise->type == ALL_ON_ONE_PAGE) {
622
+                if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
623
+
624
+                //We check if the user attempts before sending to the exercise_result.php
625
+                if ($objExercise->selectAttempts() > 0) {
626
+                    $attempt_count = Event::get_attempt_count(
627 627
                         api_get_user_id(),
628 628
                         $exerciseId,
629 629
                         $learnpath_id,
630 630
                         $learnpath_item_id,
631 631
                         $learnpath_item_view_id
632 632
                     );
633
-	                if ($attempt_count >= $objExercise->selectAttempts()) {
634
-	                    Display :: display_warning_message(
633
+                    if ($attempt_count >= $objExercise->selectAttempts()) {
634
+                        Display :: display_warning_message(
635 635
                             sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
636 636
                             false
637 637
                         );
638
-	                    if ($origin != 'learnpath') {
639
-	                        //so we are not in learnpath tool
640
-	                        echo '</div>'; //End glossary div
641
-	                        Display :: display_footer();
642
-	                    } else {
643
-	                        echo '</body></html>';
644
-	                    }
645
-	                    exit;
646
-	                }
647
-	            }
648
-	        } else {
649
-	            if ($objExercise->review_answers) {
650
-	            	header('Location: exercise_reminder.php?'.$params);
651
-	            	exit;
652
-	            } else {
638
+                        if ($origin != 'learnpath') {
639
+                            //so we are not in learnpath tool
640
+                            echo '</div>'; //End glossary div
641
+                            Display :: display_footer();
642
+                        } else {
643
+                            echo '</body></html>';
644
+                        }
645
+                        exit;
646
+                    }
647
+                }
648
+            } else {
649
+                if ($objExercise->review_answers) {
650
+                    header('Location: exercise_reminder.php?'.$params);
651
+                    exit;
652
+                } else {
653 653
                     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");
654 654
                     exit;
655
-	            }
656
-	        }
657
-	    } else {
658
-	        if ($debug) { error_log('Redirecting to exercise_submit.php'); }
659
-	        exit;
660
-	    }
661
-	}
655
+                }
656
+            }
657
+        } else {
658
+            if ($debug) { error_log('Redirecting to exercise_submit.php'); }
659
+            exit;
660
+        }
661
+    }
662 662
 } else {
663
-	$error = get_lang('ThereAreNoQuestionsForThisExercise');
664
-	// if we are in the case where user select random by category, but didn't choose the number of random question
665
-	if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
666
-		$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
667
-	}
663
+    $error = get_lang('ThereAreNoQuestionsForThisExercise');
664
+    // if we are in the case where user select random by category, but didn't choose the number of random question
665
+    if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
666
+        $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
667
+    }
668 668
 }
669 669
 
670 670
 if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
 if (api_is_course_admin() && $origin != 'learnpath') {
704 704
     echo '<div class="actions">';
705 705
     if ($show_quiz_edition == false) {
706
-    	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>';
706
+        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>';
707 707
     } else {
708
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
708
+        echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
709 709
     }
710 710
     echo '</div>';
711 711
 }
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
749 749
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
750 750
             if ($origin != 'learnpath') {
751
-            	Display :: display_footer();
751
+                Display :: display_footer();
752 752
             }
753 753
             exit;
754 754
         } else {
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 if (isset($_custom['exercises_hidden_when_no_start_date']) &&
764 764
     $_custom['exercises_hidden_when_no_start_date']
765 765
 ) {
766
-	if (empty($objExercise->start_time) || $objExercise->start_time == '0000-00-00 00:00:00') {
766
+    if (empty($objExercise->start_time) || $objExercise->start_time == '0000-00-00 00:00:00') {
767 767
         Display:: display_warning_message(
768 768
             sprintf(
769 769
                 get_lang('ExerciseNoStartedYet'),
@@ -771,20 +771,20 @@  discard block
 block discarded – undo
771 771
                 $objExercise->selectAttempts()
772 772
             )
773 773
         );
774
-		if ($origin != 'learnpath') {
775
-			Display :: display_footer();
776
-		}
777
-	}
774
+        if ($origin != 'learnpath') {
775
+            Display :: display_footer();
776
+        }
777
+    }
778 778
 }
779 779
 
780 780
 //Timer control
781 781
 if ($time_control) {
782 782
     echo $objExercise->return_time_left_div();
783
-	echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
783
+    echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
784 784
 }
785 785
 
786 786
 if ($origin != 'learnpath') {
787
-   echo '<div id="highlight-plugin" class="glossary-content">';
787
+    echo '<div id="highlight-plugin" class="glossary-content">';
788 788
 }
789 789
 
790 790
 if ($reminder == 2)  {
@@ -796,53 +796,53 @@  discard block
 block discarded – undo
796 796
     $current_question = 1; //set by default the 1st question
797 797
 
798 798
     if (!empty($my_remind_list)) {
799
-    	// Checking which questions we are going to call from the remind list
800
-		for ($i = 0; $i < count($data_tracking); $i++) {
801
-			for($j = 0; $j < count($my_remind_list); $j++) {
802
-
803
-				if (!empty($remind_question_id)) {
804
-					if ($remind_question_id == $my_remind_list[$j]) {
805
-
806
-			        	if ($remind_question_id == $data_tracking[$i]) {
807
-			        		if (isset($my_remind_list[$j+1])) {
808
-			        			$remind_question_id = $my_remind_list[$j+1];
809
-			        			$current_question = $i + 1;
810
-			        		} else {
799
+        // Checking which questions we are going to call from the remind list
800
+        for ($i = 0; $i < count($data_tracking); $i++) {
801
+            for($j = 0; $j < count($my_remind_list); $j++) {
802
+
803
+                if (!empty($remind_question_id)) {
804
+                    if ($remind_question_id == $my_remind_list[$j]) {
805
+
806
+                        if ($remind_question_id == $data_tracking[$i]) {
807
+                            if (isset($my_remind_list[$j+1])) {
808
+                                $remind_question_id = $my_remind_list[$j+1];
809
+                                $current_question = $i + 1;
810
+                            } else {
811 811
                                 // We end the remind list we go to the exercise_reminder.php please
812
-			        			$remind_question_id = -1;
813
-			        			$current_question = $i + 1; // last question
814
-			        		}
815
-			        		break 2;
816
-			            }
817
-					}
818
-				} else {
819
-					if ($my_remind_list[$j] == $data_tracking[$i]) {
820
-						if (isset($my_remind_list[$j+1])) {
821
-							$remind_question_id = $my_remind_list[$j+1];
822
-							$current_question = $i + 1; // last question
823
-						} else {
812
+                                $remind_question_id = -1;
813
+                                $current_question = $i + 1; // last question
814
+                            }
815
+                            break 2;
816
+                        }
817
+                    }
818
+                } else {
819
+                    if ($my_remind_list[$j] == $data_tracking[$i]) {
820
+                        if (isset($my_remind_list[$j+1])) {
821
+                            $remind_question_id = $my_remind_list[$j+1];
822
+                            $current_question = $i + 1; // last question
823
+                        } else {
824 824
                             // We end the remind list we go to the exercise_reminder.php please
825
-							$remind_question_id = -1;
826
-							$current_question = $i + 1; // last question
827
-						}
828
-						break 2;
829
-					}
830
-				}
831
-			}
825
+                            $remind_question_id = -1;
826
+                            $current_question = $i + 1; // last question
827
+                        }
828
+                        break 2;
829
+                    }
830
+                }
831
+            }
832 832
         }
833 833
     } else {
834
-    	if ($objExercise->review_answers) {
834
+        if ($objExercise->review_answers) {
835 835
             if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
836
-	    	header("Location: exercise_reminder.php?$params");
837
-	    	exit;
838
-    	}
836
+            header("Location: exercise_reminder.php?$params");
837
+            exit;
838
+        }
839 839
     }
840 840
 }
841 841
 
842 842
 if ($objExercise->review_answers) {
843
-	$script_php = 'exercise_reminder.php';
843
+    $script_php = 'exercise_reminder.php';
844 844
 } else {
845
-	$script_php = 'exercise_result.php';
845
+    $script_php = 'exercise_result.php';
846 846
 }
847 847
 
848 848
 if (!empty($error)) {
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
          <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1087 1087
          <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1088 1088
 
1089
-	// Show list of questions
1089
+    // Show list of questions
1090 1090
     $i = 1;
1091 1091
     $attempt_list = array();
1092 1092
     if (isset($exe_id)) {
@@ -1136,10 +1136,10 @@  discard block
 block discarded – undo
1136 1136
 
1137 1137
         $attributes = array('id' =>'remind_list['.$questionId.']');
1138 1138
         if (in_array($questionId, $remind_list)) {
1139
-        	$is_remind_on = true;
1140
-        	$attributes['checked'] = 1;
1141
-        	$remind_question = true;
1142
-        	$remind_highlight = ' remind_highlight ';
1139
+            $is_remind_on = true;
1140
+            $attributes['checked'] = 1;
1141
+            $remind_question = true;
1142
+            $remind_highlight = ' remind_highlight ';
1143 1143
         }
1144 1144
 
1145 1145
         // Showing the exercise description
@@ -1213,8 +1213,8 @@  discard block
 block discarded – undo
1213 1213
     }
1214 1214
     // end foreach()
1215 1215
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1216
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1217
-    	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1216
+        $exercise_actions =  $objExercise->show_button($questionId, $current_question);
1217
+        echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1218 1218
         echo '<br>';
1219 1219
     }
1220 1220
     echo '</form>';
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 use ChamiloSession as Session;
30 30
 
31 31
 require_once '../inc/global.inc.php';
32
-$current_course_tool  = TOOL_QUIZ;
32
+$current_course_tool = TOOL_QUIZ;
33 33
 $this_section = SECTION_COURSES;
34 34
 $debug = false;
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 $origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : '';
40 40
 
41
-$is_allowedToEdit = api_is_allowed_to_edit(null,true);
41
+$is_allowedToEdit = api_is_allowed_to_edit(null, true);
42 42
 $glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
43 43
 
44 44
 $showGlossary = in_array($glossaryExtraTools, array('true', 'exercise', 'exercise_and_lp'));
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
61 61
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
62 62
 $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
63
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
64
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
63
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
64
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
65 65
 
66 66
 $template = new Template();
67 67
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 $learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;
71 71
 $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : 0;
72
-$learnpath_item_view_id	= isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
72
+$learnpath_item_view_id = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
73 73
 
74 74
 $reminder = isset($_REQUEST['reminder']) ? intval($_REQUEST['reminder']) : 0;
75 75
 $remind_question_id = isset($_REQUEST['remind_question_id']) ? intval($_REQUEST['remind_question_id']) : 0;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 /*  Teacher takes an exam and want to see a preview,
97 97
     we delete the objExercise from the session in order to get the latest
98 98
     changes in the exercise */
99
-if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1 ) {
99
+if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1) {
100 100
     Session::erase('objExercise');
101 101
 }
102 102
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
 if ($time_control) {
168 168
 	// Get the expired time of the current exercise in track_e_exercises
169
-	$total_seconds = $objExercise->expired_time*60;
169
+	$total_seconds = $objExercise->expired_time * 60;
170 170
 }
171 171
 
172 172
 $show_clock = true;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 	if ($attempt_count >= $objExercise->selectAttempts()) {
185 185
 		$show_clock = false;
186
-		if (!api_is_allowed_to_edit(null,true)) {
186
+		if (!api_is_allowed_to_edit(null, true)) {
187 187
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
188 188
 
189 189
                 // Showing latest attempt according with task BT#1628
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                     );
214 214
 
215 215
                     if (!empty($last_attempt_info['question_list'])) {
216
-                        foreach($last_attempt_info['question_list'] as $question_data) {
216
+                        foreach ($last_attempt_info['question_list'] as $question_data) {
217 217
                             $question_id = $question_data['question_id'];
218 218
                             $marks       = $question_data['marks'];
219 219
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                             $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore'));
223 223
                         }
224 224
                     }
225
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
225
+					$score = ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
226 226
 					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
227 227
 				} else {
228 228
 					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
284 284
 		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
285 285
 
286
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
286
+		$clock_expired_time = api_get_utc_datetime($expected_time);
287 287
 		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
288 288
 
289 289
 		//Sessions  that contain the expired time
290
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
291
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
290
+		$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
291
+		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
292 292
 	}
293 293
 
294 294
     $exe_id = $objExercise->save_stat_track_exercise_info(
@@ -402,22 +402,22 @@  discard block
 block discarded – undo
402 402
 	    	   the track_et_attempt see #2069 */
403 403
 	    	if (empty($last_attempt_date)) {
404 404
 	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
405
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
405
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'], 'UTC') + $diff);
406 406
 	    	} else {
407 407
 	    		//Recalculate the time control due #2069
408
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
409
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
408
+	    		$diff = $current_timestamp - api_strtotime($last_attempt_date, 'UTC');
409
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff);
410 410
 	    	}
411 411
 	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
412 412
 
413 413
 	        //New expired time - it is due to the possible closure of session
414
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
414
+	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date, 'UTC');
415 415
 	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
416 416
 
417
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
417
+	        $expected_time = $current_timestamp + $new_expired_time_in_seconds;
418 418
 	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
419 419
 
420
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
420
+	        $clock_expired_time = api_get_utc_datetime($expected_time);
421 421
 	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
422 422
 
423 423
 			// First we update the attempt to today
@@ -433,17 +433,17 @@  discard block
 block discarded – undo
433 433
 
434 434
 	        //Sessions  that contain the expired time
435 435
 	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
436
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
436
+	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
437 437
         }
438 438
     } else {
439
-        $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
439
+        $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
440 440
     }
441 441
 } else {
442 442
     if ($debug) { error_log("7 No time control"); };
443 443
 }
444 444
 
445 445
 // Get time left for expiring time
446
-$time_left = api_strtotime($clock_expired_time,'UTC') - time();
446
+$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
447 447
 
448 448
 /*
449 449
  * The time control feature is enable here - this feature is enable for a jquery plugin called epiclock
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
     //Only for hotspot
494 494
     if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) {
495
-        $hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
495
+        $hotspot_id = (int) ($_REQUEST['hidden_hotspot_id']);
496 496
         $choice     = array($hotspot_id => '');
497 497
     }
498 498
 
@@ -520,12 +520,12 @@  discard block
 block discarded – undo
520 520
                 //saving each question
521 521
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
522 522
                     $nro_question = $current_question; // - 1;
523
-                 	$questionId   = $key;
523
+                 	$questionId = $key;
524 524
                     // gets the student choice for this question
525 525
                     $choice = $exerciseResult[$questionId];
526 526
                     if (isset($exe_id)) {
527 527
                     	// Manage the question and answer attempts
528
-                        if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
528
+                        if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice, 1)); }
529 529
                         $objExercise->manage_answer(
530 530
                             $exe_id,
531 531
                             $questionId,
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
             }
545 545
         }
546 546
         if ($debug) { error_log('9.3.  $choice is an array - end'); }
547
-        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult,1)); }
547
+        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult, 1)); }
548 548
     }
549 549
 
550 550
     // the script "exercise_result.php" will take the variable $exerciseResult from the session
551 551
     Session::write('exerciseResult', $exerciseResult);
552 552
     Session::write('remind_list', $remind_list);
553
-    Session::write('exerciseResultCoordinates',$exerciseResultCoordinates);
553
+    Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
554 554
 
555 555
     // if all questions on one page OR if it is the last question (only for an exercise with one question per page)
556 556
     if ($objExercise->type == ALL_ON_ONE_PAGE || $current_question >= $question_count) {
@@ -676,15 +676,15 @@  discard block
 block discarded – undo
676 676
 }
677 677
 
678 678
 if (!empty ($gradebook) && $gradebook == 'view') {
679
-    $interbreadcrumb[] = array ('url' => '../gradebook/' . Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
679
+    $interbreadcrumb[] = array('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('ToolGradebook'));
680 680
 }
681 681
 
682
-$interbreadcrumb[] = array ("url" => "exercise.php?".api_get_cidreq(),	"name" => get_lang('Exercises'));
683
-$interbreadcrumb[] = array ("url" => "#", "name" => $objExercise->name);
682
+$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
683
+$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
684 684
 
685 685
 if ($origin != 'learnpath') { //so we are not in learnpath tool
686
-    Display :: display_header(null,'Exercises');
687
-    if (!api_is_allowed_to_session_edit() ) {
686
+    Display :: display_header(null, 'Exercises');
687
+    if (!api_is_allowed_to_session_edit()) {
688 688
         Display :: display_warning_message(get_lang('SessionIsReadOnly'));
689 689
     }
690 690
 } else {
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
 if (api_is_course_admin() && $origin != 'learnpath') {
704 704
     echo '<div class="actions">';
705 705
     if ($show_quiz_edition == false) {
706
-    	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>';
706
+    	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>';
707 707
     } else {
708
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
708
+    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
709 709
     }
710 710
     echo '</div>';
711 711
 }
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
     }
745 745
 
746 746
     if (!$permission_to_start || $exercise_timeover) {
747
-        if (!api_is_allowed_to_edit(null,true)) {
747
+        if (!api_is_allowed_to_edit(null, true)) {
748 748
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
749 749
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
750 750
             if ($origin != 'learnpath') {
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
    echo '<div id="highlight-plugin" class="glossary-content">';
788 788
 }
789 789
 
790
-if ($reminder == 2)  {
790
+if ($reminder == 2) {
791 791
     if ($debug) { error_log(' $reminder == 2'); }
792 792
 
793 793
     $data_tracking  = $exercise_stat_info['data_tracking'];
@@ -798,14 +798,14 @@  discard block
 block discarded – undo
798 798
     if (!empty($my_remind_list)) {
799 799
     	// Checking which questions we are going to call from the remind list
800 800
 		for ($i = 0; $i < count($data_tracking); $i++) {
801
-			for($j = 0; $j < count($my_remind_list); $j++) {
801
+			for ($j = 0; $j < count($my_remind_list); $j++) {
802 802
 
803 803
 				if (!empty($remind_question_id)) {
804 804
 					if ($remind_question_id == $my_remind_list[$j]) {
805 805
 
806 806
 			        	if ($remind_question_id == $data_tracking[$i]) {
807
-			        		if (isset($my_remind_list[$j+1])) {
808
-			        			$remind_question_id = $my_remind_list[$j+1];
807
+			        		if (isset($my_remind_list[$j + 1])) {
808
+			        			$remind_question_id = $my_remind_list[$j + 1];
809 809
 			        			$current_question = $i + 1;
810 810
 			        		} else {
811 811
                                 // We end the remind list we go to the exercise_reminder.php please
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 					}
818 818
 				} else {
819 819
 					if ($my_remind_list[$j] == $data_tracking[$i]) {
820
-						if (isset($my_remind_list[$j+1])) {
821
-							$remind_question_id = $my_remind_list[$j+1];
820
+						if (isset($my_remind_list[$j + 1])) {
821
+							$remind_question_id = $my_remind_list[$j + 1];
822 822
 							$current_question = $i + 1; // last question
823 823
 						} else {
824 824
                             // We end the remind list we go to the exercise_reminder.php please
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     Display :: display_error_message($error, false);
850 850
 } else {
851 851
     if (!empty ($exercise_sound)) {
852
-        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . Security::remove_XSS($exercise_sound) . "\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
852
+        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound')."\" /></a>";
853 853
     }
854 854
     // Get number of hotspot questions for javascript validation
855 855
     $number_of_hotspot_questions = 0;
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
     }
885 885
 
886 886
     if ($number_of_hotspot_questions > 0) {
887
-        $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\"";
887
+        $onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
888 888
     }
889 889
 
890 890
     echo '<script>
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                 ICON_SIZE_SMALL,
899 899
                 false,
900 900
                 true
901
-            ) . '\';
901
+            ).'\';
902 902
 
903 903
             // Block form submition on enter
904 904
             $(".block_on_enter").keypress(function(event) {
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
             } else {
951 951
                 url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
952 952
             }
953
-            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
953
+            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
954 954
             window.location = url;
955 955
         }
956 956
 
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 
983 983
             // Only for the first time
984 984
 
985
-            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin') . '\');
985
+            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin').'\');
986 986
             $.ajax({
987 987
                 type:"post",
988 988
                 async: false,
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
                 data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
991 991
                 success: function(return_value) {
992 992
                     if (return_value == "ok") {
993
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
993
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
994 994
                     } else if (return_value == "error") {
995
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
995
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
996 996
                     } else if (return_value == "one_per_page") {
997 997
                         var url = "";
998 998
                         if ('.$reminder.' == 1 ) {
@@ -1007,13 +1007,13 @@  discard block
 block discarded – undo
1007 1007
                             url = url_extra;
1008 1008
                         }
1009 1009
 
1010
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
1010
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
1011 1011
 
1012 1012
                         window.location = url;
1013 1013
                     }
1014 1014
                 },
1015 1015
                 error: function() {
1016
-                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
1016
+                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
1017 1017
                 }
1018 1018
             });
1019 1019
             return false;
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
             free_answers = $.param(free_answers);
1048 1048
 
1049
-            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin') . '\');
1049
+            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin').'\');
1050 1050
 
1051 1051
             $.ajax({
1052 1052
                 type:"post",
@@ -1055,14 +1055,14 @@  discard block
 block discarded – undo
1055 1055
                 data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
1056 1056
                 success: function(return_value) {
1057 1057
                     if (return_value == "ok") {
1058
-                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
1058
+                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
1059 1059
                         if (validate == "validate") {
1060 1060
                             window.location = "'.$script_php.'?'.$params.'";
1061 1061
                         } else {
1062
-                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
1062
+                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
1063 1063
                         }
1064 1064
                     } else {
1065
-                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif') . '\');
1065
+                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif').'\');
1066 1066
                     }
1067 1067
                 }
1068 1068
             });
@@ -1075,16 +1075,16 @@  discard block
 block discarded – undo
1075 1075
         }
1076 1076
     </script>';
1077 1077
 
1078
-    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId .'" name="frm_exercise" '.$onsubmit.'>
1078
+    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId.'" name="frm_exercise" '.$onsubmit.'>
1079 1079
          <input type="hidden" name="formSent"				value="1" />
1080
-         <input type="hidden" name="exerciseId" 			value="'.$exerciseId . '" />
1080
+         <input type="hidden" name="exerciseId" 			value="'.$exerciseId.'" />
1081 1081
          <input type="hidden" name="num" 					value="'.$current_question.'" id="num_current_id" />
1082 1082
          <input type="hidden" name="num_answer"             value="'.$currentAnswer.'" id="num_current_answer_id" />
1083
-         <input type="hidden" name="exe_id" 				value="'.$exe_id . '" />
1084
-         <input type="hidden" name="origin" 				value="'.$origin . '" />
1085
-         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id . '" />
1086
-         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1087
-         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1083
+         <input type="hidden" name="exe_id" 				value="'.$exe_id.'" />
1084
+         <input type="hidden" name="origin" 				value="'.$origin.'" />
1085
+         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id.'" />
1086
+         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id.'" />
1087
+         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id.'" />';
1088 1088
 
1089 1089
 	// Show list of questions
1090 1090
     $i = 1;
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
         $attempt_list = Event::getAllExerciseEventByExeId($exe_id);
1094 1094
     }
1095 1095
 
1096
-    $remind_list  = array();
1096
+    $remind_list = array();
1097 1097
     if (isset($exercise_stat_info['questions_to_check']) && !empty($exercise_stat_info['questions_to_check'])) {
1098 1098
         $remind_list = explode(',', $exercise_stat_info['questions_to_check']);
1099 1099
     }
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
             $remind_highlight = 'no_remind_highlight';
1132 1132
         }
1133 1133
 
1134
-        $exercise_actions  = '';
1134
+        $exercise_actions = '';
1135 1135
         $is_remind_on = false;
1136 1136
 
1137 1137
         $attributes = array('id' =>'remind_list['.$questionId.']');
@@ -1143,10 +1143,10 @@  discard block
 block discarded – undo
1143 1143
         }
1144 1144
 
1145 1145
         // Showing the exercise description
1146
-        if (!empty($objExercise->description)){
1147
-            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i==1)) {
1148
-                echo Display::panelCollapse('<span>' .
1149
-                    get_lang('ExerciseDescriptionLabel') . '</span>',
1146
+        if (!empty($objExercise->description)) {
1147
+            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i == 1)) {
1148
+                echo Display::panelCollapse('<span>'.
1149
+                    get_lang('ExerciseDescriptionLabel').'</span>',
1150 1150
                     $objExercise->description,
1151 1151
                     'exercise-description',
1152 1152
                     [],
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
             case ALL_ON_ONE_PAGE :
1181 1181
                 $button  = '<a href="javascript://" class="btn btn-info" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
1182 1182
                 $button .= '<span id="save_for_now_'.$questionId.'"></span>&nbsp;';
1183
-                $exercise_actions  .= Display::div($button, array('class'=>'exercise_save_now_button'));
1183
+                $exercise_actions .= Display::div($button, array('class'=>'exercise_save_now_button'));
1184 1184
                 break;
1185 1185
         }
1186 1186
 
@@ -1190,13 +1190,13 @@  discard block
 block discarded – undo
1190 1190
                 'label',
1191 1191
                 Display::input(
1192 1192
                     'checkbox',
1193
-                    'remind_list[' . $questionId . ']',
1193
+                    'remind_list['.$questionId.']',
1194 1194
                     '',
1195 1195
                     $attributes
1196
-                ) . get_lang('ReviewQuestionLater'),
1196
+                ).get_lang('ReviewQuestionLater'),
1197 1197
                 array(
1198 1198
                     'class' => 'checkbox',
1199
-                    'for' => 'remind_list[' . $questionId . ']'
1199
+                    'for' => 'remind_list['.$questionId.']'
1200 1200
                 )
1201 1201
             );
1202 1202
             $exercise_actions .= Display::div($remind_question_div, array('class'=>'exercise_save_now_button'));
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
     }
1214 1214
     // end foreach()
1215 1215
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1216
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1216
+    	$exercise_actions = $objExercise->show_button($questionId, $current_question);
1217 1217
     	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1218 1218
         echo '<br>';
1219 1219
     }
Please login to merge, or discard this patch.
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -269,7 +269,9 @@  discard block
 block discarded – undo
269 269
 $clock_expired_time = null;
270 270
 
271 271
 if (empty($exercise_stat_info)) {
272
-    if ($debug)  error_log('5  $exercise_stat_info is empty ');
272
+    if ($debug) {
273
+        error_log('5  $exercise_stat_info is empty ');
274
+    }
273 275
 	$total_weight = 0;
274 276
 	$questionList = $objExercise->get_validated_question_list();
275 277
 	foreach ($questionListUncompressed as $question_id) {
@@ -280,11 +282,17 @@  discard block
 block discarded – undo
280 282
 	if ($time_control) {
281 283
 		$expected_time = $current_timestamp + $total_seconds;
282 284
 
283
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
284
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
285
+		if ($debug) {
286
+		    error_log('5.1. $current_timestamp '.$current_timestamp);
287
+		}
288
+		if ($debug) {
289
+		    error_log('5.2. $expected_time '.$expected_time);
290
+		}
285 291
 
286 292
 		$clock_expired_time 	= api_get_utc_datetime($expected_time);
287
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
293
+		if ($debug) {
294
+		    error_log('5.3. $expected_time '.$clock_expired_time);
295
+		}
288 296
 
289 297
 		//Sessions  that contain the expired time
290 298
 		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
@@ -304,8 +312,10 @@  discard block
 block discarded – undo
304 312
         $learnpath_item_id,
305 313
         $learnpath_item_view_id
306 314
     );
307
-    if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
308
-} else {
315
+    if ($debug) {
316
+        error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
317
+    }
318
+    } else {
309 319
 	$exe_id = $exercise_stat_info['exe_id'];
310 320
     // Remember last question id position.
311 321
     $isFirstTime = Session::read('firstTime');
@@ -327,8 +337,10 @@  discard block
 block discarded – undo
327 337
         }
328 338
     }
329 339
 
330
-    if ($debug)  error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
331
-}
340
+    if ($debug) {
341
+        error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
342
+    }
343
+    }
332 344
 
333 345
 $questionListInSession = Session::read('questionList');
334 346
 
@@ -384,9 +396,15 @@  discard block
 block discarded – undo
384 396
  * If the expired time is major that zero(0) then the expired time is compute on this time.
385 397
  */
386 398
 if ($time_control) {
387
-	if ($debug) error_log('7.1. Time control is enabled');
388
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
389
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
399
+	if ($debug) {
400
+	    error_log('7.1. Time control is enabled');
401
+	}
402
+	if ($debug) {
403
+	    error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
404
+	}
405
+	if ($debug) {
406
+	    error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
407
+	}
390 408
 
391 409
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
392 410
         //Timer - Get expired_time for a student
@@ -473,7 +491,9 @@  discard block
 block discarded – undo
473 491
 	}
474 492
 }
475 493
 
476
-if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
494
+if ($debug) {
495
+    error_log('8. Question list loaded '.print_r($questionList, 1));
496
+}
477 497
 
478 498
 //Real question count
479 499
 $question_count = 0;
Please login to merge, or discard this patch.
main/exercice/exercise.class.php 1 patch
Spacing   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     public $feedback_type;
28 28
     public $end_time;
29 29
     public $start_time;
30
-    public $questionList;  // array with the list of this exercise's questions
30
+    public $questionList; // array with the list of this exercise's questions
31 31
     /* including question list of the media */
32 32
     public $questionListUncompressed;
33 33
     public $results_disabled;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
131 131
         $table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
132 132
 
133
-        $id  = intval($id);
133
+        $id = intval($id);
134 134
         if (empty($this->course_id)) {
135 135
 
136 136
             return false;
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
             }
191 191
 
192 192
             if ($object->end_time != '0000-00-00 00:00:00') {
193
-                $this->end_time 	= $object->end_time;
193
+                $this->end_time = $object->end_time;
194 194
             }
195 195
             if ($object->start_time != '0000-00-00 00:00:00') {
196
-                $this->start_time 	= $object->start_time;
196
+                $this->start_time = $object->start_time;
197 197
             }
198 198
 
199 199
             //control time
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      */
479 479
     public function isRandom()
480 480
     {
481
-        if($this->random > 0 || $this->random == -1) {
481
+        if ($this->random > 0 || $this->random == -1) {
482 482
             return true;
483 483
         } else {
484 484
             return false;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                     $question_media = null;
640 640
                     if (!empty($objQuestionTmp->parent_id)) {
641 641
                         $objQuestionMedia = Question::read($objQuestionTmp->parent_id);
642
-                        $question_media  = Question::getMediaLabel($objQuestionMedia->question);
642
+                        $question_media = Question::getMediaLabel($objQuestionMedia->question);
643 643
                     }
644 644
 
645 645
                     $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM).$question_media);
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
             foreach ($questions_by_category as $categoryId => $questionList) {
1034 1034
                 $cat = new TestCategory($categoryId);
1035
-                $cat = (array)$cat;
1035
+                $cat = (array) $cat;
1036 1036
                 $cat['iid'] = $cat['id'];
1037 1037
                 //*$cat['name'] = $cat['name'];
1038 1038
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
     {
1098 1098
         if ($this->specialCategoryOrders == false) {
1099 1099
             if ($from_db && !empty($this->id)) {
1100
-                $TBL_EXERCISE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
1100
+                $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
1101 1101
                 $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
1102 1102
 
1103 1103
                 $sql = "SELECT DISTINCT e.question_order
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
                 $question_list = array();
1125 1125
 
1126 1126
                 while ($new_object = Database::fetch_object($result)) {
1127
-                    $question_list[$new_object->question_order]=  $new_object->question_id;
1127
+                    $question_list[$new_object->question_order] = $new_object->question_id;
1128 1128
                     $temp_question_list[$counter] = $new_object->question_id;
1129 1129
                     $counter++;
1130 1130
                 }
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
     public function isInList($questionId)
1269 1269
     {
1270 1270
         if (is_array($this->questionList))
1271
-            return in_array($questionId,$this->questionList);
1271
+            return in_array($questionId, $this->questionList);
1272 1272
         else
1273 1273
             return false;
1274 1274
     }
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
      */
1282 1282
     public function updateTitle($title)
1283 1283
     {
1284
-        $this->exercise=$title;
1284
+        $this->exercise = $title;
1285 1285
     }
1286 1286
 
1287 1287
     /**
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
      */
1292 1292
     public function updateAttempts($attempts)
1293 1293
     {
1294
-        $this->attempts=$attempts;
1294
+        $this->attempts = $attempts;
1295 1295
     }
1296 1296
 
1297 1297
     /**
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
      */
1302 1302
     public function updateFeedbackType($feedback_type)
1303 1303
     {
1304
-        $this->feedback_type=$feedback_type;
1304
+        $this->feedback_type = $feedback_type;
1305 1305
     }
1306 1306
 
1307 1307
     /**
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
      */
1313 1313
     public function updateDescription($description)
1314 1314
     {
1315
-        $this->description=$description;
1315
+        $this->description = $description;
1316 1316
     }
1317 1317
 
1318 1318
     /**
@@ -1442,23 +1442,23 @@  discard block
 block discarded – undo
1442 1442
      * @param string $sound - exercise sound file
1443 1443
      * @param string $delete - ask to delete the file
1444 1444
      */
1445
-    public function updateSound($sound,$delete)
1445
+    public function updateSound($sound, $delete)
1446 1446
     {
1447 1447
         global $audioPath, $documentPath;
1448 1448
         $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
1449 1449
 
1450
-        if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) {
1451
-            $this->sound=$sound['name'];
1450
+        if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) {
1451
+            $this->sound = $sound['name'];
1452 1452
 
1453
-            if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) {
1453
+            if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) {
1454 1454
                 $query = "SELECT 1 FROM $TBL_DOCUMENT
1455
-                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'";
1456
-                $result=Database::query($query);
1455
+                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'";
1456
+                $result = Database::query($query);
1457 1457
 
1458 1458
                 if (!Database::num_rows($result)) {
1459 1459
                     $id = add_document(
1460 1460
                         $this->course,
1461
-                        str_replace($documentPath,'',$audioPath).'/'.$this->sound,
1461
+                        str_replace($documentPath, '', $audioPath).'/'.$this->sound,
1462 1462
                         'file',
1463 1463
                         $sound['size'],
1464 1464
                         $sound['name']
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
                     );
1478 1478
                 }
1479 1479
             }
1480
-        } elseif($delete && is_file($audioPath.'/'.$this->sound)) {
1481
-            $this->sound='';
1480
+        } elseif ($delete && is_file($audioPath.'/'.$this->sound)) {
1481
+            $this->sound = '';
1482 1482
         }
1483 1483
     }
1484 1484
 
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
      */
1491 1491
     public function updateType($type)
1492 1492
     {
1493
-        $this->type=$type;
1493
+        $this->type = $type;
1494 1494
     }
1495 1495
 
1496 1496
     /**
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
      */
1527 1527
     public function enable()
1528 1528
     {
1529
-        $this->active=1;
1529
+        $this->active = 1;
1530 1530
     }
1531 1531
 
1532 1532
     /**
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
      */
1537 1537
     public function disable()
1538 1538
     {
1539
-        $this->active=0;
1539
+        $this->active = 0;
1540 1540
     }
1541 1541
 
1542 1542
     /**
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
                 api_get_user_id()
1665 1665
             );
1666 1666
 
1667
-            if (api_get_setting('search_enabled')=='true') {
1667
+            if (api_get_setting('search_enabled') == 'true') {
1668 1668
                 $this->search_engine_edit();
1669 1669
             }
1670 1670
         } else {
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
     public function removeFromList($questionId)
1813 1813
     {
1814 1814
         // searches the position of the question ID in the list
1815
-        $pos = array_search($questionId,$this->questionList);
1815
+        $pos = array_search($questionId, $this->questionList);
1816 1816
 
1817 1817
         // question not found
1818 1818
         if ($pos === false) {
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizDeleted', api_get_user_id());
1848 1848
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'delete', api_get_user_id());
1849 1849
 
1850
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) {
1850
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
1851 1851
             $this->search_engine_delete();
1852 1852
         }
1853 1853
     }
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
      * Creates the form to create / edit an exercise
1857 1857
      * @param FormValidator $form
1858 1858
      */
1859
-    public function createForm($form, $type='full')
1859
+    public function createForm($form, $type = 'full')
1860 1860
     {
1861 1861
         if (empty($type)) {
1862 1862
             $type = 'full';
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
             'Width' => '100%',
1888 1888
             'Height' => '150',
1889 1889
         );
1890
-        if (is_array($type)){
1890
+        if (is_array($type)) {
1891 1891
             $editor_config = array_merge($editor_config, $type);
1892 1892
         }
1893 1893
 
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
                     '2',
1942 1942
                     array('id' => 'exerciseType_2')
1943 1943
                 );
1944
-                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')), '');
1944
+                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), '');
1945 1945
 
1946 1946
                 // Type of results display on the final page
1947 1947
                 $radios_results_disabled = array();
@@ -1985,8 +1985,8 @@  discard block
 block discarded – undo
1985 1985
                 // Type of questions disposition on page
1986 1986
                 $radios = array();
1987 1987
 
1988
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1989
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1988
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1989
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1990 1990
 
1991 1991
                 $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
1992 1992
 
@@ -1996,33 +1996,33 @@  discard block
 block discarded – undo
1996 1996
 
1997 1997
                     // feedback type
1998 1998
                     $radios_feedback = array();
1999
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1999
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
2000 2000
 
2001 2001
                     if (api_get_setting('enable_quiz_scenario') == 'true') {
2002
-                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()'));
2002
+                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
2003 2003
                     }
2004
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
2005
-                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')));
2004
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2'));
2005
+                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
2006 2006
 
2007 2007
                     //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
2008 2008
                     $radios_results_disabled = array();
2009 2009
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
2010
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
2011
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
2012
-                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
2010
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
2011
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
2012
+                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
2013 2013
 
2014 2014
                     // Type of questions disposition on page
2015 2015
                     $radios = array();
2016
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1');
2017
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
2016
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
2017
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
2018 2018
                     $form->addGroup($radios, null, get_lang('ExerciseType'));
2019 2019
 
2020 2020
                 } else {
2021 2021
                     //Show options freeze
2022 2022
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
2023
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
2024
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
2025
-                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
2023
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
2024
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
2025
+                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
2026 2026
                     $result_disable_group->freeze();
2027 2027
 
2028 2028
                     //we force the options to the DirectFeedback exercisetype
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
                     $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
2031 2031
 
2032 2032
                     // Type of questions disposition on page
2033
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2034
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2033
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2034
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2035 2035
 
2036 2036
                     $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
2037 2037
                     $type_group->freeze();
@@ -2163,26 +2163,26 @@  discard block
 block discarded – undo
2163 2163
 
2164 2164
                 // number of random question
2165 2165
 
2166
-                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
2166
+                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10;
2167 2167
                 $option = range(0, $max);
2168 2168
                 $option[0] = get_lang('No');
2169 2169
                 $option[-1] = get_lang('AllQuestionsShort');
2170
-                $form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2170
+                $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2171 2171
 
2172 2172
                 // Random answers
2173 2173
                 $radios_random_answers = array();
2174
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'),'1');
2175
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'),'0');
2174
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
2175
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
2176 2176
                 $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
2177 2177
 
2178 2178
                 // Random by category
2179
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2179
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2180 2180
                 $radiocat = array();
2181
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'),'1');
2182
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'),'2');
2183
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'),'0');
2181
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1');
2182
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2');
2183
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0');
2184 2184
                 $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
2185
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2185
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2186 2186
 
2187 2187
                 // add the radio display the category name for student
2188 2188
                 $radio_display_cat_name = array();
@@ -2203,36 +2203,36 @@  discard block
 block discarded – undo
2203 2203
             );
2204 2204
 
2205 2205
             // Exercise time limit
2206
-            $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2206
+            $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2207 2207
 
2208 2208
             $var = Exercise::selectTimeLimit();
2209 2209
 
2210 2210
             if (($this->start_time != '0000-00-00 00:00:00'))
2211
-                $form->addElement('html','<div id="start_date_div" style="display:block;">');
2211
+                $form->addElement('html', '<div id="start_date_div" style="display:block;">');
2212 2212
             else
2213
-                $form->addElement('html','<div id="start_date_div" style="display:none;">');
2213
+                $form->addElement('html', '<div id="start_date_div" style="display:none;">');
2214 2214
 
2215 2215
             $form->addElement('date_time_picker', 'start_time');
2216 2216
 
2217
-            $form->addElement('html','</div>');
2217
+            $form->addElement('html', '</div>');
2218 2218
 
2219
-            $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2219
+            $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2220 2220
 
2221 2221
             if (($this->end_time != '0000-00-00 00:00:00'))
2222
-                $form->addElement('html','<div id="end_date_div" style="display:block;">');
2222
+                $form->addElement('html', '<div id="end_date_div" style="display:block;">');
2223 2223
             else
2224
-                $form->addElement('html','<div id="end_date_div" style="display:none;">');
2224
+                $form->addElement('html', '<div id="end_date_div" style="display:none;">');
2225 2225
 
2226 2226
             $form->addElement('date_time_picker', 'end_time');
2227
-            $form->addElement('html','</div>');
2227
+            $form->addElement('html', '</div>');
2228 2228
 
2229 2229
             //$check_option=$this->selectType();
2230 2230
             $diplay = 'block';
2231 2231
             $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
2232
-            $form->addElement('html','<div class="clear">&nbsp;</div>');
2232
+            $form->addElement('html', '<div class="clear">&nbsp;</div>');
2233 2233
             $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
2234 2234
 
2235
-            $form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
2235
+            $form->addElement('html', '<div id="divtimecontrol"  style="display:'.$diplay.';">');
2236 2236
 
2237 2237
             //Timer control
2238 2238
             //$time_hours_option = range(0,12);
@@ -2248,12 +2248,12 @@  discard block
 block discarded – undo
2248 2248
                     'onload' => 'check_load_time()',
2249 2249
                 )
2250 2250
             );
2251
-            $expired_date = (int)$this->selectExpiredTime();
2251
+            $expired_date = (int) $this->selectExpiredTime();
2252 2252
 
2253
-            if (($expired_date!='0')) {
2254
-                $form->addElement('html','<div id="timercontrol" style="display:block;">');
2253
+            if (($expired_date != '0')) {
2254
+                $form->addElement('html', '<div id="timercontrol" style="display:block;">');
2255 2255
             } else {
2256
-                $form->addElement('html','<div id="timercontrol" style="display:none;">');
2256
+                $form->addElement('html', '<div id="timercontrol" style="display:none;">');
2257 2257
             }
2258 2258
             $form->addText(
2259 2259
                 'enabletimercontroltotalminutes',
@@ -2264,7 +2264,7 @@  discard block
 block discarded – undo
2264 2264
                     'cols-size' => [2, 2, 8]
2265 2265
                 ]
2266 2266
             );
2267
-            $form->addElement('html','</div>');
2267
+            $form->addElement('html', '</div>');
2268 2268
 
2269 2269
             $form->addElement(
2270 2270
                 'text',
@@ -2288,23 +2288,23 @@  discard block
 block discarded – undo
2288 2288
             $defaults = array();
2289 2289
 
2290 2290
             if (api_get_setting('search_enabled') === 'true') {
2291
-                require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2291
+                require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2292 2292
 
2293
-                $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
2294
-                $form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2293
+                $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
2294
+                $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2295 2295
 
2296 2296
                 $specific_fields = get_specific_field_list();
2297 2297
 
2298 2298
                 foreach ($specific_fields as $specific_field) {
2299
-                    $form->addElement ('text', $specific_field['code'], $specific_field['name']);
2299
+                    $form->addElement('text', $specific_field['code'], $specific_field['name']);
2300 2300
                     $filter = array(
2301 2301
                         'c_id' => api_get_course_int_id(),
2302 2302
                         'field_id' => $specific_field['id'],
2303 2303
                         'ref_id' => $this->id,
2304
-                        'tool_id' => "'" . TOOL_QUIZ . "'"
2304
+                        'tool_id' => "'".TOOL_QUIZ."'"
2305 2305
                     );
2306 2306
                     $values = get_specific_field_values_list($filter, array('value'));
2307
-                    if ( !empty($values) ) {
2307
+                    if (!empty($values)) {
2308 2308
                         $arr_str_values = array();
2309 2309
                         foreach ($values as $value) {
2310 2310
                             $arr_str_values[] = $value['value'];
@@ -2315,8 +2315,8 @@  discard block
 block discarded – undo
2315 2315
                 //$form->addElement ('html','</div>');
2316 2316
             }
2317 2317
 
2318
-            $form->addElement('html','</div>');  //End advanced setting
2319
-            $form->addElement('html','</div>');
2318
+            $form->addElement('html', '</div>'); //End advanced setting
2319
+            $form->addElement('html', '</div>');
2320 2320
         }
2321 2321
 
2322 2322
         // submit
@@ -2336,10 +2336,10 @@  discard block
 block discarded – undo
2336 2336
         }
2337 2337
 
2338 2338
         // defaults
2339
-        if ($type=='full') {
2339
+        if ($type == 'full') {
2340 2340
             if ($this->id > 0) {
2341 2341
                 if ($this->random > $this->selectNbrQuestions()) {
2342
-                    $defaults['randomQuestions'] =  $this->selectNbrQuestions();
2342
+                    $defaults['randomQuestions'] = $this->selectNbrQuestions();
2343 2343
                 } else {
2344 2344
                     $defaults['randomQuestions'] = $this->random;
2345 2345
                 }
@@ -2366,8 +2366,8 @@  discard block
 block discarded – undo
2366 2366
                     $defaults['activate_end_date_check'] = 1;
2367 2367
                 }
2368 2368
 
2369
-                $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2370
-                $defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600);
2369
+                $defaults['start_time'] = ($this->start_time != '0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2370
+                $defaults['end_time'] = ($this->end_time != '0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600);
2371 2371
 
2372 2372
                 // Get expired time
2373 2373
                 if ($this->expired_time != '0') {
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
                 $defaults['text_when_finished'] = "";
2389 2389
                 $defaults['start_time'] = date('Y-m-d 12:00:00');
2390 2390
                 $defaults['display_category_name'] = 1;
2391
-                $defaults['end_time']   = date('Y-m-d 12:00:00', time()+84600);
2391
+                $defaults['end_time']   = date('Y-m-d 12:00:00', time() + 84600);
2392 2392
                 $defaults['pass_percentage'] = '';
2393 2393
                 $defaults['end_button'] = $this->selectEndButton();
2394 2394
                 $defaults['question_selection_type'] = 1;
@@ -2474,7 +2474,7 @@  discard block
 block discarded – undo
2474 2474
             $end_time = $form->getSubmitValue('end_time');
2475 2475
             $this->end_time = api_get_utc_datetime($end_time);
2476 2476
         } else {
2477
-            $this->end_time   = '0000-00-00 00:00:00';
2477
+            $this->end_time = '0000-00-00 00:00:00';
2478 2478
         }
2479 2479
 
2480 2480
         if ($form->getSubmitValue('enabletimercontrol') == 1) {
@@ -2487,9 +2487,9 @@  discard block
 block discarded – undo
2487 2487
         }
2488 2488
 
2489 2489
         if ($form->getSubmitValue('randomAnswers') == 1) {
2490
-            $this->random_answers=1;
2490
+            $this->random_answers = 1;
2491 2491
         } else {
2492
-            $this->random_answers=0;
2492
+            $this->random_answers = 0;
2493 2493
         }
2494 2494
         $this->save($type);
2495 2495
     }
@@ -2501,9 +2501,9 @@  discard block
 block discarded – undo
2501 2501
         }
2502 2502
         $course_id = api_get_course_id();
2503 2503
 
2504
-        require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
2505
-        require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
2506
-        require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2504
+        require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
2505
+        require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
2506
+        require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2507 2507
 
2508 2508
         $specific_fields = get_specific_field_list();
2509 2509
         $ic_slide = new IndexableChunk();
@@ -2513,7 +2513,7 @@  discard block
 block discarded – undo
2513 2513
             if (isset($_REQUEST[$specific_field['code']])) {
2514 2514
                 $sterms = trim($_REQUEST[$specific_field['code']]);
2515 2515
                 if (!empty($sterms)) {
2516
-                    $all_specific_terms .= ' '. $sterms;
2516
+                    $all_specific_terms .= ' '.$sterms;
2517 2517
                     $sterms = explode(',', $sterms);
2518 2518
                     foreach ($sterms as $sterm) {
2519 2519
                         $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2530,15 +2530,15 @@  discard block
 block discarded – undo
2530 2530
         $xapian_data = array(
2531 2531
             SE_COURSE_ID => $course_id,
2532 2532
             SE_TOOL_ID => TOOL_QUIZ,
2533
-            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2534
-            SE_USER => (int)api_get_user_id(),
2533
+            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2534
+            SE_USER => (int) api_get_user_id(),
2535 2535
         );
2536 2536
         $ic_slide->xapian_data = serialize($xapian_data);
2537
-        $exercise_description = $all_specific_terms .' '. $this->description;
2537
+        $exercise_description = $all_specific_terms.' '.$this->description;
2538 2538
         $ic_slide->addValue("content", $exercise_description);
2539 2539
 
2540 2540
         $di = new ChamiloIndexer();
2541
-        isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2541
+        isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2542 2542
         $di->connectDb(NULL, NULL, $lang);
2543 2543
         $di->addChunk($ic_slide);
2544 2544
 
@@ -2557,7 +2557,7 @@  discard block
 block discarded – undo
2557 2557
     function search_engine_edit()
2558 2558
     {
2559 2559
         // update search enchine and its values table if enabled
2560
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
2560
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2561 2561
             $course_id = api_get_course_id();
2562 2562
 
2563 2563
             // actually, it consists on delete terms from db,
@@ -2569,9 +2569,9 @@  discard block
 block discarded – undo
2569 2569
             $res = Database::query($sql);
2570 2570
 
2571 2571
             if (Database::num_rows($res) > 0) {
2572
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
2573
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
2574
-                require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
2572
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2573
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
2574
+                require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
2575 2575
 
2576 2576
                 $se_ref = Database::fetch_array($res);
2577 2577
                 $specific_fields = get_specific_field_list();
@@ -2582,7 +2582,7 @@  discard block
 block discarded – undo
2582 2582
                     delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
2583 2583
                     if (isset($_REQUEST[$specific_field['code']])) {
2584 2584
                         $sterms = trim($_REQUEST[$specific_field['code']]);
2585
-                        $all_specific_terms .= ' '. $sterms;
2585
+                        $all_specific_terms .= ' '.$sterms;
2586 2586
                         $sterms = explode(',', $sterms);
2587 2587
                         foreach ($sterms as $sterm) {
2588 2588
                             $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2598,17 +2598,17 @@  discard block
 block discarded – undo
2598 2598
                 $xapian_data = array(
2599 2599
                     SE_COURSE_ID => $course_id,
2600 2600
                     SE_TOOL_ID => TOOL_QUIZ,
2601
-                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2602
-                    SE_USER => (int)api_get_user_id(),
2601
+                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2602
+                    SE_USER => (int) api_get_user_id(),
2603 2603
                 );
2604 2604
                 $ic_slide->xapian_data = serialize($xapian_data);
2605
-                $exercise_description = $all_specific_terms .' '. $this->description;
2605
+                $exercise_description = $all_specific_terms.' '.$this->description;
2606 2606
                 $ic_slide->addValue("content", $exercise_description);
2607 2607
 
2608 2608
                 $di = new ChamiloIndexer();
2609
-                isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2609
+                isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2610 2610
                 $di->connectDb(NULL, NULL, $lang);
2611
-                $di->remove_document((int)$se_ref['search_did']);
2611
+                $di->remove_document((int) $se_ref['search_did']);
2612 2612
                 $di->addChunk($ic_slide);
2613 2613
 
2614 2614
                 //index and return search engine document id
@@ -2633,7 +2633,7 @@  discard block
 block discarded – undo
2633 2633
     function search_engine_delete()
2634 2634
     {
2635 2635
         // remove from search engine if enabled
2636
-        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) {
2636
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2637 2637
             $course_id = api_get_course_id();
2638 2638
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
2639 2639
             $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1';
@@ -2641,19 +2641,19 @@  discard block
 block discarded – undo
2641 2641
             $res = Database::query($sql);
2642 2642
             if (Database::num_rows($res) > 0) {
2643 2643
                 $row = Database::fetch_array($res);
2644
-                require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php');
2644
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2645 2645
                 $di = new ChamiloIndexer();
2646
-                $di->remove_document((int)$row['search_did']);
2646
+                $di->remove_document((int) $row['search_did']);
2647 2647
                 unset($di);
2648 2648
                 $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
2649
-                foreach ( $this->questionList as $question_i) {
2649
+                foreach ($this->questionList as $question_i) {
2650 2650
                     $sql = 'SELECT type FROM %s WHERE id=%s';
2651 2651
                     $sql = sprintf($sql, $tbl_quiz_question, $question_i);
2652 2652
                     $qres = Database::query($sql);
2653 2653
                     if (Database::num_rows($qres) > 0) {
2654 2654
                         $qrow = Database::fetch_array($qres);
2655 2655
                         $objQuestion = Question::getInstance($qrow['type']);
2656
-                        $objQuestion = Question::read((int)$question_i);
2656
+                        $objQuestion = Question::read((int) $question_i);
2657 2657
                         $objQuestion->search_engine_edit($this->id, FALSE, TRUE);
2658 2658
                         unset($objQuestion);
2659 2659
                     }
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
             Database::query($sql);
2665 2665
 
2666 2666
             // remove terms from db
2667
-            require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php';
2667
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2668 2668
             delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id);
2669 2669
         }
2670 2670
     }
@@ -2759,7 +2759,7 @@  discard block
 block discarded – undo
2759 2759
      */
2760 2760
     public function copy_exercise()
2761 2761
     {
2762
-        $exercise_obj= new Exercise();
2762
+        $exercise_obj = new Exercise();
2763 2763
         $exercise_obj = $this;
2764 2764
 
2765 2765
         // force the creation of a new exercise
@@ -2831,25 +2831,25 @@  discard block
 block discarded – undo
2831 2831
             $lp_id = 0;
2832 2832
         }
2833 2833
         if (empty($lp_item_id)) {
2834
-            $lp_item_id   = 0;
2834
+            $lp_item_id = 0;
2835 2835
         }
2836 2836
         if (empty($lp_item_view_id)) {
2837 2837
             $lp_item_view_id = 0;
2838 2838
         }
2839
-        $condition = ' WHERE exe_exo_id 	= ' . "'" . $this->id . "'" .' AND
2840
-					   exe_user_id 			= ' . "'" . api_get_user_id() . "'" . ' AND
2841
-					   c_id                 = ' . api_get_course_int_id() . ' AND
2842
-					   status 				= ' . "'" . Database::escape_string($status). "'" . ' AND
2843
-					   orig_lp_id 			= ' . "'" . $lp_id . "'" . ' AND
2844
-					   orig_lp_item_id 		= ' . "'" . $lp_item_id . "'" . ' AND
2845
-                       orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND
2846
-					   session_id 			= ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case
2839
+        $condition = ' WHERE exe_exo_id 	= '."'".$this->id."'".' AND
2840
+					   exe_user_id 			= ' . "'".api_get_user_id()."'".' AND
2841
+					   c_id                 = ' . api_get_course_int_id().' AND
2842
+					   status 				= ' . "'".Database::escape_string($status)."'".' AND
2843
+					   orig_lp_id 			= ' . "'".$lp_id."'".' AND
2844
+					   orig_lp_item_id 		= ' . "'".$lp_item_id."'".' AND
2845
+                       orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND
2846
+					   session_id 			= ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case
2847 2847
 
2848 2848
         $sql_track = 'SELECT * FROM '.$track_exercises.$condition;
2849 2849
 
2850 2850
         $result = Database::query($sql_track);
2851 2851
         $new_array = array();
2852
-        if (Database::num_rows($result) > 0 ) {
2852
+        if (Database::num_rows($result) > 0) {
2853 2853
             $new_array = Database::fetch_array($result, 'ASSOC');
2854 2854
             $new_array['num_exe'] = Database::num_rows($result);
2855 2855
         }
@@ -2892,12 +2892,12 @@  discard block
 block discarded – undo
2892 2892
         $questionList = array_map('intval', $questionList);
2893 2893
 
2894 2894
         $params = array(
2895
-            'exe_exo_id' => $this->id ,
2895
+            'exe_exo_id' => $this->id,
2896 2896
             'exe_user_id' => api_get_user_id(),
2897 2897
             'c_id' => api_get_course_int_id(),
2898 2898
             'status' =>  'incomplete',
2899 2899
             'session_id'  => api_get_session_id(),
2900
-            'data_tracking'  => implode(',', $questionList) ,
2900
+            'data_tracking'  => implode(',', $questionList),
2901 2901
             'start_date' => api_get_utc_datetime(),
2902 2902
             'orig_lp_id' => $safe_lp_id,
2903 2903
             'orig_lp_item_id'  => $safe_lp_item_id,
@@ -2929,7 +2929,7 @@  discard block
 block discarded – undo
2929 2929
         $nbrQuestions = $this->get_count_question_list();
2930 2930
 
2931 2931
         $all_button = $html = $label = '';
2932
-        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null;
2932
+        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
2933 2933
 
2934 2934
         if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
2935 2935
             $urlTitle = get_lang('ContinueTest');
@@ -2940,7 +2940,7 @@  discard block
 block discarded – undo
2940 2940
 
2941 2941
             $html .= Display::url(
2942 2942
                 $urlTitle,
2943
-                'exercise_submit_modal.php?' . http_build_query([
2943
+                'exercise_submit_modal.php?'.http_build_query([
2944 2944
                     'learnpath_id' => $safe_lp_id,
2945 2945
                     'learnpath_item_id' => $safe_lp_item_id,
2946 2946
                     'learnpath_item_view_id' => $safe_lp_item_view_id,
@@ -2957,7 +2957,7 @@  discard block
 block discarded – undo
2957 2957
                     'data-size' => 'md'
2958 2958
                 ]
2959 2959
             );
2960
-            $html .='<br />';
2960
+            $html .= '<br />';
2961 2961
         } else {
2962 2962
             // User
2963 2963
             if (api_is_allowed_to_session_edit()) {
@@ -2982,7 +2982,7 @@  discard block
 block discarded – undo
2982 2982
 
2983 2983
                     //Next question
2984 2984
                     if (!empty($questions_in_media)) {
2985
-                        $questions_in_media = "['".implode("','",$questions_in_media)."']";
2985
+                        $questions_in_media = "['".implode("','", $questions_in_media)."']";
2986 2986
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
2987 2987
                     } else {
2988 2988
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>';
@@ -3000,7 +3000,7 @@  discard block
 block discarded – undo
3000 3000
                     }
3001 3001
 					$class .= ' question-validate-btn'; // used to select it with jquery
3002 3002
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
3003
-                    $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
3003
+                    $all_button .= '&nbsp;'.Display::span(null, ['id' => 'save_all_reponse']);
3004 3004
                     $html .= $all_button;
3005 3005
                 }
3006 3006
             }
@@ -3242,8 +3242,8 @@  discard block
 block discarded – undo
3242 3242
             $params = array();
3243 3243
             $params['course_id'] = $course_id;
3244 3244
             $params['session_id'] = api_get_session_id();
3245
-            $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id();
3246
-            $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id;
3245
+            $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id();
3246
+            $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id;
3247 3247
             $params['question_id'] = $questionId;
3248 3248
             $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId;
3249 3249
 
@@ -3299,10 +3299,10 @@  discard block
 block discarded – undo
3299 3299
             $answer = $objAnswerTmp->selectAnswer($answerId);
3300 3300
             $answerComment = $objAnswerTmp->selectComment($answerId);
3301 3301
             $answerCorrect = $objAnswerTmp->isCorrect($answerId);
3302
-            $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
3302
+            $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId);
3303 3303
             $answerAutoId = $objAnswerTmp->selectAutoId($answerId);
3304 3304
 
3305
-            $answer_correct_array[$answerId] = (bool)$answerCorrect;
3305
+            $answer_correct_array[$answerId] = (bool) $answerCorrect;
3306 3306
 
3307 3307
             if ($debug) {
3308 3308
                 error_log("answer auto id: $answerAutoId ");
@@ -3311,7 +3311,7 @@  discard block
 block discarded – undo
3311 3311
 
3312 3312
             // Delineation
3313 3313
             $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
3314
-            $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
3314
+            $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
3315 3315
 
3316 3316
             switch ($answerType) {
3317 3317
                 // for unique answer
@@ -3324,7 +3324,7 @@  discard block
 block discarded – undo
3324 3324
                                     exe_id = '".$exeId."' AND
3325 3325
                                     question_id= '".$questionId."'";
3326 3326
                         $result = Database::query($sql);
3327
-                        $choice = Database::result($result,0,"answer");
3327
+                        $choice = Database::result($result, 0, "answer");
3328 3328
 
3329 3329
                         $studentChoice = $choice == $answerAutoId ? 1 : 0;
3330 3330
                         if ($studentChoice) {
@@ -3375,7 +3375,7 @@  discard block
 block discarded – undo
3375 3375
                     } else {
3376 3376
                         // If no result then the user just hit don't know
3377 3377
                         $studentChoice = 3;
3378
-                        $questionScore  +=  $doubt_score;
3378
+                        $questionScore += $doubt_score;
3379 3379
                     }
3380 3380
                     $totalScore = $questionScore;
3381 3381
                     break;
@@ -3391,17 +3391,17 @@  discard block
 block discarded – undo
3391 3391
                         }
3392 3392
 
3393 3393
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3394
-                        $real_answers[$answerId] = (bool)$studentChoice;
3394
+                        $real_answers[$answerId] = (bool) $studentChoice;
3395 3395
 
3396 3396
                         if ($studentChoice) {
3397
-                            $questionScore  +=$answerWeighting;
3397
+                            $questionScore += $answerWeighting;
3398 3398
                         }
3399 3399
                     } else {
3400 3400
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3401
-                        $real_answers[$answerId] = (bool)$studentChoice;
3401
+                        $real_answers[$answerId] = (bool) $studentChoice;
3402 3402
 
3403 3403
                         if (isset($studentChoice)) {
3404
-                            $questionScore  += $answerWeighting;
3404
+                            $questionScore += $answerWeighting;
3405 3405
                         }
3406 3406
                     }
3407 3407
                     $totalScore += $answerWeighting;
@@ -3419,16 +3419,16 @@  discard block
 block discarded – undo
3419 3419
                             $choice[$ind] = 1;
3420 3420
                         }
3421 3421
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3422
-                        $real_answers[$answerId] = (bool)$studentChoice;
3422
+                        $real_answers[$answerId] = (bool) $studentChoice;
3423 3423
                         if ($studentChoice) {
3424
-                            $questionScore +=$answerWeighting;
3424
+                            $questionScore += $answerWeighting;
3425 3425
                         }
3426 3426
                     } else {
3427 3427
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3428 3428
                         if (isset($studentChoice)) {
3429 3429
                             $questionScore += $answerWeighting;
3430 3430
                         }
3431
-                        $real_answers[$answerId] = (bool)$studentChoice;
3431
+                        $real_answers[$answerId] = (bool) $studentChoice;
3432 3432
                     }
3433 3433
                     $totalScore += $answerWeighting;
3434 3434
                     if ($debug) error_log("studentChoice: $studentChoice");
@@ -3440,7 +3440,7 @@  discard block
 block discarded – undo
3440 3440
                         $resultans = Database::query($sql);
3441 3441
                         while ($row = Database::fetch_array($resultans)) {
3442 3442
                             $ind = $row['answer'];
3443
-                            $result = explode(':',$ind);
3443
+                            $result = explode(':', $ind);
3444 3444
                             if (isset($result[0])) {
3445 3445
                                 $my_answer_id = isset($result[0]) ? $result[0] : '';
3446 3446
                                 $option = isset($result[1]) ? $result[1] : '';
@@ -3561,10 +3561,10 @@  discard block
 block discarded – undo
3561 3561
                             }
3562 3562
                             // adds the piece of text that is before the blank
3563 3563
                             //and ends with '[' into a general storage array
3564
-                            $real_text[] = api_substr($temp, 0, $pos +1);
3565
-                            $answer .= api_substr($temp, 0, $pos +1);
3564
+                            $real_text[] = api_substr($temp, 0, $pos + 1);
3565
+                            $answer .= api_substr($temp, 0, $pos + 1);
3566 3566
                             //take the string remaining (after the last "[" we found)
3567
-                            $temp = api_substr($temp, $pos +1);
3567
+                            $temp = api_substr($temp, $pos + 1);
3568 3568
                             // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3569 3569
                             if (($pos = api_strpos($temp, ']')) === false) {
3570 3570
                                 // adds the end of the text
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
                             //put the contents of the [] answer tag into correct_tags[]
3601 3601
                             $correct_tags[] = api_substr($temp, 0, $pos);
3602 3602
                             $j++;
3603
-                            $temp = api_substr($temp, $pos +1);
3603
+                            $temp = api_substr($temp, $pos + 1);
3604 3604
                         }
3605 3605
                         $answer = '';
3606 3606
                         $real_correct_tags = $correct_tags;
@@ -3623,7 +3623,7 @@  discard block
 block discarded – undo
3623 3623
                                 } elseif (!empty($user_tags[$i])) {
3624 3624
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3625 3625
                                     // adds the word in red at the end of the string, and strikes it
3626
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3626
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3627 3627
                                 } else {
3628 3628
                                     // adds a tabulation if no word has been typed by the student
3629 3629
                                     $answer .= ''; // remove &nbsp; that causes issue
@@ -3642,17 +3642,17 @@  discard block
 block discarded – undo
3642 3642
                                 } elseif (!empty ($user_tags[$i])) {
3643 3643
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3644 3644
                                     // adds the word in red at the end of the string, and strikes it
3645
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3645
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3646 3646
                                 } else {
3647 3647
                                     // adds a tabulation if no word has been typed by the student
3648
-                                    $answer .= '';  // remove &nbsp; that causes issue
3648
+                                    $answer .= ''; // remove &nbsp; that causes issue
3649 3649
                                 }
3650 3650
                             }
3651 3651
 
3652 3652
                             // adds the correct word, followed by ] to close the blank
3653
-                            $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]';
3654
-                            if (isset($real_text[$i +1])) {
3655
-                                $answer .= $real_text[$i +1];
3653
+                            $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
3654
+                            if (isset($real_text[$i + 1])) {
3655
+                                $answer .= $real_text[$i + 1];
3656 3656
                             }
3657 3657
                         }
3658 3658
                     } else {
@@ -3786,10 +3786,10 @@  discard block
 block discarded – undo
3786 3786
                         }
3787 3787
                         // adds the piece of text that is before the blank
3788 3788
                         //and ends with '[' into a general storage array
3789
-                        $realText[] = api_substr($temp, 0, $pos +1);
3790
-                        $answer .= api_substr($temp, 0, $pos +1);
3789
+                        $realText[] = api_substr($temp, 0, $pos + 1);
3790
+                        $answer .= api_substr($temp, 0, $pos + 1);
3791 3791
                         //take the string remaining (after the last "[" we found)
3792
-                        $temp = api_substr($temp, $pos +1);
3792
+                        $temp = api_substr($temp, $pos + 1);
3793 3793
                         // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3794 3794
                         if (($pos = api_strpos($temp, ']')) === false) {
3795 3795
                             // adds the end of the text
@@ -3823,7 +3823,7 @@  discard block
 block discarded – undo
3823 3823
                         //put the contents of the [] answer tag into correct_tags[]
3824 3824
                         $correctTags[] = api_substr($temp, 0, $pos);
3825 3825
                         $j++;
3826
-                        $temp = api_substr($temp, $pos +1);
3826
+                        $temp = api_substr($temp, $pos + 1);
3827 3827
                     }
3828 3828
                     $answer = '';
3829 3829
                     $realCorrectTags = $correctTags;
@@ -3843,22 +3843,22 @@  discard block
 block discarded – undo
3843 3843
                         } elseif (!empty($userTags[$i])) {
3844 3844
                             // else if the word entered by the student IS NOT the same as the one defined by the professor
3845 3845
                             // adds the word in red at the end of the string, and strikes it
3846
-                            $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>';
3846
+                            $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>';
3847 3847
                         } else {
3848 3848
                             // adds a tabulation if no word has been typed by the student
3849 3849
                             $answer .= ''; // remove &nbsp; that causes issue
3850 3850
                         }
3851 3851
                         // adds the correct word, followed by ] to close the blank
3852
-                        $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]';
3853
-                        if (isset($realText[$i +1])) {
3854
-                            $answer .= $realText[$i +1];
3852
+                        $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>]';
3853
+                        if (isset($realText[$i + 1])) {
3854
+                            $answer .= $realText[$i + 1];
3855 3855
                         }
3856 3856
                     }
3857 3857
                     break;
3858 3858
                 // for free answer
3859 3859
                 case FREE_ANSWER:
3860 3860
                     if ($from_database) {
3861
-                        $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3861
+                        $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3862 3862
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3863 3863
                         $resq = Database::query($query);
3864 3864
                         $data = Database::fetch_array($resq);
@@ -3869,9 +3869,9 @@  discard block
 block discarded – undo
3869 3869
                         $questionScore = $data['marks'];
3870 3870
 
3871 3871
                         if ($questionScore == -1) {
3872
-                            $totalScore+= 0;
3872
+                            $totalScore += 0;
3873 3873
                         } else {
3874
-                            $totalScore+= $questionScore;
3874
+                            $totalScore += $questionScore;
3875 3875
                         }
3876 3876
                         if ($questionScore == '') {
3877 3877
                             $questionScore = 0;
@@ -3892,14 +3892,14 @@  discard block
 block discarded – undo
3892 3892
                         $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3893 3893
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3894 3894
                         $resq   = Database::query($query);
3895
-                        $choice = Database::result($resq,0,'answer');
3895
+                        $choice = Database::result($resq, 0, 'answer');
3896 3896
                         $choice = str_replace('\r\n', '', $choice);
3897 3897
                         $choice = stripslashes($choice);
3898
-                        $questionScore = Database::result($resq,0,"marks");
3899
-                        if ($questionScore==-1) {
3900
-                            $totalScore+=0;
3898
+                        $questionScore = Database::result($resq, 0, "marks");
3899
+                        if ($questionScore == -1) {
3900
+                            $totalScore += 0;
3901 3901
                         } else {
3902
-                            $totalScore+=$questionScore;
3902
+                            $totalScore += $questionScore;
3903 3903
                         }
3904 3904
                         $arrques = $questionName;
3905 3905
                         $arrans  = $choice;
@@ -3944,7 +3944,7 @@  discard block
 block discarded – undo
3944 3944
 
3945 3945
                         while ($a_answers = Database::fetch_array($res_answers)) {
3946 3946
                             $i_answer_id = $a_answers['id']; //3
3947
-                            $s_answer_label = $a_answers['answer'];  // your daddy - your mother
3947
+                            $s_answer_label = $a_answers['answer']; // your daddy - your mother
3948 3948
                             $i_answer_correct_answer = $a_answers['correct']; //1 - 2
3949 3949
                             $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
3950 3950
 
@@ -3996,8 +3996,8 @@  discard block
 block discarded – undo
3996 3996
 
3997 3997
                             if ($show_result) {
3998 3998
                                 echo '<tr>';
3999
-                                echo '<td>' . $s_answer_label . '</td>';
4000
-                                echo '<td>' . $user_answer;
3999
+                                echo '<td>'.$s_answer_label.'</td>';
4000
+                                echo '<td>'.$user_answer;
4001 4001
 
4002 4002
                                 if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
4003 4003
                                     if (isset($real_list[$i_answer_correct_answer])) {
@@ -4106,7 +4106,7 @@  discard block
 block discarded – undo
4106 4106
                     if ($from_database) {
4107 4107
                         // getting the user answer
4108 4108
                         $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
4109
-                        $query   = "SELECT hotspot_correct, hotspot_coordinate
4109
+                        $query = "SELECT hotspot_correct, hotspot_coordinate
4110 4110
                                     FROM $TBL_TRACK_HOTSPOT
4111 4111
                                     WHERE
4112 4112
                                         hotspot_exe_id = '".$exeId."' AND
@@ -4114,20 +4114,20 @@  discard block
 block discarded – undo
4114 4114
                                         hotspot_answer_id='1'";
4115 4115
                         //by default we take 1 because it's a delineation
4116 4116
                         $resq = Database::query($query);
4117
-                        $row = Database::fetch_array($resq,'ASSOC');
4117
+                        $row = Database::fetch_array($resq, 'ASSOC');
4118 4118
 
4119 4119
                         $choice = $row['hotspot_correct'];
4120 4120
                         $user_answer = $row['hotspot_coordinate'];
4121 4121
 
4122 4122
                         // THIS is very important otherwise the poly_compile will throw an error!!
4123 4123
                         // round-up the coordinates
4124
-                        $coords = explode('/',$user_answer);
4124
+                        $coords = explode('/', $user_answer);
4125 4125
                         $user_array = '';
4126 4126
                         foreach ($coords as $coord) {
4127
-                            list($x,$y) = explode(';',$coord);
4127
+                            list($x, $y) = explode(';', $coord);
4128 4128
                             $user_array .= round($x).';'.round($y).'/';
4129 4129
                         }
4130
-                        $user_array = substr($user_array,0,-1);
4130
+                        $user_array = substr($user_array, 0, -1);
4131 4131
                     } else {
4132 4132
                         if (!empty($studentChoice)) {
4133 4133
                             $newquestionList[] = $questionId;
@@ -4137,13 +4137,13 @@  discard block
 block discarded – undo
4137 4137
                             $studentChoice = $choice[$answerId];
4138 4138
                             $questionScore += $answerWeighting;
4139 4139
 
4140
-                            if ($hotspot_delineation_result[1]==1) {
4140
+                            if ($hotspot_delineation_result[1] == 1) {
4141 4141
                                 $totalScore += $answerWeighting; //adding the total
4142 4142
                             }
4143 4143
                         }
4144 4144
                     }
4145
-                    $_SESSION['hotspot_coord'][1]	= $delineation_cord;
4146
-                    $_SESSION['hotspot_dest'][1]	= $answer_delineation_destination;
4145
+                    $_SESSION['hotspot_coord'][1] = $delineation_cord;
4146
+                    $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
4147 4147
                     break;
4148 4148
             } // end switch Answertype
4149 4149
 
@@ -4201,7 +4201,7 @@  discard block
 block discarded – undo
4201 4201
                                 $results_disabled
4202 4202
                             );
4203 4203
                             //}
4204
-                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
4204
+                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
4205 4205
                             //	if ($origin!='learnpath') {
4206 4206
                             ExerciseShowFunctions::display_multiple_answer_combination_true_false(
4207 4207
                                 $feedback_type,
@@ -4218,11 +4218,11 @@  discard block
 block discarded – undo
4218 4218
                             //}
4219 4219
                         } elseif ($answerType == FILL_IN_BLANKS) {
4220 4220
                             //if ($origin!='learnpath') {
4221
-                            ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled);
4221
+                            ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled);
4222 4222
                             //	}
4223 4223
                         } elseif ($answerType == CALCULATED_ANSWER) {
4224 4224
                             //if ($origin!='learnpath') {
4225
-                            ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0);
4225
+                            ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0);
4226 4226
                             //  }
4227 4227
                         } elseif ($answerType == FREE_ANSWER) {
4228 4228
                             //if($origin != 'learnpath') {
@@ -4276,13 +4276,13 @@  discard block
 block discarded – undo
4276 4276
                             $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
4277 4277
 
4278 4278
                             //round-up the coordinates
4279
-                            $coords = explode('/',$user_answer);
4279
+                            $coords = explode('/', $user_answer);
4280 4280
                             $user_array = '';
4281 4281
                             foreach ($coords as $coord) {
4282
-                                list($x,$y) = explode(';',$coord);
4282
+                                list($x, $y) = explode(';', $coord);
4283 4283
                                 $user_array .= round($x).';'.round($y).'/';
4284 4284
                             }
4285
-                            $user_array = substr($user_array,0,-1);
4285
+                            $user_array = substr($user_array, 0, -1);
4286 4286
 
4287 4287
                             if ($next) {
4288 4288
 
@@ -4309,7 +4309,7 @@  discard block
 block discarded – undo
4309 4309
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user));
4310 4310
                                 // //this is an area in pixels
4311 4311
                                 if ($debug > 0) {
4312
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4312
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4313 4313
                                 }
4314 4314
 
4315 4315
                                 if ($overlap < 1) {
@@ -4322,43 +4322,43 @@  discard block
 block discarded – undo
4322 4322
                                     // that is overlapped by the user's polygon
4323 4323
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4324 4324
                                     if ($debug > 1) {
4325
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4325
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4326 4326
                                     }
4327 4327
                                     // the final missing area is the percentage of the initial polygon
4328 4328
                                     // that is not overlapped by the user's polygon
4329 4329
                                     $final_missing = 100 - $final_overlap;
4330 4330
                                     if ($debug > 1) {
4331
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4331
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4332 4332
                                     }
4333 4333
                                     // the final excess area is the percentage of the initial polygon's size
4334 4334
                                     // that is covered by the user's polygon outside of the initial polygon
4335 4335
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4336 4336
                                     if ($debug > 1) {
4337
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4337
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4338 4338
                                     }
4339 4339
                                 }
4340 4340
 
4341 4341
                                 //checking the destination parameters parsing the "@@"
4342
-                                $destination_items= explode('@@', $answerDestination);
4342
+                                $destination_items = explode('@@', $answerDestination);
4343 4343
                                 $threadhold_total = $destination_items[0];
4344
-                                $threadhold_items=explode(';',$threadhold_total);
4344
+                                $threadhold_items = explode(';', $threadhold_total);
4345 4345
                                 $threadhold1 = $threadhold_items[0]; // overlap
4346 4346
                                 $threadhold2 = $threadhold_items[1]; // excess
4347
-                                $threadhold3 = $threadhold_items[2];	 //missing
4347
+                                $threadhold3 = $threadhold_items[2]; //missing
4348 4348
 
4349 4349
                                 // if is delineation
4350
-                                if ($answerId===1) {
4350
+                                if ($answerId === 1) {
4351 4351
                                     //setting colors
4352
-                                    if ($final_overlap>=$threadhold1) {
4353
-                                        $overlap_color=true; //echo 'a';
4352
+                                    if ($final_overlap >= $threadhold1) {
4353
+                                        $overlap_color = true; //echo 'a';
4354 4354
                                     }
4355 4355
                                     //echo $excess.'-'.$threadhold2;
4356
-                                    if ($final_excess<=$threadhold2) {
4357
-                                        $excess_color=true; //echo 'b';
4356
+                                    if ($final_excess <= $threadhold2) {
4357
+                                        $excess_color = true; //echo 'b';
4358 4358
                                     }
4359 4359
                                     //echo '--------'.$missing.'-'.$threadhold3;
4360
-                                    if ($final_missing<=$threadhold3) {
4361
-                                        $missing_color=true; //echo 'c';
4360
+                                    if ($final_missing <= $threadhold3) {
4361
+                                        $missing_color = true; //echo 'c';
4362 4362
                                     }
4363 4363
 
4364 4364
                                     // if pass
@@ -4367,67 +4367,67 @@  discard block
 block discarded – undo
4367 4367
                                         $final_missing <= $threadhold3 &&
4368 4368
                                         $final_excess <= $threadhold2
4369 4369
                                     ) {
4370
-                                        $next=1; //go to the oars
4371
-                                        $result_comment=get_lang('Acceptable');
4372
-                                        $final_answer = 1;	// do not update with  update_exercise_attempt
4370
+                                        $next = 1; //go to the oars
4371
+                                        $result_comment = get_lang('Acceptable');
4372
+                                        $final_answer = 1; // do not update with  update_exercise_attempt
4373 4373
                                     } else {
4374
-                                        $next=0;
4375
-                                        $result_comment=get_lang('Unacceptable');
4376
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment(1);
4377
-                                        $answerDestination=$objAnswerTmp->selectDestination(1);
4374
+                                        $next = 0;
4375
+                                        $result_comment = get_lang('Unacceptable');
4376
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment(1);
4377
+                                        $answerDestination = $objAnswerTmp->selectDestination(1);
4378 4378
                                         //checking the destination parameters parsing the "@@"
4379
-                                        $destination_items= explode('@@', $answerDestination);
4379
+                                        $destination_items = explode('@@', $answerDestination);
4380 4380
                                     }
4381
-                                } elseif($answerId>1) {
4381
+                                } elseif ($answerId > 1) {
4382 4382
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4383
-                                        if ($debug>0) {
4384
-                                            error_log(__LINE__.' - answerId is of type noerror',0);
4383
+                                        if ($debug > 0) {
4384
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4385 4385
                                         }
4386 4386
                                         //type no error shouldn't be treated
4387 4387
                                         $next = 1;
4388 4388
                                         continue;
4389 4389
                                     }
4390
-                                    if ($debug>0) {
4391
-                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
4390
+                                    if ($debug > 0) {
4391
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4392 4392
                                     }
4393 4393
                                     //check the intersection between the oar and the user
4394 4394
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
4395 4395
                                     //echo 'official';print_r($x_list);print_r($y_list);
4396 4396
                                     //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
4397
-                                    $inter= $result['success'];
4397
+                                    $inter = $result['success'];
4398 4398
 
4399 4399
                                     //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4400
-                                    $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4400
+                                    $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
4401 4401
 
4402
-                                    $poly_answer = convert_coordinates($delineation_cord,'|');
4403
-                                    $max_coord = poly_get_max($poly_user,$poly_answer);
4404
-                                    $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
4405
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4402
+                                    $poly_answer = convert_coordinates($delineation_cord, '|');
4403
+                                    $max_coord = poly_get_max($poly_user, $poly_answer);
4404
+                                    $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4405
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4406 4406
 
4407 4407
                                     if ($overlap == false) {
4408 4408
                                         //all good, no overlap
4409 4409
                                         $next = 1;
4410 4410
                                         continue;
4411 4411
                                     } else {
4412
-                                        if ($debug>0) {
4413
-                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
4412
+                                        if ($debug > 0) {
4413
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4414 4414
                                         }
4415 4415
                                         $organs_at_risk_hit++;
4416 4416
                                         //show the feedback
4417
-                                        $next=0;
4418
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
4419
-                                        $answerDestination=$objAnswerTmp->selectDestination($answerId);
4420
-
4421
-                                        $destination_items= explode('@@', $answerDestination);
4422
-                                        $try_hotspot=$destination_items[1];
4423
-                                        $lp_hotspot=$destination_items[2];
4424
-                                        $select_question_hotspot=$destination_items[3];
4425
-                                        $url_hotspot=$destination_items[4];
4417
+                                        $next = 0;
4418
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
4419
+                                        $answerDestination = $objAnswerTmp->selectDestination($answerId);
4420
+
4421
+                                        $destination_items = explode('@@', $answerDestination);
4422
+                                        $try_hotspot = $destination_items[1];
4423
+                                        $lp_hotspot = $destination_items[2];
4424
+                                        $select_question_hotspot = $destination_items[3];
4425
+                                        $url_hotspot = $destination_items[4];
4426 4426
                                     }
4427 4427
                                 }
4428 4428
                             } else {	// the first delineation feedback
4429
-                                if ($debug>0) {
4430
-                                    error_log(__LINE__.' first',0);
4429
+                                if ($debug > 0) {
4430
+                                    error_log(__LINE__.' first', 0);
4431 4431
                                 }
4432 4432
                             }
4433 4433
                         } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
@@ -4435,7 +4435,7 @@  discard block
 block discarded – undo
4435 4435
                             echo Display::tag('td', $answerMatching[$answerId]);
4436 4436
                             echo Display::tag(
4437 4437
                                 'td',
4438
-                                "$user_answer / " . Display::tag(
4438
+                                "$user_answer / ".Display::tag(
4439 4439
                                     'strong',
4440 4440
                                     $answerMatching[$answerCorrect],
4441 4441
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4575,7 +4575,7 @@  discard block
 block discarded – undo
4575 4575
                                     $exeId,
4576 4576
                                     $questionId,
4577 4577
                                     $nano
4578
-                                ) . '</td>
4578
+                                ).'</td>
4579 4579
                                 </tr>
4580 4580
                                 </table>';
4581 4581
                             break;
@@ -4634,7 +4634,7 @@  discard block
 block discarded – undo
4634 4634
 
4635 4635
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
4636 4636
                                 if ($debug > 0) {
4637
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4637
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4638 4638
                                 }
4639 4639
                                 if ($overlap < 1) {
4640 4640
                                     //shortcut to avoid complicated calculations
@@ -4645,17 +4645,17 @@  discard block
 block discarded – undo
4645 4645
                                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
4646 4646
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4647 4647
                                     if ($debug > 1) {
4648
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4648
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4649 4649
                                     }
4650 4650
                                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
4651 4651
                                     $final_missing = 100 - $final_overlap;
4652 4652
                                     if ($debug > 1) {
4653
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4653
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4654 4654
                                     }
4655 4655
                                     // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
4656 4656
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4657 4657
                                     if ($debug > 1) {
4658
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4658
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4659 4659
                                     }
4660 4660
                                 }
4661 4661
 
@@ -4665,7 +4665,7 @@  discard block
 block discarded – undo
4665 4665
                                 $threadhold_items = explode(';', $threadhold_total);
4666 4666
                                 $threadhold1 = $threadhold_items[0]; // overlap
4667 4667
                                 $threadhold2 = $threadhold_items[1]; // excess
4668
-                                $threadhold3 = $threadhold_items[2];  //missing
4668
+                                $threadhold3 = $threadhold_items[2]; //missing
4669 4669
                                 // if is delineation
4670 4670
                                 if ($answerId === 1) {
4671 4671
                                     //setting colors
@@ -4697,14 +4697,14 @@  discard block
 block discarded – undo
4697 4697
                                 } elseif ($answerId > 1) {
4698 4698
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4699 4699
                                         if ($debug > 0) {
4700
-                                            error_log(__LINE__ . ' - answerId is of type noerror', 0);
4700
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4701 4701
                                         }
4702 4702
                                         //type no error shouldn't be treated
4703 4703
                                         $next = 1;
4704 4704
                                         continue;
4705 4705
                                     }
4706 4706
                                     if ($debug > 0) {
4707
-                                        error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
4707
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4708 4708
                                     }
4709 4709
                                     //check the intersection between the oar and the user
4710 4710
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
@@ -4718,7 +4718,7 @@  discard block
 block discarded – undo
4718 4718
                                     $poly_answer = convert_coordinates($delineation_cord, '|');
4719 4719
                                     $max_coord = poly_get_max($poly_user, $poly_answer);
4720 4720
                                     $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4721
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4721
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4722 4722
 
4723 4723
                                     if ($overlap == false) {
4724 4724
                                         //all good, no overlap
@@ -4726,7 +4726,7 @@  discard block
 block discarded – undo
4726 4726
                                         continue;
4727 4727
                                     } else {
4728 4728
                                         if ($debug > 0) {
4729
-                                            error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
4729
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4730 4730
                                         }
4731 4731
                                         $organs_at_risk_hit++;
4732 4732
                                         //show the feedback
@@ -4738,12 +4738,12 @@  discard block
 block discarded – undo
4738 4738
                                         $try_hotspot = $destination_items[1];
4739 4739
                                         $lp_hotspot = $destination_items[2];
4740 4740
                                         $select_question_hotspot = $destination_items[3];
4741
-                                        $url_hotspot=$destination_items[4];
4741
+                                        $url_hotspot = $destination_items[4];
4742 4742
                                     }
4743 4743
                                 }
4744 4744
                             } else {	// the first delineation feedback
4745 4745
                                 if ($debug > 0) {
4746
-                                    error_log(__LINE__ . ' first', 0);
4746
+                                    error_log(__LINE__.' first', 0);
4747 4747
                                 }
4748 4748
                             }
4749 4749
                             break;
@@ -4765,7 +4765,7 @@  discard block
 block discarded – undo
4765 4765
                             echo Display::tag('td', $answerMatching[$answerId]);
4766 4766
                             echo Display::tag(
4767 4767
                                 'td',
4768
-                                "$user_answer / " . Display::tag(
4768
+                                "$user_answer / ".Display::tag(
4769 4769
                                     'strong',
4770 4770
                                     $answerMatching[$answerCorrect],
4771 4771
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4851,7 +4851,7 @@  discard block
 block discarded – undo
4851 4851
             //  we use the results from the session (from_db=0)
4852 4852
             // TODO Change this, because it is wrong to show the user
4853 4853
             //  some results that haven't been stored in the database yet
4854
-            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
4854
+            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) {
4855 4855
 
4856 4856
                 if ($debug) error_log('$from AND this is a hotspot kind of question ');
4857 4857
 
@@ -4860,19 +4860,19 @@  discard block
 block discarded – undo
4860 4860
                 if ($answerType == HOT_SPOT_DELINEATION) {
4861 4861
                     if (0) {
4862 4862
                         if ($overlap_color) {
4863
-                            $overlap_color='green';
4863
+                            $overlap_color = 'green';
4864 4864
                         } else {
4865
-                            $overlap_color='red';
4865
+                            $overlap_color = 'red';
4866 4866
                         }
4867 4867
                         if ($missing_color) {
4868
-                            $missing_color='green';
4868
+                            $missing_color = 'green';
4869 4869
                         } else {
4870
-                            $missing_color='red';
4870
+                            $missing_color = 'red';
4871 4871
                         }
4872 4872
                         if ($excess_color) {
4873
-                            $excess_color='green';
4873
+                            $excess_color = 'green';
4874 4874
                         } else {
4875
-                            $excess_color='red';
4875
+                            $excess_color = 'red';
4876 4876
                         }
4877 4877
                         if (!is_numeric($final_overlap)) {
4878 4878
                             $final_overlap = 0;
@@ -4884,33 +4884,33 @@  discard block
 block discarded – undo
4884 4884
                             $final_excess = 0;
4885 4885
                         }
4886 4886
 
4887
-                        if ($final_overlap>100) {
4887
+                        if ($final_overlap > 100) {
4888 4888
                             $final_overlap = 100;
4889 4889
                         }
4890 4890
 
4891
-                        $table_resume='<table class="data_table">
4891
+                        $table_resume = '<table class="data_table">
4892 4892
                                 <tr class="row_odd" >
4893 4893
                                     <td></td>
4894
-                                    <td ><b>' . get_lang('Requirements') . '</b></td>
4895
-                                    <td><b>' . get_lang('YourAnswer') . '</b></td>
4894
+                                    <td ><b>' . get_lang('Requirements').'</b></td>
4895
+                                    <td><b>' . get_lang('YourAnswer').'</b></td>
4896 4896
                                 </tr>
4897 4897
                                 <tr class="row_even">
4898
-                                    <td><b>' . get_lang('Overlap') . '</b></td>
4899
-                                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
4900
-                                    <td><div style="color:' . $overlap_color . '">'
4901
-                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
4898
+                                    <td><b>' . get_lang('Overlap').'</b></td>
4899
+                                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
4900
+                                    <td><div style="color:' . $overlap_color.'">'
4901
+                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
4902 4902
                                 </tr>
4903 4903
                                 <tr>
4904
-                                    <td><b>' . get_lang('Excess') . '</b></td>
4905
-                                    <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
4906
-                                    <td><div style="color:' . $excess_color . '">'
4907
-                                        . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
4904
+                                    <td><b>' . get_lang('Excess').'</b></td>
4905
+                                    <td>' . get_lang('Max').' '.$threadhold2.'</td>
4906
+                                    <td><div style="color:' . $excess_color.'">'
4907
+                                        . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
4908 4908
                                 </tr>
4909 4909
                                 <tr class="row_even">
4910
-                                    <td><b>' . get_lang('Missing') . '</b></td>
4911
-                                    <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
4912
-                                    <td><div style="color:' . $missing_color . '">'
4913
-                                        . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
4910
+                                    <td><b>' . get_lang('Missing').'</b></td>
4911
+                                    <td>' . get_lang('Max').' '.$threadhold3.'</td>
4912
+                                    <td><div style="color:' . $missing_color.'">'
4913
+                                        . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
4914 4914
                                 </tr>
4915 4915
                             </table>';
4916 4916
                         if ($next == 0) {
@@ -4925,20 +4925,20 @@  discard block
 block discarded – undo
4925 4925
                             $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
4926 4926
                         }
4927 4927
 
4928
-                        echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>
4928
+                        echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
4929 4929
                             <p style="text-align:center">';
4930 4930
 
4931
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
4931
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
4932 4932
                         $message .= $table_resume;
4933
-                        $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />';
4933
+                        $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
4934 4934
                         if ($organs_at_risk_hit > 0) {
4935
-                            $message .= '<p><b>' . get_lang('OARHit') . '</b></p>';
4935
+                            $message .= '<p><b>'.get_lang('OARHit').'</b></p>';
4936 4936
                         }
4937
-                        $message .='<p>' . $comment . '</p>';
4937
+                        $message .= '<p>'.$comment.'</p>';
4938 4938
                         echo $message;
4939 4939
                     } else {
4940 4940
                         echo $hotspot_delineation_result[0]; //prints message
4941
-                        $from_database = 1;  // the hotspot_solution.swf needs this variable
4941
+                        $from_database = 1; // the hotspot_solution.swf needs this variable
4942 4942
                     }
4943 4943
 
4944 4944
                     //save the score attempts
@@ -4960,20 +4960,20 @@  discard block
 block discarded – undo
4960 4960
                             $exerciseResultCoordinates[$quesId]
4961 4961
                         );
4962 4962
                     } else {
4963
-                        if ($final_answer==0) {
4963
+                        if ($final_answer == 0) {
4964 4964
                             $questionScore = 0;
4965
-                            $answer=0;
4965
+                            $answer = 0;
4966 4966
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4967 4967
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4968
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4969
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val);
4968
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4969
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val);
4970 4970
                                 }
4971 4971
                             }
4972 4972
                         } else {
4973 4973
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4974 4974
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4975
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4976
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val);
4975
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4976
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val);
4977 4977
                                 }
4978 4978
                             }
4979 4979
                         }
@@ -4992,7 +4992,7 @@  discard block
 block discarded – undo
4992 4992
                     echo "
4993 4993
                         <tr>
4994 4994
                             <td colspan=\"2\">
4995
-                                <p><em>" . get_lang('HotSpot') . "</em></p>
4995
+                                <p><em>" . get_lang('HotSpot')."</em></p>
4996 4996
 
4997 4997
                                 <div id=\"hotspot-solution-$questionId\"></div>
4998 4998
 
@@ -5030,7 +5030,7 @@  discard block
 block discarded – undo
5030 5030
 
5031 5031
         if ($saved_results) {
5032 5032
             if ($debug) error_log("Save question results $saved_results");
5033
-            if ($debug) error_log(print_r($choice ,1 ));
5033
+            if ($debug) error_log(print_r($choice, 1));
5034 5034
 
5035 5035
             if (empty($choice)) {
5036 5036
                 $choice = 0;
@@ -5042,14 +5042,14 @@  discard block
 block discarded – undo
5042 5042
                         $ans = $reply[$i];
5043 5043
                         Event::saveQuestionAttempt(
5044 5044
                             $questionScore,
5045
-                            $ans . ':' . $choice[$ans],
5045
+                            $ans.':'.$choice[$ans],
5046 5046
                             $quesId,
5047 5047
                             $exeId,
5048 5048
                             $i,
5049 5049
                             $this->id
5050 5050
                         );
5051 5051
                         if ($debug) {
5052
-                            error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]);
5052
+                            error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
5053 5053
                         }
5054 5054
                     }
5055 5055
                 } else {
@@ -5060,7 +5060,7 @@  discard block
 block discarded – undo
5060 5060
                     $reply = array_keys($choice);
5061 5061
 
5062 5062
                     if ($debug) {
5063
-                        error_log("reply " . print_r($reply, 1) . "");
5063
+                        error_log("reply ".print_r($reply, 1)."");
5064 5064
                     }
5065 5065
                     for ($i = 0; $i < sizeof($reply); $i++) {
5066 5066
                         $ans = $reply[$i];
@@ -5119,7 +5119,7 @@  discard block
 block discarded – undo
5119 5119
 
5120 5120
                 Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id);
5121 5121
             } else {
5122
-                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id);
5122
+                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
5123 5123
             }
5124 5124
         }
5125 5125
 
@@ -5129,8 +5129,8 @@  discard block
 block discarded – undo
5129 5129
 
5130 5130
         if ($saved_results) {
5131 5131
             $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5132
-            $sql = 'UPDATE ' . $stat_table . ' SET
5133
-                        exe_result = exe_result + ' . floatval($questionScore) . '
5132
+            $sql = 'UPDATE '.$stat_table.' SET
5133
+                        exe_result = exe_result + ' . floatval($questionScore).'
5134 5134
                     WHERE exe_id = ' . $exeId;
5135 5135
             if ($debug) error_log($sql);
5136 5136
             Database::query($sql);
@@ -5154,7 +5154,7 @@  discard block
 block discarded – undo
5154 5154
      */
5155 5155
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5156 5156
     {
5157
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5157
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5158 5158
             return null;
5159 5159
         }
5160 5160
         // Email configuration settings
@@ -5205,7 +5205,7 @@  discard block
 block discarded – undo
5205 5205
         $msg = str_replace("#course#", $courseInfo['name'], $msg1);
5206 5206
 
5207 5207
         if ($origin != 'learnpath') {
5208
-            $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5208
+            $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5209 5209
         }
5210 5210
         $msg1 = str_replace("#url#", $url_email, $msg);
5211 5211
         $mail_content = $msg1;
@@ -5234,7 +5234,7 @@  discard block
 block discarded – undo
5234 5234
      */
5235 5235
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5236 5236
     {
5237
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5237
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5238 5238
             return null;
5239 5239
         }
5240 5240
         // Email configuration settings
@@ -5297,11 +5297,11 @@  discard block
 block discarded – undo
5297 5297
             $msg .= '</table><br />';
5298 5298
 
5299 5299
 
5300
-            $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
5301
-            $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
5302
-            $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
5303
-            $msg    = str_replace("#mail#",        $user_info['email'],$msg1);
5304
-            $msg    = str_replace("#course#",      $course_info['name'],$msg1);
5300
+            $msg1   = str_replace("#exercise#", $this->exercise, $msg);
5301
+            $msg    = str_replace("#firstName#", $user_info['firstname'], $msg1);
5302
+            $msg1   = str_replace("#lastName#", $user_info['lastname'], $msg);
5303
+            $msg    = str_replace("#mail#", $user_info['email'], $msg1);
5304
+            $msg    = str_replace("#course#", $course_info['name'], $msg1);
5305 5305
 
5306 5306
             if ($origin != 'learnpath') {
5307 5307
                 $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
@@ -5330,7 +5330,7 @@  discard block
 block discarded – undo
5330 5330
 
5331 5331
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5332 5332
     {
5333
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5333
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5334 5334
             return null;
5335 5335
         }
5336 5336
         // Email configuration settings
@@ -5354,7 +5354,7 @@  discard block
 block discarded – undo
5354 5354
             $answer_type = $item['answer_type'];
5355 5355
 
5356 5356
             if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
5357
-                $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5357
+                $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5358 5358
                     .'<tr>'
5359 5359
                         .'<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>'
5360 5360
                         .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>'
@@ -5387,7 +5387,7 @@  discard block
 block discarded – undo
5387 5387
                             .'<td>&nbsp;#mail#</td>'
5388 5388
                         .'</tr>'
5389 5389
                     .'</table>';
5390
-            $msg .=  '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
5390
+            $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />';
5391 5391
             $msg1 = str_replace("#exercise#", $this->exercise, $msg);
5392 5392
             $msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
5393 5393
             $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
@@ -5395,7 +5395,7 @@  discard block
 block discarded – undo
5395 5395
             $msg = str_replace("#course#", $course_info['name'], $msg1);
5396 5396
 
5397 5397
             if ($origin != 'learnpath') {
5398
-                $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5398
+                $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5399 5399
             }
5400 5400
             $msg1 = str_replace("#url#", $url_email, $msg);
5401 5401
             $mail_content = $msg1;
@@ -5461,10 +5461,10 @@  discard block
 block discarded – undo
5461 5461
         }
5462 5462
         $html  = '<div class="question-result">';
5463 5463
         $html .= Display::page_header(
5464
-            Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5464
+            Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5465 5465
         );
5466 5466
         $html .= Display::description($array);
5467
-        $html .="</div>";
5467
+        $html .= "</div>";
5468 5468
         return $html;
5469 5469
     }
5470 5470
 
@@ -5581,7 +5581,7 @@  discard block
 block discarded – undo
5581 5581
                     false,
5582 5582
                     $objExercise->selectPropagateNeg()
5583 5583
                 );
5584
-                $totalScore      += $question_result['score'];
5584
+                $totalScore += $question_result['score'];
5585 5585
             }
5586 5586
 
5587 5587
             if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
@@ -5787,7 +5787,7 @@  discard block
 block discarded – undo
5787 5787
         }
5788 5788
 
5789 5789
         $rawMessage = "";
5790
-        if (!empty($message)){
5790
+        if (!empty($message)) {
5791 5791
             $rawMessage = $message;
5792 5792
             $message = Display::return_message($message, 'warning', false);
5793 5793
         }
@@ -5803,7 +5803,7 @@  discard block
 block discarded – undo
5803 5803
     {
5804 5804
         $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
5805 5805
         $sql = "SELECT max_score FROM $TBL_LP_ITEM
5806
-            WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'";
5806
+            WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'";
5807 5807
         $result = Database::query($sql);
5808 5808
         if (Database::num_rows($result) > 0) {
5809 5809
             return true;
@@ -6131,7 +6131,7 @@  discard block
 block discarded – undo
6131 6131
         $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
6132 6132
         $result = Database::query($sql_track);
6133 6133
         $new_array = array();
6134
-        if (Database::num_rows($result) > 0 ) {
6134
+        if (Database::num_rows($result) > 0) {
6135 6135
             $new_array = Database::fetch_array($result, 'ASSOC');
6136 6136
 
6137 6137
             $new_array['duration'] = null;
@@ -6143,11 +6143,11 @@  discard block
 block discarded – undo
6143 6143
                 $start_date = api_strtotime($start_date, 'UTC');
6144 6144
                 $end_date = api_strtotime($end_date, 'UTC');
6145 6145
                 if ($start_date && $end_date) {
6146
-                    $mytime = $end_date- $start_date;
6146
+                    $mytime = $end_date - $start_date;
6147 6147
                     $new_learnpath_item = new learnpathItem(null);
6148 6148
                     $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime);
6149 6149
                     $h = get_lang('h');
6150
-                    $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
6150
+                    $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
6151 6151
                     $new_array['duration'] = $time_attemp;
6152 6152
                 }
6153 6153
             }
@@ -6169,7 +6169,7 @@  discard block
 block discarded – undo
6169 6169
                     $result = Database::query($sql);
6170 6170
                 }
6171 6171
             } else {
6172
-                $remind_list = explode(',',$exercise_info['questions_to_check']);
6172
+                $remind_list = explode(',', $exercise_info['questions_to_check']);
6173 6173
 
6174 6174
                 $remind_list_string = '';
6175 6175
                 if ($action == 'add') {
@@ -6181,7 +6181,7 @@  discard block
 block discarded – undo
6181 6181
                         }
6182 6182
                         $remind_list_string = implode(',', $remind_list);
6183 6183
                     }
6184
-                } elseif ($action == 'delete')  {
6184
+                } elseif ($action == 'delete') {
6185 6185
                     if (!empty($remind_list)) {
6186 6186
                         if (in_array($question_id, $remind_list)) {
6187 6187
                             $remind_list = array_flip($remind_list);
@@ -6423,7 +6423,7 @@  discard block
 block discarded – undo
6423 6423
                     true
6424 6424
                 );
6425 6425
 
6426
-                $counter += count($mediaQuestions[$questionId]) - 1 ;
6426
+                $counter += count($mediaQuestions[$questionId]) - 1;
6427 6427
                 $before = count($questionList);
6428 6428
                 $wasMedia = true;
6429 6429
                 $nextValue += count($questionList);
@@ -6502,7 +6502,7 @@  discard block
 block discarded – undo
6502 6502
                         // If it was already seen, then merge the previous with
6503 6503
                         // the current category
6504 6504
                         $oldQuestionList = $newCategoryList[$rootElement]['question_list'];
6505
-                        $category['question_list'] = array_merge($oldQuestionList , $category['question_list']);
6505
+                        $category['question_list'] = array_merge($oldQuestionList, $category['question_list']);
6506 6506
                         $newCategoryList[$rootElement] = $category;
6507 6507
                     }
6508 6508
                 }
@@ -6528,7 +6528,7 @@  discard block
 block discarded – undo
6528 6528
 
6529 6529
                 if ($useRootAsCategoryTitle) {
6530 6530
                     if (isset($category['parent_info'])) {
6531
-                        $categoryName  = $category['parent_info']['title'];
6531
+                        $categoryName = $category['parent_info']['title'];
6532 6532
                     }
6533 6533
                 }
6534 6534
                 $html .= '<div class="row">';
@@ -6671,7 +6671,7 @@  discard block
 block discarded – undo
6671 6671
         // end foreach()
6672 6672
 
6673 6673
         if ($this->type == ALL_ON_ONE_PAGE) {
6674
-            $exercise_actions =  $this->show_button($questionId, $currentQuestion);
6674
+            $exercise_actions = $this->show_button($questionId, $currentQuestion);
6675 6675
             echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
6676 6676
         }
6677 6677
     }
@@ -6757,7 +6757,7 @@  discard block
 block discarded – undo
6757 6757
 
6758 6758
             // Showing the question
6759 6759
 
6760
-            $exercise_actions  = null;
6760
+            $exercise_actions = null;
6761 6761
 
6762 6762
             echo '<a id="questionanchor'.$questionId.'"></a><br />';
6763 6763
             echo '<div id="question_div_'.$questionId.'" class="main_question '.$remind_highlight.'" >';
@@ -7025,7 +7025,7 @@  discard block
 block discarded – undo
7025 7025
                         $header .= Display::tag('th', get_lang('Feedback'));
7026 7026
                     }
7027 7027
                     $s .= '<table class="data_table">';
7028
-                    $s.= Display::tag('tr', $header, array('style' => 'text-align:left;'));
7028
+                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
7029 7029
                 }
7030 7030
             }
7031 7031
 
@@ -7125,7 +7125,7 @@  discard block
 block discarded – undo
7125 7125
                             $s .= '<td>';
7126 7126
                             $s .= $comment;
7127 7127
                             $s .= '</td>';
7128
-                            $s .='</tr>';
7128
+                            $s .= '</tr>';
7129 7129
                         } else {
7130 7130
                             $s .= $answer_input;
7131 7131
                         }
@@ -7139,7 +7139,7 @@  discard block
 block discarded – undo
7139 7139
                             }
7140 7140
                         }
7141 7141
 
7142
-                        $s .='<tr>';
7142
+                        $s .= '<tr>';
7143 7143
                         $s .= Display::tag('td', $answer);
7144 7144
 
7145 7145
                         if (!empty($quiz_question_options)) {
@@ -7166,7 +7166,7 @@  discard block
 block discarded – undo
7166 7166
                             $s .= $comment;
7167 7167
                             $s .= '</td>';
7168 7168
                         }
7169
-                        $s.='</tr>';
7169
+                        $s .= '</tr>';
7170 7170
                     }
7171 7171
 
7172 7172
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
@@ -7195,16 +7195,16 @@  discard block
 block discarded – undo
7195 7195
                     $answer_input .= '</label>';
7196 7196
 
7197 7197
                     if ($show_comment) {
7198
-                        $s.= '<tr>';
7198
+                        $s .= '<tr>';
7199 7199
                         $s .= '<td>';
7200
-                        $s.= $answer_input;
7200
+                        $s .= $answer_input;
7201 7201
                         $s .= '</td>';
7202 7202
                         $s .= '<td>';
7203 7203
                         $s .= $comment;
7204 7204
                         $s .= '</td>';
7205
-                        $s.= '</tr>';
7205
+                        $s .= '</tr>';
7206 7206
                     } else {
7207
-                        $s.= $answer_input;
7207
+                        $s .= $answer_input;
7208 7208
                     }
7209 7209
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7210 7210
                     $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
@@ -7217,7 +7217,7 @@  discard block
 block discarded – undo
7217 7217
                         }
7218 7218
                     }
7219 7219
                     $answer = Security::remove_XSS($answer);
7220
-                    $s .='<tr>';
7220
+                    $s .= '<tr>';
7221 7221
                     $s .= Display::tag('td', $answer);
7222 7222
 
7223 7223
                     foreach ($objQuestionTmp->options as $key => $item) {
@@ -7241,7 +7241,7 @@  discard block
 block discarded – undo
7241 7241
                         $s .= $comment;
7242 7242
                         $s .= '</td>';
7243 7243
                     }
7244
-                    $s.='</tr>';
7244
+                    $s .= '</tr>';
7245 7245
                 } elseif ($answerType == FILL_IN_BLANKS) {
7246 7246
                     list($answer) = explode('::', $answer);
7247 7247
 
@@ -7275,7 +7275,7 @@  discard block
 block discarded – undo
7275 7275
                                     $value = str_replace('&nbsp;', '', trim($value[0]));
7276 7276
                                 }
7277 7277
                                 $correct_item = preg_quote($correct_item);
7278
-                                $correct_item = api_preg_replace('|/|', '\/', $correct_item);   // to prevent error if there is a / in the text to find
7278
+                                $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find
7279 7279
                                 $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1);
7280 7280
                             }
7281 7281
                             $i++;
@@ -7332,7 +7332,7 @@  discard block
 block discarded – undo
7332 7332
                         }
7333 7333
 
7334 7334
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7335
-                            $s.= '<script>
7335
+                            $s .= '<script>
7336 7336
                                 jsPlumb.ready(function() {
7337 7337
                                     jsPlumb.connect({
7338 7338
                                         source: "window_'.$windowId.'",
@@ -7347,14 +7347,14 @@  discard block
 block discarded – undo
7347 7347
                         }
7348 7348
                         $s .= '</select></div></td>';
7349 7349
 
7350
-                        $s.='<td width="45%" valign="top" >';
7350
+                        $s .= '<td width="45%" valign="top" >';
7351 7351
 
7352 7352
                         if (isset($select_items[$lines_count])) {
7353
-                            $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7353
+                            $s .= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7354 7354
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7355 7355
                                   </div>';
7356 7356
                         } else {
7357
-                            $s.='&nbsp;';
7357
+                            $s .= '&nbsp;';
7358 7358
                         }
7359 7359
 
7360 7360
                         $s .= '</td>';
@@ -7368,16 +7368,16 @@  discard block
 block discarded – undo
7368 7368
                                 $s .= '<tr>
7369 7369
                                       <td colspan="2"></td>
7370 7370
                                       <td valign="top">';
7371
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7371
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7372 7372
                                 $s .= $select_items[$lines_count]['answer'];
7373
-                                $s.="</td>
7373
+                                $s .= "</td>
7374 7374
                                 </tr>";
7375 7375
                                 $lines_count++;
7376 7376
                             } // end while()
7377 7377
                         }  // end if()
7378 7378
                         $matching_correct_answer++;
7379 7379
                     }
7380
-                } elseif ($answerType ==  DRAGGABLE) {
7380
+                } elseif ($answerType == DRAGGABLE) {
7381 7381
                     // matching type, showing suggestions and answers
7382 7382
                     // TODO: replace $answerId by $numAnswer
7383 7383
 
@@ -7420,7 +7420,7 @@  discard block
 block discarded – undo
7420 7420
                         $s .= '</select>';
7421 7421
 
7422 7422
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7423
-                            $s.= '<script>
7423
+                            $s .= '<script>
7424 7424
                                 $(function() {
7425 7425
                                     deleteItem($("#'.$questionId.'_'.$selectedValue.'"), $("#drop_'.$windowId.'"));
7426 7426
                                 });
@@ -7429,11 +7429,11 @@  discard block
 block discarded – undo
7429 7429
 
7430 7430
 
7431 7431
                         if (isset($select_items[$lines_count])) {
7432
-                            $s.= '<div id="window_'.$windowId.'_answer" class="">
7432
+                            $s .= '<div id="window_'.$windowId.'_answer" class="">
7433 7433
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7434 7434
                                   </div>';
7435 7435
                         } else {
7436
-                            $s.='&nbsp;';
7436
+                            $s .= '&nbsp;';
7437 7437
                         }
7438 7438
                         $lines_count++;
7439 7439
                         //if the left side of the "matching" has been completely
@@ -7442,7 +7442,7 @@  discard block
 block discarded – undo
7442 7442
                         if (($lines_count - 1) == $num_suggestions) {
7443 7443
                             // if it remains answers to shown at the right side
7444 7444
                             while (isset($select_items[$lines_count])) {
7445
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7445
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7446 7446
                                 $s .= $select_items[$lines_count]['answer'];
7447 7447
                                 $lines_count++;
7448 7448
                             }
@@ -7545,9 +7545,9 @@  discard block
 block discarded – undo
7545 7545
 
7546 7546
             if (!$only_questions) {
7547 7547
                 if ($show_title) {
7548
-                    $html .=  TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7549
-                    $html .=  '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7550
-                    $html .=  $questionDescription;
7548
+                    $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7549
+                    $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7550
+                    $html .= $questionDescription;
7551 7551
                 } else {
7552 7552
                     $html .= '<div class="media">';
7553 7553
                     $html .= '<div class="pull-left">';
@@ -7563,11 +7563,11 @@  discard block
 block discarded – undo
7563 7563
                     $html .= '</div>';
7564 7564
                 }
7565 7565
                 //@todo I need to the get the feedback type
7566
-                $html .=  '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7567
-                $html .=  '<table class="exercise_questions">
7566
+                $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7567
+                $html .= '<table class="exercise_questions">
7568 7568
                            <tr>
7569 7569
                             <td valign="top" colspan="2">';
7570
-                $html .=  '</td></tr>';
7570
+                $html .= '</td></tr>';
7571 7571
             }
7572 7572
 
7573 7573
             $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
Please login to merge, or discard this patch.
main/exercice/overview.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 require_once '../inc/global.inc.php';
14 14
 
15
-$current_course_tool  = TOOL_QUIZ;
15
+$current_course_tool = TOOL_QUIZ;
16 16
 
17 17
 // Clear the exercise session just in case
18 18
 if (isset($_SESSION['objExercise'])) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 if ($time_control) {
51 51
     // Get time left for expiring time
52
-    $time_left = api_strtotime($clock_expired_time,'UTC') - time();
52
+    $time_left = api_strtotime($clock_expired_time, 'UTC') - time();
53 53
 
54 54
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
55 55
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 $html = '';
74 74
 $message = '';
75
-$html.= '<div class="exercise">';
75
+$html .= '<div class="exercise">';
76 76
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
77 77
 $edit_link = '';
78 78
 if ($is_allowed_to_edit && $objExercise->sessionId == $sessionId) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 $blockShowAnswers = false;
173 173
 if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
174
-    if (count($attempts) < $objExercise->attempts ) {
174
+    if (count($attempts) < $objExercise->attempts) {
175 175
         $blockShowAnswers = true;
176 176
     }
177 177
 }
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
             $attempt_result['exe_result'],
185 185
             $attempt_result['exe_weighting']
186 186
         );
187
-        $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?';
188
-        $attempt_url .= api_get_cidreq() . '&show_headers=1&';
187
+        $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?';
188
+        $attempt_url .= api_get_cidreq().'&show_headers=1&';
189 189
         $attempt_url .= http_build_query([
190 190
             'id' => $attempt_result['exe_id']
191 191
         ]);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
             get_lang('Show'),
196 196
             $attempt_url,
197 197
             [
198
-                'class' => $btn_class . 'btn btn-default',
198
+                'class' => $btn_class.'btn btn-default',
199 199
                 'data-title' => get_lang('Show'),
200 200
                 'data-size' => 'lg'
201 201
             ]
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             ),
214 214
             'userIp' => $attempt_result['user_ip']
215 215
         );
216
-        $attempt_link .= "&nbsp;&nbsp;&nbsp;" . $teacher_revised;
216
+        $attempt_link .= "&nbsp;&nbsp;&nbsp;".$teacher_revised;
217 217
 
218 218
         if (in_array(
219 219
             $objExercise->results_disabled,
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
         $attempt_message = Display::return_message($attempt_message, 'info');
305 305
     }
306 306
     if ($visible_return['value'] == true) {
307
-        $message .=   $attempt_message;
307
+        $message .= $attempt_message;
308 308
     }
309 309
 }
310 310
 
311 311
 if ($time_control) {
312
-    $html.= $objExercise->return_time_left_div();
312
+    $html .= $objExercise->return_time_left_div();
313 313
 }
314 314
 
315 315
 $html .= $message;
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
     $table_content,
330 330
     ['class' => 'table-responsive']
331 331
 );
332
-$html.= '</div>';
332
+$html .= '</div>';
333 333
 echo $html;
334 334
 
335 335
 Display::display_footer();
Please login to merge, or discard this patch.