Moodle
  1. Moodle
  2. MDL-31702

Cannot start attempt at quiz if no graded questions are present

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Quiz
    • Labels:
    • Environment:
      Centos 5.7 and 6.2 x86_64, Postgresql 8.4 and 9.1, php 5.3, apache 2.2
    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide

      1. Create a quiz.
      2. On the edit quiz page, add one question; Ensure Maximum grade is non-zero; and set the grade for the question you added to zero.
      3. Click the preview link in the settings block to try starting an attempt.
      4. Look at the resulting error message, and see if you think it makes sense.

      Show
      1. Create a quiz. 2. On the edit quiz page, add one question; Ensure Maximum grade is non-zero; and set the grade for the question you added to zero. 3. Click the preview link in the settings block to try starting an attempt. 4. Look at the resulting error message, and see if you think it makes sense.
    • Workaround:
      Hide
      • Set grades to the questions
      • Hide the categories in the gradebook

      This seems to come closest to the "ungraded" quiz from moodle 2.1.1 as implemented by our instructors. Any information regarding better ways to achieve the desired effect would be highly appreciated

      Show
      Set grades to the questions Hide the categories in the gradebook This seems to come closest to the "ungraded" quiz from moodle 2.1.1 as implemented by our instructors. Any information regarding better ways to achieve the desired effect would be highly appreciated
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      38288

      Description

      Description of the problem
      -------------------------------------------
      After upgrading from moodle 2.1.1 to 2.2.1+ (Build: 20120213), students attempting to solve a quiz where all questions are graded with 0 points are faced with an error message:

      "Cannot start an attempt at this quiz. The quiz is supposed to be graded but there are no questions in the quiz that are worth any marks"
      Stack trace:
      line 73 of /mod/quiz/locallib.php: moodle_exception thrown
      line 148 of /mod/quiz/startattempt.php: call to quiz_create_attempt()

      The quiz in question is used for giving the students opportunities to self-test their progress and should not be graded. It seems that prior to the upgrade, this could be achieved by allocating 0 points for each question.

      Exprected behaviour
      -------------------------------------------
      It would be nice to either provide an option to keep the quiz ungraded or to warn the administrator during upgrade about this change in behaviour.

      Note:
      -------------------------------------------
      We upgraded directly from 2.1.1 to 2.2.1+. It seems that the Question Engine update was done while performing this update, because a backup from before the update lists
      "This appears to be a site that has not yet been upgraded to include the new question engine."

      while the same helper plugin returns for the 2.2.1+ site
      "This appears to be a site that has been upgraded to include the new question engine."

      (sorry if this is common knowledge)

        Issue Links

          Activity

          Hide
          Martin Schwinzerl added a comment -

          Forget to mention: This is probably related to the problems of this guy:
          http://moodle.org/mod/forum/discuss.php?d=195597

          Show
          Martin Schwinzerl added a comment - Forget to mention: This is probably related to the problems of this guy: http://moodle.org/mod/forum/discuss.php?d=195597
          Hide
          Tim Hunt added a comment -

          The error does mean exactly what it says, but perhaps it could be clearer.

          The problem is that all the questions have grade 0, so quiz.sumgrades = 0, but quiz.grade is > 0. The problem is that when we get to the end of the quiz, Moodle has to compute

          $grade = $summarks * quiz.grade / quiz.sumgrades

          which gives a divide by zero error. Moodle 2.2 checks for this and gives the error before starting an attempt, so the teacher discovers the problem quickly and can fix it.

          Show
          Tim Hunt added a comment - The error does mean exactly what it says, but perhaps it could be clearer. The problem is that all the questions have grade 0, so quiz.sumgrades = 0, but quiz.grade is > 0. The problem is that when we get to the end of the quiz, Moodle has to compute $grade = $summarks * quiz.grade / quiz.sumgrades which gives a divide by zero error. Moodle 2.2 checks for this and gives the error before starting an attempt, so the teacher discovers the problem quickly and can fix it.
          Hide
          Martin Schwinzerl added a comment -

          Thanks for your quick reply!

          Yes, this summarises roughly what we figured out ourselves so far. As already mentioned in the bug report, the main problem is that our instructors/teachers used the individual grades == 0 setting on purpose to prevent the results to appear in the gradebook. It may be a dumb question (and please appologise if this is the wrong place to ask this questions), but what would be the "official" way to get an ungraded quiz for self - evaluation in moodle >= 2.2 ?

          • Grades > 0 + Hiding of Grading category / aspect in grade book (this is what we do now as a workaround)
          • Set quiz - grade == 0 (no idea if that case is treated differently)
          • ?

          I don't know if that would mesh with the philosophy behind the quiz module, but an option for "no rating" / "no grading" like there is for example in the forum in combination with a hint towards this option in the error message would be easier to grasp (at least for our teachers, who had no idea what implication setting grades == 0 had).

          Many thanks in advance & best regards
          Martin

          Show
          Martin Schwinzerl added a comment - Thanks for your quick reply! Yes, this summarises roughly what we figured out ourselves so far. As already mentioned in the bug report, the main problem is that our instructors/teachers used the individual grades == 0 setting on purpose to prevent the results to appear in the gradebook. It may be a dumb question (and please appologise if this is the wrong place to ask this questions), but what would be the "official" way to get an ungraded quiz for self - evaluation in moodle >= 2.2 ? Grades > 0 + Hiding of Grading category / aspect in grade book (this is what we do now as a workaround) Set quiz - grade == 0 (no idea if that case is treated differently) ? I don't know if that would mesh with the philosophy behind the quiz module, but an option for "no rating" / "no grading" like there is for example in the forum in combination with a hint towards this option in the error message would be easier to grasp (at least for our teachers, who had no idea what implication setting grades == 0 had). Many thanks in advance & best regards Martin
          Hide
          Tim Hunt added a comment -

          The recommended way it to set quiz->grade = 0.

          You may ask: why doesn't Moodle do that automatically when all the questions have grade = 0.

          The answer is about what happens if a teacher decides to re-create a quiz by removing all the old questions, and then adding a new set. In this case, it is really bad if quiz->grade gets rest to zero at the point where all the questions have been removed.

          And, teachers adding and removing questions from their quiz seems to be to be a more common situation than teachers creating a quiz that is not graded at all. (Although ungraded quizzes are an important use-case. That is why they work.)

          Show
          Tim Hunt added a comment - The recommended way it to set quiz->grade = 0. You may ask: why doesn't Moodle do that automatically when all the questions have grade = 0. The answer is about what happens if a teacher decides to re-create a quiz by removing all the old questions, and then adding a new set. In this case, it is really bad if quiz->grade gets rest to zero at the point where all the questions have been removed. And, teachers adding and removing questions from their quiz seems to be to be a more common situation than teachers creating a quiz that is not graded at all. (Although ungraded quizzes are an important use-case. That is why they work.)
          Hide
          Martin Schwinzerl added a comment -

          Many thanks for your explanaition, the rationale behind the behaviour makes a lot of sense. We will instruct our teachers to use that approach.

          best regards
          Martin

          Show
          Martin Schwinzerl added a comment - Many thanks for your explanaition, the rationale behind the behaviour makes a lot of sense. We will instruct our teachers to use that approach. best regards Martin
          Hide
          Tim Hunt added a comment -

          OK, I have improved the error message.

          Show
          Tim Hunt added a comment - OK, I have improved the error message.
          Hide
          Helen Foster added a comment -

          Tim, your language string edit looks good to me. I've also created a page in the docs explaining the error:
          http://docs.moodle.org/en/error/quiz/cannotstartgradesmismatch

          Sorry I can't review your change to mod/quiz/locallib.php but I expect it's fine.

          Show
          Helen Foster added a comment - Tim, your language string edit looks good to me. I've also created a page in the docs explaining the error: http://docs.moodle.org/en/error/quiz/cannotstartgradesmismatch Sorry I can't review your change to mod/quiz/locallib.php but I expect it's fine.
          Hide
          Tim Hunt added a comment -

          Thanks for the review Helen.

          Show
          Tim Hunt added a comment - Thanks for the review Helen.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Some hours ago...

          the main moodle.git repository has been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Some hours ago... the main moodle.git repository has been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Sam Hemelryk added a comment -

          Thanks for the improvement Tim, has been integrated now.

          Show
          Sam Hemelryk added a comment - Thanks for the improvement Tim, has been integrated now.
          Hide
          Dan Poltawski added a comment -

          Works perfectly on all branches.

          [you wouldn't believe how long I spent looking for maximum grade on the quiz edit page - not familiar enough with quiz!]

          Show
          Dan Poltawski added a comment - Works perfectly on all branches. [you wouldn't believe how long I spent looking for maximum grade on the quiz edit page - not familiar enough with quiz!]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          FCT (fixed, closing, thanks). Ciao

          "I feel a very unusual sensation - if it is not indigestion, I think it must be gratitude!"
          ~ Benjamin Disraeli

          Show
          Eloy Lafuente (stronk7) added a comment - FCT (fixed, closing, thanks). Ciao "I feel a very unusual sensation - if it is not indigestion, I think it must be gratitude!" ~ Benjamin Disraeli

            People

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

              Dates

              • Created:
                Updated:
                Resolved: