Skip to main content

Grading Page

Route: /dashboard/classes/[classId]/grading
File: app/dashboard/classes/[classId]/grading/page.tsx

The grading page is where teachers enter and manage student grades. It provides a spreadsheet-like interface for recording scores per assessment.

Page Layout

Selectors

Two dropdowns at the top:

SelectorSourceNotes
TermGET /api/terms?yearId=<id>Terms for the class's academic year
SubjectGET /api/classes/:id/my-subjectsFiltered by teacher role - class teachers see all, subject teachers see only their assigned subjects

When both are selected, assessments for that term + subject combination are loaded.

Assessment Cards

Displays assessments as horizontal selectable cards:

ElementDescription
TitleAssessment name (e.g., "Mid-term Exam")
Type badgeExam or Coursework
Max scoree.g., "/100"

Assessment Actions (top-right icons):

  • Exclude/Include toggle - excludes the assessment from grade calculations
  • Edit - opens edit dialog
  • Delete - confirmation dialog with cascade warning

Create Assessment

A dialog form with:

FieldRequiredDescription
TitleYesAssessment name
TypeYesExam or Coursework
Assessment DateNoDate of the assessment
Max ScoreYesMaximum possible score (default: 100)
WeightNoWeight within its type category
Sort OrderNoDisplay ordering

Grade Entry Table

When an assessment is selected, a table appears showing all students assigned to the selected subject:

ColumnDescription
StudentFull name
ScoreEditable number input, capped to max score
RemarksOptional text input
ExcludeToggle button per student grade

Score Clamping

Scores are clamped client-side:

  • Negative values → 0
  • Values above max score → max_score

No error toast is shown - the value is silently adjusted.

Bulk Save

The Save All Grades button collects all entered scores and sends them as a single POST /api/grades/bulk request. This uses upsert behavior, so:

  • New grades are created
  • Existing grades are updated
  • Empty score fields are skipped

Grade Exclusion

Each student's grade has an exclude toggle (eye icon). When excluded:

  • The grade is marked with is_excluded = true
  • It is skipped in all grade calculations
  • An optional exclusion reason can be provided

Student Filtering

The table only shows students who are assigned to the selected subject (student_subject_profile exists). This is achieved by passing ?subjectId=<id> to the enrolled students endpoint.

When the subject selector changes, the student list refreshes automatically.

API Calls

ActionEndpoint
Class infoGET /api/classes
My subjectsGET /api/classes/:id/my-subjects
TermsGET /api/terms?yearId=<id>
List assessmentsGET /api/assessments?termId=&subjectId=
Create assessmentPOST /api/assessments
Update assessmentPATCH /api/assessments/:id
Exclude assessmentPATCH /api/assessments/:id/exclude
Delete assessmentDELETE /api/assessments/:id
List gradesGET /api/grades?assessmentId=<id>
Save grades (bulk)POST /api/grades/bulk
Exclude gradePATCH /api/grades/:id/exclude
Enrolled studentsGET /api/classes/:id/students?subjectId=<id>