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

Deleting module instance with completion tracking on grade causes errors

    Details

    • Testing Instructions:
      Hide

      EASY test instructions:

      0. Enable completion on site and course. Ensure debugging is set to max level (DEVELOPER) so you can see the message if it occurs. Ensure course AJAX is turned off because it sucks... er, I mean, so that you can see the message in normal browser window.
      1. Add new 'online text' assignment. Type in name, description. In completion section, choose automatic completion and tick the 'when student gets a grade' checkbox. Save and view.
      2. Click to submit the assignment yourself (as admin or whoever). Enter some text and save.
      3. Click the '1 submitted assignment' link and give the assignment a grade. Save grades.
      4. Go back to the course page and use the X button to delete the assignment. Confirm the prompt.

      Expected: Assignment is deleted without any error or warning.

      Show
      EASY test instructions: 0. Enable completion on site and course. Ensure debugging is set to max level (DEVELOPER) so you can see the message if it occurs. Ensure course AJAX is turned off because it sucks... er, I mean, so that you can see the message in normal browser window. 1. Add new 'online text' assignment. Type in name, description. In completion section, choose automatic completion and tick the 'when student gets a grade' checkbox. Save and view. 2. Click to submit the assignment yourself (as admin or whoever). Enter some text and save. 3. Click the '1 submitted assignment' link and give the assignment a grade. Save grades. 4. Go back to the course page and use the X button to delete the assignment. Confirm the prompt. Expected: Assignment is deleted without any error or warning.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull Master Branch:
      MDL-28643-master

      Description

      When deleting a module instance that has activity completion tracking enabled the follow error is thrown:

      Couldn't find course-module for module '<modname>', instance '<instanceid>', course '<courseid>'

      line 803 of \lib\grade\grade_grade.php: call to debugging()
      line 262 of \lib\grade\grade_object.php: call to grade_grade->notify_changed()
      line 352 of \lib\grade\grade_item.php: call to grade_object->delete()
      line 336 of \lib\grade\grade_item.php: call to grade_item->delete_all_grades()
      line 1288 of \lib\gradelib.php: call to grade_item->delete()
      line 215 of \lib\adminlib.php: call to grade_uninstalled_module()
      line 94 of \admin\modules.php: call to uninstall_plugin()

      Then when later visting the course as a student who had achieved a completion record, the follow PHP notices are throw:

      Notice: Trying to get property of non-object in \lib\completionlib.php on line 898
      Notice: Trying to get property of non-object in \lib\completionlib.php on line 903
      Notice: Trying to get property of non-object in \lib\completionlib.php on line 912

      Replication instructions:

      1. Ensure debugging is turned on
      2. Turn off Ajax/JS in your profile
      3. Create an activity module instance (e.g. assignment)
      4. Set the completion to "achieve grade"
      5. Assign a grade to a student
      6. Run the cron manually by visiting /admin/cron.php
      7. Delete the module instance, or uninstall the module entirely (will throw debugging error)
      8. Visit the course as the student with the completion record (will throw PHP notices)

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Oct/11