Moodle
  1. Moodle
  2. MDL-31095

Adding and removing questions from the quiz can reset max grade.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.4, 2.2.1
    • Fix Version/s: 2.1.5, 2.2.2
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      1. As teacher/admin, create a quiz and go to the edit page (edit.php)

      2. Make sure Maximum grade: is set to something non-zero (e.g. 10.00). (Total of grades: will be 0.00 at this stage.)

      3. Add a description, and a True/false question, in that order. It should now say Maximum grade: 10.00, Total of grades: 1.00.

      4. Remove the True/false question. It should now say Maximum grade: 10.00, Total of grades: 0.00.

      5. Click the 'Preview' link in the settings navigation. You should see an appropriate error message, and the continue button should take you to the quiz view.php page.

      6. Remove the Description from the quiz. It should still say Maximum grade: 10.00, Total of grades: 0.00.

      7. Click the 'Preview' link in the settings navigation. The page should reload (because trying to start an attempt at an empty quiz redirects you to the quiz edit page).

      8. Copy the URL of the 'Preview' - it will be ... startattempt.php... and will include sesskey. Log in as student, and edit the startattempt.php URL to include the student's sesskey. Then try to go to that URL. You should get a different appropriate error message about not being able to start a quiz with no questions, and the continue button should take you to the quiz view.php page. (Note, the only way to get this error is to hack the URL like this.)

      9. Back as teacher/admin, go to edit.php again, go to the order and paging tab, and make sure you can set the Maximum grade.

      10. Now add the True/false question back to the quiz, and attempt the quiz as the student.

      11. Back as teacher, on edit.php, 'Edit quiz' tab. Try changing the Grade: for the True/false question to 0. The Maximum grade: should now be automatically set to 0.

      12. Set the grade for the True/false question back to something non-zero. Then set The Maximum grade: back to something non-zero. Go to the quiz reports and make sure the scores have been correctly updated at every stage to display the correct values. (If the maximum is 0, the correct behaviour may be to show no grades.)

      Show
      1. As teacher/admin, create a quiz and go to the edit page (edit.php) 2. Make sure Maximum grade: is set to something non-zero (e.g. 10.00). (Total of grades: will be 0.00 at this stage.) 3. Add a description, and a True/false question, in that order. It should now say Maximum grade: 10.00, Total of grades: 1.00. 4. Remove the True/false question. It should now say Maximum grade: 10.00, Total of grades: 0.00. 5. Click the 'Preview' link in the settings navigation. You should see an appropriate error message, and the continue button should take you to the quiz view.php page. 6. Remove the Description from the quiz. It should still say Maximum grade: 10.00, Total of grades: 0.00. 7. Click the 'Preview' link in the settings navigation. The page should reload (because trying to start an attempt at an empty quiz redirects you to the quiz edit page). 8. Copy the URL of the 'Preview' - it will be ... startattempt.php... and will include sesskey. Log in as student, and edit the startattempt.php URL to include the student's sesskey. Then try to go to that URL. You should get a different appropriate error message about not being able to start a quiz with no questions, and the continue button should take you to the quiz view.php page. (Note, the only way to get this error is to hack the URL like this.) 9. Back as teacher/admin, go to edit.php again, go to the order and paging tab, and make sure you can set the Maximum grade. 10. Now add the True/false question back to the quiz, and attempt the quiz as the student. 11. Back as teacher, on edit.php, 'Edit quiz' tab. Try changing the Grade: for the True/false question to 0. The Maximum grade: should now be automatically set to 0. 12. Set the grade for the True/false question back to something non-zero. Then set The Maximum grade: back to something non-zero. Go to the quiz reports and make sure the scores have been correctly updated at every stage to display the correct values. (If the maximum is 0, the correct behaviour may be to show no grades.)
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      37521

      Description

      It turns out that that fix for MDL-21934, while an improvement, was not sufficient. We (at the OU) have now thought of a better logic.

      The problem is that if $quiz->sumgrades is 0 (such as when you have just removed all questions from a quiz, prior to adding some different ones) then we have to set $quiz->grade to 0, otherwise there will be a divide by zero error when a student attempts the quiz, and we try to compute their final grade.

      However, when you are editing the quiz, there are no attempts yet, and so this theoretical difficulty does not arise, and the resetting to 0 is bloody annoying.

      So, the proposed solution is:

      1. In quiz_update_sumgrades, change the logic for doing quiz_set_grade(0, $quiz) from layout not empty to quiz has attempts.

      2. Add a test when someone tries to start an attempt. If sumgrades is 0, while grade is non-zero, give a nice error at this time.

      3. In addition, display quiz grade on the order and paging tab of mod/quiz/edit.php, so it is clearer what is going on.

        Issue Links

          Activity

          Hide
          Tim Hunt added a comment -

          Mahmoud, please could you review this. Thanks.

          Show
          Tim Hunt added a comment - Mahmoud, please could you review this. Thanks.
          Hide
          Mahmoud Kassaei added a comment -

          Following the test instructions it is doing exactly as it is described in the test instructions. The changes in the code look fine, now it updates sumgrades after deleting previews and uses correct conditons to set the grade, print errors, and thow exceptions.

          Good job Tim!

          Show
          Mahmoud Kassaei added a comment - Following the test instructions it is doing exactly as it is described in the test instructions. The changes in the code look fine, now it updates sumgrades after deleting previews and uses correct conditons to set the grade, print errors, and thow exceptions. Good job Tim!
          Hide
          Tim Hunt added a comment -

          Thanks Mahmoud. Submitting for integration now.

          Show
          Tim Hunt added a comment - Thanks Mahmoud. Submitting for integration now.
          Hide
          Sam Hemelryk added a comment -

          Thanks tim - integrated now.

          Show
          Sam Hemelryk added a comment - Thanks tim - integrated now.
          Hide
          Rossiani Wijaya added a comment -

          This is working great.

          Test passed.

          Show
          Rossiani Wijaya added a comment - This is working great. Test passed.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          This is now available in the git and cvs repositories.

          Consider the responsibility of your fingerprints engraved there for future generations!

          Thanks for the work, closing, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - This is now available in the git and cvs repositories. Consider the responsibility of your fingerprints engraved there for future generations! Thanks for the work, closing, ciao

            People

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

              Dates

              • Created:
                Updated:
                Resolved: