Add "Unanswered" status for unique questions see BT#15579

pull/2901/head
Julio Montoya 7 years ago
parent e3921c60f8
commit 94b7ca55b6
  1. 7
      app/Resources/public/css/base.css
  2. 11
      main/exercise/exercise.class.php
  3. 4
      main/exercise/exercise_show.php
  4. 55
      main/exercise/question.class.php
  5. 1
      main/inc/lib/exercise.lib.php

@ -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);

@ -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;
}
/**

@ -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])) {

@ -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'] : '',

@ -4678,6 +4678,7 @@ EOT;
'score' => $my_total_score,
'weight' => $my_total_weight,
'comments' => $comnt,
'user_answered' => $result['user_answered'],
];
}

Loading…
Cancel
Save