Skip to content

Exam: reliable answer saving and schedules, exam/question editing, and a show-result option - #33

Merged
mfarim merged 3 commits into
mainfrom
feat/cbt-exam-improvements
Nov 28, 2026
Merged

mfarim merged 3 commits into
mainfrom
feat/cbt-exam-improvements

Conversation

@mfarim

@mfarim mfarim commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Problem

Several things could cost students their answers or lock a class out during a real exam, and some backend features had no screen:

  • A failed answer save was swallowed and the UI still said "Saved". Essays sent one request per keystroke, and the automatic submit at the fifth violation never fired.
  • Rate limits were keyed by IP, so a school lab behind one public address would be blocked.
  • The backend container ran in UTC while schedule times are naive local times (LocalDateTime), so exam windows and deadlines were evaluated 7 hours off for WIB.
  • An exam with an end time before its start, or a duration longer than its window, was accepted.
  • Admins could not create an exam (Teacher profile not found).
  • Exams and questions could not be edited after creation. short_answer, exam types, allowRetry and showResult existed in the backend but not in the UI, and showResult was never applied.

What changed

Exam room (student)

  • Answers go through a save queue (answerSaver.ts) with automatic retries. Unsaved answers stay visible and block submit; essays are saved after a typing pause.
  • Automatic submit at the fifth violation and at time-up now works and retries until the result arrives. The timer is computed from the deadline. No more alert() in the exam room.
  • Attempts waiting for essay grading (needs_grading) are shown as such instead of offering the exam again.

Exam management (teacher/admin)

  • Edit an exam after creation, schedule included (PUT /exams/{id}).
  • Edit questions (PUT /exams/{id}/questions/{questionId}), including the explanation field.
  • Short-answer questions in the editor and the exam room.
  • Exam type select aligned with the backend enum, an "allow retry" option, and a retry link for students.
  • Schedule validation on both sides: end after start, duration fits the window. The form shows the server's validation message.
  • Admins create an exam by choosing the teacher who owns it.

Show result

  • New "show the score to students" checkbox, on by default. With it off, the student only sees that the exam is finished; turning it on later releases the scores. The teacher's monitor is unchanged.

Platform

  • Authenticated requests are rate-limited per user instead of per IP; limits are configurable under app.rate-limit.*.
  • The backend runs in Asia/Jakarta by default (TZ / APP_TIMEZONE).

Behaviour and API changes

  • POST /exams/attempts/{attemptId}/submit adds resultHidden; score and passed are omitted when the exam hides results.
  • Student exam list: studentScore and studentPassed are null while results are hidden.
  • Student grade report: exams with hidden results are left out of averages and counts.
  • ExamDto: new optional teacherId (used when an admin creates the exam); durationMinutes must be at least 1 and passingScore between 0 and 100.

Deployment notes

  • Migration V6 sets show_result = TRUE on existing exams. The flag was never applied before, so this keeps current behaviour: students keep seeing their scores.
  • Time zone takes effect on deploy. Stored schedules and deadlines are then read as local time; historical timestamps written under UTC stay 7 hours behind. Deploy outside exam hours.
  • New optional env vars: APP_TIMEZONE (default Asia/Jakarta), APP_RATE_LIMIT_LOGIN_PER_IP (default 100), APP_RATE_LIMIT_AUTH_PER_IP (default 200).

Not in this PR

  • Essay grading screen for teachers.
  • Image and audio upload for questions.
  • Admins creating assignments and materials.

…e limits reliable

- Exam runner: answers go through a save queue with automatic retries. A failed
  save stays visible and blocks submit, essays are saved after a typing pause
  instead of on every keystroke, and the automatic submit at the fifth violation
  and when time runs out now works.
- Attempts waiting for essay grading are shown as such instead of offering the
  exam again.
- Schedules: reject an end time before the start time and a duration that does
  not fit in the window; the form shows the server's validation message.
- Admins can create an exam by choosing the teacher who owns it.
- Rate limiting: authenticated requests are limited per user instead of per IP
  and the per-IP login limit is configurable, so a school lab behind one public
  address is not locked out.
- Run the backend in Asia/Jakarta (TZ / APP_TIMEZONE) so schedule times entered
  as local time are read as local time.
…pes and retry option

- Exams can be edited after creation, schedule included (PUT /exams/{id}).
- Questions can be edited (PUT /exams/{id}/questions/{questionId}); the
  explanation field is available and attached image/audio paths are kept.
- Short-answer questions in the editor and in the exam room.
- Exam type select aligned with the backend enum (quiz, UTS, UAS, praktik,
  tryout), shown on the exam card.
- "Allow retry" option in the exam form and a retry link on the student card.
… exam

The show_result flag was stored but never applied: students always saw their
score. It now decides what a student sees.

- Exam form: "show the score to students" checkbox (on by default). Turning it
  on later releases the scores.
- With the setting off, the submit response, the student's exam list and the
  student's grade report no longer carry the score of that exam. The exam card
  and the result screen say the score has not been shared yet. The teacher's
  monitor is unchanged.
- V6 migration switches show_result on for existing exams so they keep showing
  scores as before; the demo seed does the same for the demo exams.
@mfarim mfarim self-assigned this Nov 28, 2026
@mfarim mfarim added the enhancement New feature or request label Nov 28, 2026
@mfarim
mfarim merged commit f505c6d into main Nov 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant