Lesson edit propagation
Recurrences and converging courses in the calendar, edit scopes, forks, subject and substitutions, what students of published courses see, notices, the students' Home and iCal.
Status on 04/10/2026 (branch test/convergence-stress, in production with bec7dff9c4 plus the fixes marked on this page). The user guide is Editing lessons shared by several courses. A more detailed map with code references is docs/CALENDAR_PROPAGATION_MAP.md in the repository.
Data model
events: the content of an occurrence (name, description, dates, frequency,onPremise, room androomSource, links, attachments, books,subjectwithlevelId, suspension and rescheduling). One Event per occurrence.calendar_events: where the occurrence lives (calendarId,eventId, a copy ofdates,sharedId,recurringId,lectureId).- Vertical (recurrence): the occurrences of a series in one calendar share a
recurringId. - Horizontal (convergence): rows of several course calendars with the same
sharedIdnormally point to the same Event. Changing the Event changes every course without copying anything. - Fork: a row that gets its own Event (new id) while keeping its
sharedId; a later "everywhere" edit brings it back onto the shared Event. - Colour is not an event field: it is the calendar's colour.
Edit scopes
PUT /calendars/:calendarId/events/:id with updateEventTarget (vertical) and calendarsUpdateStrategy (horizontal). The course lesson dialog (PATCH /courses/:courseId/chapters/:chapterId/lectures/:id) sends no strategy: the change reaches the calendar with courseId and applies to every converging calendar.
calendarsUpdateStrategy: all ("Change everywhere") | calendarsUpdateStrategy: this ("This calendar only") | |
|---|---|---|
this ("This occurrence only") | updates the shared Event and re-aligns every row with the same sharedId (forked ones included) | forks: a new Event for the caller's row only |
cascade ("This and the following ones") | as above plus the later occurrences of the series, time shifts applied as a delta | forks every later occurrence of that calendar |
all ("All occurrences") | as above on the whole series, only occurrences not yet ended | forks the unfinished occurrences of that calendar |
Future only (G4, fixed in this branch). CalendarEventsRepository.getChildCalendarEvents(…, { notFinishedAt }) keeps only occurrences ending after now; vertical updates (updateChildEventForAllCalendar, updateChildEventForThisCalendar) and date validation use it. Rebuilding a recurrence (frequency change) still sees the whole series.
Fields and propagation
| Field (dialog) | Vertical | Horizontal "everywhere" | Horizontal "this only" |
|---|---|---|---|
title, description, place (onPremise.address), attachments, books | yes | yes (shared Event) | yes, on the copy |
| links | yes | yes | yes; an empty list with isLinkAndAttachmentUpdate removes every link (G2) |
| time and duration | yes (delta on Event and rows) | yes | yes |
chosen room (roomSource) | yes | yes | yes (G2, G9) |
| subject and level | unchanged unless the edit names them (G1) | same | same (G2) |
Forks, subject, responsible and substitutions
The responsibles rule (level → subject → course → manager) reads the Event's subject.id and subject.levelId; substitutions are event_substitutions rows per Event. Hence:
- G1 (fixed): an edit that did not name the subject turned it into
null(setSubjectToNullIfOmittedAndExists) and removed it from the whole series in every course; responsibles and substitutions fell back to the course teacher. The subject now changes only with an object (null= removed). - G2 (fixed): forks (
CreateEventDto.fromSharedEvent,fromEvent,fromExistingEvent,fromLectureEventUpdate) keep subject and level,roomSource, suspension, rescheduling and place (utils/forked-event-fields.util.ts). - G3 (fixed):
EventSubstitutionsCarryService.followForkcopies the active, unfinished substitution rows onto the new Event, with the forked row's calendar, course and lesson, at every fork (rescheduling included). - G5 (fixed): moving a lesson updates
eventStart/eventEndof its substitution rows (refreshSeriesDates). - A fork made before the substitution is an Event of its own with the same subject: the substitution finds it like the others.
Rows, groups, grading, substitute access and how substitutions follow forks (one row per course): Substitutions.
Published courses: live or at publication (today)
After publication every edit goes through a course draft (updateToLatestOrCreateDraftCalendars). The draft calendar, however, is a shallow copy: its rows point to the same Events as the published calendar (CreateCalendarEvent.fromPublishedCourseCalendar). As a result:
| Change | Students' calendar | Lesson in the course (lectures, course page) |
|---|---|---|
| everywhere, one occurrence or the series | immediately in every converging course: the shared Event is updated and every row with that sharedId is re-aligned, published ones included | new draft version; students see it after republishing |
| this calendar only on a shared occurrence | after republishing (new Event for the draft row only) | after republishing |
this calendar only on an already forked row (eventId ≠ sharedId) | the fork's Event is edited: if the fork was created before the last publication the published row uses it too, so immediately (that course only) | after republishing |
| from the lesson dialog (course) | like "everywhere" | after republishing |
series children (cascade/all) | immediately: dates shift on rows by eventId, published ones included | after republishing |
- New version: every edit creates a draft
course_versionwith revisions of the touched lessons (activity logUPDATE_MANYon the lesson, without field details). At publication the draft calendar becomes the published one without copying (handleCycleCalendars); calendars of cycles 2+ are recreated with new Events. - Students on older versions: in LIVE courses every member moves to the new version at publication (
handleCourseReview); later enrolments get the published version. There is no per-student version pinning. - Substitutions and cycles 2+: calendars of later cycles recreated at publication do not carry substitution rows (open, G7).
Proposal: a course option (to be decided, not built)
lessonEditsApply: 'live' | 'on-publish' in the course settings (Settings → Calendar):
live(proposed default for logistics): time, place, link and room changes go straight to the published calendar (no calendar draft) and the published lesson gets the same fields through a "logistics" revision that does not require republishing; title, description, attachments and books follow the same choice or wait for publication (second question for the owner).on-publish: the draft becomes a real copy (Events cloned for draft rows at the first change, withfollowForkfor substitutions and members), so nothing reaches students before publication; at publication the published rows switch to the draft's Events.- Convergence: the option applies to the group of courses sharing the lesson. If courses in the group differ, at the first change the
on-publishcourses fork their row (like "this calendar only") and the dialog says so before saving. - Notices: with
live, "Notify students" fires on save; withon-publish, at publication, one notification per student summarising the changed lessons.
"Notify students" on edits
- Gateway:
notifyStudentsinUpdateEventGatewayDto(calendar) andUpdateLectureGatewayDto(lesson dialog). In the app the checkbox shows only for unfinished course lessons and only when title, time, place, link or room change (web-next/lib/lesson-notice.ts), on by default. - Calendar: after the update
LessonChangeNoticesService.announcecompares the previous Event with the change (lessonChangeFields), takes the lesson and, withcascade/all, the other unfinished occurrences; the courses are all converging ones with "everywhere" or from the lesson dialog, only the caller's with "this calendar only". - Students:
COURSE_MEMBERS.LIST_COURSE_STUDENTSfor those courses, merged without duplicates and without the editor (planLessonChangeNotice), thenEVENTS.LESSONS_CHANGED→lessons-changednotification (in-app and push), one per student. App text:web-next/lib/lesson-change-text.ts; it opens the course page. - It never makes the edit fail and sends no email.
Other student notices (fixed in this branch)
- Suspension and rescheduling: one email per student per lesson even across converging courses; only courses with email enabled (the list used to be filtered and then sent unfiltered); settings read per course; dates in the student's language and in Europe/Rome when the profile has no timezone (
utils/lesson-change-notices.util.ts). - Push for a cancelled substitution: "lessons go back to the usual teacher" (it used to still say "teaches").
Calendar view: one row per calendar (05/10)
Owner's decision: "each calendar shows its own events".
POST /calendars/events/searchwithperCalendar: true(only the web-next Calendar view) returns one row per requested calendar: a converging lesson with N calendars on comes N times, each with its owncalendarId, hence that course's colour and name. Without the flag (Home, assistant, searches) it stays one row per event, as before. Logic inapps/calendar/.../search-rows.util.ts: events that came in only because the searcher substitutes on them (calendars not requested) stay a single row, and only if the event is not already in a requested calendar; occurrences moved by cycle stay distinct.- With
perCalendarevery row of a shared lesson carriesconvergentCalendarIds: all the calendars that contain it (one read ofcalendarId/sharedId), including the ones that are off. The event dialog lists those the viewer knows (on or hidden) and counts the others. - In the grid a row's key is
event@calendar(CalendarEvent.id);data-event-idstays the event,data-calendar-idtells the calendar. - Checkboxes: turning a calendar off calls
DELETE /calendars/selections(POSTonly adds: the checkbox used to come back after a reload). Course calendars are remembered per course, on the server:preferences.calendar.hiddenCoursesnext to the selections, on the profile (personal) or on the academy member (per context);GET/PUT /calendars/hidden-courseswith the whole list (profile app,RETRIEVE_HIDDEN_COURSES/SET_HIDDEN_COURSES). A new version of a hidden course's calendar stays hidden, a course never seen shows up (components/calendar/engine/calendar-visibility.ts, tested withnode --test; backendtests/unit/calendar-hidden-courses.spec.ts). For students the server selections do not follow calendar versions (theCALENDAR_VERSION_CREATEDrealignment is for managers and editors): hence the per-course memory. Migration: until 07/10 the memory was inlocalStorage(aladia:calendar:hidden-courses:<user>:<context>); on the first load those courses are merged with the server's (mergeHiddenCourses) and the local key is removed. The preference entities carry the field, so saving the profile or the member does not erase it. - Staff and students use the same view: same behaviour.
Students' Home
For academy Students and Viewers (onlyReadsAcademy) the Home builds Today's meetings from the course calendars (GET /calendars?includeCourses=true, then POST /calendars/events/search with calendarIds), like the header calendar: same period picker, same rows and substitution badges, no "whose" filter and no "New event". The Home used to search with responsible=me, which is always empty for a student. The search returns an event shared by several courses once.
iCal
GET /calendars/integrations/feed/:token.ics (calendar-feeds.service.ts, feedEvents): one VEVENT per occurrence (Event + start) even when the lesson sits in several course calendars of the same user; UID = the oldest calendar_event (existing subscriptions keep it); courses in CATEGORIES; LOCATION from the place; suspended lessons and lessons rescheduled to another day are CANCELLED; LAST-MODIFIED also follows Event edits. The feed does not include the teacher.