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

Problem and Solution of Course Reset - Assignment Dates

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide
      1. Create a course starting on 1/jan/2014
      2. Add one online assignment, one offline assignment, and three new assignment (assign) with "Allow submission from" 2/jan/2014
      3. Reset course with course start date as 2/jan/2014
      4. Make sure all all assignments have proper start date 3/jan/2014
      5. Rerun above test with assignment starting on 5/jan/2014 and reset course with course starting 10/jan/2014 and make sure dates for assignment is 13/jan/2014
      Show
      Create a course starting on 1/jan/2014 Add one online assignment, one offline assignment, and three new assignment (assign) with "Allow submission from" 2/jan/2014 Reset course with course start date as 2/jan/2014 Make sure all all assignments have proper start date 3/jan/2014 Rerun above test with assignment starting on 5/jan/2014 and reset course with course starting 10/jan/2014 and make sure dates for assignment is 13/jan/2014
    • Workaround:
      Hide

      Move 5 lines from reset_userdata to assignment_reset_userdata after its main loop is finished and will look like this (moodle 2.1.4):
      function assignment_reset_userdata($data) {
      global $CFG;

      $status = array();
      foreach (get_plugin_list('assignment') as $type=>$dir)

      { require_once("$dir/assignment.class.php"); $assignmentclass = "assignment_$type"; $ass = new $assignmentclass(); $status = array_merge($status, $ass->reset_userdata($data)); }

      /// moved code start
      /// updating dates - shift may be negative too
      if ($data->timeshift)

      { shift_course_mod_dates('assignment', array('timedue', 'timeavailable'), $data->timeshift, $data->courseid); $status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged').': '.$typestr, 'error'=>false); }

      /// moved code end

      return $status;
      }

      Show
      Move 5 lines from reset_userdata to assignment_reset_userdata after its main loop is finished and will look like this (moodle 2.1.4): function assignment_reset_userdata($data) { global $CFG; $status = array(); foreach (get_plugin_list('assignment') as $type=>$dir) { require_once("$dir/assignment.class.php"); $assignmentclass = "assignment_$type"; $ass = new $assignmentclass(); $status = array_merge($status, $ass->reset_userdata($data)); } /// moved code start /// updating dates - shift may be negative too if ($data->timeshift) { shift_course_mod_dates('assignment', array('timedue', 'timeavailable'), $data->timeshift, $data->courseid); $status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged').': '.$typestr, 'error'=>false); } /// moved code end return $status; }
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull Master Branch:
      wip-mdl-31405-new
    • Sprint:
      BACKEND Sprint 6

      Description

      Course reset does not work correctly if activity dates are to be updated and course contains more than one type of assignment. This is due to fact that function assignment/lib.php: assignment_reset_userdata contains a loop for all assignment types. This calls the function reset_userdata and repetitively calls moodlelib.php::shift_course_mod_data. The last one should be called only once for all assignments.

        Gliffy Diagrams

          Attachments

          1. lib.patch
            0.8 kB
          2. locallib.patch
            0.8 kB
          3. patches1.9-2.5.zip
            4 kB

            Activity

              People

              • Votes:
                6 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Nov/13