Hi!
In this plugin, when the User is updating the course, it triggers a "course_updated" event:
events.php
"
$observers = array(
array (
'eventname' => '\core\event\course_updated',
'callback' => '\local_myplugin\helper::update_event',
),
...
"
I catch this event
helper.php
"
public static function update_event($courseupdated_event) {
...
$data = $courseupdated_event->get_data();
$details = $courseupdated_event->get_record_snapshot('course', $courseinfo['courseid']);
...
"
During this process, I'm modifying a bit `$data` and I create a new event "Calendar_event" (I mark the end date of the course in the calendar in fact)
...
$newcalendar_event = \calendar_event::create($data);
}
"
And now, here's the bug:
the course is updated with the data that I've modified to create the "calendar_event", not the original data!
For example:
If I put in the calendar the date "9/05/2021", the course gets updated to "9/05/2021"
I only wanted to modify the calendar, not the normal process of updating the course.
I've never modified "$courseupdated_event" and somehow, it's as if my "$newcalendar_event" becomes a "course_updated" event!