courses Courses & Seasonal Schedules¶
Author: Zhenyu Yang yangzhenyu@sust.edu.cn, Sixu Wei reisa@sust.edu.cn
Last updated: Apr 24, 2026
Corresponding API docs: Course API
courses Code Entry¶
backend/apps/courses/models/__init__.pybackend/apps/courses/views.pybackend/apps/courses/services/__init__.py
courses Core Data¶
Course¶
The course master record, storing basic course information, teacher, class, course number, semester range, and raw import fields.
CourseOccurrence¶
A single class session instance, storing:
occurrence_dateclassroomsectionsschedule_keystatussource_typeremark
At runtime, CourseOccurrence serves as the source of truth for scheduled classes; the system no longer derives actual classes from an independent periodic schedule table.
Query Model¶
CourseViewSetis a read-only ViewSet.Supported filters:
teacher_idclass_namestart_dateend_date
Queries prefetch occurrences with
status in (scheduled, rescheduled).When a date range is provided:
The course set only includes courses that have occurrences within the range.
sessionsare also trimmed accordingly.
Import, Export & Template¶
Import Template¶
Entry:
GET /courses/import-templatesuperadmin/secretaryonly.The template is dynamically generated by the backend.
Excel Import¶
Entry:
POST /courses/importsuperadmin/secretaryonly.File format:
.xlsx/.xls, max 50MB.Business rules are governed by
CourseImportService; the current implementation retains the following key constraints:Import must include
semester_start_date.Records where the administrative class column (
行政班) containsUCare imported directly.Other records are only imported for the 2nd and 3rd floors of Building 5.
Physical education courses have a special branch.
When the number of successfully processed records is greater than 0,
semester_start_dateis written back toSystemConfig.
Export¶
Entry:
GET /courses/exportsuperadmin/secretaryonly.Export data re-aggregates occurrences by pattern for generating an Excel weekly view.
Rescheduling¶
Entry:
POST /courses/sessions/{session_id}/reschedulePermissions:
The current course teacher
superadminsecretaryassistant
The current implementation requires the new time range to fully match a standard class period; cross-day rescheduling is not supported.
The rescheduling date must fall within the course’s
start_datetoend_date.
Seasonal Schedules¶
Class period times are not hardcoded in models; they are dynamically resolved by
SeasonConfigService.At runtime, the system switches between winter and summer schedules based on
SystemConfig.season.Changing the season setting clears the course time cache.
courses and Other Modules¶
classrooms.scheduleandsignage.scheduleboth depend on expanded course instance results.borrowingscourse conflict detection depends on course instances.checkinsusesCourseOccurrenceto create check-in sessions.