Passed
Push — 1.10.x ( 5654d2...115d5a )
by Yannick
263:14 queued 212:07
created
main/exercice/hotspot_admin.inc.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -907,10 +907,10 @@
 block discarded – undo
907 907
                                         <?php } else { ?>
908 908
                                             <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
909 909
                                                    <?php
910
-                                               }
911
-                                           }
912
-                                           if ($answerType == HOT_SPOT) {
913
-                                               ?>
910
+                                                }
911
+                                            }
912
+                                            if ($answerType == HOT_SPOT) {
913
+                                                ?>
914 914
                                         <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
915 915
                                         <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
916 916
                                         <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" />
Please login to merge, or discard this patch.
main/exercice/hotspot_savescore.inc.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,15 +17,15 @@
 block discarded – undo
17 17
 $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
18 18
 if ($_GET['answerId'] == "0") // click is NOT on a hotspot
19 19
 {
20
-	$hit = 0;
21
-	$answerId = NULL;
20
+    $hit = 0;
21
+    $answerId = NULL;
22 22
 }
23 23
 else // user clicked ON a hotspot
24 24
 {
25
-	$hit = 1;
26
-	$answerId = api_substr($_GET['answerId'],22,2);
27
-	// Save into session
28
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
25
+    $hit = 1;
26
+    $answerId = api_substr($_GET['answerId'],22,2);
27
+    // Save into session
28
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
29 29
 }
30 30
 //round-up the coordinates
31 31
 $coords = explode('/',$coordinates);
Please login to merge, or discard this patch.
main/exercice/exercise_submit_modal.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 $learnpath_id = 0;
42 42
 
43 43
 if (empty($learnpath_id)) {
44
-	$learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']);
44
+    $learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']);
45 45
 }
46 46
 
47 47
 $learnpath_item_id = 0;
48 48
 
49 49
 if (empty($learnpath_item_id)) {
50
-	$learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']);
50
+    $learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']);
51 51
 }
52 52
 
53 53
 $_SESSION['hotspot_coord']=array();
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 $coords = explode('/', $_GET['hotspot']);
69 69
 $user_array = '';
70 70
 if (is_array($coords) && count($coords) > 0) {
71
-	foreach ($coords as $coord) {
71
+    foreach ($coords as $coord) {
72 72
         if (!empty($coord)) {
73 73
             list($x, $y) = explode(';', $coord);
74 74
             $user_array .= round($x).';'.round($y).'/';
75 75
         }
76
-	}
76
+    }
77 77
 }
78 78
 
79 79
 $choice_value = '';
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 // Getting the options by js
88 88
 if (empty($choice_value)) {
89 89
 
90
-	echo "<script>
90
+    echo "<script>
91 91
 		// this works for only radio buttons
92 92
 		var f = self.parent.window.document.frm_exercise;
93 93
 		var choice_js='';
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 		}
117 117
 
118 118
 	";
119
-	// IMPORTANT
120
-	//this is the real redirect function
121
-	//echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
119
+    // IMPORTANT
120
+    //this is the real redirect function
121
+    //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
122 122
     echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
123 123
     echo "$('#global-modal .modal-body').load(url);";
124
-	echo '</script>';
124
+    echo '</script>';
125 125
 
126 126
     exit;
127 127
 }
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 
175 175
 // creates a temporary Question object
176 176
 if (in_array($questionid, $questionList)) {
177
-	$objQuestionTmp 	= Question :: read($questionid);
178
-	$questionName		=$objQuestionTmp->selectTitle();
179
-	$questionDescription=$objQuestionTmp->selectDescription();
180
-	$questionWeighting	=$objQuestionTmp->selectWeighting();
181
-	$answerType			=$objQuestionTmp->selectType();
182
-	$quesId				=$objQuestionTmp->selectId(); //added by priya saini
177
+    $objQuestionTmp 	= Question :: read($questionid);
178
+    $questionName		=$objQuestionTmp->selectTitle();
179
+    $questionDescription=$objQuestionTmp->selectDescription();
180
+    $questionWeighting	=$objQuestionTmp->selectWeighting();
181
+    $answerType			=$objQuestionTmp->selectType();
182
+    $quesId				=$objQuestionTmp->selectId(); //added by priya saini
183 183
 }
184 184
 
185 185
 $objAnswerTmp=new Answer($questionid);
@@ -202,43 +202,43 @@  discard block
 block discarded – undo
202 202
 $totalScore = 0;
203 203
 
204 204
 if (!empty($choice_value)) {
205
-	for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
206
-		$answer            = $objAnswerTmp->selectAnswer($answerId);
207
-		$answerComment     = $objAnswerTmp->selectComment($answerId);
208
-		$answerDestination = $objAnswerTmp->selectDestination($answerId);
209
-
210
-		$answerCorrect     = $objAnswerTmp->isCorrect($answerId);
211
-		$answerWeighting   = $objAnswerTmp->selectWeighting($answerId);
212
-		$numAnswer         = $objAnswerTmp->selectAutoId($answerId);
213
-
214
-		//delineation
215
-		$delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
216
-		$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
205
+    for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
206
+        $answer            = $objAnswerTmp->selectAnswer($answerId);
207
+        $answerComment     = $objAnswerTmp->selectComment($answerId);
208
+        $answerDestination = $objAnswerTmp->selectDestination($answerId);
209
+
210
+        $answerCorrect     = $objAnswerTmp->isCorrect($answerId);
211
+        $answerWeighting   = $objAnswerTmp->selectWeighting($answerId);
212
+        $numAnswer         = $objAnswerTmp->selectAutoId($answerId);
213
+
214
+        //delineation
215
+        $delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
216
+        $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
217 217
         if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);}
218 218
 
219
-		switch($answerType) {
220
-			// for unique answer
221
-			case UNIQUE_ANSWER :
222
-				$studentChoice = ($choice_value == $numAnswer)?1:0;
223
-				if ($studentChoice) {
224
-					$questionScore	+=$answerWeighting;
225
-					$totalScore		+=$answerWeighting;
226
-					$newquestionList[]=$questionid;
227
-				}
228
-				break;
229
-			case HOT_SPOT_DELINEATION :
230
-			    $studentChoice=$choice[$answerId];
231
-				if ($studentChoice) {
232
-					$newquestionList[]=$questionid;
233
-				}
234
-				if ($answerId===1) {
235
-					$questionScore	+=$answerWeighting;
236
-					$totalScore		+=$answerWeighting;
237
-					$_SESSION['hotspot_coord'][1]	=$delineation_cord;
238
-					$_SESSION['hotspot_dest'][1]	=$answer_delineation_destination;
239
-				}
240
-				break;
241
-		}
219
+        switch($answerType) {
220
+            // for unique answer
221
+            case UNIQUE_ANSWER :
222
+                $studentChoice = ($choice_value == $numAnswer)?1:0;
223
+                if ($studentChoice) {
224
+                    $questionScore	+=$answerWeighting;
225
+                    $totalScore		+=$answerWeighting;
226
+                    $newquestionList[]=$questionid;
227
+                }
228
+                break;
229
+            case HOT_SPOT_DELINEATION :
230
+                $studentChoice=$choice[$answerId];
231
+                if ($studentChoice) {
232
+                    $newquestionList[]=$questionid;
233
+                }
234
+                if ($answerId===1) {
235
+                    $questionScore	+=$answerWeighting;
236
+                    $totalScore		+=$answerWeighting;
237
+                    $_SESSION['hotspot_coord'][1]	=$delineation_cord;
238
+                    $_SESSION['hotspot_dest'][1]	=$answer_delineation_destination;
239
+                }
240
+                break;
241
+        }
242 242
 
243 243
 
244 244
         if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
                         $lp_hotspot=$destination_items[2];
336 336
                         $select_question_hotspot=$destination_items[3];
337 337
                         $url_hotspot=$destination_items[4];
338
-                         //echo 'show the feedback';
338
+                            //echo 'show the feedback';
339 339
                     }
340 340
                 } elseif($answerId>1) {
341 341
                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
@@ -392,41 +392,41 @@  discard block
 block discarded – undo
392 392
                 //we send the error
393 393
             }
394 394
         }
395
-	}
395
+    }
396 396
 
397
-	if ($overlap_color) {
398
-		$overlap_color='green';
397
+    if ($overlap_color) {
398
+        $overlap_color='green';
399 399
     } else {
400
-		$overlap_color='red';
400
+        $overlap_color='red';
401 401
     }
402
-	if ($missing_color) {
403
-		$missing_color='green';
402
+    if ($missing_color) {
403
+        $missing_color='green';
404 404
     } else {
405
-		$missing_color='red';
405
+        $missing_color='red';
406 406
     }
407
-	if ($excess_color) {
408
-		$excess_color='green';
407
+    if ($excess_color) {
408
+        $excess_color='green';
409 409
     } else {
410
-		$excess_color='red';
410
+        $excess_color='red';
411 411
     }
412 412
 
413 413
     if (!is_numeric($final_overlap)) {
414
-    	$final_overlap = 0;
414
+        $final_overlap = 0;
415 415
     }
416 416
 
417 417
     if (!is_numeric($final_missing)) {
418
-    	$final_missing = 0;
418
+        $final_missing = 0;
419 419
     }
420 420
     if (!is_numeric($final_excess)) {
421
-    	$final_excess = 0;
421
+        $final_excess = 0;
422 422
     }
423 423
 
424 424
     if ($final_excess>100) {
425
-    	$final_excess = 100;
425
+        $final_excess = 100;
426 426
     }
427 427
 
428 428
 
429
-	$table_resume = '<table class="data_table" >
429
+    $table_resume = '<table class="data_table" >
430 430
 	<tr class="row_odd" >
431 431
 		<td></td>
432 432
 		<td ><b>'.get_lang('Requirements').'</b></td>
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
452 452
 	</tr>
453 453
 	</table>';
454
-	//var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
454
+    //var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
455 455
 }
456 456
 $_SESSION['newquestionList'] = $newquestionList;
457 457
 
@@ -468,68 +468,68 @@  discard block
 block discarded – undo
468 468
 if ($answerType != HOT_SPOT_DELINEATION) {
469 469
     if (!empty($destination)) {
470 470
         $item_list = explode('@@',$destination);
471
-    	//print_R($item_list);
472
-    	$try = $item_list[0];
473
-    	$lp = $item_list[1];
474
-    	$destinationid= $item_list[2];
475
-    	$url=$item_list[3];
471
+        //print_R($item_list);
472
+        $try = $item_list[0];
473
+        $lp = $item_list[1];
474
+        $destinationid= $item_list[2];
475
+        $url=$item_list[3];
476 476
     }
477
-	$table_resume='';
477
+    $table_resume='';
478 478
 } else {
479
-		$try = $try_hotspot;
480
-		$lp = $lp_hotspot;
481
-		$destinationid= $select_question_hotspot;
482
-		$url=$url_hotspot;
483
-	if ($organs_at_risk_hit==0 && $wrong_results==false ) {
484
-		// no error = no oar and no wrong result for delineation
485
-		//show if no error
486
-		//echo 'no error';
487
-		$comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
488
-		$answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);
489
-
490
-		//we send the error
491
-		$destination_items= explode('@@', $answerDestination);
492
-		$try=$destination_items[1];
493
-		$lp=$destination_items[2];
494
-		$destinationid=$destination_items[3];
495
-		$url=$destination_items[4];
496
-		$exerciseResult[$questionid] = 1;
497
-	} else {
498
-		$exerciseResult[$questionid] = 0;
499
-	}
479
+        $try = $try_hotspot;
480
+        $lp = $lp_hotspot;
481
+        $destinationid= $select_question_hotspot;
482
+        $url=$url_hotspot;
483
+    if ($organs_at_risk_hit==0 && $wrong_results==false ) {
484
+        // no error = no oar and no wrong result for delineation
485
+        //show if no error
486
+        //echo 'no error';
487
+        $comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
488
+        $answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);
489
+
490
+        //we send the error
491
+        $destination_items= explode('@@', $answerDestination);
492
+        $try=$destination_items[1];
493
+        $lp=$destination_items[2];
494
+        $destinationid=$destination_items[3];
495
+        $url=$destination_items[4];
496
+        $exerciseResult[$questionid] = 1;
497
+    } else {
498
+        $exerciseResult[$questionid] = 0;
499
+    }
500 500
 }
501 501
 
502 502
 // the link to retry the question
503 503
 if (isset($try) && $try==1) {
504
-	$num_value_array= (array_keys($questionList, $questionid));
505
-	$links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
504
+    $num_value_array= (array_keys($questionList, $questionid));
505
+    $links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
506 506
 }
507 507
 
508 508
 // the link to theory (a learning path)
509 509
 if (!empty($lp)) {
510
-	$lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
511
-	$list = new LearnpathList(api_get_user_id());
512
-	$flat_list = $list->get_flat_list();
513
-	$links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
510
+    $lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
511
+    $list = new LearnpathList(api_get_user_id());
512
+    $flat_list = $list->get_flat_list();
513
+    $links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
514 514
 }
515 515
 $links.='<br />';
516 516
 
517 517
 // the link to an external website or link
518 518
 if (!empty($url)) {
519
-	$links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
519
+    $links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
520 520
 }
521 521
 
522 522
 // the link to finish the test
523 523
 if ($destinationid==-1) {
524
-	$links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
524
+    $links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
525 525
 } else {
526
-	// the link to other question
527
-	if (in_array($destinationid,$questionList)) {
528
-		$objQuestionTmp = Question :: read($destinationid);
529
-		$questionName=$objQuestionTmp->selectTitle();
530
-		$num_value_array= (array_keys($questionList, $destinationid));
531
-		$links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
532
-	}
526
+    // the link to other question
527
+    if (in_array($destinationid,$questionList)) {
528
+        $objQuestionTmp = Question :: read($destinationid);
529
+        $questionName=$objQuestionTmp->selectTitle();
530
+        $num_value_array= (array_keys($questionList, $destinationid));
531
+        $links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
532
+    }
533 533
 }
534 534
 
535 535
 echo '<script>
@@ -546,43 +546,43 @@  discard block
 block discarded – undo
546 546
 </script>';
547 547
 
548 548
 if ($links!='') {
549
-	/*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
549
+    /*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
550 550
     <a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>';*/
551
-	echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
552
-
553
-	if ($answerType == HOT_SPOT_DELINEATION) {
554
-		if ($organs_at_risk_hit > 0) {
555
-			//$message='<p>'.get_lang('YourDelineation').'</p>';
556
-			//$message.=$table_resume;
557
-			$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
558
-			//if ($wrong_results) { }
559
-			$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
560
-			$message.='<p>'.$comment.'</p>';
561
-		} else {
562
-			$message='<p>'.get_lang('YourDelineation').'</p>';
563
-			$message.=$table_resume;
564
-			$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
565
-			$message.='<p>'.$comment.'</p>';
566
-		}
567
-		echo $message;
568
-	} else {
569
-		echo '<p>'.$comment.'</p>';
570
-	}
571
-	echo '<h3>'.$links.'</h3>';
572
-	echo '</div>';
573
-
574
-	$_SESSION['hot_spot_result']=$message;
575
-	$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
576
-	//reseting the exerciseResult variable
577
-	Session::write('exerciseResult',$exerciseResult);
578
-
579
-	//save this variables just in case the exercise loads an LP with other exercise
580
-	$_SESSION['objExerciseExtra'.$exerciseId] 	 = $_SESSION['objExercise'];
581
-	$_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
582
-	$_SESSION['questionListExtra'.$exerciseId]	 = $_SESSION['questionList'];
551
+    echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
552
+
553
+    if ($answerType == HOT_SPOT_DELINEATION) {
554
+        if ($organs_at_risk_hit > 0) {
555
+            //$message='<p>'.get_lang('YourDelineation').'</p>';
556
+            //$message.=$table_resume;
557
+            $message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
558
+            //if ($wrong_results) { }
559
+            $message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
560
+            $message.='<p>'.$comment.'</p>';
561
+        } else {
562
+            $message='<p>'.get_lang('YourDelineation').'</p>';
563
+            $message.=$table_resume;
564
+            $message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
565
+            $message.='<p>'.$comment.'</p>';
566
+        }
567
+        echo $message;
568
+    } else {
569
+        echo '<p>'.$comment.'</p>';
570
+    }
571
+    echo '<h3>'.$links.'</h3>';
572
+    echo '</div>';
573
+
574
+    $_SESSION['hot_spot_result']=$message;
575
+    $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
576
+    //reseting the exerciseResult variable
577
+    Session::write('exerciseResult',$exerciseResult);
578
+
579
+    //save this variables just in case the exercise loads an LP with other exercise
580
+    $_SESSION['objExerciseExtra'.$exerciseId] 	 = $_SESSION['objExercise'];
581
+    $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
582
+    $_SESSION['questionListExtra'.$exerciseId]	 = $_SESSION['questionList'];
583 583
 } else {
584
-	$questionNum++;
585
-	echo '<script>
584
+    $questionNum++;
585
+    echo '<script>
586 586
 			self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
587 587
    			//self.parent.tb_remove();
588 588
  	 	</script>';
Please login to merge, or discard this patch.
main/exercice/answer.class.php 1 patch
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
         return [];
156 156
     }
157 157
 
158
-     /**
159
-     * returns all answer ids from this question Id
160
-     *
161
-     * @author Yoselyn Castillo
162
-     * @return array - $id (answer ids)
163
-     */
158
+        /**
159
+         * returns all answer ids from this question Id
160
+         *
161
+         * @author Yoselyn Castillo
162
+         * @return array - $id (answer ids)
163
+         */
164 164
     public function selectAnswerId()
165 165
     {
166 166
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         }
181 181
 
182 182
         return $id;
183
-	}
183
+    }
184 184
 
185 185
     /**
186 186
      * Reads answer information from the data base ordered by parameter
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
      */
191 191
     public function readOrderedBy($field, $order='ASC')
192 192
     {
193
-		$field = Database::escape_string($field);
194
-		if (empty($field)) {
195
-			$field = 'position';
196
-		}
193
+        $field = Database::escape_string($field);
194
+        if (empty($field)) {
195
+            $field = 'position';
196
+        }
197 197
 
198
-		if ($order != 'ASC' && $order!='DESC') {
199
-			$order = 'ASC';
200
-		}
198
+        if ($order != 'ASC' && $order!='DESC') {
199
+            $order = 'ASC';
200
+        }
201 201
 
202
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
203
-		$TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
204
-		$questionId = intval($this->questionId);
202
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
203
+        $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
204
+        $questionId = intval($this->questionId);
205 205
 
206
-		$sql = "SELECT type FROM $TBL_QUIZ
206
+        $sql = "SELECT type FROM $TBL_QUIZ
207 207
 		        WHERE c_id = {$this->course_id} AND id = $questionId";
208
-		$result_question = Database::query($sql);
209
-		$questionType = Database::fetch_array($result_question);
208
+        $result_question = Database::query($sql);
209
+        $questionType = Database::fetch_array($result_question);
210 210
 
211 211
         if ($questionType['type'] == DRAGGABLE) {
212 212
             // Random is done by submit.js.tpl
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             return true;
216 216
         }
217 217
 
218
-		$sql = "SELECT
218
+        $sql = "SELECT
219 219
 		            answer,
220 220
 		            correct,
221 221
 		            comment,
@@ -230,16 +230,16 @@  discard block
 block discarded – undo
230 230
                     c_id = {$this->course_id} AND
231 231
                     question_id='".$questionId."'
232 232
                 ORDER BY $field $order";
233
-		$result=Database::query($sql);
234
-
235
-		$i = 1;
236
-		// while a record is found
237
-		$doubt_data = null;
238
-		while ($object = Database::fetch_object($result)) {
239
-		    if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
240
-		        $doubt_data = $object;
233
+        $result=Database::query($sql);
234
+
235
+        $i = 1;
236
+        // while a record is found
237
+        $doubt_data = null;
238
+        while ($object = Database::fetch_object($result)) {
239
+            if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
240
+                $doubt_data = $object;
241 241
                 continue;
242
-		    }
242
+            }
243 243
             $this->answer[$i] = $object->answer;
244 244
             $this->correct[$i] = $object->correct;
245 245
             $this->comment[$i] = $object->comment;
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
             $this->destination[$i] = $object->destination;
249 249
             $this->autoId[$i] = $object->id_auto;
250 250
             $i++;
251
-		}
251
+        }
252 252
 
253
-		if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
253
+        if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
254 254
             $this->answer[$i] = $doubt_data->answer;
255 255
             $this->correct[$i] = $doubt_data->correct;
256 256
             $this->comment[$i] = $doubt_data->comment;
@@ -259,86 +259,86 @@  discard block
 block discarded – undo
259 259
             $this->destination[$i] = $doubt_data->destination;
260 260
             $this->autoId[$i] = $doubt_data->id_auto;
261 261
             $i++;
262
-	    }
262
+        }
263 263
         $this->nbrAnswers = $i-1;
264
-	}
265
-
266
-	/**
267
-	 * returns the autoincrement id identificator
268
-	 *
269
-	 * @author Juan Carlos Ra�a
270
-	 * @return integer - answer num
271
-	 */
264
+    }
265
+
266
+    /**
267
+     * returns the autoincrement id identificator
268
+     *
269
+     * @author Juan Carlos Ra�a
270
+     * @return integer - answer num
271
+     */
272 272
     public function selectAutoId($id)
273 273
     {
274
-		return isset($this->autoId[$id]) ? $this->autoId[$id] : null;
275
-	}
276
-
277
-	/**
278
-	 * returns the number of answers in this question
279
-	 *
280
-	 * @author Olivier Brouckaert
281
-	 * @return integer - number of answers
282
-	 */
283
-	public function selectNbrAnswers()
274
+        return isset($this->autoId[$id]) ? $this->autoId[$id] : null;
275
+    }
276
+
277
+    /**
278
+     * returns the number of answers in this question
279
+     *
280
+     * @author Olivier Brouckaert
281
+     * @return integer - number of answers
282
+     */
283
+    public function selectNbrAnswers()
284 284
     {
285
-		return $this->nbrAnswers;
286
-	}
287
-
288
-	/**
289
-	 * returns the question ID which the answers belong to
290
-	 *
291
-	 * @author Olivier Brouckaert
292
-	 * @return integer - the question ID
293
-	 */
294
-	public function selectQuestionId()
285
+        return $this->nbrAnswers;
286
+    }
287
+
288
+    /**
289
+     * returns the question ID which the answers belong to
290
+     *
291
+     * @author Olivier Brouckaert
292
+     * @return integer - the question ID
293
+     */
294
+    public function selectQuestionId()
295 295
     {
296
-		return $this->questionId;
297
-	}
298
-
299
-	/**
300
-	 * returns the question ID of the destination question
301
-	 *
302
-	 * @author Julio Montoya
303
-	 * @return integer - the question ID
304
-	 */
305
-	public function selectDestination($id)
296
+        return $this->questionId;
297
+    }
298
+
299
+    /**
300
+     * returns the question ID of the destination question
301
+     *
302
+     * @author Julio Montoya
303
+     * @return integer - the question ID
304
+     */
305
+    public function selectDestination($id)
306 306
     {
307
-		return isset($this->destination[$id]) ? $this->destination[$id] : null;
308
-	}
307
+        return isset($this->destination[$id]) ? $this->destination[$id] : null;
308
+    }
309 309
 
310 310
     /**
311
-	 * returns the answer title
312
-	 *
313
-	 * @author Olivier Brouckaert
314
-	 * @param - integer $id - answer ID
315
-	 * @return string - answer title
316
-	 */
317
-	public function selectAnswer($id)
318
-	{
319
-		return isset($this->answer[$id]) ? $this->answer[$id] : null;
320
-	}
321
-
322
-	/**
323
-	 * return array answer by id else return a bool
324
-	 */
325
-	public function selectAnswerByAutoId($auto_id)
326
-	{
327
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
328
-
329
-		$auto_id = intval($auto_id);
330
-		$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
311
+     * returns the answer title
312
+     *
313
+     * @author Olivier Brouckaert
314
+     * @param - integer $id - answer ID
315
+     * @return string - answer title
316
+     */
317
+    public function selectAnswer($id)
318
+    {
319
+        return isset($this->answer[$id]) ? $this->answer[$id] : null;
320
+    }
321
+
322
+    /**
323
+     * return array answer by id else return a bool
324
+     */
325
+    public function selectAnswerByAutoId($auto_id)
326
+    {
327
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
328
+
329
+        $auto_id = intval($auto_id);
330
+        $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
331 331
 				WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
332
-		$rs = Database::query($sql);
332
+        $rs = Database::query($sql);
333 333
 
334
-		if (Database::num_rows($rs) > 0) {
335
-			$row = Database::fetch_array($rs, 'ASSOC');
334
+        if (Database::num_rows($rs) > 0) {
335
+            $row = Database::fetch_array($rs, 'ASSOC');
336 336
 
337
-			return $row;
338
-		}
337
+            return $row;
338
+        }
339 339
 
340
-		return false;
341
-	}
340
+        return false;
341
+    }
342 342
 
