AladiaDocs

Academic year

Course versions, the year version and bulk publishing, recurring lessons (series), convergences, per-edition content, user flow, limits and tests of the academic year. Only built behaviour, with code references.

Status (05/10/2026). The cycle engine, series, convergences, wizard, control room, archive and "Set up your school year" are in production (phases 0–4, branch feat/academic-year). Year versions (§2) and "This year only" edits without versions (§3.5) are on branch release/anno-versioni, the Recurrences step (§3.6) on release/anno-ricorrenze: covered by unit tests (tests/unit/academic-year-versions.spec.ts); the E2E runs on the test academies happen after the release (§8). Paths are relative to backend/ unless they say web-next/. User guide: Academic years and Versions and the academic year. See also Lesson change propagation and Substitutions.

1. Course versions today

A course has a linear row of versions (course_versions, one per change): each version is a snapshot of pointers (course, chapters[].lectures[]) to the main documents or their revisions (course_revisions, chapter_revisions, lecture_revisions).

conceptrulewhere
the latestexactly one: the newest by createdAt; the builder edits itapps/course/src/app/course-versions/course-versions.repository.ts:234
the published oneexactly one with status: published (the newest)course-versions.repository.ts:253
grouping in the Versions panelevery version is born a root (parentId = _id); a change on a draft moves the chain under the new one (shown as a revision of the same draft)libs/common/src/common/models/microservices/course/course-version.model.ts:83, apps/course/src/app/course-versions/services/course-versions-change.service.ts:950

What creates a version. Every change goes through CourseVersionsChangeService.handleChanges (course-versions-change.service.ts:69), one per course at a time:

latest versionchangeeffect
published (or draft/rejected of a course already published)handleChangesOnPublished (:182) → handleUpdate (:689)new draft version vN+1 on top, with a new revision of the entity; the published one does not change
draft of a never-published coursehandleChangesOnDraft (:233)new version on top; the main document is updated, the previous version points to a revision with the old content
  • createCycle and deleteCycle go through handleChanges: they create a version (apps/course/src/app/courses/service/course-cycles.service.ts:165, :72).
  • updateCycle does not create versions: it writes the dates on the course the latest version points to (course-cycles.service.ts:305, write at :368).
  • Lesson edits from the calendar go through batchUpdateLectures → handleUpdateMany on the latest version (apps/course/src/app/lectures/service/lectures-upsert.service.ts:2345, course-versions-upsert.service.ts:269): if the latest is published, a draft is born. Fields: title, dates, duration, description, frequency, links, attachments. Subject and books are written separately, always on the lesson, without versions. Exception for academic-year editions: §3.5.

Version actions.

actionwhat it doeswhere
Create versioncopies the latest into a new version on topcourse-versions-upsert.service.ts:110
Restorecopies the chosen version on top (new version, restored); the others staycourse-versions-upsert.service.ts:62
Publishthe latest goes online right away: the previously published one becomes "unpublished" and the new one published. If going online fails, the version stays a draft and can be published againcourses-status.service.ts
Publish a non-latest versionfirst a restore (on top), then publishingcourses-status.service.ts:120

No review (27/10/2026). Course review is gone: no workspace queue, no Aladia review, no AI auto-approval, no VERIFYING state. Whoever can press "Publish" (course.update on the course) puts the version online for every course (internal, public, personal), in a single service (apps/gateway/src/gateway/controllers/course/courses/course-publication.service.ts). Paid courses still need Stripe Connect; free ones don't (libs/common/src/common/guards/stripe-onboarding.guard.ts). The old endpoints PATCH /courses/:id/review, PATCH /courses/:id/withdraw-review, GET /courses/search/verifying and /marketplace/reviews/* answer 410 Gone. The migration scripts/migrations/2026-10-course-review-removed.js moved every pending/VERIFYING version back to draft (nothing was auto-published). Content-moderation strikes can still suspend publishing.

2. Versions in the academic year

Decision of 05/10. Pure rules in libs/common/src/common/academic-year/year-versions.ts.

2.1 Starting version

