microsoft / o365-moodle

Office 365 and Azure Active Directory plugins for Moodle
GNU General Public License v3.0
180 stars 137 forks source link

Feature request: Improvements in handing calendar sync of module due date override #2502

Open slewislcm opened 8 months ago

slewislcm commented 8 months ago

Hi, When I apply an assignment override for a student, in their outlook calendar it show both the dates, the original due date and the override date. When it should just have the one date in the calendar. The Moodle calendar just shows the one date. Moodle 4.1.4 local_o365 4.1.3 Will this be changed in future release?

thanks, Simon 365 calendar moodle-calendar

weilai-irl commented 7 months ago

Hi @slewislcm

At a glance, there shouldn't be duplicate events in Outlook calendar. There is an observer function in local_o365 plugin that listens for Moodle \core\event\calendar_event_deleted event, and would make Graph API call to delete the event from Outlook calendar. As long as the Moodle event is triggered in case an assignment date is overridden, this should be triggered.

We will try to recreate the issue locally and investigate further.

Regards, Lai

weilai-irl commented 6 months ago

Hi @slewislcm

I performed some investigation on the reported issue. I confirm I can reproduce the issue, but I'm afraid a technical solution may not be possible without heavy rework on the calendar sync feature. I'll try to explain it in this note.

First of all, it worths highlighting that the calendar events sync from Moodle to Outlook is triggered by Moodle observer functions, which listens for Moodle events (not calendar events) and reacts to them. The exact Moodle events that are relevant to the calendar sync feature are:

To complicate things up, there are a few types of Moodle calendar events:

With this understanding, this is what happens when a user gets an assignment due date override:

  1. The prerequisite to reproduce the issue is to make sure the user has configured calendar sync in both personal calendar, and the course calendar in which the assignment activity is created.
  2. When an assignment with due date is created, Moodle will create a "custom event", with modulename set as "assign", instance set as ID of the assignment activity, courseid field set to be the ID of the course, and userid set to 0. The calendar sync feature will then look for all enrolled users of the course who have configured to sync the course events with Outlook, and create the event if needed. Note Outlook events created from courses that are connected to Teams will be created as an Outlook group event, with the course teacher as organiser, and students as invitees.
  3. When an assignment due date override is created, the previous "custom event" is not changed. Instead, a new calendar event is created, which has modulename set as "assign", instance set as ID of the assignment activity, courseid field set to be 0, and userid set to be the ID of the overridden user. Note the only difference with the event record above is on the courseid and userid fields. The calendar sync feature will then find the user and create the event in Outlook if sync is configured on. With this in mind, in order to delete the original due date event from Outlook calendar when a due date override is created, we will need to remove the user from the original event attendee list before creating a new Outlook calendar event for the new overridden date. Technically this will require new observer functions that listens for override created and deleted Moodle events (so that it would add the user back to the attendee list to when an override is deleted). This will also need to be done fore each activity module that can have override.

Overall what's required is technically feasible, but will require a lot of effort.

I'd suggest we convert this as a feature request, and queue it for now. We may proceed with it if it gets enough votes.

Regards, Lai