Browse Source

Add new "result disable" option in exercises "Show only correct answer" BT#15233

Julio Montoya 6 years ago
parent
commit
7c93e97232

+ 24 - 45
main/exercise/exercise.class.php

@@ -3537,8 +3537,10 @@ class Exercise
                     if (!empty($studentChoice)) {
                         if ($studentChoice == $answerCorrect) {
                             // correct answer and student is Unsure or PrettySur
-                            if ($quiz_question_options[$studentChoiceDegree]['position'] >= 3
-                                && $quiz_question_options[$studentChoiceDegree]['position'] < 9) {
+                            if (isset($quiz_question_options[$studentChoiceDegree]) &&
+                                $quiz_question_options[$studentChoiceDegree]['position'] >= 3 &&
+                                $quiz_question_options[$studentChoiceDegree]['position'] < 9
+                            ) {
                                 $questionScore += $true_score;
                             } else {
                                 // student ignore correct answer
@@ -3629,21 +3631,15 @@ class Exercise
                         }
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
 
+                        $real_answers[$answerId] = false;
                         if ($answerCorrect == $studentChoice) {
-                            //$answerCorrect = 1;
                             $real_answers[$answerId] = true;
-                        } else {
-                            //$answerCorrect = 0;
-                            $real_answers[$answerId] = false;
                         }
                     } else {
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
+                        $real_answers[$answerId] = false;
                         if ($answerCorrect == $studentChoice) {
-                            //$answerCorrect = 1;
                             $real_answers[$answerId] = true;
-                        } else {
-                            //$answerCorrect = 0;
-                            $real_answers[$answerId] = false;
                         }
                     }
                     break;
@@ -3659,31 +3655,27 @@ class Exercise
 
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                         if ($answerCorrect == 1) {
+                            $real_answers[$answerId] = false;
                             if ($studentChoice) {
                                 $real_answers[$answerId] = true;
-                            } else {
-                                $real_answers[$answerId] = false;
                             }
                         } else {
+                            $real_answers[$answerId] = true;
                             if ($studentChoice) {
                                 $real_answers[$answerId] = false;
-                            } else {
-                                $real_answers[$answerId] = true;
                             }
                         }
                     } else {
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                         if ($answerCorrect == 1) {
+                            $real_answers[$answerId] = false;
                             if ($studentChoice) {
                                 $real_answers[$answerId] = true;
-                            } else {
-                                $real_answers[$answerId] = false;
                             }
                         } else {
+                            $real_answers[$answerId] = true;
                             if ($studentChoice) {
                                 $real_answers[$answerId] = false;
-                            } else {
-                                $real_answers[$answerId] = true;
                             }
                         }
                     }
@@ -4283,6 +4275,12 @@ class Exercise
                                 }
                             }
 
