Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21336

Numerical question not showing correct answer when correct answer is zero

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.7
    • Fix Version/s: 1.9.8
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      If the correct answer to a numerical question is non-zero, then that correct answer can be shown when an incorrect submission is made. This is done by selecting 'Answers' in the Review options of the quiz setup. However, if the correct answer is '0' (zero) then the correct answer does not display on submission. It also appears that the number of incorrect attempts on a question where the answer is zero is not being recorded.

      This was initially posted in the Quiz forum http://moodle.org/mod/forum/discuss.php?d=141424 and Pierre Pichet replied,

      "This is related to the test done for showing or not the Correct answer
      like line 306 of shortanswer/questiontype.php

      if ($correctanswer) {
      echo ('<div class="correctness">');
      print_string('correctansweris', 'quiz', s($correctanswer, true));
      echo ('</div>');
      }
      if $correctanswer == 0 , it will not show.
      If not already done, I will fill a bug report later this day (with the solution...)"

        Gliffy Diagrams

          Activity

          Hide
          ppichet Pierre Pichet added a comment -

          replacing by
          $correctanswer != ''
          works Ok either on numerical or on short answer.

          Show
          ppichet Pierre Pichet added a comment - replacing by $correctanswer != '' works Ok either on numerical or on short answer.
          Hide
          ppichet Pierre Pichet added a comment -

          This happen also on numerical and short answer in cloze question type.
          The solution is the same.
          line 316 of multianswer/questiontype.php
          if ($correctanswer != '') {

          Show
          ppichet Pierre Pichet added a comment - This happen also on numerical and short answer in cloze question type. The solution is the same. line 316 of multianswer/questiontype.php if ($correctanswer != '') {

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                25/Mar/10