Skip to content

Add Assigned Exam feature - #154

Merged
kristofer merged 3 commits into
mainfrom
copilot/add-exam-feature
Jun 8, 2026
Merged

kristofer merged 3 commits into
mainfrom
copilot/add-exam-feature

Conversation

Copilot AI commented Jun 8, 2026 •

Copy link
Copy Markdown

Transforms the unused Assigned Quizzes concept into a fully functional Assigned Exam system. Admins generate named exams of N random questions (default 30) filtered by category and difficulty level (1/2/3), assign them to students via a unique URL, and view per-student scores in a results table. Students take exams via token URL with live progress tracking and a per-question score breakdown on completion.

Backend

  • Migration (006_assigned_exams): three new tables — exams, exam_assignments, exam_attempts
  • Models: Exam, ExamAssignment, ExamAttempt, ExamStudentResult, ExamStatus, ExamInfo (with AccessToken field for student URL generation)
  • ExamRepository interface added to Database; implemented by both SQLiteDB and InMemoryDB
  • API handlers (api/exam.go): GenerateExam, ListExams, AssignToStudents, GetStatus, GetAssignedExams, StartExam, SubmitExam, GetCategories
  • Routes: student (/assigned-exams, /exam/start, /exam/submit) and instructor (/instructor/exams/...)

Exam generation builds a dynamic SQL query filtering questions by topic category join and difficulty range mapping (Level 1 → easy, Level 2 → medium, Level 3 → hard), then randomly selects up to the requested count:

// difficultyRanges maps UI levels 1/2/3 to DB difficulty column ranges
func difficultyRanges(levels []int) (min, max int) { ... }

Answer order is randomized per attempt via math/rand.Shuffle (auto-seeded in Go 1.20+). Grading computes score as (correct / total) * 100 and stores per-question correctness in question_results map[string]bool.

Frontend

  • instructor.html: new "Assigned Exams" section — generate form (name + dynamic category checkboxes + difficulty checkboxes + question count), assign form (exam dropdown + student list + URL copy), status table with per-exam "View Scores" drill-down showing each student's completion and score
  • dashboard.html / dashboard.js: "Assigned Exams" button with pending-count badge; collapsible list with Start/Retake per exam
  • exam.html (new): token-based student exam page — requires login, loads questions via POST /exam/start, shows all questions with shuffled radio-button answers and a live progress bar, submits via POST /exam/submit, renders score with pass/warn/fail coloring and per-question ✅/❌ breakdown

Copilot AI linked an issue Jun 8, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add new exam feature for assigned quizzes Add Assigned Exam feature Jun 8, 2026
Copilot AI requested a review from kristofer June 8, 2026 14:39
@kristofer
kristofer marked this pull request as ready for review June 8, 2026 21:29
@kristofer
kristofer merged commit 9a4cc64 into main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need a new "exam" feature.

2 participants