343 343
     /**
344 344
      * returns the answer title from an answer's position
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
      * @param - integer $id - answer ID
348 348
      * @return bool - answer title
349 349
      */
350
-	public function selectAnswerIdByPosition($pos)
351
-	{
352
-		foreach ($this->position as $k => $v) {
353
-			if ($v != $pos) {
354
-				continue;
355
-			}
350
+    public function selectAnswerIdByPosition($pos)
351
+    {
352
+        foreach ($this->position as $k => $v) {
353
+            if ($v != $pos) {
354
+                continue;
355
+            }
356 356
 
357
-			return $k;
358
-		}
357
+            return $k;
358
+        }
359 359
 
360
-		return false;
361
-	}
360
+        return false;
361
+    }
362 362
 
363 363
     /**
364 364
      * Returns a list of answers
@@ -367,18 +367,18 @@  discard block
 block discarded – undo
367 367
      * of (id, answer, comment, grade) and grade=weighting
368 368
      */
369 369
     public function getAnswersList($decode = false)
370
-     {
371
-	 	$list = array();
372
-         for ($i = 1; $i <= $this->nbrAnswers; $i++) {
373
-             if (!empty($this->answer[$i])) {
374
-
375
-	 			//Avoid problems when parsing elements with accents
376
-	 			if ($decode) {
377
-	        		$this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
378
-	        		$this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
379
-	 			}
380
-
381
-	 			$list[] = array(
370
+        {
371
+            $list = array();
372
+            for ($i = 1; $i <= $this->nbrAnswers; $i++) {
373
+                if (!empty($this->answer[$i])) {
374
+
375
+                    //Avoid problems when parsing elements with accents
376
+                    if ($decode) {
377
+                    $this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
378
+                    $this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
379
+                    }
380
+
381
+                    $list[] = array(
382 382
                     'id' => $i,
383 383
                     'answer' => $this->answer[$i],
384 384
                     'comment' => $this->comment[$i],
@@ -387,134 +387,134 @@  discard block
 block discarded – undo
387 387
                     'hotspot_type' => $this->hotspot_type[$i],
388 388
                     'correct' => $this->correct[$i],
389 389
                     'destination' => $this->destination[$i]
390
-				);
390
+                );
391
+            }
391 392
             }
392
-	 	}
393 393
 
394
-	 	return $list;
395
-	 }
394
+            return $list;
395
+        }
396 396
 
397
-	/**
398
-	 * Returns a list of grades
399
-	 * @author Yannick Warnier <[email protected]>
400
-	 * @return array	List of grades where grade=weighting (?)
401
-	 */
397
+    /**
398
+     * Returns a list of grades
399
+     * @author Yannick Warnier <[email protected]>
400
+     * @return array	List of grades where grade=weighting (?)
401
+     */
402 402
     public function getGradesList()
403
-     {
404
-	 	$list = array();
405
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
406
-	 		if(!empty($this->answer[$i])){
407
-	 			$list[$i] = $this->weighting[$i];
408
-	 		}
409
-	 	}
410
-	 	return $list;
411
-	 }
412
-
413
-	 /**
414
-	  * Returns the question type
415
-	  * @author	Yannick Warnier <[email protected]>
416
-	  * @return	integer	The type of the question this answer is bound to
417
-	  */
403
+        {
404
+            $list = array();
405
+            for ($i = 0; $i<$this->nbrAnswers;$i++){
406
+                if(!empty($this->answer[$i])){
407
+                    $list[$i] = $this->weighting[$i];
408
+                }
409
+            }
410
+            return $list;
411
+        }
412
+
413
+        /**
414
+         * Returns the question type
415
+         * @author	Yannick Warnier <[email protected]>
416
+         * @return	integer	The type of the question this answer is bound to
417
+         */
418 418
     public function getQuestionType()
419
-     {
420
-	 	$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
421
-	 	$sql = "SELECT type FROM $TBL_QUESTIONS
419
+        {
420
+            $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
421
+            $sql = "SELECT type FROM $TBL_QUESTIONS
422 422
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
423
-	 	$res = Database::query($sql);
424
-	 	if (Database::num_rows($res)<=0){
425
-	 		return null;
426
-	 	}
427
-	 	$row = Database::fetch_array($res);
428
-
429
-	 	return $row['type'];
430
-	 }
431
-
432
-
433
-	/**
434
-	 * tells if answer is correct or not
435
-	 *
436
-	 * @author Olivier Brouckaert
437
-	 * @param - integer $id - answer ID
438
-	 * @return integer - 0 if bad answer, not 0 if good answer
439
-	 */
423
+            $res = Database::query($sql);
424
+            if (Database::num_rows($res)<=0){
425
+                return null;
426
+            }
427
+            $row = Database::fetch_array($res);
428
+
429
+            return $row['type'];
430
+        }
431
+
432
+
433
+    /**
434
+     * tells if answer is correct or not
435
+     *
436
+     * @author Olivier Brouckaert
437
+     * @param - integer $id - answer ID
438
+     * @return integer - 0 if bad answer, not 0 if good answer
439
+     */
440 440
     public function isCorrect($id)
441
-	{
442
-		return isset($this->correct[$id]) ? $this->correct[$id] : null;
443
-	}
444
-
445
-	/**
446
-	 * returns answer comment
447
-	 *
448
-	 * @author Olivier Brouckaert
449
-	 * @param - integer $id - answer ID
450
-	 * @return string - answer comment
451
-	 */
441
+    {
442
+        return isset($this->correct[$id]) ? $this->correct[$id] : null;
443
+    }
444
+
445
+    /**
446
+     * returns answer comment
447
+     *
448
+     * @author Olivier Brouckaert
449
+     * @param - integer $id - answer ID
450
+     * @return string - answer comment
451
+     */
452 452
     public function selectComment($id)
453
-	{
453
+    {
454 454
         return isset($this->comment[$id]) ? $this->comment[$id] : null;
455
-	}
456
-
457
-	/**
458
-	 * returns answer weighting
459
-	 *
460
-	 * @author Olivier Brouckaert
461
-	 * @param - integer $id - answer ID
462
-	 * @return integer - answer weighting
463
-	 */
455
+    }
456
+
457
+    /**
458
+     * returns answer weighting
459
+     *
460
+     * @author Olivier Brouckaert
461
+     * @param - integer $id - answer ID
462
+     * @return integer - answer weighting
463
+     */
464 464
     public function selectWeighting($id)
465
-	{
466
-		return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
467
-	}
468
-
469
-	/**
470
-	 * returns answer position
471
-	 *
472
-	 * @author Olivier Brouckaert
473
-	 * @param - integer $id - answer ID
474
-	 * @return integer - answer position
475
-	 */
476
-	function selectPosition($id)
477
-	{
478
-		return isset($this->position[$id]) ? $this->position[$id] : null;
479
-	}
480
-
481
-	/**
482
-	 * returns answer hotspot coordinates
483
-	 *
484
-	 * @author	Olivier Brouckaert
485
-	 * @param	integer	Answer ID
486
-	 * @return	integer	Answer position
487
-	 */
465
+    {
466
+        return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
467
+    }
468
+
469
+    /**
470
+     * returns answer position
471
+     *
472
+     * @author Olivier Brouckaert
473
+     * @param - integer $id - answer ID
474
+     * @return integer - answer position
475
+     */
476
+    function selectPosition($id)
477
+    {
478
+        return isset($this->position[$id]) ? $this->position[$id] : null;
479
+    }
480
+
481
+    /**
482
+     * returns answer hotspot coordinates
483
+     *
484
+     * @author	Olivier Brouckaert
485
+     * @param	integer	Answer ID
486
+     * @return	integer	Answer position
487
+     */
488 488
     public function selectHotspotCoordinates($id)
489
-	{
490
-		return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
491
-	}
492
-
493
-	/**
494
-	 * returns answer hotspot type
495
-	 *
496
-	 * @author	Toon Keppens
497
-	 * @param	integer		Answer ID
498
-	 * @return	integer		Answer position
499
-	 */
489
+    {
490
+        return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
491
+    }
492
+
493
+    /**
494
+     * returns answer hotspot type
495
+     *
496
+     * @author	Toon Keppens
497
+     * @param	integer		Answer ID
498
+     * @return	integer		Answer position
499
+     */
500 500
     public function selectHotspotType($id)
