+ // Store the context.
+ $context = context_course::instance($course->id);
+
+ // Update the course object we are passing to the event.
+ $dbcourse->category = $course->category;
+ $dbcourse->sortorder = $course->sortorder;
+
+ // Trigger a course updated event.
+ $event = \core\event\course_updated::create(array(
+ 'objectid' => $course->id,
+ 'context' => $context,
+ 'other' => array('shortname' => $dbcourse->shortname,
+ 'fullname' => $dbcourse->fullname)
+ ));
+ $event->add_record_snapshot('course', $dbcourse);
+ $event->set_legacy_logdata(array($course->id, 'course', 'move', 'edit.php?id=' . $course->id, $course->id));
+ $event->trigger();
+