Completed
Push — 1.10.x ( f834ff...8104fe )
by
unknown
52:59
created
main/exercice/exercise_show.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
93 93
 
94 94
 if (empty($objExercise)) {
95
-	$objExercise = new Exercise();
95
+    $objExercise = new Exercise();
96 96
     $objExercise->read($exercise_id);
97 97
 }
98 98
 $feedback_type = $objExercise->feedback_type;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 //Only users can see their own results
101 101
 if (!$is_allowedToEdit) {
102 102
     if ($student_id != $current_user_id) {
103
-    	api_not_allowed(true);
103
+        api_not_allowed(true);
104 104
     }
105 105
 }
106 106
 
107 107
 if (isset($_SESSION['gradebook'])) {
108
-	$gradebook=	Security::remove_XSS($_SESSION['gradebook']);
108
+    $gradebook=	Security::remove_XSS($_SESSION['gradebook']);
109 109
 }
110 110
 
111 111
 if (!empty($gradebook) && $gradebook=='view') {
112
-	$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook'));
112
+    $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook'));
113 113
 }
114 114
 
115 115
 $fromlink = '';
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
125 125
 
126 126
 if ($origin != 'learnpath') {
127
-	Display::display_header('');
127
+    Display::display_header('');
128 128
 } else {
129 129
     $htmlHeadXtra[] = "
130 130
     <style>
131 131
     body { background: none;}
132 132
     </style>
133 133
     ";
134
-	Display::display_reduced_header();
134
+    Display::display_reduced_header();
135 135
 }
136 136
 ?>
137 137
 <script>
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
         }
211 211
     }
212 212
 } else {
213
-	Display::display_warning_message(get_lang('CantViewResults'));
214
-	$show_results = false;
213
+    Display::display_warning_message(get_lang('CantViewResults'));
214
+    $show_results = false;
215 215
 }
216 216
 
217 217
 if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
218
-	$show_results = false;
218
+    $show_results = false;
219 219
 }
220 220
 
