Moodle
  1. Moodle
  2. MDL-29447

Course reset does not fully remove quiz attempts

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.1.3
    • Component/s: Blocks, Quiz
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. Create a quiz in a course.
      2. Attempt it as some students.
      3. Use course reset to delete all attempts.
      4. Go to the quiz reports, and verify not graph is shown.
      5. If possible, also verify that the correct records were deleted from the quiz_grades table.

      Show
      1. Create a quiz in a course. 2. Attempt it as some students. 3. Use course reset to delete all attempts. 4. Go to the quiz reports, and verify not graph is shown. 5. If possible, also verify that the correct records were deleted from the quiz_grades table.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      The course reset does not fully remove quiz attempts. They are still visible in the Quiz Results block and they are included in the bar chart on the Results page.

      To reproduce
      ===========

      • As Admin, create a new course
      • Enrol an editor and a student onto it
      • Log in as teacher, create a quiz and add a question to it
      • Log in as student and attempt the quiz
      • Log in as editor and check the student's response is shown. Grade it if not auto-graded.
      • Reset the course (Course administration > Reset), ticking "Delete all quiz attempts"
      • Go to the quiz, then Results > Grades. Bar chart shows the attempt which should have been removed.
      • On the course home page, add the Quiz Results block and configure it with default settings. It now shows the attempt which should have been removed.

      Expected result
      ============

      • Results bar chart should show no attempts
      • Quiz Results block should show no attempts

      Actual result
      ==========

      • Results bar chart shows the pre-reset attempt
      • Quiz Results block shows the name and grade of the pre-reset attempt

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Steve Bond added a comment -

            Presumably this arises from MDL-3567. Apologies, I only just spotted that.

            Show
            Steve Bond added a comment - Presumably this arises from MDL-3567 . Apologies, I only just spotted that.
            Hide
            Tim Hunt added a comment -

            Thanks for spotting the duplicate.

            Show
            Tim Hunt added a comment - Thanks for spotting the duplicate.
            Hide
            Jean-Michel Vedrine added a comment -

            Hello Tim,
            I don't quite agree that this issue is a duplicate of MDL-3567.
            There is one important thing mentionned here that is not in MDL-3567 : when you reset all attempts of a quiz in a course, the graph at the end of the overview report is still showing all deleted attempts.
            The instructions to reproduce given by the submitter are very clear so I am not sure i should repeat them ?

            • create a quiz instance in a course
            • add some students attempts to this quiz
            • reset the course checking the box to reset all students atttempts
            • go to quiz results overview report
              the report show 0 attempts as expected but the bar graph still display all deleted attempts.
              I have not looked at the code so I don't know if the quiz results block problem and the bar chart problem have the same cause but as MDL-3567 only speak of the quiz result block problem (that I don't use) I am worried that the bar chart problem could be forgotten if this issue is closed as duplicate.
              A side note : in my case the "old" attempts came from my Moodle 1.9 website and I did the reset after having upgraded to Moodle 2.1.1 but I don't think this may be relevant. Anyway I will test in a fresh Moodle 2.1.1 install and report.
              I will also try to sport in the code and in the database what the problem is
            Show
            Jean-Michel Vedrine added a comment - Hello Tim, I don't quite agree that this issue is a duplicate of MDL-3567 . There is one important thing mentionned here that is not in MDL-3567 : when you reset all attempts of a quiz in a course, the graph at the end of the overview report is still showing all deleted attempts. The instructions to reproduce given by the submitter are very clear so I am not sure i should repeat them ? create a quiz instance in a course add some students attempts to this quiz reset the course checking the box to reset all students atttempts go to quiz results overview report the report show 0 attempts as expected but the bar graph still display all deleted attempts. I have not looked at the code so I don't know if the quiz results block problem and the bar chart problem have the same cause but as MDL-3567 only speak of the quiz result block problem (that I don't use) I am worried that the bar chart problem could be forgotten if this issue is closed as duplicate. A side note : in my case the "old" attempts came from my Moodle 1.9 website and I did the reset after having upgraded to Moodle 2.1.1 but I don't think this may be relevant. Anyway I will test in a fresh Moodle 2.1.1 install and report. I will also try to sport in the code and in the database what the problem is
            Hide
            Jean-Michel Vedrine added a comment -

            As I was thinking the problem is the same with a fresh Moodle 2.1.1 test install
            Looking at the database, the reason is that the records in the mdl_quiz_grades table are not deleted.

            Show
            Jean-Michel Vedrine added a comment - As I was thinking the problem is the same with a fresh Moodle 2.1.1 test install Looking at the database, the reason is that the records in the mdl_quiz_grades table are not deleted.
            Hide
            Jean-Michel Vedrine added a comment -

            Suggested fix :
            add
            $DB->delete_records_select('quiz_grades',
            'quiz IN (SELECT id FROM

            {quiz} WHERE course = ?)', array($data->courseid));
            after
            $DB->delete_records_select('quiz_attempts',
            'quiz IN (SELECT id FROM {quiz}

            WHERE course = ?)', array($data->courseid));
            in the quiz_reset_userdata function in mod/quiz/lib.php

            Now I must find the right query to fix my production database and delete all the unwanted records in the quiz_grades table !! If you have any idea ?

            Show
            Jean-Michel Vedrine added a comment - Suggested fix : add $DB->delete_records_select('quiz_grades', 'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid)); after $DB->delete_records_select('quiz_attempts', 'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid)); in the quiz_reset_userdata function in mod/quiz/lib.php Now I must find the right query to fix my production database and delete all the unwanted records in the quiz_grades table !! If you have any idea ?
            Hide
            Tim Hunt added a comment -

            OK, so it was not actually a duplicate. Re-opening.

            Show
            Tim Hunt added a comment - OK, so it was not actually a duplicate. Re-opening.
            Hide
            Tim Hunt added a comment -

            Looking at the code, I also noticed MDL-29662

            Show
            Tim Hunt added a comment - Looking at the code, I also noticed MDL-29662
            Hide
            Tim Hunt added a comment -

            Thanks Jean-Michel. Patch submitted for integration.

            Note that this was a regression introduced in Moodle 2.1, so does not need to be back-ported to earlier branches.

            Show
            Tim Hunt added a comment - Thanks Jean-Michel. Patch submitted for integration. Note that this was a regression introduced in Moodle 2.1, so does not need to be back-ported to earlier branches.
            Hide
            Eloy Lafuente (stronk7) added a comment -

            The main moodle.git repository has just 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 - The main moodle.git repository has just 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 Tim - this has been integrated now

            Show
            Sam Hemelryk added a comment - Thanks Tim - this has been integrated now
            Hide
            Jason Fowler added a comment -

            Tested on integration 2.1 and master, works fine

            Show
            Jason Fowler added a comment - Tested on integration 2.1 and master, works fine
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Many thanks for the hard work developing and testing this. It has been spread to cvs and git upstream repositories.

            Closing, ciao

            Show
            Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work developing and testing this. It has been spread to cvs and git upstream repositories. Closing, ciao

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: