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

Add original course id to course_restored event

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.1
    • Fix Version/s: 3.2
    • Component/s: Backup, Course, Events API
    • Labels:
    • Testing Instructions:
      Hide

      To Test

      On same site:
      1. create watcher for the course_restored event
      2. in the callback for that watcher log the event passed into it.
      3. create two moodle courses on the same site
      4. import one course into the other
      5. check the logged event to make sure $event->other['originalcourseid'] matches the course that was imported

      On different site:
      1. create watcher for the course_restored event
      2. in the callback for that watcher log the event passed into it.
      3. create two moodle courses on the different sites
      4. import one course into the other
      5. check the logged event to make sure $event->other['originalcourseid'] is not defined.

      Show
      To Test On same site: 1. create watcher for the course_restored event 2. in the callback for that watcher log the event passed into it. 3. create two moodle courses on the same site 4. import one course into the other 5. check the logged event to make sure $event->other ['originalcourseid'] matches the course that was imported On different site: 1. create watcher for the course_restored event 2. in the callback for that watcher log the event passed into it. 3. create two moodle courses on the different sites 4. import one course into the other 5. check the logged event to make sure $event->other ['originalcourseid'] is not defined.
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull Master Branch:
      MDL-46942-added-original-course

      Description

      We have a custom video server that holds videos which have been upload to it by users directly from Moodle courses. Each video has specific viewing permissions set to it based on the course they were uploaded from and the user that was uploading.

      Starting a new year, we create new courses and migrate old course into those new courses. as we do each year.

      Within our video repository plugin, we created an observer for the course_restored event that is using a web service to our video server which is migrating the permissions for each video that is linked to the original course into the newly restored (imported) course. for that, we made a tiny change to Moodle core inside the course_restored parameters and added original_course_id param.

      If it seems logical and useful, please consider adding this information to the event.

      Add:

      'original_course_id'=>$this->controller->get_info()->original_course_id
      

      As last param on the \core\event\course_restored::create event.

      And change the course_restored::get_description to:

      $original_course_id = (isset($this->other['original_course_id'])) ? $this->other['original_course_id'] : 'NA';
              return "The user with id '$this->userid' restored old course (id='$original_course_id') to a new course with id '$this->courseid'.";
      

      What do you think?

        Attachments

          Activity

            People

            Assignee:
            moodle.com moodle.com
            Reporter:
            nadavkav Nadav Kavalerchik
            Peer reviewer:
            Ankit Agarwal
            Integrator:
            Dan Poltawski
            Tester:
            cameron1729
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              5/Dec/16