Pārlūkot izejas kodu

Fix delineation results see BT#15827

Julio Montoya 5 gadi atpakaļ
vecāks
revīzija
d81cef333d

+ 58 - 36
main/exercise/exercise.class.php

@@ -3072,16 +3072,10 @@ class Exercise
         $weight = 0
     ) {
         $track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
-        $safe_lp_id = intval($safe_lp_id);
-        $safe_lp_item_id = intval($safe_lp_item_id);
-        $safe_lp_item_view_id = intval($safe_lp_item_view_id);
+        $safe_lp_id = (int) $safe_lp_id;
+        $safe_lp_item_id = (int) $safe_lp_item_id;
+        $safe_lp_item_view_id = (int) $safe_lp_item_view_id;
 
-        if (empty($safe_lp_id)) {
-            $safe_lp_id = 0;
-        }
-        if (empty($safe_lp_item_id)) {
-            $safe_lp_item_id = 0;
-        }
         if (empty($clock_expired_time)) {
             $clock_expired_time = null;
         }
@@ -3130,7 +3124,7 @@ class Exercise
         $currentAnswer = '',
         $myRemindList = []
     ) {
-        global $origin, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id;
+        global $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id;
         $nbrQuestions = $this->getQuestionCount();
         $buttonList = [];
         $html = $label = '';
@@ -3144,21 +3138,20 @@ class Exercise
                 $urlTitle = get_lang('EndTest');
             }
             $url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit_modal.php?'.api_get_cidreq();
-
+            $url .= '&'.http_build_query([
+                'learnpath_id' => $safe_lp_id,
+                'learnpath_item_id' => $safe_lp_item_id,
+                'learnpath_item_view_id' => $safe_lp_item_view_id,
+                'hotspot' => $hotspot_get,
+                'nbrQuestions' => $nbrQuestions,
+                'num' => $questionNum,
+                'exerciseType' => $this->type,
+                'exerciseId' => $this->id,
+                'reminder' => empty($myRemindList) ? null : 2,
+            ]);
             $html .= Display::url(
                 $urlTitle,
-                $url.'&'.http_build_query([
-                    'learnpath_id' => $safe_lp_id,
-                    'learnpath_item_id' => $safe_lp_item_id,
-                    'learnpath_item_view_id' => $safe_lp_item_view_id,
-                    'origin' => $origin,
-                    'hotspot' => $hotspot_get,
-                    'nbrQuestions' => $nbrQuestions,
-                    'num' => $questionNum,
-                    'exerciseType' => $this->type,
-                    'exerciseId' => $this->id,
-                    'reminder' => empty($myRemindList) ? null : 2,
-                ]),
+                $url,
                 [
                     'class' => 'ajax btn btn-default',
                     'data-title' => Security::remove_XSS(get_lang('Comment')),
@@ -3605,7 +3598,7 @@ class Exercise
                 ['hotspotAnswerId' => 'ASC']
             );
         }
-        $debug= true;
+        $debug = true;
         if ($debug) {
             error_log('Start answer loop ');
         }
@@ -4740,8 +4733,8 @@ class Exercise
                             $user_array = $_SESSION['exerciseResultCoordinates'][$questionId];
                         }
                     }
