Subjects
How a campus subject is created, aligned to the national curriculum, offered to streams, given teachers, and removed.
A subject belongs to one campus and one level, is owned by a department, and may point at a national (NCDC) curriculum subject. It reaches students by being offered on a stream, and teachers by being assigned per stream.
All routes need a bearer token and a permission on subject; none has a feature flag. Paths start with /api/v1; the full list is in the route reference. Combinations only point at existing subjects whose kind is principal or subsidiary (see Combinations).
The subject
| Route | Permission | Notes |
|---|---|---|
POST /subjects (createSubject) | create | Needs campusId, name, level, departmentId. Optional code, isCompulsory (false), description, curriculumSubjectId, kind |
GET /subjects (listSubjects) | list | Filters campusId, level |
GET /subjects/:id (getSubject) | read | |
PATCH /subjects/:id (updateSubject) | update | Setting or clearing curriculumSubjectId sets alignmentStatus |
PATCH /subjects/:id/alignment (alignSubject) | update | The only way to store supplementary |
DELETE /subjects/:id (deleteSubject) | delete | Soft-deletes the subject and its links |
Alignment. With a curriculumSubjectId, alignmentStatus is aligned; without one, unaligned. alignSubject with supplementary or unaligned clears the link.
Kind. principal or subsidiary, meant for A-level only. The service doesn't enforce that; the combination validator does.
Delete soft-deletes the subject's student subject rows, stream offerings, teacher links and schemes of work, then the subject itself, because soft deletes don't cascade.
| When | Message |
|---|---|
| Unknown national subject | Curriculum subject not found |
| Unknown department | Department not found |
| Department scoped to another campus | Department must be school-wide or scoped to the subject campus |
| Same name on the campus (create or rename) | A subject named "{name}" already exists on this campus. ... (it suggests putting the level in the name, for example "Physics (A level)") |
Changing level while offered anywhere | {name} is offered on {n} stream(s); remove it from them before changing its level |
| Deleting a subject used by a combination | Subject is part of a combination; remove it from the combination first |
| Unknown id | Subject not found |
Offering it on streams
| Route | Permission | Does |
|---|---|---|
POST /subjects/:subjectId/streams (assignSubjectToStream) | manage | Offers it on one stream (classId, streamId) |
POST /subjects/:subjectId/classes (assignSubjectToClass) | manage | Offers it on every stream of a class, skipping ones that have it |
DELETE /subjects/:subjectId/classes/:classId/streams/:streamId (unassignSubjectFromStream) | manage | Removes one stream |
DELETE /subjects/:subjectId/classes/:classId (unassignSubjectFromClass) | manage | Removes every stream of the class |
listSubjectClasses, listClassSubjects, listStreamSubjects | list | Read the links |
After an offering is added, if the subject is compulsory or aligned to the national list, the service runs syncCompulsoryForStream. That backfills any missing compulsory subjects (school-compulsory plus NCDC-derived) for every active or pending enrollment in the stream. It only adds rows.
Removing an offering is a hard delete. It also removes the subject from students in that stream and hard-deletes the matching teacher links. (Deleting the subject itself soft-deletes instead.)
| When | Message |
|---|---|
| Class on another campus | {class} is not on the same campus as {subject} |
| Class and subject levels differ | {subject} is an A-level subject; {class} is O level (or the reverse) |
| Stream already has it | Subject is already assigned to this stream |
| Class has no streams | No streams found for this class |
| Every stream already has it | Subject is already assigned to all streams in this class |
| Nothing to remove | Subject assignment not found for this stream (or for this class) |
The single-stream route doesn't check that the stream belongs to the class.
Subject teachers
A teacher is linked per subject, class and stream (subject_x_teacher). These rows give the teacher their subject-teacher scope in the permission system.
| Route | Permission | Does |
|---|---|---|
POST /subjects/:subjectId/stream-teachers (assignSubjectTeacherToStream) | manage | One stream |
POST /subjects/:subjectId/class-teachers (assignSubjectTeacherToClass) | manage | Every stream of the class that offers the subject, skipping existing |
DELETE .../classes/:classId/streams/:streamId/teachers/:staffId (unassignSubjectTeacherFromStream) | manage | Hard delete, one stream |
DELETE .../classes/:classId/teachers/:staffId (unassignSubjectTeacherFromClass) | manage | Hard delete, whole class |
listSubjectTeachers, listClassSubjectTeachers, listStaffSubjectsByClass | list | Read the links |
| When | Message |
|---|---|
| Subject not offered on that stream | {subject} is not offered on this stream yet; assign the subject to the stream first |
| Not offered on any stream of the class | {subject} is not offered on any stream of this class yet |
| Already linked on that stream | This teacher is already assigned to this subject for this stream |
| Already linked on every stream | Teacher is already assigned to this subject in all streams |
| Nothing to remove | Subject teacher assignment not found for this stream (or for this class) |
The national list
GET /curriculum/subjects (listCurriculumSubjects) and GET /curriculum/subjects/:id (getCurriculumSubject) need only a bearer token. Every school reads the same rows, in name order. An optional group filter isn't validated, so an unknown group returns an empty list. A missing id throws Curriculum subject not found.