+                            if ($results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                                if ($s_user_answer != $i_answer_correct_answer) {
+                                    continue;
+                                }
+                            }
+
                             if ($show_result) {
                                 if ($this->showExpectedChoice() == false &&
                                     $showTotalScoreAndUserChoicesInLastAttempt === false
@@ -4901,6 +4899,7 @@ class Exercise
                     if ($debug) {
                         error_log('Showing questions $from '.$from);
                     }
+
                     switch ($answerType) {
                         case UNIQUE_ANSWER:
                         case UNIQUE_ANSWER_IMAGE:
@@ -5097,26 +5096,6 @@ class Exercise
                         case HOT_SPOT_DELINEATION:
                             $user_answer = $user_array;
                             if ($next) {
-                                //$tbl_track_e_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
-                                // Save into db
-                                /*	$sql = "INSERT INTO $tbl_track_e_hotspot (
-                                 * hotspot_user_id,
-                                 *  hotspot_course_code,
-                                 *  hotspot_exe_id,
-                                 *  hotspot_question_id,
-                                 *  hotspot_answer_id,
-                                 *  hotspot_correct,
-                                 *  hotspot_coordinate
-                                 *  )
-                                VALUES (
-                                 * '".Database::escape_string($_user['user_id'])."',
-                                 *  '".Database::escape_string($_course['id'])."',
-                                 *  '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."',
-                                 *  '".Database::escape_string($answerId)."',
-                                 *  '".Database::escape_string($studentChoice)."',
-                                 *  '".Database::escape_string($user_array)."')";
-                                $result = Database::query($sql,__FILE__,__LINE__);
-                                 */
                                 $user_answer = $user_array;
                                 // we compare only the delineation not the other points
                                 $answer_question = $_SESSION['hotspot_coord'][1];
@@ -5266,7 +5245,6 @@ class Exercise
                                 )
                             );
                             echo '</tr>';
-
                             break;
                         case ANNOTATION:
                             ExerciseShowFunctions::displayAnnotationAnswer(
@@ -5578,16 +5556,17 @@ class Exercise
             ) {
                 if ($choice != 0) {
                     $reply = array_keys($choice);
-                    for ($i = 0; $i < sizeof($reply); $i++) {
+                    $countReply = count($reply);
+                    for ($i = 0; $i < $countReply; $i++) {
                         $chosenAnswer = $reply[$i];
                         if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
                             if ($choiceDegreeCertainty != 0) {
                                 $replyDegreeCertainty = array_keys($choiceDegreeCertainty);
-                                $answerDegreeCertainty = $replyDegreeCertainty[$i];
+                                $answerDegreeCertainty = isset($replyDegreeCertainty[$i]) ? $replyDegreeCertainty[$i] : '';
+                                $answerValue = isset($choiceDegreeCertainty[$answerDegreeCertainty]) ? $choiceDegreeCertainty[$answerDegreeCertainty] : '';
                                 Event::saveQuestionAttempt(
                                     $questionScore,
-                                    $chosenAnswer.':'.$choice[$chosenAnswer].':'.
-                                    $choiceDegreeCertainty[$answerDegreeCertainty],
+                                    $chosenAnswer.':'.$choice[$chosenAnswer].':'.$answerValue,
                                     $quesId,
                                     $exeId,
                                     $i,
@@ -8403,14 +8382,14 @@ class Exercise
             ['id' => 'result_disabled_6']
         );
 
-        /*$resultDisabledGroup[] = $form->createElement(
+        $resultDisabledGroup[] = $form->createElement(
             'radio',
             'results_disabled',
             null,
             get_lang('ExerciseShowOnlyCorrectAnswer'),
             '7',
             ['id' => 'result_disabled_7']
-        );*/
+        );
 
         $group = $form->addGroup(
             $resultDisabledGroup,

+ 6 - 0
main/exercise/fill_blanks.class.php

@@ -1231,6 +1231,12 @@ class FillBlanks extends Question
 
         // rebuild the sentence with student answer inserted
         for ($i = 0; $i < count($listStudentAnswerInfo['common_words']); $i++) {
+            if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                if (isset($listStudentAnswerInfo['student_score'][$i]) &&
+                    $listStudentAnswerInfo['student_score'][$i] != 1) {
+                    continue;
+                }
+            }
             $result .= isset($listStudentAnswerInfo['common_words'][$i]) ? $listStudentAnswerInfo['common_words'][$i] : '';
             $result .= isset($listStudentAnswerInfo['student_answer'][$i]) ? $listStudentAnswerInfo['student_answer'][$i] : '';
         }

+ 29 - 1
main/exercise/hotspot_answers.as.php

@@ -163,8 +163,36 @@ if (!$hideExpectedAnswer) {
 
     /** @var CQuizAnswer $hotSpotAnswer */
     foreach ($result as $hotSpotAnswer) {
+        $hotSpotAnswerId = $hotSpotAnswer->getIid();
+
+        // Show only correct hotspots
+        if ($objExercise->selectResultsDisabled() == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+            $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
+            // Check auto id
+            $sql = "SELECT hotspot_correct
+                    FROM $TBL_TRACK_HOTSPOT
+                    WHERE
+                        hotspot_exe_id = $exeId AND
+                        hotspot_question_id= $questionId AND
+                        hotspot_answer_id = ".$hotSpotAnswerId."
+                    ORDER BY hotspot_id ASC";
+            $result = Database::query($sql);
+            $studentChoice = false;
+            if (Database::num_rows($result)) {
+                $studentChoice = Database::result(
+                    $result,
+                    0,
+                    'hotspot_correct'
+                );
+            }
+
+            if (!$studentChoice) {
+                continue;
+            }
+        }
+
         $hotSpot = [];
-        $hotSpot['id'] = $hotSpotAnswer->getIid();
+        $hotSpot['id'] = $hotSpotAnswerId;
         $hotSpot['answer'] = $hotSpotAnswer->getAnswer();
 
         switch ($hotSpotAnswer->getHotspotType()) {

+ 4 - 5
main/exercise/overview.php

@@ -52,7 +52,7 @@ $interbreadcrumb[] = [
     'url' => 'exercise.php?'.api_get_cidreq(),
     'name' => get_lang('Exercises'),
 ];
-$interbreadcrumb[] = ["url" => "#", "name" => $objExercise->selectTitle(true)];
+$interbreadcrumb[] = ['url' => '#', 'name' => $objExercise->selectTitle(true)];
 
 $time_control = false;
 $clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
@@ -210,10 +210,7 @@ if (in_array(
 if (!empty($attempts)) {
     $i = $counter;
     foreach ($attempts as $attempt_result) {
-        $score = ExerciseLib::show_score(
-            $attempt_result['exe_result'],
-            $attempt_result['exe_weighting']
-        );
+        $score = ExerciseLib::show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']);
         $attempt_url = api_get_path(WEB_CODE_PATH).'exercise/result.php?';
         $attempt_url .= api_get_cidreq().'&show_headers=1&';
         $attempt_url .= http_build_query([
@@ -254,6 +251,7 @@ if (!empty($attempts)) {
                 RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
                 RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
                 RESULT_DISABLE_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
             ]
         )) {
             $row['result'] = $score;
@@ -267,6 +265,7 @@ if (!empty($attempts)) {
                 RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
                 RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
                 RESULT_DISABLE_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
             ]
         ) || (
             $objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&

+ 9 - 5
main/exercise/question.class.php

@@ -1980,20 +1980,20 @@ abstract class Question
         if (!empty($counter)) {
             $counterLabel = (int) $counter;
         }
-        $score_label = get_lang('Wrong');
+        $scoreLabel = get_lang('Wrong');
         $class = 'error';
         if (isset($score['pass']) && $score['pass'] == true) {
-            $score_label = get_lang('Correct');
+            $scoreLabel = get_lang('Correct');
             $class = 'success';
         }
 
         if (in_array($this->type, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) {
             $score['revised'] = isset($score['revised']) ? $score['revised'] : false;
             if ($score['revised'] == true) {
-                $score_label = get_lang('Revised');
+                $scoreLabel = get_lang('Revised');
                 $class = '';
             } else {
-                $score_label = get_lang('NotRevised');
+                $scoreLabel = get_lang('NotRevised');
                 $class = 'warning';
                 if (isset($score['weight'])) {
                     $weight = float_format($score['weight'], 1);
@@ -2029,7 +2029,10 @@ abstract class Question
         // dont display score for certainty degree questions
         if ($this->type != MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
             if (isset($score['result'])) {
-                $header .= $exercise->getQuestionRibbon($class, $score_label, $score['result'], $scoreCurrent);
+                if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                    $score['result'] = null;
+                }
+                $header .= $exercise->getQuestionRibbon($class, $scoreLabel, $score['result'], $scoreCurrent);
             }
         }
 
@@ -2070,6 +2073,7 @@ abstract class Question
     }
 
     /**
+     * @deprecated
      * Create a question from a set of parameters.
      *
      * @param   int     Quiz ID

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

@@ -4429,6 +4429,10 @@ EOT;
             $show_results = true;
         }
 
+        if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+            $show_results = true;
+        }
+
         if (in_array(
             $objExercise->results_disabled,
             [

+ 88 - 88
main/inc/lib/exercise_show_functions.lib.php

@@ -57,11 +57,6 @@ class ExerciseShowFunctions
             echo '<tr><td>';
             echo Security::remove_XSS($answerHTML, COURSEMANAGERLOWSECURITY);
             echo '</td>';
-            if (!api_is_allowed_to_edit(null, true) && $feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
-                echo '<td>';
-                $comm = Event::get_comments($id, $questionId);
-                echo '</td>';
-            }
             echo '</tr>';
         }
     }
@@ -103,11 +98,6 @@ class ExerciseShowFunctions
                 echo '</td><td>';
                 echo Security::remove_XSS($status);
                 echo '</td>';
-                if (!api_is_allowed_to_edit(null, true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
-                    echo '<td>';
-                    $comm = Event::get_comments($id, $questionId);
-                    echo '</td>';
-                }
                 echo '</tr>';
             }
         } else {
@@ -116,11 +106,6 @@ class ExerciseShowFunctions
             } else {
                 echo '<tr><td>';
                 echo Security::remove_XSS($answer);
-                if (!api_is_allowed_to_edit(null, true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
-                    echo '<td>';
-                    $comm = Event::get_comments($id, $questionId);
-                    echo '</td>';
-                }
                 echo '</tr>';
             }
         }
@@ -254,55 +239,62 @@ class ExerciseShowFunctions
         }
 
         $hotspot_colors = [
-            "", // $i starts from 1 on next loop (ugly fix)
-            "#4271B5",
-            "#FE8E16",
-            "#45C7F0",
-            "#BCD631",
-            "#D63173",
-            "#D7D7D7",
-            "#90AFDD",
-            "#AF8640",
-            "#4F9242",
-            "#F4EB24",
-            "#ED2024",
-            "#3B3B3B",
-            "#F7BDE2",
+            '', // $i starts from 1 on next loop (ugly fix)
+            '#4271B5',
+            '#FE8E16',
+            '#45C7F0',
+            '#BCD631',
+            '#D63173',
+            '#D7D7D7',
+            '#90AFDD',
+            '#AF8640',
+            '#4F9242',
+            '#F4EB24',
+            '#ED2024',
+            '#3B3B3B',
+            '#F7BDE2',
         ];
-        echo '<table class="data_table"><tr>';
-        echo '<td class="text-center" width="5%">';
-        echo '<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color:'.
+
+        $content = '<table class="data_table"><tr>';
+        $content .= '<td class="text-center" width="5%">';
+        $content .= '<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color:'.
             $hotspot_colors[$orderColor].'"></span>';
-        echo '</td>';
-        echo '<td class="text-left" width="25%">';
-        echo "$answerId - $answer";
-        echo '</td>';
-        echo '<td class="text-left" width="10%">';
+        $content .= '</td>';
+        $content .= '<td class="text-left" width="25%">';
+        $content .= "$answerId - $answer";
+        $content .= '</td>';
+        $content .= '<td class="text-left" width="10%">';
         if (!$hide_expected_answer) {
             $status = Display::label(get_lang('Incorrect'), 'danger');
             if ($studentChoice) {
                 $status = Display::label(get_lang('Correct'), 'success');
+            } else {
+                if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                    return '';
+                }
             }
-            echo $status;
+            $content .= $status;
         }
-        echo '</td>';
+        $content .= '</td>';
         if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
-            echo '<td class="text-left" width="60%">';
+            $content .= '<td class="text-left" width="60%">';
             if ($studentChoice) {
-                echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
+                $content .= '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
             }
-            echo '</td>';
+            $content .= '</td>';
         } else {
-            echo '<td class="text-left" width="60%">&nbsp;</td>';
+            $content .= '<td class="text-left" width="60%">&nbsp;</td>';
         }
-        echo '</tr>';
+        $content .= '</tr>';
+
+        echo $content;
     }
 
     /**
      * Display the answers to a multiple choice question.
      *
      * @param Exercise $exercise
-     * @param int      $feedback_type                Feedback type
+     * @param int      $feedbackType                Feedback type
      * @param int      $answerType                   Answer type
      * @param int      $studentChoice                Student choice
      * @param string   $answer                       Textual answer
@@ -317,7 +309,7 @@ class ExerciseShowFunctions
      */
     public static function display_unique_or_multiple_answer(
         $exercise,
-        $feedback_type,
+        $feedbackType,
         $answerType,
         $studentChoice,
         $answer,
@@ -342,15 +334,22 @@ class ExerciseShowFunctions
             $answer = str_replace($tags, '', $answer);
         }
 
+        $studentChoiceInt = (int) $studentChoice;
+        $answerCorrectChoice = (int) $answerCorrect;
+
         $hide_expected_answer = false;
         switch ($resultsDisabled) {
             case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
+                if ($studentChoiceInt !== $answerCorrectChoice) {
+                    return '';
+                }
+
                 if (!$answerCorrect) {
-                    $hide_expected_answer = true;
+                    return '';
                 }
                 break;
             case RESULT_DISABLE_SHOW_SCORE_ONLY:
-                if ($feedback_type == 0) {
+                if ($feedbackType == 0) {
                     $hide_expected_answer = true;
                 }
                 break;
@@ -384,14 +383,8 @@ class ExerciseShowFunctions
         echo '</td>';
 
         if ($exercise->showExpectedChoice()) {
-            /*$status = Display::label(get_lang('Incorrect'), 'danger');
-            if ($studentChoice && $answerCorrect) {
-                $status = Display::label(get_lang('Correct'), 'success');
-            }*/
-            $studentChoiceChoice = (int) $studentChoice;
-            $answerCorrectChoice = (int) $answerCorrect;
             $status = Display::label(get_lang('Incorrect'), 'danger');
-            if ($studentChoiceChoice === $answerCorrectChoice) {
+            if ($studentChoiceInt === $answerCorrectChoice) {
                 $status = Display::label(get_lang('Correct'), 'success');
             }
             echo '<td width="20%">';
@@ -399,7 +392,7 @@ class ExerciseShowFunctions
             echo '</td>';
         }
 
-        if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
+        if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
             echo '<td width="20%">';
             if ($studentChoice) {
                 $color = 'black';
@@ -444,7 +437,7 @@ class ExerciseShowFunctions
      */
     public static function display_multiple_answer_true_false(
         $exercise,
-        $feedback_type,
+        $feedbackType,
         $answerType,
         $studentChoice,
         $answer,
@@ -459,7 +452,7 @@ class ExerciseShowFunctions
         $hide_expected_answer = false;
         switch ($resultsDisabled) {
             case RESULT_DISABLE_SHOW_SCORE_ONLY:
-                if ($feedback_type == 0) {
+                if ($feedbackType == 0) {
                     $hide_expected_answer = true;
                 }
                 break;
@@ -471,29 +464,30 @@ class ExerciseShowFunctions
                 }
                 break;
         }
-        echo '<tr><td width="5%">';
+
+        $content = '<tr><td width="5%">';
         $course_id = api_get_course_int_id();
         $new_options = Question::readQuestionOption($questionId, $course_id);
         // Your choice
         if (isset($new_options[$studentChoice])) {
-            echo get_lang($new_options[$studentChoice]['name']);
+            $content .= get_lang($new_options[$studentChoice]['name']);
         } else {
-            echo '-';
+            $content .= '-';
         }
         echo '</td><td width="5%">';
         // Expected choice
         if (!$hide_expected_answer) {
             if (isset($new_options[$answerCorrect])) {
-                echo get_lang($new_options[$answerCorrect]['name']);
+                $content .= get_lang($new_options[$answerCorrect]['name']);
             } else {
-                echo '-';
+                $content .= '-';
             }
         } else {
-            echo '-';
+            $content .= '-';
         }
-        echo '</td><td width="40%">';
-        echo $answer;
-        echo '</td>';
+        $content .= '</td><td width="40%">';
+        $content .= $answer;
+        $content .= '</td>';
         if ($exercise->showExpectedChoice()) {
             $status = Display::label(get_lang('Incorrect'), 'danger');
             if (isset($new_options[$studentChoice])) {
@@ -501,31 +495,35 @@ class ExerciseShowFunctions
                     $status = Display::label(get_lang('Correct'), 'success');
                 }
             }
-            echo '<td width="20%">';
-            echo $status;
-            echo '</td>';
+            $content .= '<td width="20%">';
+            $content .= $status;
+            $content .= '</td>';
         }
-        if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
-            echo '<td width="20%">';
-            $color = "black";
+        if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
+            if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                if ($studentChoice != $answerCorrect) {
+                    return '';
+                }
+            }
+            $content .= '<td width="20%">';
+            $color = 'black';
             if (isset($new_options[$studentChoice])) {
                 if ($studentChoice == $answerCorrect) {
-                    $color = "green";
+                    $color = 'green';
                 }
 
                 if ($hide_expected_answer) {
                     $color = '';
                 }
-                echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
-            }
-            echo '</td>';
-            if ($ans == 1) {
-                $comm = Event::get_comments($id, $questionId);
+                $content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
             }
+            $content .= '</td>';
         } else {
-            echo '<td>&nbsp;</td>';
+            $content .= '<td>&nbsp;</td>';
         }
-        echo '</tr>';
+        $content .= '</tr>';
+
+        echo $content;
     }
 
     /**
@@ -582,7 +580,9 @@ class ExerciseShowFunctions
         echo '</td><td width="20%">';
         echo $answer;
         echo '</td><td width="5%" style="text-align:center;">';
-        echo $newOptions[$studentChoiceDegree]['name'];
+        if (isset($newOptions[$studentChoiceDegree])) {
+            echo $newOptions[$studentChoiceDegree]['name'];
+        }
         echo '</td>';
 
         $degreeInfo = $question->getResponseDegreeInfo(
@@ -628,7 +628,7 @@ class ExerciseShowFunctions
      */
     public static function display_multiple_answer_combination_true_false(
         $exercise,
-        $feedback_type,
+        $feedbackType,
         $answerType,
         $studentChoice,
         $answer,
@@ -643,7 +643,7 @@ class ExerciseShowFunctions
         $hide_expected_answer = false;
         switch ($resultsDisabled) {
             case RESULT_DISABLE_SHOW_SCORE_ONLY:
-                if ($feedback_type == 0) {
+                if ($feedbackType == 0) {
                     $hide_expected_answer = true;
                 }
                 break;
@@ -694,7 +694,7 @@ class ExerciseShowFunctions
             echo '</td>';
         }
 
-        if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
+        if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
             echo '<td width="20%">';
             //@todo replace this harcoded value
             if ($studentChoice) {
@@ -718,21 +718,21 @@ class ExerciseShowFunctions
     }
 
     /**
-     * @param $feedback_type
+     * @param $feedbackType
      * @param $exe_id
      * @param $questionId
      * @param null $questionScore
      * @param int  $resultsDisabled
      */
     public static function displayAnnotationAnswer(
-        $feedback_type,
+        $feedbackType,
         $exe_id,
         $questionId,
         $questionScore = null,
         $resultsDisabled = 0
     ) {
         $comments = Event::get_comments($exe_id, $questionId);
-        if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
+        if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
             if ($questionScore <= 0 && empty($comments)) {
                 echo '<br />'.ExerciseLib::getNotCorrectedYetText();
             }

+ 1 - 7
main/inc/lib/javascript/hotspot/js/hotspot.js

@@ -764,11 +764,9 @@ window.HotspotQuestion = (function () {
                         default:
                             hotspot = SquareModel.decode(hotspotInfo);
                             break;
-
                         case 'circle':
                             hotspot = EllipseModel.decode(hotspotInfo);
                             break;
-
                         case 'poly':
                             hotspot = PolygonModel.decode(hotspotInfo);
                             break;
@@ -891,9 +889,7 @@ window.HotspotQuestion = (function () {
                 })
                 .on('mousedown', 'circle, text', function (e) {
                     e.preventDefault();
-
                     isMoving = true;
-
                     if (e.target.tagName === 'circle') {
                         //Hack to move correctly the hot spots if there are more than one HS question in same page
                         answerIndex = $(e.target).next().html();
@@ -1141,16 +1137,14 @@ window.HotspotQuestion = (function () {
                     modifyAnswers: parseInt(config.questionId)
                 });
                 break;
-
             case 'user':
                 xhrQuestion = $.getJSON(config.relPath + 'exercise/hotspot_actionscript.as.php?' + _p.web_cid_query, {
                     modifyAnswers: parseInt(config.questionId),
                     exe_id: parseInt(config.exerciseId)
                 });
                 break;
-
             case 'solution':
-            //no break
+                //no break
             case 'preview':
                 xhrQuestion = $.getJSON(config.relPath + 'exercise/hotspot_answers.as.php?' + _p.web_cid_query, {
                     modifyAnswers: parseInt(config.questionId),