Session log — Course quiz (check at the end)
← All session logs
Session log — Course quiz (check at the end)
Summary
Designed and shipped a "check at the end of a course" feature on s2l.online. Each course can now have an optional short multiple-choice quiz, learners take it after marking the last lesson complete, results are scored automatically, and the admin gets a report by course and by learner. The simple "check" version, not a full graded exam.
Decisions
- Start with the simple "check at the end" model, not a full learning assessment (no question banks, no randomisation, no timers, no certificates).
- Each course can have the quiz on or off, with its own pass mark and a retake toggle. Some courses can have no quiz at all.
- Learners must already be signed in to take the quiz. Lessons require sign-in too, so no extra auth needed.
- Quiz lives at the same /learn/ page via a query parameter (?quiz=1), shown after the last lesson is marked complete.
- For V1, passing the quiz does not gate course completion. The quiz is a bonus check. Required-to-complete is a later decision.
- Quizzes English-only for now. Course translations exist; quiz translations do not.
- Implementation went inside the existing EP Courses plugin (matches the pattern Kenn uses on s2l), in a separate include file (
includes/class-ep-quiz.php) so the main plugin file does not balloon.
Changes made
- New file
class-ep-quiz.phpcontaining schema setup, data access, learner quiz rendering, admin quiz manager rendering, reports rendering, and AJAX handlers. - New JS
ep-courses-quiz.jsfor the quiz form submit, admin question editor, and report screens. - New CSS
ep-courses-quiz.cssfor both learner-facing and admin styling. Mobile-first, 44px tap targets on options. - Three new columns on
ep_courses:quiz_enabled,quiz_pass_mark,quiz_allow_retakes. - Two new tables:
ep_quiz_questions(id, course_id, question text, four options, correct letter, sort order) andep_quiz_attempts(id, user, course, score, total, percent, passed, answers JSON, attempted_at). - Patched
plugin.phpto require the new include, instantiate the quiz module in construct, register the new JS and CSS assets, exposequiz_csrf_token()as a public proxy, inject the "Take the check" button under the last lesson once completed, short-circuitrender_course_viewerfor?quiz=1to render the quiz page, add a "Quiz" button on each course row in the admin table, add a new "Quiz Reports" tab next to Courses / Enrolments / Activity, append the quiz manager and question editor HTML to the admin pane, and dispatch the new AJAX actions infetch(). - Local working copies live in
ep-courses-changes/for traceability. - Backup of the previous plugin.php taken on the server as
plugin.php.bak.20260523222527.preqz.
Follow-ups
- Hasmukh to try it: pick a course, tap Quiz, switch it on, add three or four questions, save. Then take it as a signed-in test learner.
- Decide whether any course should have a required quiz (pass to complete). If yes, add the gating logic next session.
- Decide whether the quiz button should also appear on the course landing page, not only after the last lesson. Today it only appears under the last lesson once that lesson is marked complete.
- Add quiz translations alongside the existing course/lesson translations system if multilingual quizzes are wanted.
- Smoke tested guest URLs after deploy (front page, courses listing, course landing, lesson viewer, lesson 1, ?quiz=1) — all 200, no new PHP errors. End-to-end test as an admin and as a learner is Hasmukh's next step.