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

Fix for calendar assignment event updates on every cron cycle

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.4, 2.7.1, 2.8
    • 2.6.5, 2.7.2
    • Assignment, Calendar
    • Linux Debian 7.2
      PHP 5.5.15
    • PostgreSQL
    • MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MDL-46539-fix-28
    • Hide

      see -> Description

      Show
      see -> Description
    • Easy
    • Hide

      Add an assignment with "always show description == 0" and set "allow submission from date".

      check the query in mod/assign/locallib.php cron(), line 1755

      With our "lastcron == 0" we get on every cron() run for all assigments with "always show description == 0" a event log item added to our log

      Testing following the fix:

      1) Deploy the fix. Confirm that the course logs are no longer showing a 'calendar edit' log for every assignment with showdescription = 0 whenever the cron runs.
      2) Create a new assignment. Make sure it's set so that:

      "Allow submissions from" is enabled, and the date is set to a time that's after the previous cron run, but before the next scheduled cron run.
      "Due date" is enabled, and the date is set to some time in the future.
      "Always show description" is unchecked.

      3) Wait for the cron to run again (or wait until after the "Allow submissions from" date and run it yourself).
      4) Confirm that the description in the calendar for the due date event (or in the appropriate row in mdl_event) is updated. OR, check the logs and confirm that a 'calendar edit' log is shown.

      Show
      Add an assignment with "always show description == 0" and set "allow submission from date". check the query in mod/assign/locallib.php cron(), line 1755 With our "lastcron == 0" we get on every cron() run for all assigments with "always show description == 0" a event log item added to our log Testing following the fix: 1) Deploy the fix. Confirm that the course logs are no longer showing a 'calendar edit' log for every assignment with showdescription = 0 whenever the cron runs. 2) Create a new assignment. Make sure it's set so that: "Allow submissions from" is enabled, and the date is set to a time that's after the previous cron run, but before the next scheduled cron run. "Due date" is enabled, and the date is set to some time in the future. "Always show description" is unchecked. 3) Wait for the cron to run again (or wait until after the "Allow submissions from" date and run it yourself). 4) Confirm that the description in the calendar for the due date event (or in the appropriate row in mdl_event) is updated. OR, check the logs and confirm that a 'calendar edit' log is shown.

    Description

      Hi,

      Today I upgraded our Moodle instance from latest 2.6 stable to latest 2.7 stable.
      I'm using the MOODLE_27_STABLE branch.
      I noticed that we get a lot "calendar_event_updated" events on every cron cycle run.

      The user with id '2' updated the event 'Progr1 Final Coding Quiz - Group B' with id '690'.
      .................

      It seems that all update events are from assignments.

      How to reproduce:

      Add an assignment with "always show description == 0" and set "allow submission from date".

      check the query in mod/assign/locallib.php cron(), line 1755

      With our "lastcron == 0" we get on every cron() run for all assigments with "always show description == 0" a event log item added to our log.

      After digging into the sources, I found one possible solution for my problem.
      In "mod/assign/locallib.php" function cron()

      locallib.php

      public static function cron() {
        ......
        $lastcron = $DB->get_field('modules', 'lastcron', array('name'=>'mod_assign'));
        should be changed to the correct 'name'
        $lastcron = $DB->get_field('modules', 'lastcron', array('name'=>'assign'));
        .....
      }
      

      The lastcron field is never set because the cron() function which is called from "assign_cron" in "mod/assign/lib.php" returns "true" but then the return data goes into Nirvana

      Normally assign_cron() should return "true/false" to signal the caller to store the last cron call time

      Currently assign_cron() in "mod/assign/lib.php" don't return anything.

      Moreover this assig_cron() seems to be a special problem because this function also is calling some submodules crons. The question is where to put the "last cron" field setter for the assign cron task.

      My proposal would be to add the "lastcron" field setter to:

      locallib.php

      public static function cron() {
        ......
        $DB->set_field('modules', 'lastcron', $timenow, array('name' => 'assign'));
        return true;
      }
      

      regards

      Mario

      Attachments

        Activity

          People

            jmarthaler Jon Marthaler
            mwehr Mario Wehr
            Damyon Wiese Damyon Wiese
            Marina Glancy Marina Glancy
            John Okely John Okely
            Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
            Votes:
            9 Vote for this issue
            Watchers:
            15 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              8/Sep/14