-                    $_SESSION['hotspot_coord'][1] = $delineation_cord;
-                    $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
+                    $_SESSION['hotspot_coord'][$questionId][1] = $delineation_cord;
+                    $_SESSION['hotspot_dest'][$questionId][1] = $answer_delineation_destination;
                     break;
                 case ANNOTATION:
                     if ($from_database) {
@@ -4931,8 +4924,8 @@ class Exercise
                             if ($next) {
                                 $user_answer = $user_array;
                                 // We compare only the delineation not the other points
-                                $answer_question = $_SESSION['hotspot_coord'][1];
-                                $answerDestination = $_SESSION['hotspot_dest'][1];
+                                $answer_question = $_SESSION['hotspot_coord'][$questionId][1];
+                                $answerDestination = $_SESSION['hotspot_dest'][$questionId][1];
 
                                 // Calculating the area
                                 $poly_user = convert_coordinates($user_answer, '/');
@@ -5295,8 +5288,8 @@ class Exercise
                             if ($next) {
                                 $user_answer = $user_array;
                                 // we compare only the delineation not the other points
-                                $answer_question = $_SESSION['hotspot_coord'][1];
-                                $answerDestination = $_SESSION['hotspot_dest'][1];
+                                $answer_question = $_SESSION['hotspot_coord'][$questionId][1];
+                                $answerDestination = $_SESSION['hotspot_dest'][$questionId][1];
 
                                 // calculating the area
                                 $poly_user = convert_coordinates($user_answer, '/');
@@ -5497,7 +5490,7 @@ class Exercise
                 if ($debug) {
                     error_log('$from AND this is a hotspot kind of question ');
                 }
-                if ($answerType == HOT_SPOT_DELINEATION) {
+                if ($answerType === HOT_SPOT_DELINEATION) {
                     if ($showHotSpotDelineationTable) {
                         $overlap_color = 'red';
                         if ($overlap_color) {
@@ -5562,10 +5555,9 @@ class Exercise
                             $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
                         }
 
-                        echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
-                            <p style="text-align:center">';
-
-                        $message = '<p>'.get_lang('YourDelineation').'</p>';
+                        $message = '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
+                                    <p style="text-align:center">';
+                        $message .= '<p>'.get_lang('YourDelineation').'</p>';
                         $message .= $table_resume;
                         $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
                         if ($organs_at_risk_hit > 0) {
@@ -5573,11 +5565,14 @@ class Exercise
                         }
                         $message .= '<p>'.$comment.'</p>';
                         echo $message;
+
+                        $_SESSION['hotspot_delineation_result'][$this->selectId()][$questionId][0] = $message;
+                        $_SESSION['hotspot_delineation_result'][$this->selectId()][$questionId][1] = $_SESSION['exerciseResultCoordinates'][$questionId];
                     } else {
                         echo $hotspot_delineation_result[0];
                     }
 
-                    //save the score attempts
+                    // Save the score attempts
                     if (1) {
                         //getting the answer 1 or 0 comes from exercise_submit_modal.php
                         $final_answer = isset($hotspot_delineation_result[1]) ? $hotspot_delineation_result[1] : '';
@@ -9971,6 +9966,12 @@ class Exercise
         return $group;
     }
 
+    /**
+     * @param Question $objQuestionTmp
+     * @param int      $questionId
+     * @param bool     $show_results
+     * @param array    $question_result
+     */
     public function getDelineationResult(Question $objQuestionTmp, $questionId, $show_results, $question_result)
     {
         $id = (int) $objQuestionTmp->id;
@@ -10124,6 +10125,27 @@ class Exercise
                     </table>
                 ";
         }
+    }
+
+    /**
+     * Clean exercise session variables
+     */
+    public static function cleanSessionVariables()
+    {
+        Session::erase('objExercise');
+        Session::erase('exe_id');
+        Session::erase('calculatedAnswerId');
+        Session::erase('duration_time_previous');
+        Session::erase('duration_time');
+        Session::erase('objQuestion');
+        Session::erase('objAnswer');
+        Session::erase('questionList');
+        Session::erase('exerciseResult');
+        Session::erase('firstTime');
 
+        Session::erase('exerciseResultCoordinates');
+        Session::erase('hotspot_coord');
+        Session::erase('hotspot_dest');
+        Session::erase('hotspot_delineation_result');
     }
 }

+ 1 - 9
main/exercise/exercise.php

@@ -69,15 +69,7 @@ $exercisePath = substr($exercisePath, 0, strpos($exercisePath, $exfile));
 $exercisePath = $exercisePath.'exercise.php';
 
 // Clear the exercise session
-Session::erase('objExercise');
-Session::erase('objQuestion');
-Session::erase('objAnswer');
-Session::erase('questionList');
-Session::erase('exerciseResult');
-Session::erase('firstTime');
-Session::erase('calculatedAnswerId');
-Session::erase('duration_time_previous');
-Session::erase('duration_time');
+Exercise::cleanSessionVariables();
 
 //General POST/GET/SESSION/COOKIES parameters recovery
 $origin = api_get_origin();

+ 13 - 34
main/exercise/exercise_result.php

@@ -36,9 +36,6 @@ $origin = api_get_origin();
 if (empty($objExercise)) {
     $objExercise = Session::read('objExercise');
 }
-if (empty($remind_list)) {
-    $remind_list = isset($_REQUEST['remind_list']) ? $_REQUEST['remind_list'] : null;
-}
 
 $exe_id = isset($_REQUEST['exe_id']) ? (int) $_REQUEST['exe_id'] : 0;
 
@@ -106,19 +103,12 @@ if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) {
         Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32).'</a>';
     echo '</div>';
 }
-
-$feedback_type = $objExercise->getFeedbackType();
 $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
-
-if (!empty($exercise_stat_info['data_tracking'])) {
-    $question_list = explode(',', $exercise_stat_info['data_tracking']);
-}
-
 $learnpath_id = isset($exercise_stat_info['orig_lp_id']) ? $exercise_stat_info['orig_lp_id'] : 0;
 $learnpath_item_id = isset($exercise_stat_info['orig_lp_item_id']) ? $exercise_stat_info['orig_lp_item_id'] : 0;
 $learnpath_item_view_id = isset($exercise_stat_info['orig_lp_item_view_id']) ? $exercise_stat_info['orig_lp_item_view_id'] : 0;
 
-if ($origin == 'learnpath') {
+if ($origin === 'learnpath') {
     ?>
     <form method="GET" action="exercise.php?<?php echo api_get_cidreq(); ?>">
     <input type="hidden" name="origin" value="<?php echo $origin; ?>" />
@@ -129,7 +119,6 @@ if ($origin == 'learnpath') {
 }
 
 $i = $total_score = $max_score = 0;
-
 $remainingMessage = '';
 $attemptButton = '';
 
@@ -170,10 +159,9 @@ if ($objExercise->selectAttempts() > 0) {
     } else {
         $attempt_count++;
         $remainingAttempts = $objExercise->selectAttempts() - $attempt_count;
-
         if ($remainingAttempts) {
             $attemptMessage = sprintf(get_lang('RemainingXAttempts'), $remainingAttempts);
-            $remainingMessage = sprintf("<p>%s</p> %s", $attemptMessage, $attemptButton);
+            $remainingMessage = sprintf('<p>%s</p> %s', $attemptMessage, $attemptButton);
         }
     }
 } else {
@@ -187,19 +175,23 @@ if (!empty($exercise_stat_info)) {
 
 $max_score = $objExercise->get_max_score();
 
-if ($origin !== 'embeddable') {
+if ($origin === 'embeddable') {
+    showEmbeddableFinishButton();
+} else {
     echo Display::return_message(get_lang('Saved').'<br />', 'normal', false);
 }
 
-if ($origin == 'embeddable') {
-    showEmbeddableFinishButton();
+$saveResults = true;
+$feedbackType = $objExercise->getFeedbackType();
+if (!in_array($feedbackType, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
+    //$saveResults = false;
 }
 
 // Display and save questions
 ExerciseLib::displayQuestionListByAttempt(
     $objExercise,
     $exe_id,
-    true,
+    $saveResults,
     $remainingMessage
 );
 
@@ -222,20 +214,12 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
     echo '</div>';
 
     if (api_is_allowed_to_session_edit()) {
-        Session::erase('objExercise');
-        Session::erase('exe_id');
-        Session::erase('calculatedAnswerId');
-        Session::erase('duration_time_previous');
-        Session::erase('duration_time');
+        Exercise::cleanSessionVariables();
     }
     Display::display_footer();
 } elseif ($origin === 'embeddable') {
     if (api_is_allowed_to_session_edit()) {
-        Session::erase('objExercise');
-        Session::erase('exe_id');
-        Session::erase('calculatedAnswerId');
-        Session::erase('duration_time_previous');
-        Session::erase('duration_time');
+        Exercise::cleanSessionVariables();
     }
 
     Session::write('attempt_remaining', $remainingMessage);
@@ -247,18 +231,13 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
     $href = $lp_mode === 'fullscreen' ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
 
     if (api_is_allowed_to_session_edit()) {
-        Session::erase('objExercise');
-        Session::erase('exe_id');
-        Session::erase('calculatedAnswerId');
-        Session::erase('duration_time_previous');
-        Session::erase('duration_time');
+        Exercise::cleanSessionVariables();
     }
     Session::write('attempt_remaining', $remainingMessage);
 
     // Record the results in the learning path, using the SCORM interface (API)
     echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
     echo '<script type="text/javascript">'.$href.'</script>';
-
     Display::display_reduced_footer();
 }
 

+ 0 - 4
main/exercise/exercise_submit.php

@@ -98,8 +98,6 @@ $choice = empty($choice) ? isset($_REQUEST['choice2']) ? $_REQUEST['choice2'] :
 // From submit modal
 $current_question = isset($_REQUEST['num']) ? (int) $_REQUEST['num'] : null;
 $currentAnswer = isset($_REQUEST['num_answer']) ? (int) $_REQUEST['num_answer'] : null;
-$endExercise = isset($_REQUEST['end_exercise']) && $_REQUEST['end_exercise'] == 1 ? true : false;
-
 $logInfo = [
     'tool' => TOOL_QUIZ,
     'tool_id' => $exerciseId,
@@ -1550,10 +1548,8 @@ if (!empty($error)) {
     }
     echo '</form>';
 }
-
 if (!in_array($origin, ['learnpath', 'embeddable'])) {
     // So we are not in learnpath tool
     echo '</div>'; //End glossary div
 }
-
 Display::display_footer();

+ 30 - 90
main/exercise/exercise_submit_modal.php

@@ -14,22 +14,6 @@ api_protect_course_script();
 
 require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
 
-$message = null;
-$dbg_local = 0;
-$gradebook = null;
-$final_overlap = null;
-$final_missing = null;
-$final_excess = null;
-$threadhold1 = null;
-$threadhold2 = null;
-$threadhold3 = null;
-
-$exerciseResult = Session::read('exerciseResult');
-$exerciseResultCoordinates = isset($_REQUEST['exerciseResultCoordinates']) ? $_REQUEST['exerciseResultCoordinates'] : null;
-
-$learnpath_id = isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : 0;
-$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? (int) $_REQUEST['learnpath_item_id'] : 0;
-
 /** @var Exercise $objExercise */
 $objExercise = Session::read('objExercise');
 
@@ -37,20 +21,23 @@ if (empty($objExercise)) {
     api_not_allowed();
 }
 
-Session::write('hotspot_coord', []);
-$newQuestionList = Session::read('newquestionList', []);
+$feedbackType = $objExercise->getFeedbackType();
+$exerciseType = $objExercise->type;
+if (!in_array($feedbackType, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
+    api_not_allowed();
+}
+
+$exerciseResult = Session::read('exerciseResult');
+$learnpath_id = isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : 0;
+$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? (int) $_REQUEST['learnpath_item_id'] : 0;
 $questionList = Session::read('questionList');
 
 $exerciseId = (int) $_GET['exerciseId'];
-$exerciseType = (int) $_GET['exerciseType'];
+//$exerciseType = (int) $_GET['exerciseType'];
 $questionNum = (int) $_GET['num'];
-$nbrQuestions = isset($_GET['nbrQuestions']) ? (int) $_GET['nbrQuestions'] : null;
+//$nbrQuestions = isset($_GET['nbrQuestions']) ? (int) $_GET['nbrQuestions'] : null;
 $questionId = $questionList[$questionNum];
 
-// Clean extra session variables
-Session::erase('objExerciseExtra'.$exerciseId);
-Session::erase('exerciseResultExtra'.$exerciseId);
-Session::erase('questionListExtra'.$exerciseId);
 $choiceValue = isset($_GET['choice']) ? $_GET['choice'] : '';
 $hotSpot = isset($_GET['hotspot']) ? $_GET['hotspot'] : '';
 
@@ -106,11 +93,11 @@ if (empty($choiceValue) && empty($hotSpot)) {
         //var my_choiceDc = $('*[name*=\"choiceDegreeCertainty['+question_id+']\"]').serialize();        
     ";
 
-    $url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit_modal.php';
     // IMPORTANT
     // This is the real redirect function
-    $extraUrl = '&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id;
-    echo ' url = "'.addslashes($url).'?hotspotcoord="+ hotspotcoord + "&"+ hotspot + "&"+ my_choice + "&'.$extraUrl.'";';
+    $extraUrl = '&exerciseId='.$exerciseId.'&num='.$questionNum.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id;
+    $url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit_modal.php?'.api_get_cidreq().$extraUrl;
+    echo ' url = "'.addslashes($url).'&hotspotcoord="+ hotspotcoord + "&"+ hotspot + "&"+ my_choice;';
     echo "$('#global-modal .modal-body').load(url);";
     echo '</script>';
     exit;
@@ -141,32 +128,11 @@ if (is_array($choice)) {
 
 // the script "exercise_result.php" will take the variable $exerciseResult from the session
 Session::write('exerciseResult', $exerciseResult);
-Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
-
-// creates a temporary Question object
-if (in_array($questionId, $questionList)) {
-    $objQuestionTmp = Question::read($questionId);
-    $questionName = $objQuestionTmp->selectTitle();
-    $questionDescription = $objQuestionTmp->selectDescription();
-    $questionWeighting = $objQuestionTmp->selectWeighting();
-    $answerType = $objQuestionTmp->selectType();
-    $quesId = $objQuestionTmp->selectId(); //added by priya saini
-}
 
+$objQuestionTmp = Question::read($questionId);
+$answerType = $objQuestionTmp->selectType();
 $objAnswerTmp = new Answer($questionId);
 $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
-$choice = $exerciseResult[$questionId];
-$destination = [];
-$comment = '';
-$next = 1;
-Session::write('hotspot_coord', []);
-Session::write('hotspot_dest', []);
-$overlap_color = $missing_color = $excess_color = false;
-$organs_at_risk_hit = 0;
-$wrong_results = false;
-$hot_spot_load = false;
-$questionScore = 0;
-$totalScore = 0;
 $showResult = false;
 
 $objAnswerTmp = new Answer($questionId, api_get_course_int_id());
@@ -194,15 +160,16 @@ switch ($answerType) {
             $_SESSION['exerciseResultCoordinates'][$questionId] = $choiceValue; //needed for exercise_result.php
             $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
             $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
-            $_SESSION['hotspot_coord'][1] = $delineation_cord;
-            $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
+            $_SESSION['hotspot_coord'][$questionId][1] = $delineation_cord;
+            $_SESSION['hotspot_dest'][$questionId][1] = $answer_delineation_destination;
         }
         break;
     case CALCULATED_ANSWER:
-        $_SESSION['calculatedAnswerId'][$questionId] = mt_rand(
+        /*$_SESSION['calculatedAnswerId'][$questionId] = mt_rand(
             1,
             $nbrAnswers
-        );
+        );*/
+        //var_dump($_SESSION['calculatedAnswerId'][$questionId]);
         break;
 }
 
@@ -223,16 +190,6 @@ $result = $objExercise->manage_answer(
     true
 );
 $manageAnswerHtmlContent = ob_get_clean();
-
-if ($showResult) {
-    /*echo $objQuestionTmp->return_header(
-        $objExercise,
-        $questionNum,
-        []
-    );
-    echo $manageAnswerHtmlContent;*/
-}
-
 $contents = '';
 $answerCorrect = false;
 if (!empty($result)) {
@@ -255,9 +212,6 @@ if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_DIRECT) {
         $answerId = $result['correct_answer_id'];
         $contents = $objAnswerTmp->selectComment($answerId);
     }
-    if ($answerType === HOT_SPOT_DELINEATION) {
-        $contents = $manageAnswerHtmlContent;
-    }
 } else {
     $contents = Display::return_message(get_lang('Incorrect'), 'warning');
     if ($answerCorrect) {
@@ -265,7 +219,9 @@ if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_DIRECT) {
     }
 }
 
-Session::write('newquestionList', $newQuestionList);
+if ($answerType === HOT_SPOT_DELINEATION) {
+    $contents = $manageAnswerHtmlContent;
+}
 $links = '';
 if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_DIRECT) {
     if (isset($choiceValue) && $choiceValue == -1) {
@@ -297,8 +253,6 @@ if (isset($try) && $try == 1) {
 // the link to theory (a learning path)
 if (!empty($lp)) {
     $lp_url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
-    /*$list = new LearnpathList(api_get_user_id());
-    $flat_list = $list->get_flat_list();*/
     $links .= Display:: return_icon(
         'theory.gif',
         '',
@@ -309,7 +263,7 @@ if (!empty($lp)) {
 $links .= '<br />';
 
 // the link to an external website or link
-if (!empty($url) && $url <> -1) {
+if (!empty($url) && $url != -1) {
     $links .= Display:: return_icon(
         'link.gif',
         '',
@@ -317,10 +271,8 @@ if (!empty($url) && $url <> -1) {
     ).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
 }
 
-//if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_POPUP) {
-    $nextQuestion = $questionNum + 1;
-    $destinationId = isset($questionList[$nextQuestion]) ? $questionList[$nextQuestion] : -1;
-//}
+$nextQuestion = $questionNum + 1;
+$destinationId = isset($questionList[$nextQuestion]) ? $questionList[$nextQuestion] : -1;
 
 // the link to finish the test
 if ($destinationId == -1) {
@@ -332,8 +284,6 @@ if ($destinationId == -1) {
 } else {
     // the link to other question
     if (in_array($destinationId, $questionList)) {
-        /*$objQuestionTmp = Question::read($destinationId);
-        $questionName = $objQuestionTmp->selectTitle();*/
         $num_value_array = array_keys($questionList, $destinationId);
         $icon = Display::return_icon(
                 'quiz.png',
@@ -349,10 +299,10 @@ if ($destinationId == -1) {
 echo '<script>
 function SendEx(num) {
     if (num == -1) {
-        window.location.href = "exercise_result.php?'.api_get_cidreq().'&take_session=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
+        window.location.href = "exercise_result.php?'.api_get_cidreq().'&take_session=1&exerciseId='.$exerciseId.'&num="+num+"&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
     } else {
         num -= 1;
-        window.location.href = "exercise_submit.php?'.api_get_cidreq().'&tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
+        window.location.href = "exercise_submit.php?'.api_get_cidreq().'&tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
     }    
     return false;
 }
@@ -362,20 +312,10 @@ if (!empty($links)) {
     echo '<div>'.$contents.'</div>';
     echo '<div style="padding-left: 450px"><h5>'.$links.'</h5></div>';
     echo '</div>';
-
-    Session::write('hot_spot_result', $message);
-    $_SESSION['hotspot_delineation_result'][$exerciseId][$questionId] = [$message, $exerciseResult[$questionId]];
-    // Resetting the exerciseResult variable
-    Session::write('exerciseResult', $exerciseResult);
-
-    // Save this variables just in case the exercise loads an LP with other exercise
-    Session::write('objExerciseExtra'.$exerciseId, Session::read('objExercise'));
-    Session::write('exerciseResultExtra'.$exerciseId, Session::read('exerciseResult'));
-    Session::write('questionListExtra'.$exerciseId, Session::read('questionList'));
 } else {
     $questionNum++;
     echo '<script>
-            window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'";
+            window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&'.api_get_cidreq().'";
         </script>';
 }
 echo '</div>';

+ 1 - 4
main/exercise/overview.php

@@ -15,10 +15,7 @@ require_once __DIR__.'/../inc/global.inc.php';
 $current_course_tool = TOOL_QUIZ;
 
 // Clear the exercise session just in case
-Session::erase('objExercise');
-Session::erase('calculatedAnswerId');
-Session::erase('duration_time_previous');
-Session::erase('duration_time');
+Exercise::cleanSessionVariables();
 
 $this_section = SECTION_COURSES;
 

+ 2 - 4
main/inc/ajax/exercise.ajax.php

@@ -549,7 +549,7 @@ switch ($action) {
                     $hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$my_question_id];
                 }
 
-                if ($type == 'simple') {
+                if ($type === 'simple') {
                     // Getting old attempt in order to decrees the total score.
                     $old_result = $objExercise->manage_answer(
                         $exeId,
@@ -560,10 +560,8 @@ switch ($action) {
                         false,
                         true,
                         false,
-                        $objExercise->selectPropagateNeg(),
-                        []
+                        $objExercise->selectPropagateNeg()
                     );
-
                     // Removing old score.
                     $total_score = $total_score - $old_result['score'];
                 }

+ 0 - 1
main/inc/lib/exercise.lib.php

@@ -4415,7 +4415,6 @@ EOT;
         // Hide results
         $show_results = false;
         $show_only_score = false;
-
         if (in_array($objExercise->results_disabled,
             [
                 RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,