casestarts fromwhere
the course has a published versionthe latest published onestartVersionOf, year-versions.ts:78
never publishedthe latest draft (not an "open draft")same
a teacher's open draft (latest, newer than the published one, not published)left out; with Include the draft it starts from itopenDraftOf, year-versions.ts:52
a version picked by hand in the wizardthat onesame

The wizard's Courses step reads POST /academic-years/versions (gateway AcademicYearPublicationService.startVersions, course app CourseYearVersionsService.startOf, apps/course/src/app/courses/service/course-year-versions.service.ts:74): per course the start, the published one, the open draft with its author's name and the 10 latest versions. Choices go into choices.versions ([{ courseId, versionId?, includeDraft? }]). The open draft triggers no notice: it stays in the history, untouched and restorable.

2.2 Creating the year

For every chosen course the preparation (AcademicYearsService.run, apps/calendar/src/app/academic-years/academic-years.service.ts:345, choice at :379) asks the course app for a new draft version (CourseEditionsService.ensureInYearVersion, apps/course/src/app/courses/service/course-editions.service.ts:195):

  1. title yearVersionTitle (year-versions.ts:42): "2027/28" → "Anno 2027/28";
  2. a copy of the starting version (CourseVersionsChangeService.branchVersion, course-versions-change.service.ts:992): it becomes the latest; the published one and the teacher's draft don't change;
  3. the year's cycle inside the copy (CourseCyclesService.createCycleInNewVersion, course-cycles.service.ts:235): on an already-published course in a new course revision, on a never-published one on the main document. If the start already has a cycle in the period (the first cycle of a class born for the year) the version is just the copy;
  4. the edition's own lessons enter from the year version onwards (attachToVersions, course-editions.service.ts:661): the published version doesn't see them;
  5. the version carries academicYearId; the edition (course_editions) records versionId and startVersionId; the year (academic_years.courses[]) versionId, startVersionId and the open draft (draft: { id, profileId, createdAt, included }).

Resumable: if the course's year version already exists it is reused with its cycle. Nothing is published at creation.

Example: Maths 3A has v3 published (June) and Ms Rossi's draft v4 (September).

