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

Badges creator being set to 0 on backup restoration

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • master_MDL-47076
    • Hide

      1) Create a user and give them a sitewide role like site manager
      2) Create a course
      3) Edit the courses completion criteria and make it based off manual completion
      4) Add the self completion block to the view course page
      5) Log in as the user and create a badge within that course

      • On the criteria tab, set it to award based off the course completion (with a min grade of 0)
      • On the message tab, set notify badge creator to every time

      6) Activate the badge
      7) Backup the course making sure that users and badges are ticked
      8) Download the backup file and upload to a course where no user matches the creator id (or delete the creator from the mdl_user table manually)
      9) Restore the course (including the badge) into a new course
      10) Check in the database, the creator id of the restored badge should not be 0
      11) Create a learner, enrol them in the course
      12) Log in as the learner and complete the course via the self completion block to earn the badge
      13) Run the cron, no error should occur.

      Show
      1) Create a user and give them a sitewide role like site manager 2) Create a course 3) Edit the courses completion criteria and make it based off manual completion 4) Add the self completion block to the view course page 5) Log in as the user and create a badge within that course On the criteria tab, set it to award based off the course completion (with a min grade of 0) On the message tab, set notify badge creator to every time 6) Activate the badge 7) Backup the course making sure that users and badges are ticked 8) Download the backup file and upload to a course where no user matches the creator id (or delete the creator from the mdl_user table manually) 9) Restore the course (including the badge) into a new course 10) Check in the database, the creator id of the restored badge should not be 0 11) Create a learner, enrol them in the course 12) Log in as the learner and complete the course via the self completion block to earn the badge 13) Run the cron, no error should occur.

      If you back up a course including badges, then restore it and the usercreator of the badge doesn't match a user in the system it gets set to 0. I would expect it to default to the user restoring the course (ie $USER->id), it being 0 causes issues if it tries to send messages to notify the creator about the badge being awarded.

      Steps to replicate:
      1) Create a user and give them a sitewide role like site manager
      2) Create a course
      3) Log in as the user and create a badge within that course

      • Make sure it has a criteria (manual issue by role is probably the easiest)
      • Set notify badge creator to everytime on the messages tab

      4) Activate the badge
      5) Backup the course making sure that users and badges are ticked
      6) Download the backup file and upload to a course where no user matches the creator id (or delete the creator from the mdl_user table manually)
      7) Restore the course (including the badge) into a new course
      8) Check in the database, the creator id of the restored badge will be 0
      9) Create a learner, enrol them in the course, and award them the badge
      10) Run the cron, you will get the invalid user error below when it tries to send the creator a notification about the badge being awarded.

      Default exception handler: Invalid user Debug: SELECT * FROM

      {user}

      WHERE id = ?
      [array (
      0 => '0',
      )]
      Error code: invaliduser

      • line 1411 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
      • line 1387 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
      • line 129 of /badges/cron.php: call to moodle_database->get_record()
      • line 108 of /badges/cron.php: call to badge_assemble_notification()
      • line 35 of /badges/cron.php: call to badge_message_cron()
      • line 545 of /lib/cronlib.php: call to badge_cron()
      • line 61 of /admin/cli/cron.php: call to cron_run()

      !!! Invalid user !!!

            david.curry David Curry
            david.curry David Curry
            Ankit Agarwal Ankit Agarwal
            Marina Glancy Marina Glancy
            Dave Cooper Dave Cooper
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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