501
-	{
502
-		return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
503
-	}
504
-
505
-	/**
506
-	 * Creates a new answer
507
-	 *
508
-	 * @author Olivier Brouckaert
509
-	 * @param string 	$answer answer title
510
-	 * @param integer 	$correct 0 if bad answer, not 0 if good answer
511
-	 * @param string 	$comment answer comment
512
-	 * @param integer 	$weighting answer weighting
513
-	 * @param integer 	$position answer position
514
-	 * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
515
-	 * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
501
+    {
502
+        return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
503
+    }
504
+
505
+    /**
506
+     * Creates a new answer
507
+     *
508
+     * @author Olivier Brouckaert
509
+     * @param string 	$answer answer title
510
+     * @param integer 	$correct 0 if bad answer, not 0 if good answer
511
+     * @param string 	$comment answer comment
512
+     * @param integer 	$weighting answer weighting
513
+     * @param integer 	$position answer position
514
+     * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
515
+     * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
516 516
      * @param string   $destination
517
-	 */
517
+     */
518 518
     public function createAnswer(
519 519
         $answer,
520 520
         $correct,
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
         $new_hotspot_type = null,
526 526
         $destination = ''
527 527
     ) {
528
-		$this->new_nbrAnswers++;
528
+        $this->new_nbrAnswers++;
529 529
         $id = $this->new_nbrAnswers;
530 530
         $this->new_answer[$id] = $answer;
531 531
         $this->new_correct[$id] = $correct;
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
         $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
536 536
         $this->new_hotspot_type[$id] = $new_hotspot_type;
537 537
         $this->new_destination[$id] = $destination;
538
-	}
538
+    }
539 539
 
540 540
     /**
541 541
      * Updates an answer
@@ -577,31 +577,31 @@  discard block
 block discarded – undo
577 577
         ];
578 578
 
579 579
         Database::update($answerTable, $params, ['id_auto = ?' => $autoId]);
580
-	}
580
+    }
581 581
 
582
-	/**
583
-	 * Records answers into the data base
584
-	 *
585
-	 * @author Olivier Brouckaert
586
-	 */
582
+    /**
583
+     * Records answers into the data base
584
+     *
585
+     * @author Olivier Brouckaert
586
+     */
587 587
     public function save()
588 588
     {
589
-		$answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
590
-		$questionId = intval($this->questionId);
589
+        $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
590
+        $questionId = intval($this->questionId);
591 591
 
592
-		$c_id = $this->course['real_id'];
592
+        $c_id = $this->course['real_id'];
593 593
         $correctList = [];
594 594
         $answerList = [];
595 595
 
596
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
597
-			$answer = $this->new_answer[$i];
598
-			$correct = $this->new_correct[$i];
599
-			$comment = $this->new_comment[$i];
600
-			$weighting = $this->new_weighting[$i];
601
-			$position = $this->new_position[$i];
602
-			$hotspot_coordinates = $this->new_hotspot_coordinates[$i];
603
-			$hotspot_type = $this->new_hotspot_type[$i];
604
-			$destination = $this->new_destination[$i];
596
+        for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
597
+            $answer = $this->new_answer[$i];
598
+            $correct = $this->new_correct[$i];
599
+            $comment = $this->new_comment[$i];
600
+            $weighting = $this->new_weighting[$i];
601
+            $position = $this->new_position[$i];
602
+            $hotspot_coordinates = $this->new_hotspot_coordinates[$i];
603
+            $hotspot_type = $this->new_hotspot_type[$i];
604
+            $destination = $this->new_destination[$i];
605 605
             $autoId = $this->selectAutoId($i);
606 606
 
607 607
             if (!isset($this->position[$i])) {
@@ -698,36 +698,36 @@  discard block
 block discarded – undo
698 698
             }
699 699
         }
700 700
 
701
-		// moves $new_* arrays
702
-		$this->answer = $this->new_answer;
703
-		$this->correct = $this->new_correct;
704
-		$this->comment = $this->new_comment;
705
-		$this->weighting = $this->new_weighting;
706
-		$this->position = $this->new_position;
707
-		$this->hotspot_coordinates = $this->new_hotspot_coordinates;
708
-		$this->hotspot_type = $this->new_hotspot_type;
709
-
710
-		$this->nbrAnswers = $this->new_nbrAnswers;
711
-		$this->destination = $this->new_destination;
712
-		// clears $new_* arrays
713
-
714
-		$this->cancel();
715
-	}
716
-
717
-	/**
718
-	 * Duplicates answers by copying them into another question
719
-	 *
720
-	 * @author Olivier Brouckaert
721
-	 * @param  int question id
701
+        // moves $new_* arrays
702
+        $this->answer = $this->new_answer;
703
+        $this->correct = $this->new_correct;
704
+        $this->comment = $this->new_comment;
705
+        $this->weighting = $this->new_weighting;
706
+        $this->position = $this->new_position;
707
+        $this->hotspot_coordinates = $this->new_hotspot_coordinates;
708
+        $this->hotspot_type = $this->new_hotspot_type;
709
+
710
+        $this->nbrAnswers = $this->new_nbrAnswers;
711
+        $this->destination = $this->new_destination;
712
+        // clears $new_* arrays
713
+
714
+        $this->cancel();
715
+    }
716
+
717
+    /**
718
+     * Duplicates answers by copying them into another question
719
+     *
720
+     * @author Olivier Brouckaert
721
+     * @param  int question id
722 722
      * @param  array destination course info (result of the function api_get_course_info() )
723
-	 */
723
+     */
724 724
     public function duplicate($newQuestionId, $course_info = null)
725 725
     {
726 726
         if (empty($course_info)) {
727 727
             $course_info = $this->course;
728 728
         }
729 729
 
730
-		$TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
730
+        $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
731 731
         $fixed_list = array();
732 732
 
733 733
         if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 
742 742
             if (!empty($origin_options)) {
743 743
                 foreach ($origin_options as $item) {
744
-            	   $new_option_list[] = $item['id'];
744
+                    $new_option_list[] = $item['id'];
745 745
                 }
746 746
             }
747 747
 
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
             }
756 756
         }
757 757
 
758
-		// if at least one answer
759
-		if ($this->nbrAnswers) {
760
-			// inserts new answers into data base
761
-			$c_id = $course_info['real_id'];
758
+        // if at least one answer
759
+        if ($this->nbrAnswers) {
760
+            // inserts new answers into data base
761
+            $c_id = $course_info['real_id'];
762 762
 
763
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
763
+            for ($i=1;$i <= $this->nbrAnswers;$i++) {
764 764
                 if ($this->course['id'] != $course_info['id']) {
765 765
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
766 766
                         $this->answer[$i],
@@ -774,8 +774,8 @@  discard block
 block discarded – undo
774 774
                     );
775 775
                 }
776 776
 
777
-				$answer = $this->answer[$i];
778
-				$correct = $this->correct[$i];
777
+                $answer = $this->answer[$i];
778
+                $correct = $this->correct[$i];
779 779
 
780 780
                 if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
781 781
                     self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
@@ -783,12 +783,12 @@  discard block
 block discarded – undo
783 783
                     $correct = $fixed_list[intval($correct)];
784 784
                 }
785 785
 
786
-				$comment = $this->comment[$i];
787
-				$weighting = $this->weighting[$i];
788
-				$position = $this->position[$i];
789
-				$hotspot_coordinates = $this->hotspot_coordinates[$i];
790
-				$hotspot_type = $this->hotspot_type[$i];
791
-				$destination = $this->destination[$i];
786
+                $comment = $this->comment[$i];
787
+                $weighting = $this->weighting[$i];
788
+                $position = $this->position[$i];
789
+                $hotspot_coordinates = $this->hotspot_coordinates[$i];
790
+                $hotspot_type = $this->hotspot_type[$i];
791
+                $destination = $this->destination[$i];
792 792
 
793 793
                 $params = [
794 794
                     'c_id' => $c_id,
@@ -808,9 +808,9 @@  discard block
 block discarded – undo
808 808
                     $sql = "UPDATE $TBL_REPONSES SET id = iid, id_auto = iid WHERE iid = $id";
809 809
                     Database::query($sql);
810 810
                 }
811
-			}
811
+            }
812 812
         }
813
-	}
813
+    }
814 814
 
815 815
     /**
816 816
      * Get the necessary JavaScript for some answers
Please login to merge, or discard this patch.
main/exercice/fill_blanks.class.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -729,43 +729,43 @@  discard block
 block discarded – undo
729 729
     }
730 730
     
731 731
     /**
732
-    * Return an array of student state answers for fill the blank questions
733
-    * for each students that answered the question
734
-    * -2  : didn't answer
735
-    * -1  : student answer is wrong
736
-    *  0  : student answer is correct
737
-    * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
738
-    *
739
-    * @param $testId
740
-    * @param $questionId
741
-    * @param $studentsIdList
742
-    * @param $startDate
743
-    * @param $endDate
744
-    * @param bool $useLastAnswerredAttempt
745
-    * @return array
746
-    * (
747
-    *     [student_id] => Array
748
-    *         (
749
-    *             [first fill the blank for question] => -1
750
-    *             [second fill the blank for question] => 2
751
-    *             [third fill the blank for question] => -1
752
-    *         )
753
-    * )
754
-    */
732
+     * Return an array of student state answers for fill the blank questions
733
+     * for each students that answered the question
734
+     * -2  : didn't answer
735
+     * -1  : student answer is wrong
736
+     *  0  : student answer is correct
737
+     * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
738
+     *
739
+     * @param $testId
740
+     * @param $questionId
741
+     * @param $studentsIdList
742
+     * @param $startDate
743
+     * @param $endDate
744
+     * @param bool $useLastAnswerredAttempt
745
+     * @return array
746
+     * (
747
+     *     [student_id] => Array
748
+     *         (
749
+     *             [first fill the blank for question] => -1
750
+     *             [second fill the blank for question] => 2
751
+     *             [third fill the blank for question] => -1
752
+     *         )
753
+     * )
754
+     */
755 755
     public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) {
756 756
 
757
-       $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
758
-       $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
759
-       $courseId = api_get_course_int_id();
757
+        $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
758
+        $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
759
+        $courseId = api_get_course_int_id();
760 760
 
761
-       require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
761
+        require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
762 762
 
763
-       // request to have all the answers of student for this question
764
-       // student may have doing it several time
765
-       // student may have not answered the bracket id, in this case, is result of the answer is empty
763
+        // request to have all the answers of student for this question
764
+        // student may have doing it several time
765
+        // student may have not answered the bracket id, in this case, is result of the answer is empty
766 766
 
767
-       // we got the less recent attempt first
768
-       $sql = '
767
+        // we got the less recent attempt first
768
+        $sql = '
769 769
            SELECT * FROM '.$tblTrackEAttempt.' tea
770 770
 
771 771
            LEFT JOIN '.$tblTrackEExercise.' tee
@@ -781,49 +781,49 @@  discard block
 block discarded – undo
781 781
            ORDER BY user_id, tea.exe_id;
782 782
        ';
783 783
 
784
-       $res = Database::query($sql);
785
-       $tabUserResult = array();
786
-       $bracketNumber = 0;
787
-       // foreach attempts for all students starting with his older attempt
788
-       while ($data = Database::fetch_array($res)) {
789
-           $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
784
+        $res = Database::query($sql);
785
+        $tabUserResult = array();
786
+        $bracketNumber = 0;
787
+        // foreach attempts for all students starting with his older attempt
788
+        while ($data = Database::fetch_array($res)) {
789
+            $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
790 790
 
791
-           // for each bracket to find in this question
792
-           foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
791
+            // for each bracket to find in this question
792
+            foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
793 793
 
794
-               if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
795
-                   // student has answered this bracket, cool
796
-                   switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
797
-                       case self::FILL_THE_BLANK_MENU :
794
+                if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
795
+                    // student has answered this bracket, cool
796
+                    switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
797
+                        case self::FILL_THE_BLANK_MENU :
798 798
                            // get the indice of the choosen answer in the menu
799 799
                            // we know that the right answer is the first entry of the menu, ie 0
800 800
                            // (remember, menu entries are shuffled when taking the test)
801 801
                            $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]);
802
-                           break;
803
-                       default :
802
+                            break;
803
+                        default :
804 804
                            if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
805
-                               $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
806
-                           } else {
807
-                               $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
808
-                           }
809
-                   }
810
-               } else {
811
-                   // student didn't answer this bracket
812
-                   if ($useLastAnswerredAttempt) {
813
-                       // if we take into account the last answered attempt
814
-                       if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
815
-                           $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
816
-                       }
817
-                   } else {
818
-                       // we take the last attempt, even if the student answer the question before
819
-                       $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
820
-                   }
821
-               }
822
-           }
823
-
824
-
825
-       }
826
-       return $tabUserResult;
805
+                                $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
806
+                            } else {
807
+                                $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
808
+                            }
809
+                    }
810
+                } else {
811
+                    // student didn't answer this bracket
812
+                    if ($useLastAnswerredAttempt) {
813
+                        // if we take into account the last answered attempt
814
+                        if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
815
+                            $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
816
+                        }
817
+                    } else {
818
+                        // we take the last attempt, even if the student answer the question before
819
+                        $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
820
+                    }
821
+                }
822
+            }
823
+
824
+
825
+        }
826
+        return $tabUserResult;
827 827
     }
828 828
 
829 829
 
Please login to merge, or discard this patch.
main/exercice/hotspot_answers.as.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 $course_id     = api_get_course_int_id();
29 29
 
30 30
 if ($answer_type == HOT_SPOT_DELINEATION) {
31
-	// Query db for answers
32
-	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
31
+    // Query db for answers
32
+    $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
33 33
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type <> 'noerror' ORDER BY id";
34 34
 } else {
35
-	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
35
+    $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
36 36
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id";
37 37
 }
38 38
 $result = Database::query($sql);
@@ -69,29 +69,29 @@  discard block
 block discarded – undo
69 69
     $hotSpot['id'] = $hotspot['id'];
70 70
     $hotSpot['answer'] = $hotspot['answer'];
71 71
 
72
-	// Square or rectancle
73
-	if ($hotspot['hotspot_type'] == 'square' ) {
72
+    // Square or rectancle
73
+    if ($hotspot['hotspot_type'] == 'square' ) {
74 74
         $hotSpot['type'] = 'square';
75
-	}
75
+    }
76 76
 
77
-	// Circle or ovale
78
-	if ($hotspot['hotspot_type'] == 'circle') {
77
+    // Circle or ovale
78
+    if ($hotspot['hotspot_type'] == 'circle') {
79 79
         $hotSpot['type'] = 'circle';
80
-	}
80
+    }
81 81
 
82
-	// Polygon
83
-	if ($hotspot['hotspot_type'] == 'poly') {
82
+    // Polygon
83
+    if ($hotspot['hotspot_type'] == 'poly') {
84 84
         $hotSpot['type'] = 'poly';
85
-	}
85
+    }
86 86
 
87
-	// Delineation
88
-	if ($hotspot['hotspot_type'] == 'delineation') {
87
+    // Delineation
88
+    if ($hotspot['hotspot_type'] == 'delineation') {
89 89
         $hotSpot['type'] = 'delineation';
90
-	}
91
-	// oar
92
-	if ($hotspot['hotspot_type'] == 'oar') {
90
+    }
91
+    // oar
92
+    if ($hotspot['hotspot_type'] == 'oar') {
93 93
         $hotSpot['type'] = 'delineation';
94
-	}
94
+    }
95 95
 
96 96
     $hotSpot['coord'] = $hotspot['hotspot_coordinates'];
97 97
 
Please login to merge, or discard this patch.
main/exercice/exercise_reminder.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -223,10 +223,10 @@
 block discarded – undo
223 223
 
224 224
     $counter++;
225 225
     if ($objExercise->type == ONE_PER_PAGE) {
226
-       $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
227
-       $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
226
+        $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
227
+        $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
228 228
     } else {
229
-       $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
229
+        $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
230 230
     }
231 231
     //Check if the question doesn't have an answer
232 232
     if (!in_array($questionId, $exercise_result)) {
Please login to merge, or discard this patch.
main/exercice/exercise_result.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 $gradebook = '';
61 61
 if (isset($_SESSION['gradebook'])) {
62
-	$gradebook=	$_SESSION['gradebook'];
62
+    $gradebook=	$_SESSION['gradebook'];
63 63
 }
64 64
 if (!empty($gradebook) && $gradebook=='view') {
65 65
     $interbreadcrumb[] = array(
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 $htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
80 80
 
81 81
 if ($origin != 'learnpath') {
82
-	// So we are not in learnpath tool
83
-	Display::display_header($nameTools, get_lang('Exercise'));
82
+    // So we are not in learnpath tool
83
+    Display::display_header($nameTools, get_lang('Exercise'));
84 84
 } else {
85 85
     $htmlHeadXtra[] = "
86 86
     <style>
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
 
95 95
 // I'm in a preview mode as course admin. Display the action menu.
96 96
 if (api_is_course_admin() && $origin != 'learnpath') {
97
-	echo '<div class="actions">';
98
-	echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
97
+    echo '<div class="actions">';
98
+    echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
99 99
         Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>';
100
-	echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
100
+    echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
101 101
         Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>';
102
-	echo '</div>';
102
+    echo '</div>';
103 103
 }
104 104
 
105 105
 $feedback_type = $objExercise->feedback_type;
106 106
 $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
107 107
 
108 108
 if (!empty($exercise_stat_info['data_tracking'])) {
109
-	$question_list = explode(',', $exercise_stat_info['data_tracking']);
109
+    $question_list = explode(',', $exercise_stat_info['data_tracking']);
110 110
 }
111 111
 
112 112
 $learnpath_id = $exercise_stat_info['orig_lp_id'];
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
         Session::erase('exe_id');
181 181
     }
182 182
 
183
-	Display::display_footer();
183
+    Display::display_footer();
184 184
 } else {
185
-	$lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
186
-	$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
187
-	$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
185
+    $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
186
+    $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
187
+    $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
188 188
 
189 189
     if (api_is_allowed_to_session_edit()) {
190 190
         Session::erase('objExercise');
191 191
         Session::erase('exe_id');
192 192
     }
193 193
 
194
-	// Record the results in the learning path, using the SCORM interface (API)
195
-	echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
194
+    // Record the results in the learning path, using the SCORM interface (API)
195
+    echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
196 196
     echo '<script type="text/javascript">'.$href.'</script>';
197
-	echo '</body></html>';
197
+    echo '</body></html>';
198 198
 }
Please login to merge, or discard this patch.
main/exercice/exercise_result.class.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 */
10 10
 class ExerciseResult
11 11
 {
12
-	private $results = array();
12
+    private $results = array();
13 13
     public $includeAllUsers = false;
14 14
     public $onlyBestAttempts = false;
15 15
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $exercise_id = 0,
47 47
         $hotpotato_name = null
48 48
     ) {
49
-		$return = array();
49
+        $return = array();
50 50
 
51 51
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
52 52
         $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
             $session_id_and .= " AND exe_exo_id = $exercise_id ";
67 67
         }
68 68
 
69
-		if (empty($user_id)) {
69
+        if (empty($user_id)) {
70 70
             $user_id_and = null;
71
-			$sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
71
+            $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
72 72
 			            official_code,
73 73
                         ce.title as extitle,
74 74
                         te.exe_result as exresult ,
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
                     te.status != 'incomplete' AND
92 92
                     te.c_id = ce.c_id $user_id_and  $session_id_and AND
93 93
                     ce.active <>-1";
94
-		} else {
94
+        } else {
95 95
             $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
96
-			// get only this user's results
96
+            // get only this user's results
97 97
             $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
98 98
                     official_code,
99 99
                     ce.title as extitle,
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
                         te.c_id = ce.c_id $user_id_and $session_id_and AND
120 120
                         ce.active <>-1 AND
121 121
                     ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
122
-		}
122
+        }
123 123
 
124
-		$results = array();
125
-		$resx = Database::query($sql);
124
+        $results = array();
125
+        $resx = Database::query($sql);
126 126
         $bestAttemptPerUser = array();
127
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
127
+        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
128 128
             if ($this->onlyBestAttempts) {
129 129
                 if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
130 130
                     $bestAttemptPerUser[$rowx['excruid']] = $rowx;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             } else {
137 137
                 $results[] = $rowx;
138 138
             }
139
-		}
139
+        }
140 140
 
141 141
         if ($this->onlyBestAttempts) {
142 142
             $results = $bestAttemptPerUser;
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
                     continue;
191 191
                 }
192 192
 
193
-				$return[$i] = array();
194
-				if (empty($user_id)) {
193
+                $return[$i] = array();
194
+                if (empty($user_id)) {
195 195
                     $return[$i]['official_code']   = $result['official_code'];
196 196
                     if (api_is_western_name_order()) {
197 197
                         $return[$i]['first_name']   = $results[$i]['userpart1'];
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
                         $return[$i]['first_name']   = $results[$i]['userpart2'];
201 201
                         $return[$i]['last_name']    = $results[$i]['userpart1'];
202 202
                     }
203
-					$return[$i]['user_id']      = $results[$i]['excruid'];
204
-					$return[$i]['email']        = $results[$i]['exemail'];
205
-				}
206
-				$return[$i]['title'] = $result['extitle'];
207
-				$return[$i]['start_date'] = api_get_local_time($result['exstart']);
203
+                    $return[$i]['user_id']      = $results[$i]['excruid'];
204
+                    $return[$i]['email']        = $results[$i]['exemail'];
205
+                }
206
+                $return[$i]['title'] = $result['extitle'];
207
+                $return[$i]['start_date'] = api_get_local_time($result['exstart']);
208 208
                 $return[$i]['end_date'] = api_get_local_time($result['exdate']);
209 209
                 $return[$i]['duration'] = $result['duration'];
210
-				$return[$i]['result'] = $result['exresult'];
211
-				$return[$i]['max'] = $result['exweight'];
210
+                $return[$i]['result'] = $result['exresult'];
211
+                $return[$i]['max'] = $result['exweight'];
212 212
                 $return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
213 213
                 $return[$i]['lp_id'] = $result['orig_lp_id'];
214 214
                 $return[$i]['lp_name'] = $result['lp_name'];
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 
222 222
                 $userWithResults[$result['excruid']] = 1;
223 223
                 $i++;
224
-			}
225
-		}
224
+            }
225
+        }
226 226
 
227 227
         if ($this->includeAllUsers) {
228 228
             $latestId = count($return);
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
             }
266 266
         }
267 267
 
268
-		$this->results = $return;
268
+        $this->results = $return;
269 269
 
270
-		return true;
271
-	}
270
+        return true;
271
+    }
272 272
 
