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

assign_refresh_events() might not refresh other assignments from other courses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1.6, 3.2.3
    • 3.1.5, 3.2.2
    • Assignment
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MDL-58463-master
    • Hide
      1. Run PHP Unit for mod_assign_lib_testcase:

        vendor/bin/phpunit mod_assign_lib_testcase mod/assign/tests/lib_test.php
        

        (or if using MDK)

        mdk phpunit -r -u mod/assign/tests/lib_test.php
        

        • Confirm that there are no errors nor failures.
      Show
      Run PHP Unit for mod_assign_lib_testcase: vendor/bin/phpunit mod_assign_lib_testcase mod/assign/tests/lib_test.php (or if using MDK) mdk phpunit -r -u mod/assign/tests/lib_test.php Confirm that there are no errors nor failures.

      The following logic in assign_refresh_events() is wrong:

      if (!$courseid) {
          $courseid = $assign->course;
          if (!$course = $DB->get_record('course', array('id' => $courseid), '*')) {
              continue;
          }
      }
      

      In the case where the course ID parameter is not passed, then all assignment events from all courses should be refreshed. However, with the logic above, only the first course's assignments will be refreshed since for the other assignments in other courses, the expression

          if (!$cm = get_coursemodule_from_instance('assign', $assign->id, $courseid, false)) {
              continue;
          }
      

      will evaluate to true due to a non-existent course module due to the course ID not matching the assignment's course ID.

      Note: This only affects 32 and 31 since the fix for this issue is already being addressed in MDL-57607 on master. This issue has not been discovered since there was basically no use-case for 32 and 31 where a course ID of 0 is being passed.

        1. assign_data_generator.php
          6 kB
          Jun Pataleta
        2. assign_refresh_test.php
          0.4 kB
          Jun Pataleta

            jpataleta Jun Pataleta
            jpataleta Jun Pataleta
            Mark Nelson Mark Nelson
            Dan Poltawski Dan Poltawski
            Ankit Agarwal Ankit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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