momentv3v4 (Rossi's draft)v5 "Anno 2027/28"
before the wizardpublisheddraft, latest—
after "Create" (draft not included)publisheddraft, untoucheddraft, latest, copy of v3 + 2027/28 cycle
after "Publish the year"unpublisheddraft, untouchedpublished

With Include the draft v5 is a copy of v4.

Cancel the preparation (dropYearVersion, course-editions.service.ts:528): if nobody edited the year version afterwards, it disappears with its course revision and the latest goes back to the previous one; if it was edited, the cycle is removed as usual (deleteCycle, which creates a version).

2.3 Publish the year

Bulk publishing (gateway AcademicYearPublicationService.publish, apps/gateway/src/gateway/controllers/academic-years/academic-year-publication.service.ts:102):

  1. for the courses not yet published, the course app finds the version to publish (CourseYearVersionsService, course-year-versions.service.ts): the course's latest version (the year version or a later edit of it), as long as it still has the year's cycle;
  2. per course (three at a time): paid without the owner's Stripe Connect → error; otherwise the same road as "Publish" (§1): the version goes online directly, for every course (internal and public alike). There is no review and no "only dates change" option. The previously published version becomes "unpublished";
  3. the calendar app records the outcome per course (academic-years.service.ts): published or error with its reason; it publishes the editions of the courses that passed; the first time at least one course passes the year becomes active, teacher changes are applied and teachers are notified.

Before publishing, the dialog calls POST /academic-years/:id/publication-plan and shows how many courses go online and those to fix.

Outcomes (in academic_years.courses[].publication, shown in the control room and as a publication-failed item in "To fix"):

outcomereasons
publishedthe course went online; legacy-edition for a year prepared before versions (only the edition is published, as back then)
errorstripe-onboarding-required, publish-refused, year-version-superseded (the latest version no longer has the cycle: a "Restore" removed it), year-version-missing, the error message

Repeatable and idempotent: on an active year with failed courses canRetryPublication (academic-years.service.ts) enables Retry unpublished courses; courses already published are not redone; with no errors a new "Publish" answers 409.

2.4 Editions and versions

Each edition born from the wizard records the version it comes from (course_editions.versionId, and startVersionId); earlier years' editions are not touched (the year version is born next to them, not in their place). On publishing, as for any live course, handleCourseReview moves the course's members to the published version (course_members.versionId, oldVersionId = the previous one): the content of their cycle does not change, because the year version is a copy of the published one plus the new cycle's own lessons, and every cycle sees its own lessons plus the introduction (§5). With "Include the draft" (or a hand-picked version) that version's differences reach every cycle, as with any publishing.

3. Recurring lessons (series)

3.1 What a series is

course_series (calendar app, libs/common/src/common/models/microservices/calendar/course-series.model.ts): a recurring lesson of a course.

  • rule: weekly/once, interval (weeks), weekdays (ISO, 1 = Monday), startTime "HH:mm", durationMinutes, timezone, anchorOffsetDays, spanDays. Wall-clock time in the academy's time zone: 9:00 stays 9:00 across daylight-saving changes (occurrencesOf, libs/common/src/common/academic-year/series-rule.ts:92).
  • template: title, description, place, room, Meet link, links, attachments, books, subject and level.
  • convergenceKey, sourceKey, aliases (heads of the series generated in later years), sourceLectureIds (source lessons in order), origin (migration | engine | onboarding), confidence, exceptions.

3.2 Rebuilding for existing courses

reconstructSeries (libs/common/src/common/academic-year/series-reconstruction.ts:129), on the fly for courses without series (CourseSeriesService.forCourses, apps/calendar/src/app/academic-years/course-series.service.ts:70) or with the migration:

  • make-ups are dropped (rows with originalEventId); the original lesson counts at its date;
  • grouped by recurringId (none: a single lesson);
  • days, time and duration: the most frequent in the last third of the series, at least 3 rows (:195); a mid-year "this and following" change is the new plan, the earlier stretch counts as replanned;
  • template: the most frequent; convergence: the most frequent sharedId;
  • confidence (:245): high ≤ 10% off plan, medium ≤ 30%, low beyond → "Timetable rebuilt with low confidence" in "To fix".

3.3 Holidays and closures

Occurrences are generated on the new dates and skip the new year's holidays and closures (closedDaysFor); a one-off (once) lesson on a closed day is a lesson-on-closure conflict in the preview.

3.4 Exceptions not carried and "Applies to"

The engine starts from the series, not from the occurrences: moved, suspended, made-up, forked lessons and substitutions are not carried. Every edit to a course lesson writes series_changes (SeriesChangesService.recordEventUpdate, apps/calendar/src/app/academic-years/series-changes.service.ts:69), one row per field:

  • This year only (default); a single occurrence always applies to this year only (effectiveAppliesTo, libs/common/src/common/academic-year/series-changes.ts:63);
  • Also in the baseline (following years) on "this and following"/"all": it also writes the series right away (with "Edit everywhere", the series of the whole convergence);
  • the wizard's "Changes to carry" step preselects the baseline ones; content changed "this year only" and not chosen goes back to its previous value in the copy (contentReverts, libs/common/src/common/academic-year/year-input.ts:136).

3.5 Calendar edits that don't create versions

On academic-year editions (cycles in course_editions with academicYearId) a "This year only" edit (the default, and always for a single occurrence) stays in the edition: it is written on the cycle's own lesson (and on its open revision in the latest version, if any), with dates on the edition's cycle, without course versions (applyThisYearEditionUpdates, lectures-upsert.service.ts:2420; rule splitThisYearEditionEvents, apps/course/src/app/lectures/service/edition-lecture-update.util.ts:22). "Also in the baseline" follows the usual versioning (§1) and also writes the series. The calendar sends the "Applies to" with the lesson update (appliesToOf, apps/calendar/src/app/calendar-events/service/calendar-events-upsert.service.ts:85; LectureEventUpdatedDto.appliesTo, cycleId). Realignments without "Applies to" (nightly reconciliation) count as "this year only". Courses without academic years and out-of-year cycles: unchanged.

3.6 The wizard's "Recurrences" step

Between "Courses" and "Convergences" the wizard shows, for each chosen course, its series (including those rebuilt on the fly): name, subject and level, days, time, duration, interval, teacher and confidence (low-confidence ones highlighted). Existing series can only be corrected, no additions or removals:

fieldrule
days1–7 (ISO), at least one; with new days the first lesson goes back to the Monday of its week, also every 2 weeks (correctedRule, libs/common/src/common/academic-year/series-corrections.ts)
timelocal "HH:mm"
duration5–720 minutes
intervalevery 1–8 weeks
teacherit is the subject and level teacher (there's no per-series teacher): changing it here changes the "Teachers" step row, applied on publishing

PATCH /academic-years/series/:seriesId (AcademicYearsService.correctSeries, apps/calendar/src/app/academic-years/academic-years.service.ts) writes the series right away (CourseSeriesService.correct: origin: 'wizard', confidence: 'high') and one series_changes row per field (kind: 'correction', appliesTo: 'baseline', scope: 'all', SeriesChangesService.recordCorrection). So:

  • preview and creation use the corrected series; it also applies to later years;
  • the current year doesn't change (no event touched);
  • a corrected series is no longer "Timetable rebuilt with low confidence";
  • rebuilding with refresh doesn't overwrite it (it only rewrites origin: 'migration');
  • corrections don't show among the "Changes to carry" (they're already in the baseline) and can't be undone by unticking.

Convergences: if the series has a convergenceKey and other series with the same key are among the chosen courses, the wizard asks "Correct the whole convergence?": with Correct the whole convergence the correction applies to all (alsoSeriesIds); with Only this one the convergence keeps different times and ends up in "To fix" as "Shared lesson with different times across courses" (ruleMismatch).

Example: Science of Liceo 2B (Friday at 12, medium confidence) corrected to 15:00 → in 2027/28 all its lessons at 15:00; 2026/27 stays at 12; 2028/29 will start from 15:00.

4. Convergences

A convergence is the same lesson in several courses: series of different courses with the same convergenceKey (the original sharedId). In the new year there is one event per occurrence with one row per calendar and the same sharedId (generateGroup, apps/calendar/src/app/academic-years/cycle-engine.service.ts:199). Rules (planYear, libs/common/src/common/academic-year/year-plan.ts:94):

situationresultwhere it shows
all the convergence's courses chosenlesson shared by all—
one course left out, ≥ 2 remainshared among those leftConvergences changed in the preview, with "Also include …"
1 remainsa normal lesson of that courseConvergences changed (becomes: single, :212)
0 remainnot generated—
convergence unticked in the Convergences stepone lesson per course—
different times across coursesthe first series' rule is used; "Shared lesson with different times across courses" in "To fix"ruleMismatch, :141
same teacher in two overlapping lessons"Teacher booked twice at the same time" conflict in the preview and "To fix"teacher-double-booked, :279

Example (test dataset): Maths year 1 is shared by Liceo 1A, Liceo 1B and Serale 1 (C1); English by Tecnico 3 INF and 3 ELE (C3). Leaving out Serale 1 and Tecnico 3 ELE:

convergencebeforeafter
C1 Maths year 11A + 1B + Serale 1shared 1A + 1B
C3 English3 INF + 3 ELEnormal lesson of 3 INF
C2, C4wholewhole

5. Per-edition content

A generated edition has its own lessons: copies with a single entry in cycles (its cycle); course_editions.ownContent says which cycles have them (isEditionLecture, libs/common/src/common/academic-year/edition-lectures.ts:27). A cycle with its own lessons sees those plus the ones without a cycle (the introduction: on-demand, born with the course), which apply to every cycle (decision of 07/10, lectureBelongsToCycle); the other cycles see the historical lessons. This applies to the preview, the player and the chapter lessons (aggregateCycleDateToLectures); the attendance register lists only live lessons, so it does not change. Attendance, grades and recordings stay in their cycle.

Matching by position (linkLectures, cycle-engine.service.ts:388; copy in CourseEditionsService.createLectures, course-editions.service.ts:296): the series' new occurrences, by date, are matched to the source lessons in the same position (sourceLectureIds[i]) and copy their title, description, attachments, links and books (COPIED_FIELDS, :66), subject, access level, chapter.

the number of lessons in the new year…effect
is the sameeach new lesson copies the one in the same position
grows (fewer closures, longer year)the extra lessons come from the series template (title, description, attachments, links, books, subject) in the chapter covering the date, otherwise the last one
shrinks (more closures)the last source lessons are not copied

Chapters and structure stay shared; the chapters' dates for the new cycle are those of cycle 1 shifted by calendar days. Own lessons enter the versions from the year version onwards (§2.2).

6. User flow

  1. Teaching › Planner › Year › Prepare the new year (Owner and Admin): a seven-step wizard in a centred dialog (web-next/components/academic-years/prepare-year-dialog.tsx): Dates and closures → Courses (with starting version and "Include the draft") → Recurrences (series corrections, §3.6) → Convergences → Changes to carry → Teachers → Preview (counts, conflicts, Convergences changed).
  2. Create: the year is born preparing; the preparation runs in the background, resumable (complete groups skipped, half-done ones redone; automatic resume of jobs stalled for 2 minutes, resumeStale, academic-years.service.ts:117). Each course gets its "Anno …" draft version; nothing is published.
  3. Control room (web-next/components/academic-years/academic-year-control-room.tsx, in the Planner ?view=year&year=<id>): progress, To fix (each item links to where it is fixed; conflicts can be Ignored), PDF summary, course list with lessons, version state ("draft version", "teacher's draft not included") and outcome.
  4. Publish the year (when nothing blocks): a dialog with the summary of the courses that go online and those to fix; then the outcome per course (published or error); Retry unpublished courses if any failed.
  5. Close year (on an active year): archived, editions read-only (ArchivedYearsGuard, course_editions.archivedAt).
  6. Cancel the preparation (while preparing, academic-years.service.ts:775): removes editions, lessons, calendars and year versions (§2.2); earlier years and teachers' drafts stay.

"Set up your school year" (academy without courses, setup-school-year-dialog.tsx) creates classes, subjects and series, then the same year with the same engine; "Publish the year" also publishes, in bulk, the classes still in draft (internal courses: direct).

7. Known limits and what it doesn't do yet

  • New convergences: the new year can't add or merge convergences; they can only be kept, reduced or split.
  • Recurrences: only existing series can be corrected (days, time, duration, interval); series can't be added or removed (to not recreate one, untick it in the "Convergences" step), and the teacher stays the subject and level teacher.
  • Assignments (exams_course has no cycle): not copied into the new year.
  • Students: the new year starts empty; no promotion.
  • A cycle created from the course page (even if it joins a year, generateCycle, academic-years.service.ts:810) follows the old road: cycle in the latest version, no year version, published with the course.
  • For a never-published course all versions point to the main documents: the "draft" can't be kept apart (§1).
  • "This year only" edits on editions don't update chapter durations.

8. Tests

speccovershow
tests/unit/academic-year-versions.spec.tsstart (published, draft excluded/included, hand-picked, never published), one version per course and resume, per-course plan (idempotency, superseded version), bulk publishing (direct, already done, Stripe, refusal), outcomes in the calendar (active year, retry), "this year only" edits without versionscd backend && npx jest -c jest.unit.config.cjs tests/unit/academic-year-versions.spec.ts
tests/unit/academic-year-series-corrections.spec.ts"Recurrences" step: validation, changed fields, days realigned to Monday, saved series (origin wizard, high confidence, baseline row), convergence extended on confirmation or with different times (ruleMismatch), another academy's series refusedsame
tests/unit/internal-course-publish.spec.ts"Publish": direct for every coursesame
tests/unit/academic-year-core.spec.ts, cycle-engine.spec.ts, cycle-phase0.spec.ts, academic-year-phase34.spec.ts, academic-year-wiring.spec.ts, academic-year-resume.spec.tsrules, DST, closures, rebuilding, convergences, conflicts, "Applies to", engine, archive, resumesame
web-next/e2e/help/flows/academic-year/academic-year.spec.mjson the ACYEAR dataset ("Collaudo convergenze" academy): a "teacher" draft before the wizard; N "Anno 2027/28" draft versions, nothing published at creation, draft untouched; series, local time, counts; exceptions not carried; convergences; teachers; bulk "Publish the year" with per-course outcome, previous published "unpublished", draft in history, year cycle in the student's version, second "Publish" 409; "Recurrences" step: Science of Liceo 2B corrected to 15:00 → in 2027/28 at 15:00; source year untouchednode web-next/e2e/help/flows/_support/seed-academic-year.mjs --apply then node web-next/e2e/help/flows/run.mjs academic-year/academic-year [--shots]
web-next/e2e/help/flows/academic-year/onboarding.spec.mjs"Set up your school year"; a year version per class from the latest draft; direct bulk publishing (internal classes); cycle visible to the studentnode web-next/e2e/help/flows/run.mjs academic-year/onboarding [--shots]

The parts in §2 and §3.5 can be tested on the test academies only after the release of backend and web-next.

Appendix A. API

Gateway apps/gateway/src/gateway/controllers/academic-years/academic-years.controller.ts, Owner and Admin of the active academy (the list also for staff):

routewhat it does
GET /academic-yearsthe academy's years
GET /academic-years/defaultstime zone and holidays (step 1)
POST /academic-years/sourceseries, convergences, changes, subjects/levels with today's teachers
POST /academic-years/versionsstarting version, published, open draft (with author) and recent versions per course
POST /academic-years/previewgroups, counts, conflicts, convergences changed, closed days
POST /academic-years · GET/PATCH /academic-years/:idcreate (with choices), read, change
POST /academic-years/:id/preparestart or resume the preparation
POST /academic-years/:id/cancelcancel the preparation
GET /academic-years/:id/summarycontrol room: year, "To fix", canPublish, canRetryPublication, report
POST /academic-years/:id/acknowledge"Ignore"/"Restore"
POST /academic-years/:id/publication-plancourses that go online and those to fix
POST /academic-years/:id/publishbulk publishing, all direct (or retry)
POST /academic-years/:id/closearchive
PATCH /academic-years/series/:seriesId{ correction: { weekdays?, startTime?, durationMinutes?, interval? }, alsoSeriesIds?, yearStart? } → "Recurrences" step
POST /academic-years/series/reconstruct · POST /academic-years/seriesrebuild series; series from a timetable (onboarding)

Appendix B. Phase 0 (cycle fixes, in production)

The old clone of cycle 1's calendar (handleCycleCalendars) was replaced by the engine; the defects closed (duplicated make-up, lost suspensions/place/room/Meet, holidays not skipped, first event's members on all, inherited sharedId, DST in UTC, members $pull that removed nothing, duplicated cycle entries) are in docs/CALENDAR_PROPAGATION_MAP.md §11 and tests/unit/cycle-phase0.spec.ts.

Appendix C. Migrations

migrationwhat
scripts/migrations/2026-10-cycle-calendars-phase0.jsremoves the inherited sharedId from cycle 2+ calendars and deleted cycles from members; report of duplicated calendars
scripts/migrations/2026-10-academic-year-series.jsrebuilds course_series for live courses (optional)
scripts/migrations/2026-10-academic-year-current.jsper academy, the Current year from the cycles containing DATE; course_editions with ownContent: false

All PHASE=plan (default) → PHASE=apply → PHASE=rollback; filters ORG, ONLY. Year versions need no migration: the new fields (course_versions.academicYearId, course_editions.versionId/startVersionId, academic_years.courses[].versionId/startVersionId/draft/publication) are optional; a year prepared before publishes only the editions, as back then (legacy-edition).

On this page