## Context Learn now supports secure learner-side quiz question retrieval. The next step towards a complete learner quiz workflow is allowing authorised learners to start a quiz and persist their attempts. This will also establish the database foundation needed for the GSoC 2027 Offline-First Learning project. ## Proposed Changes - Introduce a database table to store learner quiz attempts. - Add an authenticated API endpoint to initiate a quiz attempt. - Associate each attempt with the correct quiz, activity and learner. - Store an attempt ID, status and creation timestamp. - Validate quiz existence and active learner enrollment. - Generate the learner identity on the server using the authenticated session. - Return the newly created attempt details. ## Acceptance Criteria - [ ] Authenticated and enrolled learners can start quiz attempts. - [ ] Unauthenticated requests return 401. - [ ] Unenrolled learners cannot create attempts. - [ ] Attempt records are persisted in D1. - [ ] Each attempt is associated with the correct learner and quiz. - [ ] Learners cannot create attempts on behalf of other users. - [ ] Existing quiz functionality remains unaffected. - [ ] Relevant automated tests pass. ## Scope This issue covers attempt creation and persistence only. Answer saving, quiz submission, grading, attempt history UI, IndexedDB and offline synchronisation are out of scope. ## Relevant Files - `learn/src/worker.py` - `learn/schema.sql` - `learn/migrations/` - `learn/tests/test_quizzes.py` Reuse the existing authentication, enrollment and database patterns. Please discuss any attempt lifecycle or database design considerations before implementation.
Activity