221 221
 if ($show_results || $show_only_total_score) {
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
 $exerciseResult = array();
264 264
 
265 265
 while ($row = Database::fetch_array($result)) {
266
-	$question_list_from_database[] = $row['question_id'];
267
-	$exerciseResult[$row['question_id']] = $row['answer'];
266
+    $question_list_from_database[] = $row['question_id'];
267
+    $exerciseResult[$row['question_id']] = $row['answer'];
268 268
 }
269 269
 
270 270
 //Fixing #2073 Fixing order of questions
271 271
 if (!empty($track_exercise_info['data_tracking'])) {
272
-	$temp_question_list = explode(',', $track_exercise_info['data_tracking']);
272
+    $temp_question_list = explode(',', $track_exercise_info['data_tracking']);
273 273
 
274 274
     // Getting question list from data_tracking
275 275
     if (!empty($temp_question_list)) {
@@ -308,23 +308,23 @@  discard block
 block discarded – undo
308 308
 
309 309
 foreach ($questionList as $questionId) {
310 310
 
311
-	$choice = $exerciseResult[$questionId];
312
-	// destruction of the Question object
313
-	unset($objQuestionTmp);
311
+    $choice = $exerciseResult[$questionId];
312
+    // destruction of the Question object
313
+    unset($objQuestionTmp);
314 314
 
315 315
     // creates a temporary Question object
316 316
     $objQuestionTmp = Question::read($questionId);
317 317
     $questionWeighting = $objQuestionTmp->selectWeighting();
318 318
     $answerType = $objQuestionTmp->selectType();
319 319
 
320
-	// Start buffer
320
+    // Start buffer
321 321
     ob_start();
322 322
 
323 323
     /* Use switch
324 324
     switch ($answerType) {
325 325
     }*/
326 326
 
327
-	if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
327
+    if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
328 328
         $question_result = $objExercise->manage_answer(
329 329
             $id,
330 330
             $questionId,
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
         );
453 453
         $questionScore = $question_result['score'];
454 454
         $totalScore += $question_result['score'];
455
-	} elseif ($answerType == HOT_SPOT) {
456
-	    if ($show_results) {
457
-		    echo '<table width="500" border="0"><tr>
455
+    } elseif ($answerType == HOT_SPOT) {
456
+        if ($show_results) {
457
+            echo '<table width="500" border="0"><tr>
458 458
                     <td valign="top" align="center" style="padding-left:0px;" >
459 459
                         <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
460
-		}
460
+        }
461 461
         $question_result = $objExercise->manage_answer(
462 462
             $id,
463 463
             $questionId,
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                 <br>
497 497
             ";
498 498
         }
499
-	} else if($answerType == HOT_SPOT_DELINEATION) {
499
+    } else if($answerType == HOT_SPOT_DELINEATION) {
500 500
 
501 501
         $question_result = $objExercise->manage_answer(
502 502
             $id,
@@ -651,15 +651,15 @@  discard block
 block discarded – undo
651 651
                 </table>
652 652
             ";
653 653
         }
654
-	}
654
+    }
655 655
 
656
-	if ($show_results) {
657
-	    if ($answerType != HOT_SPOT) {
658
-	        echo '</table>';
659
-	    }
660
-	}
656
+    if ($show_results) {
657
+        if ($answerType != HOT_SPOT) {
658
+            echo '</table>';
659
+        }
660
+    }
661 661
 
662
-	$comnt = null;
662
+    $comnt = null;
663 663
 
664 664
     if ($show_results) {
665 665
         if (
@@ -676,18 +676,18 @@  discard block
 block discarded – undo
676 676
 
677 677
         $marksname = '';
678 678
 
679
-		if ($isFeedbackAllowed) {
680
-			$name = "fckdiv".$questionId;
681
-			$marksname = "marksName".$questionId;
682
-			if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
683
-				$url_name = get_lang('EditCommentsAndMarks');
684
-			} else {
685
-				if ($action=='edit') {
686
-					$url_name = get_lang('EditIndividualComment');
687
-				} else {
688
-					$url_name = get_lang('AddComments');
689
-				}
690
-			}
679
+        if ($isFeedbackAllowed) {
680
+            $name = "fckdiv".$questionId;
681
+            $marksname = "marksName".$questionId;
682
+            if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
683
+                $url_name = get_lang('EditCommentsAndMarks');
684
+            } else {
685
+                if ($action=='edit') {
686
+                    $url_name = get_lang('EditIndividualComment');
687
+                } else {
688
+                    $url_name = get_lang('AddComments');
689
+                }
690
+            }
691 691
             echo '<br />';
692 692
             echo Display::url(
693 693
                 $url_name,
@@ -696,26 +696,26 @@  discard block
 block discarded – undo
696 696
                     'class' => 'btn btn-default',
697 697
                     'onclick' => "showfck('".$name."', '".$marksname."');")
698 698
             );
699
-			echo '<br />';
699
+            echo '<br />';
700 700
 
701 701
             echo '<div id="feedback_'.$name.'" style="width:100%">';
702
-			$comnt = trim(Event::get_comments($id, $questionId));
703
-			if (empty($comnt)) {
704
-				echo '<br />';
705
-			} else {
706
-				echo '<div id="question_feedback">'.$comnt.'</div>';
707
-			}
708
-			echo '</div>';
702
+            $comnt = trim(Event::get_comments($id, $questionId));
703
+            if (empty($comnt)) {
704
+                echo '<br />';
705
+            } else {
706
+                echo '<div id="question_feedback">'.$comnt.'</div>';
707
+            }
708
+            echo '</div>';
709 709
 
710 710
             echo '<div id="'.$name.'" style="display:none">';
711
-			$arrid[] = $questionId;
712
-			$feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
713
-			$feedback_form->addElement('html','<br>');
714
-			$renderer =& $feedback_form->defaultRenderer();
715
-			$renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
716
-			$renderer->setCustomElementTemplate('<div align="left">{element}</div>');
717
-			$comnt = Event::get_comments($id, $questionId);
718
-			$default = array('comments_'.$questionId =>  $comnt);
711
+            $arrid[] = $questionId;
712
+            $feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
713
+            $feedback_form->addElement('html','<br>');
714
+            $renderer =& $feedback_form->defaultRenderer();
715
+            $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
716
+            $renderer->setCustomElementTemplate('<div align="left">{element}</div>');
717
+            $comnt = Event::get_comments($id, $questionId);
718
+            $default = array('comments_'.$questionId =>  $comnt);
719 719
 
720 720
             if ($useAdvancedEditor) {
721 721
                 $feedback_form->addElement(
@@ -732,52 +732,52 @@  discard block
 block discarded – undo
732 732
             } else {
733 733
                 $feedback_form->addElement('textarea', 'comments_' . $questionId);
734 734
             }
735
-			$feedback_form->addElement('html','<br>');
736
-			$feedback_form->setDefaults($default);
737
-			$feedback_form->display();
738
-			echo '</div>';
739
-
740
-		} else {
741
-			$comnt = Event::get_comments($id, $questionId);
742
-			echo '<br />';
743
-			if (!empty($comnt)) {
744
-				echo '<b>'.get_lang('Feedback').'</b>';
745
-				echo '<div id="question_feedback">'.$comnt.'</div>';
746
-			}
747
-		}
748
-
749
-		if ($is_allowedToEdit && $isFeedbackAllowed) {
750
-			if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
751
-				$marksname = "marksName".$questionId;
735
+            $feedback_form->addElement('html','<br>');
736
+            $feedback_form->setDefaults($default);
737
+            $feedback_form->display();
738
+            echo '</div>';
739
+
740
+        } else {
741
+            $comnt = Event::get_comments($id, $questionId);
742
+            echo '<br />';
743
+            if (!empty($comnt)) {
744
+                echo '<b>'.get_lang('Feedback').'</b>';
745
+                echo '<div id="question_feedback">'.$comnt.'</div>';
746
+            }
747
+        }
748
+
749
+        if ($is_allowedToEdit && $isFeedbackAllowed) {
750
+            if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
751
+                $marksname = "marksName".$questionId;
752 752
                 echo '<div id="'.$marksname.'" style="display:none">';
753 753
                 echo '<form name="marksform_'.$questionId.'" method="post" action="">';
754
-				$arrmarks[] = $questionId;
755
-				echo get_lang("AssignMarks");
756
-				echo "&nbsp;<select name='marks' id='marks'>";
757
-				for ($i=0;$i<=$questionWeighting;$i++) {
758
-					echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>';
759
-				}
760
-				echo '</select>';
761
-				echo '</form><br /></div>';
762
-
763
-				if ($questionScore == -1 ) {
764
-					$questionScore = 0;
765
-				  	echo Display::return_message(get_lang('notCorrectedYet'));
766
-				}
767
-			} else {
768
-				$arrmarks[] = $questionId;
769
-				echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action="">
754
+                $arrmarks[] = $questionId;
755
+                echo get_lang("AssignMarks");
756
+                echo "&nbsp;<select name='marks' id='marks'>";
757
+                for ($i=0;$i<=$questionWeighting;$i++) {
758
+                    echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>';
759
+                }
760
+                echo '</select>';
761
+                echo '</form><br /></div>';
762
+
763
+                if ($questionScore == -1 ) {
764
+                    $questionScore = 0;
765
+                        echo Display::return_message(get_lang('notCorrectedYet'));
766
+                }
767
+            } else {
768
+                $arrmarks[] = $questionId;
769
+                echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action="">
770 770
 					  <select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>';
771
-			}
772
-		} else {
773
-			if ($questionScore == -1) {
774
-				 $questionScore = 0;
775
-			}
776
-		}
777
-	}
771
+            }
772
+        } else {
773
+            if ($questionScore == -1) {
774
+                    $questionScore = 0;
775
+            }
776
+        }
777
+    }
778 778
 