273
-	/**
274
-	 * Exports the complete report as a CSV file
275
-	 * @param	string		Document path inside the document tool
276
-	 * @param	integer		Optional user ID
277
-	 * @param	boolean		Whether to include user fields or not
278
-	 * @return	boolean		False on error
279
-	 */
273
+    /**
274
+     * Exports the complete report as a CSV file
275
+     * @param	string		Document path inside the document tool
276
+     * @param	integer		Optional user ID
277
+     * @param	boolean		Whether to include user fields or not
278
+     * @return	boolean		False on error
279
+     */
280 280
     public function exportCompleteReportCSV(
281 281
         $document_path = '',
282 282
         $user_id = null,
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $exercise_id = 0,
286 286
         $hotpotato_name = null
287 287
     ) {
288
-		global $charset;
289
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
-
291
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
292
-		if(!empty($user_id)) {
293
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
-		}
295
-		$data = '';
288
+        global $charset;
289
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
+
291
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
292
+        if(!empty($user_id)) {
293
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
+        }
295
+        $data = '';
296 296
         if (api_is_western_name_order()) {
297 297
             if(!empty($this->results[0]['first_name'])) {
298 298
                 $data .= get_lang('FirstName').';';
@@ -316,28 +316,28 @@  discard block
 block discarded – undo
316 316
         $data .= get_lang('Email').';';
317 317
         $data .= get_lang('Groups').';';
318 318
 
319
-		if ($export_user_fields) {
320
-			//show user fields section with a big th colspan that spans over all fields
321
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
-			$num = count($extra_user_fields);
323
-			foreach($extra_user_fields as $field) {
324
-				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
-			}
326
-		}
327
-
328
-		$data .= get_lang('Title').';';
329
-		$data .= get_lang('StartDate').';';
319
+        if ($export_user_fields) {
320
+            //show user fields section with a big th colspan that spans over all fields
321
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
+            $num = count($extra_user_fields);
323
+            foreach($extra_user_fields as $field) {
324
+                $data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
+            }
326
+        }
327
+
328
+        $data .= get_lang('Title').';';
329
+        $data .= get_lang('StartDate').';';
330 330
         $data .= get_lang('EndDate').';';
331 331
         $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
332
-		$data .= get_lang('Score').';';
333
-		$data .= get_lang('Total').';';
332
+        $data .= get_lang('Score').';';
333
+        $data .= get_lang('Total').';';
334 334
         $data .= get_lang('Status').';';
335 335
         $data .= get_lang('ToolLearnpath').';';
336 336
         $data .= get_lang('UserIsCurrentlySubscribed').';';
337
-		$data .= "\n";
337
+        $data .= "\n";
338 338
 
339
-		//results
340
-		foreach ($this->results as $row) {
339
+        //results
340
+        foreach ($this->results as $row) {
341 341
 
342 342
             if (api_is_western_name_order()) {
343 343
                 $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
@@ -354,51 +354,51 @@  discard block
 block discarded – undo
354 354
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355 355
             $data .= str_replace("\r\n",'  ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
356 356
 
357
-			if ($export_user_fields) {
358
-				//show user fields data, if any, for this user
359
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
-				foreach($user_fields_values as $value) {
361
-					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
-				}
363
-			}
357
+            if ($export_user_fields) {
358
+                //show user fields data, if any, for this user
359
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
+                foreach($user_fields_values as $value) {
361
+                    $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
+                }
363
+            }
364 364
 
365
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
-			$data .= str_replace("\r\n",'  ',$row['start_date']).';';
365
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
+            $data .= str_replace("\r\n",'  ',$row['start_date']).';';
367 367
             $data .= str_replace("\r\n",'  ',$row['end_date']).';';
368 368
             $data .= str_replace("\r\n",'  ',$row['duration']).';';
369
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
370
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
369
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
370
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
371 371
             $data .= str_replace("\r\n",'  ',$row['status']).';';
372 372
             $data .= str_replace("\r\n",'  ',$row['lp_name']).';';
373 373
             $data .= str_replace("\r\n",'  ',$row['is_user_subscribed']).';';
374
-			$data .= "\n";
375
-		}
376
-
377
-		//output the results
378
-		$len = strlen($data);
379
-		header('Content-type: application/octet-stream');
380
-		header('Content-Type: application/force-download');
381
-		header('Content-length: '.$len);
382
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
-			header('Content-Disposition: filename= '.$filename);
384
-		} else {
385
-			header('Content-Disposition: attachment; filename= '.$filename);
386
-		}
387
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
-			header('Pragma: ');
389
-			header('Cache-Control: ');
390
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
-		}
392
-		header('Content-Description: '.$filename);
393
-		header('Content-transfer-encoding: binary');
394
-		echo $data;
395
-		return true;
396
-	}
397
-
398
-	/**
399
-	 * Exports the complete report as an XLS file
400
-	 * @return	boolean		False on error
401
-	 */
374
+            $data .= "\n";
375
+        }
376
+
377
+        //output the results
378
+        $len = strlen($data);
379
+        header('Content-type: application/octet-stream');
380
+        header('Content-Type: application/force-download');
381
+        header('Content-length: '.$len);
382
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
+            header('Content-Disposition: filename= '.$filename);
384
+        } else {
385
+            header('Content-Disposition: attachment; filename= '.$filename);
386
+        }
387
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
+            header('Pragma: ');
389
+            header('Cache-Control: ');
390
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
+        }
392
+        header('Content-Description: '.$filename);
393
+        header('Content-transfer-encoding: binary');
394
+        echo $data;
395
+        return true;
396
+    }
397
+
398
+    /**
399
+     * Exports the complete report as an XLS file
400
+     * @return	boolean		False on error
401
+     */
402 402
     public function exportCompleteReportXLS(
403 403
         $document_path = '',
404 404
         $user_id = null,
@@ -407,35 +407,35 @@  discard block
 block discarded – undo
407 407
         $exercise_id = 0,
408 408
         $hotpotato_name = null
409 409
     ) {
410
-		global $charset;
411
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
413
-		if (!empty($user_id)) {
414
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
-		}
410
+        global $charset;
411
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
413
+        if (!empty($user_id)) {
414
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
+        }
416 416
 
417 417
         $spreadsheet = new PHPExcel();
418 418
         $spreadsheet->setActiveSheetIndex(0);
419 419
         $worksheet = $spreadsheet->getActiveSheet();
420 420
 
421
-		$line = 0;
422
-		$column = 0; //skip the first column (row titles)
421
+        $line = 0;
422
+        $column = 0; //skip the first column (row titles)
423 423
 
424
-		// check if exists column 'user'
425
-		$with_column_user = false;
426
-		foreach ($this->results as $result) {
427
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
-				$with_column_user = true;
429
-				break;
430
-			}
431
-		}
424
+        // check if exists column 'user'
425
+        $with_column_user = false;
426
+        foreach ($this->results as $result) {
427
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
+                $with_column_user = true;
429
+                break;
430
+            }
431
+        }
432 432
 
433 433
         $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
434 434
 
435
-		if ($with_column_user) {
435
+        if ($with_column_user) {
436 436
             if (api_is_western_name_order()) {
437
-    			$worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName'));
438
-    			$column++;
437
+                $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName'));
438
+                $column++;
439 439
                 $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('LastName'));
440 440
                 $column++;
441 441
             } else {
@@ -451,43 +451,43 @@  discard block
 block discarded – undo
451 451
             }
452 452
 
453 453
             $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email'));
454
-		    $column++;
455
-		}
454
+            $column++;
455
+        }
456 456
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Groups'));
457
-	    $column++;
458
-
459
-		if ($export_user_fields) {
460
-			//show user fields section with a big th colspan that spans over all fields
461
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462
-
463
-			//show the fields names for user fields
464
-			foreach ($extra_user_fields as $field) {
465
-				$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
466
-				$column++;
467
-			}
468
-		}
469
-
470
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
471
-		$column++;
472
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
457
+        $column++;
458
+
459
+        if ($export_user_fields) {
460
+            //show user fields section with a big th colspan that spans over all fields
461
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462
+
463
+            //show the fields names for user fields
464
+            foreach ($extra_user_fields as $field) {
465
+                $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
466
+                $column++;
467
+            }
468
+        }
469
+
470
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
471
+        $column++;
472
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
473 473
         $column++;
474 474
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate'));
475 475
         $column++;
476 476
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
477
-		$column++;
478
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
479
-		$column++;
480
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
481
-		$column++;
477
+        $column++;
478
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
479
+        $column++;
480
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
481
+        $column++;
482 482
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status'));
483
-		$column++;
483
+        $column++;
484 484
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ToolLearnpath'));
485 485
         $column++;
486 486
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('UserIsCurrentlySubscribed'));
487
-		$line++;
487
+        $line++;
488 488
 
489
-		foreach ($this->results as $row) {
490
-			$column = 0;
489
+        foreach ($this->results as $row) {
490
+            $column = 0;
491 491
 
492 492
             if ($with_column_user) {
493 493
                 if (api_is_western_name_order()) {
@@ -509,22 +509,22 @@  discard block
 block discarded – undo
509 509
 
510 510
                 $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
511 511
                 $column++;
512
-			}
512
+            }
513 513
 
514 514
             $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
515 515
             $column++;
516 516
 
517
-			if ($export_user_fields) {
518
-				//show user fields data, if any, for this user
519
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
520
-				foreach($user_fields_values as $value) {
521
-					$worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
522
-					$column++;
523
-				}
524
-			}
525
-
526
-			$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
527
-			$column++;
517
+            if ($export_user_fields) {
518
+                //show user fields data, if any, for this user
519
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
520
+                foreach($user_fields_values as $value) {
521
+                    $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
522
+                    $column++;
523
+                }
524
+            }
525
+
526
+            $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
527
+            $column++;
528 528
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']);
529 529
             $column++;
530 530
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']);
@@ -540,14 +540,14 @@  discard block
 block discarded – undo
540 540
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['lp_name']);
541 541
             $column++;
542 542
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['is_user_subscribed']);
543
-			$line++;
544
-		}
543
+            $line++;
544
+        }
545 545
 
546 546
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
547 547
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
548 548
         $writer->save($file);
549 549
         DocumentManager::file_send_for_download($file, true, $filename);
550 550
 
551
-		return true;
552
-	}
551
+        return true;
552
+    }
553 553
 }
Please login to merge, or discard this patch.