Browse Source

Change result disable option see BT#15743

Option RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING now
works like
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER and
RESULT_DISABLE_RANKING
Julio 5 years ago
parent
commit
1d4ec845a7

+ 5 - 1
main/exercise/MatchingDraggable.php

@@ -265,7 +265,11 @@ class MatchingDraggable extends Question
         $header = parent::return_header($exercise, $counter, $score);
         $header .= '<table class="matching '.$this->question_table_class.'"><tr>';
         $header .= '<th>'.get_lang('ElementList').'</th>';
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('YourChoice').'</th>';
         }
 

+ 12 - 4
main/exercise/exercise.class.php

@@ -4322,7 +4322,11 @@ class Exercise
                                     case MATCHING:
                                     case MATCHING_DRAGGABLE:
                                         echo '<tr>';
-                                        if ($this->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                                        if (!in_array($this->results_disabled, [
+                                            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                                            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+                                            ])
+                                        ) {
                                             echo '<td>'.$s_answer_label.'</td>';
                                             echo '<td>'.$user_answer.'</td>';
                                         } else {
@@ -4365,7 +4369,11 @@ class Exercise
                                         }
                                         echo '<tr>';
                                         if ($this->showExpectedChoice()) {
-                                            if ($this->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                                            if (!in_array($this->results_disabled, [
+                                                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                                                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+                                            ])
+                                            ) {
                                                 echo '<td>'.$user_answer.'</td>';
                                             } else {
                                                 $status = Display::label(get_lang('Correct'), 'success');
@@ -8605,8 +8613,8 @@ class Exercise
             'radio',
             'results_disabled',
             null,
-            get_lang('AutoEvaluationAndRankingMode'),
-            RESULT_DISABLE_AUTOEVALUATION_AND_RANKING,
+            get_lang('ExerciseShowOnlyGlobalScoreAndCorrectAnswersAndRankingMode'),
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
             ['id' => 'result_disabled_8']
         );
 

+ 0 - 2
main/exercise/exercise.php

@@ -1152,7 +1152,6 @@ if (!empty($exerciseList)) {
                                     RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
                                     RESULT_DISABLE_SHOW_SCORE_ONLY,
                                     RESULT_DISABLE_RANKING,
-                                    RESULT_DISABLE_AUTOEVALUATION_AND_RANKING,
                                 ]
                             )
                         ) {
@@ -1219,7 +1218,6 @@ if (!empty($exerciseList)) {
                                 RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
                                 RESULT_DISABLE_SHOW_SCORE_ONLY,
                                 RESULT_DISABLE_RANKING,
-                                RESULT_DISABLE_AUTOEVALUATION_AND_RANKING,
                             ]
                         )
                     ) {

+ 1 - 1
main/exercise/exercise_show.php

@@ -1028,7 +1028,7 @@ if (!empty($category_list) && ($show_results || $show_only_total_score || $showT
 
 if (in_array(
     $track_exercise_info['results_disabled'],
-    [RESULT_DISABLE_RANKING, RESULT_DISABLE_AUTOEVALUATION_AND_RANKING]
+    [RESULT_DISABLE_RANKING, RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING]
 )) {
     echo Display::page_header(get_lang('Ranking'), null, 'h4');
     echo ExerciseLib::displayResultsInRanking(

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

@@ -1265,6 +1265,7 @@ class FillBlanks extends Question
         $hideExpectedAnswer = false;
         $hideUserSelection = false;
         switch ($resultsDisabled) {
+            case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING:
             case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
                 $hideUserSelection = true;
                 break;

+ 5 - 1
main/exercise/global_multiple_answer.class.php

@@ -269,7 +269,11 @@ class GlobalMultipleAnswer extends Question
         $header = parent::return_header($exercise, $counter, $score);
         $header .= '<table class="'.$this->question_table_class.'"><tr>';
 
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('Choice').'</th>';
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }

+ 5 - 1
main/exercise/matching.class.php

@@ -287,7 +287,11 @@ class Matching extends Question
         $header .= '<tr>';
 
         $header .= '<th>'.get_lang('ElementList').'</th>';
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('Choice').'</th>';
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }

+ 5 - 1
main/exercise/multiple_answer.class.php

@@ -235,7 +235,11 @@ class MultipleAnswer extends Question
         $header .= '<table class="'.$this->question_table_class.'"><tr>';
 
         $header .= '<th>'.get_lang('Choice').'</th>';
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }
 

+ 5 - 1
main/exercise/multiple_answer_combination.class.php

@@ -232,7 +232,11 @@ class MultipleAnswerCombination extends Question
         $header = parent::return_header($exercise, $counter, $score);
         $header .= '<table class="'.$this->question_table_class.'"><tr>';
 
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('Choice').'</th>';
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }

+ 13 - 2
main/exercise/multiple_answer_true_false.class.php

@@ -313,7 +313,11 @@ class MultipleAnswerTrueFalse extends Question
         $header = parent::return_header($exercise, $counter, $score);
         $header .= '<table class="'.$this->question_table_class.'"><tr>';
 
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('Choice').'</th>';
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }
@@ -324,7 +328,14 @@ class MultipleAnswerTrueFalse extends Question
             $header .= '<th>'.get_lang('Status').'</th>';
         }
         if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM ||
-            $exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+            in_array(
+                $exercise->results_disabled,
+                [
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
+                ]
+            )
+        ) {
             $header .= '<th>'.get_lang('Comment').'</th>';
         }
         $header .= '</tr>';

+ 3 - 3
main/exercise/overview.php

@@ -253,7 +253,7 @@ if (!empty($attempts)) {
                 RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
                 RESULT_DISABLE_RANKING,
                 RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
-                RESULT_DISABLE_AUTOEVALUATION_AND_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
             ]
         )) {
             $row['result'] = $score;
@@ -268,7 +268,7 @@ if (!empty($attempts)) {
                 RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
                 RESULT_DISABLE_RANKING,
                 RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
-                RESULT_DISABLE_AUTOEVALUATION_AND_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
             ]
         ) || (
             $objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
@@ -326,7 +326,7 @@ if (!empty($attempts)) {
             }
             break;
         case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS:
-        case RESULT_DISABLE_AUTOEVALUATION_AND_RANKING:
+        case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING:
         case RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES:
         case RESULT_DISABLE_RANKING:
             $header_names = [

+ 20 - 4
main/exercise/question.class.php

@@ -1994,7 +1994,11 @@ abstract class Question
 
         $scoreLabel = get_lang('Wrong');
 
-        if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $scoreLabel = get_lang('QuizWrongAnswerHereIsTheCorrectOne');
         }
 
@@ -2002,7 +2006,11 @@ abstract class Question
         if (isset($score['pass']) && $score['pass'] == true) {
             $scoreLabel = get_lang('Correct');
 
-            if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+            if (in_array($exercise->results_disabled, [
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+            ])
+            ) {
                 $scoreLabel = get_lang('CorrectAnswer');
             }
 
@@ -2036,7 +2044,11 @@ abstract class Question
                 }
                 break;
             case UNIQUE_ANSWER:
-                if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                if (in_array($exercise->results_disabled, [
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+                ])
+                ) {
                     if (isset($score['user_answered'])) {
                         if ($score['user_answered'] === false) {
                             $scoreLabel = get_lang('Unanswered');
@@ -2066,7 +2078,11 @@ abstract class Question
         // dont display score for certainty degree questions
         if ($this->type != MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
             if (isset($score['result'])) {
-                if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                if (in_array($exercise->results_disabled, [
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+                ])
+                ) {
                     $score['result'] = null;
                 }
                 $header .= $exercise->getQuestionRibbon($class, $scoreLabel, $score['result'], $scoreCurrent);

+ 5 - 1
main/exercise/unique_answer.class.php

@@ -417,7 +417,11 @@ class UniqueAnswer extends Question
         $header .= '<table class="'.$this->question_table_class.'"><tr>';
 
         $header .= '<th>'.get_lang('Choice').'</th>';
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }
 

+ 5 - 1
main/exercise/unique_answer_no_option.class.php

@@ -404,7 +404,11 @@ class UniqueAnswerNoOption extends Question
         $header = parent::return_header($exercise, $counter, $score);
         $header .= '<table class="'.$this->question_table_class.'"><tr>';
 
-        if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (!in_array($exercise->results_disabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             $header .= '<th>'.get_lang('Choice').'</th>';
             $header .= '<th>'.get_lang('ExpectedChoice').'</th>';
         }

+ 1 - 1
main/inc/lib/api.lib.php

@@ -478,7 +478,7 @@ define('RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT', 4);
 define('RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK', 5);
 define('RESULT_DISABLE_RANKING', 6);
 define('RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER', 7);
-define('RESULT_DISABLE_AUTOEVALUATION_AND_RANKING', 8);
+define('RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING', 8);
 
 // 4: Show final score only with  and show expected answers only on the last attempt
 

+ 2 - 2
main/inc/lib/exercise.lib.php

@@ -4435,7 +4435,7 @@ EOT;
             [
                 RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
                 RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
-                RESULT_DISABLE_AUTOEVALUATION_AND_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
             ]
         )) {
             $show_results = true;
@@ -4867,7 +4867,7 @@ EOT;
 
         if (in_array(
             $objExercise->selectResultsDisabled(),
-            [RESULT_DISABLE_RANKING, RESULT_DISABLE_AUTOEVALUATION_AND_RANKING]
+            [RESULT_DISABLE_RANKING, RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING]
         )) {
             echo Display::page_header(get_lang('Ranking'), null, 'h4');
             echo self::displayResultsInRanking(

+ 23 - 8
main/inc/lib/exercise_show_functions.lib.php

@@ -260,7 +260,11 @@ class ExerciseShowFunctions
             if ($studentChoice) {
                 $status = Display::label(get_lang('Correct'), 'success');
             } else {
-                if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+                if (in_array($resultsDisabled, [
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                    RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+                ])
+                ) {
                     return '';
                 }
             }
@@ -340,12 +344,12 @@ class ExerciseShowFunctions
 
         $showComment = false;
         switch ($resultsDisabled) {
+            case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING:
             case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
                 $hideStudentChoice = false;
                 $hide_expected_answer = true;
                 $status = Display::label(get_lang('Correct'), 'success');
                 $showComment = true;
-                //var_dump($answerCorrect."-".$studentChoice ." - ".$answerCorrectChoice);
                 if (!$answerCorrect && empty($studentChoice)) {
                     return '';
                 }
@@ -372,7 +376,11 @@ class ExerciseShowFunctions
         $iconAnswer .= '.png';
 
         $studentChoiceClass = '';
-        if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+        if (in_array($resultsDisabled, [
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+            RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+        ])
+        ) {
             if ($answerCorrect) {
                 $studentChoiceClass = 'success';
             }
@@ -403,9 +411,6 @@ class ExerciseShowFunctions
 
         if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM && $studentChoice) {
             $showComment = true;
-            if (!$answerCorrect && $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
-                // $showComment = false;
-            }
         }
 
         if ($showComment) {
@@ -459,6 +464,7 @@ class ExerciseShowFunctions
         $hide_expected_answer = false;
         $hideStudentChoice = false;
         switch ($resultsDisabled) {
+            case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING:
             case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
                 $hideStudentChoice = false;
                 $hide_expected_answer = true;
@@ -521,7 +527,11 @@ class ExerciseShowFunctions
         if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
             $content .= '<td width="20%">';
             $color = 'black';
-            if (isset($new_options[$studentChoice]) || $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+            if (isset($new_options[$studentChoice]) || in_array($exercise->results_disabled, [
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+                ])
+            ) {
                 if ($studentChoice == $answerCorrect) {
                     $color = 'green';
                 }
@@ -655,6 +665,7 @@ class ExerciseShowFunctions
         $hide_expected_answer = false;
         $hideStudentChoice = false;
         switch ($resultsDisabled) {
+            case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING:
             case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
                 $hideStudentChoice = true;
                 $hide_expected_answer = true;
@@ -718,7 +729,11 @@ class ExerciseShowFunctions
         if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
             echo '<td width="20%">';
             //@todo replace this harcoded value
-            if ($studentChoice || $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
+            if ($studentChoice || in_array($resultsDisabled, [
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER_AND_RANKING,
+                RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
+            ])
+            ) {
                 $color = 'black';
                 if ($studentChoice == $answerCorrect) {
                     $color = 'green';