779 779
     $my_total_score  = $questionScore;
780
-	$my_total_weight = $questionWeighting;
780
+    $my_total_weight = $questionWeighting;
781 781
     $totalWeighting += $questionWeighting;
782 782
     $category_was_added_for_this_test = false;
783 783
 
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 
824 824
     $score = array();
825 825
     if ($show_results) {
826
-		$score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false);
826
+        $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false);
827 827
         $score['pass'] = $my_total_score >= $my_total_weight ? true : false;
828 828
         $score['type'] = $answerType;
829 829
         $score['score'] = $my_total_score;
@@ -831,16 +831,16 @@  discard block
 block discarded – undo
831 831
         $score['comments'] = isset($comnt) ? $comnt : null;
832 832
     }
833 833
 
834
-	unset($objAnswerTmp);
835
-	$i++;
834
+    unset($objAnswerTmp);
835
+    $i++;
836 836
 
837 837
     $contents = ob_get_clean();
838 838
     $question_content = '<div class="question_row">';
839
- 	if ($show_results) {
839
+        if ($show_results) {
840 840
         // Shows question title an description
841
-	    $question_content .= $objQuestionTmp->return_header(null, $counter, $score);
842
-	}
843
-	$counter++;
841
+        $question_content .= $objQuestionTmp->return_header(null, $counter, $score);
842
+    }
843
+    $counter++;
844 844
     $question_content .= $contents;
