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

If you duplicate an assignment in Moodle 2.1 that has course completion enabled, it breaks course completion for the course

XMLWordPrintable

    • MySQL
    • MOODLE_21_STABLE
    • MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Hide

      Go to the database and manually delete all the duplicate entries in the tables mdl_course_completion_aggr_methd and mdl_course_completion_criteria associated with the course that has the problem. This fixes the issue.

      Show
      Go to the database and manually delete all the duplicate entries in the tables mdl_course_completion_aggr_methd and mdl_course_completion_criteria associated with the course that has the problem. This fixes the issue.
    • Hide

      IMPORTANT: Testing this requires git-abilities in order to switch of branch and/or apply patches.

      IMPORTANT: This needs to be tested on all 2.x branches and master, so all the steps below are for each branch:

      1) BEFORE applying the patch, create one course, with course completion enabled.

      2) Add 1-2 students to it.

      3) create one activity (any is ok), for example one "page" and define activity completion to require viewing the resource.

      4) define course completion to include the page resource just created.

      5) logged as student, view the page.

      6) TEST: As admin, look to the course-completion report and verify that the student appears to have completed the page resource.

      7) Backup the course, with users and all activities.

      8) duplicate the activity (x2 icon). Should end ok. (Note, in 20_STABLE where the duplication feature was not available you can go to the page resource and then perform one backup & restore of that activity. It's 100% equivalent).

      9) TEST: go to the completion report. Error happens.

      10) TEST: Go to the DB, look the course_completion_aggr_methd table, some records for the course are duplicated.

      11) SWITCH to branch having the patch applied OR apply it for the current branch.

      12) Go to site main page. Upgrade process should be ignited.

      13) TEST: The upgrade process ends without error.

      14) TEST: Go to the DB, look the course_completion_aggr_methd table, the duplicate records in 10) are out.

      15) TEST: go to the completion report. No error happens.

      16) Duplicate the page resource again.

      17) TEST: go to the completion report. No error happens.

      18) TEST: The completion report continues showing only one page resource.

      19) Restore the course backup created in 7) restoring onto current course and adding information.

      20) TEST: The restore ends without problem

      21) TEST: go to the completion report. No error happens.

      22) TEST: In the completion report now there are 2 page resources shown, both with the student in 5) being shown as completed.

      Show
      IMPORTANT: Testing this requires git-abilities in order to switch of branch and/or apply patches. IMPORTANT: This needs to be tested on all 2.x branches and master, so all the steps below are for each branch: 1) BEFORE applying the patch, create one course, with course completion enabled. 2) Add 1-2 students to it. 3) create one activity (any is ok), for example one "page" and define activity completion to require viewing the resource. 4) define course completion to include the page resource just created. 5) logged as student, view the page. 6) TEST: As admin, look to the course-completion report and verify that the student appears to have completed the page resource. 7) Backup the course, with users and all activities. 8) duplicate the activity (x2 icon). Should end ok. (Note, in 20_STABLE where the duplication feature was not available you can go to the page resource and then perform one backup & restore of that activity. It's 100% equivalent). 9) TEST: go to the completion report. Error happens. 10) TEST: Go to the DB, look the course_completion_aggr_methd table, some records for the course are duplicated. 11) SWITCH to branch having the patch applied OR apply it for the current branch. 12) Go to site main page. Upgrade process should be ignited. 13) TEST: The upgrade process ends without error. 14) TEST: Go to the DB, look the course_completion_aggr_methd table, the duplicate records in 10) are out. 15) TEST: go to the completion report. No error happens. 16) Duplicate the page resource again. 17) TEST: go to the completion report. No error happens. 18) TEST: The completion report continues showing only one page resource. 19) Restore the course backup created in 7) restoring onto current course and adding information. 20) TEST: The restore ends without problem 21) TEST: go to the completion report. No error happens. 22) TEST: In the completion report now there are 2 page resources shown, both with the student in 5) being shown as completed.

      If you duplicate an assignment that has course completion enabled then course completion no longer works.
      If you then go to the course completion report, or the course completion settings you get the following errors.

      Found more than one record in fetch() !

      Debugging on

      More information about this error Stack trace:

      line 429 of /lib/setuplib.php: moodle_exception thrown

      line 130 of /lib/completion/data_object.php: call to print_error()

      line 83 of /lib/completion/completion_aggregation.php: call to data_object::fetch_helper()

      line 65 of /lib/completion/data_object.php: call to completion_aggregation::fetch()

      line 374 of /lib/completionlib.php: call to data_object->__construct()

      line 65 of /course/completion_form.php: call to completion_info->get_aggregation_method()

      line 152 of /lib/formslib.php: call to course_completion_form->definition()

      line 73 of /course/completion.php: call to moodleform->moodleform()

      The table mdl_course_completion_aggr_methd is then populated with 1000's of records relating to the course with the issue. Only fix is to delete these records. Then all works fine.

            stronk7 Eloy Lafuente (stronk7)
            ack Richard Ackland
            Sam Hemelryk Sam Hemelryk
            Michael de Raadt Michael de Raadt
            Votes:
            35 Vote for this issue
            Watchers:
            31 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.