diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index f52c1e2088..a1b6848946 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -2487,6 +2487,13 @@ div.admin_section h4 { float: left; } +.ribbon .rib-info { + background: deepskyblue; + border-top: none; + border-bottom: none; + float: left; +} + .ribbon .rib-gray { background: #cccccc; background-image: -ms-linear-gradient(top, #bbbbbb, #cccccc); diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 3436fad456..87e6bd90ef 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -3445,6 +3445,8 @@ class Exercise if ($debug) { error_log('Start answer loop '); } + + $userAnsweredQuestion = false; for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answer = $objAnswerTmp->selectAnswer($answerId); $answerComment = $objAnswerTmp->selectComment($answerId); @@ -3476,6 +3478,9 @@ class Exercise $result = Database::query($sql); $choice = Database::result($result, 0, 'answer'); + if ($userAnsweredQuestion === false) { + $userAnsweredQuestion = !empty($choice); + } $studentChoice = $choice == $answerAutoId ? 1 : 0; if ($studentChoice) { $questionScore += $answerWeighting; @@ -5353,6 +5358,7 @@ class Exercise 'threadhold2' => $threadhold2, 'threadhold3' => $threadhold3, ]; + if ($from == 'exercise_result') { // if answer is hotspot. To the difference of exercise_show.php, // we use the results from the session (from_db=0) @@ -5754,7 +5760,7 @@ class Exercise } } - $return_array = [ + $return = [ 'score' => $questionScore, 'weight' => $questionWeighting, 'extra' => $extra_data, @@ -5762,9 +5768,10 @@ class Exercise 'open_answer' => $arrans, 'answer_type' => $answerType, 'generated_oral_file' => $generatedFile, + 'user_answered' => $userAnsweredQuestion, ]; - return $return_array; + return $return; } /** diff --git a/main/exercise/exercise_show.php b/main/exercise/exercise_show.php index 8f0b03e040..3010841767 100755 --- a/main/exercise/exercise_show.php +++ b/main/exercise/exercise_show.php @@ -925,6 +925,10 @@ foreach ($questionList as $questionId) { $score['score'] = $my_total_score; $score['weight'] = $my_total_weight; $score['comments'] = isset($comnt) ? $comnt : null; + + if (isset($question_result['user_answered'])) { + $score['user_answered'] = $question_result['user_answered']; + } } if (in_array($objQuestionTmp->type, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) { diff --git a/main/exercise/question.class.php b/main/exercise/question.class.php index 16638f9b4a..9c6ba3922a 100755 --- a/main/exercise/question.class.php +++ b/main/exercise/question.class.php @@ -2005,28 +2005,42 @@ abstract class Question $class = 'success'; } - if (in_array($this->type, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) { - $score['revised'] = isset($score['revised']) ? $score['revised'] : false; - if ($score['revised'] == true) { - $scoreLabel = get_lang('Revised'); - $class = ''; - } else { - $scoreLabel = get_lang('NotRevised'); - $class = 'warning'; - if (isset($score['weight'])) { - $weight = float_format($score['weight'], 1); - $score['result'] = ' ? / '.$weight; - } - $model = ExerciseLib::getCourseScoreModel(); - if (!empty($model)) { - $score['result'] = ' ? '; - } + switch ($this->type) { + case FREE_ANSWER: + case ORAL_EXPRESSION: + case ANNOTATION: + $score['revised'] = isset($score['revised']) ? $score['revised'] : false; + if ($score['revised'] == true) { + $scoreLabel = get_lang('Revised'); + $class = ''; + } else { + $scoreLabel = get_lang('NotRevised'); + $class = 'warning'; + if (isset($score['weight'])) { + $weight = float_format($score['weight'], 1); + $score['result'] = ' ? / '.$weight; + } + $model = ExerciseLib::getCourseScoreModel(); + if (!empty($model)) { + $score['result'] = ' ? '; + } - $hide = api_get_configuration_value('hide_free_question_score'); - if ($hide === true) { - $score['result'] = '-'; + $hide = api_get_configuration_value('hide_free_question_score'); + if ($hide === true) { + $score['result'] = '-'; + } } - } + break; + case UNIQUE_ANSWER: + if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) { + if (isset($score['user_answered'])) { + if ($score['user_answered'] === false) { + $scoreLabel = get_lang('Unanswered'); + $class = 'info'; + } + } + } + break; } // display question category, if any @@ -2038,6 +2052,7 @@ abstract class Question if ($show_media) { $header .= $this->show_media_content(); } + $scoreCurrent = [ 'used' => isset($score['score']) ? $score['score'] : '', 'missing' => isset($score['weight']) ? $score['weight'] : '', diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 3b5704e2f0..a5d0003ef9 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -4678,6 +4678,7 @@ EOT; 'score' => $my_total_score, 'weight' => $my_total_weight, 'comments' => $comnt, + 'user_answered' => $result['user_answered'], ]; }