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

Way to find which users were created during course restore process

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
    • MOODLE_402_STABLE
    • MDL-68347-master-2
    • Hide
      1. Log in as admin
      2. Navigate to Courses > Restore course in site administration
      3. Upload backup-moodle2-course-2-c1-20230208-1655.mbz and press Restore
      4. Follow the restore wizard, restoring as a new course, leaving everything default
      5. Make sure the users were created on this site and enrolled into the restored course
      6. Navigate to Reports > Logs in site administration
      7. Get the site logs
      8. Confirm you see two User created event types, described as The user with id '2' created the user with id '4' during restore of the course with id '2'.
        • Note the first ID 2 is your admin ID; 4 is the ID of the user being imported; the last 2 is the ID of the course being imported
      Show
      Log in as admin Navigate to Courses > Restore course in site administration Upload backup-moodle2-course-2-c1-20230208-1655.mbz and press Restore Follow the restore wizard, restoring as a new course, leaving everything default Make sure the users were created on this site and enrolled into the restored course Navigate to Reports > Logs in site administration Get the site logs Confirm you see two User created event types, described as The user with id '2' created the user with id '4' during restore of the course with id '2'. Note the first ID 2 is your admin ID; 4 is the ID of the user being imported; the last 2 is the ID of the course being imported
    • WP - Sprint 2.0 (Marina), WP Sprint 2023-I1.1 (Marina)

      The "user_created" event is not triggered during course restore on purpose, restore process does not trigger any core events.
      There is a "course_restored" event that can be observed, however there is no way/API currently to find the list of created users (or modules, etc)

      From conversation with stronk7

      Eloy Lafuente Plaza, [6 Apr 2020 at 10:53:53]:
      so there are 2 alternatives:

      • or we create that new user_created_on_reastore event
      • or we use something into temp tables to have them at hand and we observe the course_restored event.

      Marina, [6 Apr 2020 at 10:54:57]:
      ok thanks

      it is ok to add methods to course_restored event class to find relevant data? Like list of created users for example

      these methods can only be used inside event observers

      Eloy Lafuente Plaza, [6 Apr 2020 at 10:56:23]:
      doesn't sound wrong, is my first thought.

      can be useful to others observing the same event. Just hope it doesn't end being a spaghetti/monster event (then maybe we should consider moving it apart)

      Marina, [6 Apr 2020 at 10:59:22]:
      is it possible that there is a scenario when users are created during restore process but then another error occurs and course is not restored and course_restored event is not triggered?

      Eloy Lafuente Plaza, [6 Apr 2020 at 11:01:42]:
      uff, everything is possible 🙂 I don't think we run restore under transaction ...

            marina Marina Glancy
            marina Marina Glancy
            Paul Holden Paul Holden
            Ilya Tregubov Ilya Tregubov
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 6 hours, 15 minutes
                1d 6h 15m

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