845 845
     $question_content .= '</div>';
846 846
     $exercise_content .= $question_content;
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 
851 851
 //Total score
852 852
 if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
853
-	if ($show_results || $show_only_total_score) {
853
+    if ($show_results || $show_only_total_score) {
854 854
         $total_score_text .= '<div class="question_row">';
855 855
         $my_total_score_temp = $totalScore;
856
-	    if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
857
-	        $my_total_score_temp = 0;
858
-	    }
856
+        if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
857
+            $my_total_score_temp = 0;
858
+        }
859 859
         $total_score_text .= ExerciseLib::get_question_ribbon(
860 860
             $objExercise,
861 861
             $my_total_score_temp,
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
             true
864 864
         );
865 865
         $total_score_text .= '</div>';
866
-	}
866
+    }
867 867
 }
868 868
 
869 869
 if (!empty($category_list) && ($show_results || $show_only_total_score)) {
@@ -887,26 +887,26 @@  discard block
 block discarded – undo
887 887
 }
888 888
 
889 889
 if ($isFeedbackAllowed) {
890
-	if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
891
-		echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
892
-		echo '<input type = "hidden" name="lp_item_id"       value="'.$learnpath_id.'">';
893
-		echo '<input type = "hidden" name="lp_item_view_id"  value="'.$lp_item_view_id.'">';
894
-		echo '<input type = "hidden" name="student_id"       value="'.$student_id.'">';
895
-		echo '<input type = "hidden" name="total_score"      value="'.$totalScore.'"> ';
896
-		echo '<input type = "hidden" name="my_exe_exo_id"    value="'.$exercise_id.'"> ';
897
-	} else {
898
-		echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
899
-	}
900
-	if ($origin !='learnpath' && $origin!='student_progress') {
890
+    if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
891
+        echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
892
+        echo '<input type = "hidden" name="lp_item_id"       value="'.$learnpath_id.'">';
893
+        echo '<input type = "hidden" name="lp_item_view_id"  value="'.$lp_item_view_id.'">';
894
+        echo '<input type = "hidden" name="student_id"       value="'.$student_id.'">';
895
+        echo '<input type = "hidden" name="total_score"      value="'.$totalScore.'"> ';
896
+        echo '<input type = "hidden" name="my_exe_exo_id"    value="'.$exercise_id.'"> ';
897
+    } else {
898
+        echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
899
+    }
900
+    if ($origin !='learnpath' && $origin!='student_progress') {
901 901
         echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>';
902
-		?>
902
+        ?>
903 903
         <br />
904 904
         <button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');">
905 905
             <?php echo get_lang('CorrectTest'); ?>
906 906
         </button>
907 907
 		</form>
908 908
 		<?php
909
-	}
909
+    }
910 910
 }
911 911
 
912 912
 //Came from lpstats in a lp
@@ -923,21 +923,21 @@  discard block
 block discarded – undo
923 923
 }
924 924
 
925 925
 if ($origin != 'learnpath') {
926
-	//we are not in learnpath tool
927
-	Display::display_footer();
926
+    //we are not in learnpath tool
927
+    Display::display_footer();
928 928
 } else {
929
-	if (!isset($_GET['fb_type'])) {
930
-		$lp_mode =  $_SESSION['lp_mode'];
931
-		$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
932
-		$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
933
-		echo '<script type="text/javascript">'.$href.'</script>';
934
-		// Record the results in the learning path, using the SCORM interface (API)
935
-		echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
936
-		echo '</body></html>';
937
-	} else {
938
-		Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
929
+    if (!isset($_GET['fb_type'])) {
930
+        $lp_mode =  $_SESSION['lp_mode'];
931
+        $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
932
+        $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
933
+        echo '<script type="text/javascript">'.$href.'</script>';
934
+        // Record the results in the learning path, using the SCORM interface (API)
935
+        echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
936
+        echo '</body></html>';
937
+    } else {
938
+        Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
939 939
         echo '<br />';
940
-	}
940
+    }
941 941
 }
942 942
 
943 943
 // Destroying the session
Please login to merge, or discard this patch.