Course Creation
This page documents the real course creation flow in ILS, based on the current ILS-dev source. It describes the frontend steps, the API call, and the backend handler that persists the new course.
Entry point
- Frontend route:
/admin/courses - File:
ILS-dev/frontend/src/pages/CoursesPage.jsx - Navigation in
ILS-dev/frontend/src/App.jsxdefines the route: admin/courses→CoursesPageadmin/courses/new→CourseForm
Step-by-step flow
- The user opens the admin course bank page.
CoursesPage.jsxloads the existing course list fromGET /api/courses.-
The page renders a
+ New Coursebutton linking to/admin/courses/new. -
The user clicks
+ New Course. - React Router navigates to
/admin/courses/new. -
App.jsxmaps that route toILS-dev/frontend/src/pages/CourseForm.jsx. -
CourseForm.jsxrenders the course editor form. - Fields shown include:
- Full Name
- Short Code / Identifier
- Level
- Duration
- Description
- Course Color
- Status (
draft,published,archived) - Enrollment Type (
Open Enrollment,Invite Only) - Total Credits (ECTS)
- Partner Institutions (checkboxes, loaded from
/api/institutions)
-
File:
ILS-dev/frontend/src/pages/CourseForm.jsx -
The user fills in the course details and submits the form.
- The form submit handler is
save()inCourseForm.jsx. - It builds a payload object with the entered values.
- It calls
fetchApi('/courses', { method: 'POST', ... })for a new course. -
File:
ILS-dev/frontend/src/lib/api.jsdefinesfetchApi()and prefixes requests with/api. -
The frontend sends a POST request to the backend.
- Actual request path:
POST /api/courses - Payload keys include:
titledescriptioncodeshort_codedurationleveltotal_creditsstatusenrollment_typeprimary_colorinstitutionIdsdefault_teaching_method_iddefault_assessment_type_id
-
File:
ILS-dev/frontend/src/pages/CourseForm.jsx -
The backend receives
POST /api/courses. - Route file:
ILS-dev/backend/routes/course.js - The route handler checks for
req.models.Course. - It requires
payload.title; if missing, it returns400withtitle is required. - It calls
models.Course.create(payload)to persist the new course. - On success, it returns
201with the created course object. -
On database errors, it returns a structured error response.
-
The frontend handles the backend response.
CourseForm.jsxreads the JSON response and updates the form state.- For a new course, it navigates to the newly created course detail view (
/admin/courses/:id). - For an existing course, it sets a saved confirmation state and keeps the user on the form.
- If the response fails, the page displays a save error message.
Trigger chain
- UI event: click
+ New Course→ navigate to/admin/courses/new - UI event: submit form →
CourseForm.jsxsave() - API call:
POST /api/courses - Backend action:
models.Course.create(payload)inbackend/routes/course.js - DB persistence: Sequelize creates a new
Courserow - UI reaction: success alert, redirect to
/admin/courses
Important implementation notes
- The frontend always uses
fetchApi()fromILS-dev/frontend/src/lib/api.js, which prefixes paths with/api. - The backend route is mounted under
/api/coursesinILS-dev/backend/index.js. CourseForm.jsxalso loads institutions fromGET /api/institutionsto support the partner institution checkbox list.- There is no explicit course creation helper outside the admin flow; the route is driven entirely by
CoursesPage.jsxandCourseForm.jsx.
Missing or unclear items
- The backend
course.jsroute file implementsGET /,POST /,GET /:id,PUT /:id, andDELETE /:id, so course editing and soft delete are supported by the current API. - The form loads partner institutions from
GET /api/institutions, but the exact institution-course linking semantics are handled by the backend and may depend on the current institution records.
Last updated: 2026-07-08