# ACVE Task Implementation ## Scope - Add 3 mini-games with persisted scoring and profile grading. - Add deterministic study recommendations from user profile/progress. - Auto-issue completion certificates and support PDF download. - Add enrolled-courses view (`/my-courses`). - Show `Continue` instead of `Start Course` when user is enrolled. - Update case studies with Andres source content (`case_studies.txt`). ## Implemented Items ## 1. Mini-games + profile grade - Expanded interactive modules to 3 in `lib/data/mockPractice.ts`. - Added DB persistence for attempts via: - `app/(protected)/practice/[slug]/actions.ts` - `submitPracticeAttempt` - `getPracticeAttempts` - Replaced localStorage attempt history in `app/(protected)/practice/[slug]/page.tsx`. - Added profile grade computation in `lib/recommendations.ts#getMiniGameGrade`. ## 2. Recommendations - Added deterministic recommendation engine in `lib/recommendations.ts`: - `refreshStudyRecommendations` - `getActiveRecommendations` - Recommendations refresh after: - mini-game submission - lesson completion toggle - Recommendations are displayed on `/profile`. ## 3. Certificates + PDF - Added certificate issuance utility in `lib/certificates.ts`: - `issueCertificateIfEligible` - `buildCertificatePdf` - Hooked issuance after lesson completion in: - `app/(protected)/courses/[slug]/learn/actions.ts` - Added PDF endpoint: - `app/api/certificates/[id]/pdf/route.ts` ## 4. Enrolled courses view - Added protected page: - `app/(protected)/my-courses/page.tsx` - Displays enrolled courses, progress, continue/review CTA, and certificate download CTA. ## 5. Start vs Continue - Updated course detail CTA in: - `app/(public)/courses/[slug]/page.tsx` - Logic: - enrolled user => `Continue` - not enrolled => `Start Course` - unauthenticated => `Login to start` ## 6. Case studies update - Expanded case-study type model: - `types/caseStudy.ts` - Replaced mock cases with: - Marbury v. Madison - Miranda v. Arizona - Brown v. Board of Education - Updated pages to render: - resumen - terminos juridicos con definiciones - resultado juridico - "Ponte a prueba" - Files: - `lib/data/mockCaseStudies.ts` - `app/(public)/case-studies/page.tsx` - `app/(public)/case-studies/[slug]/page.tsx` ## Navigation updates - Added authenticated links in navbar: - `/my-courses` - `/profile` - File: - `components/Navbar.tsx` ## Prisma changes (schema) - Updated `prisma/schema.prisma` with: - `MiniGame`, `MiniGameQuestion`, `MiniGameAttempt`, `StudyRecommendation` - `Certificate.certificateNumber`, `Certificate.pdfVersion` - `@@unique([userId, courseId])` on `Certificate` - Updated `prisma/seed.ts` to seed 3 mini-games + questions. ## Validation - Ran: `npm run lint` (passes; one pre-existing warning remains in `lib/auth/requireTeacher.ts`). ## Required follow-up (environment) - Prisma client generation failed in this environment due Node runtime mismatch (`Node v18`, project expects `>=24`). - Before production use of new DB-backed features, run: 1. Node 24+ runtime 2. `npx prisma generate` 3. apply migration for schema updates