Skip to main content

Term Module

Location: backend/src/term/

The term module manages terms (semesters) within an academic year. Each term defines its own grading weight split between exams and coursework.

Files​

FilePurpose
term.module.tsModule definition
term.controller.tsAPI endpoints
term.service.tsBusiness logic
dto/create-term.dto.tsValidation for creation
dto/update-term.dto.tsValidation for updates

Data Model​

FieldTypeDescription
idUUIDPrimary key
academic_year_idUUIDParent academic year
nameenummichaelmas, hilary, or trinity
start_datedateTerm start
end_datedateTerm end
exam_weightnumberPercentage weight for exams (0-100)
coursework_weightnumberPercentage weight for coursework (0-100)
is_ministry_reportingbooleanWhether this is the term reported to the Ministry of Education
sort_ordernumberDisplay order

Term Names and Default Sort Order​

TermTypical PeriodDefault Sort
michaelmasSeptember – December1
hilaryJanuary – April2
trinityApril – July3

Weight Validation​

The exam_weight + coursework_weight must always equal 100. For example:

  • Exam 60% + Coursework 40% = 100 (valid)
  • Exam 80% + Coursework 30% = 110 (rejected)

API Endpoints​

All endpoints require AuthGuard.

GET /api/terms?yearId=<academic_year_id>​

Returns all terms for the specified academic year, ordered by sort_order.

Query Parameters:

ParamRequiredDescription
yearIdYesThe academic year ID to fetch terms for

GET /api/terms/:id​

Returns a single term by ID.


POST /api/terms​

Creates a new term.

Body:

{
"academicYearId": "uuid",
"name": "michaelmas",
"startDate": "2025-09-01",
"endDate": "2025-12-15",
"examWeight": 60,
"courseworkWeight": 40,
"isMinistryReporting": false,
"sortOrder": 1
}

Error Handling:

  • Duplicate term name within the same year → 409 Conflict
  • Weight sum ≠ 100 → 400 Bad Request

PATCH /api/terms/:id​

Updates a term. All fields are optional. Weight validation still applies.


DELETE /api/terms/:id​

Deletes a term. Fails with 409 Conflict if the term has existing assessments or grades (foreign key constraint).