feat: course prerequisites, announcements, admin dashboard, course import - #450
Merged
Conversation
…port ChainLearnOfficial#354 — GET /api/v1/courses/:id/prerequisites - courses.prerequisites: jsonb string[] column (migration 0020), admin-configurable via existing POST/PUT /admin/courses (self-reference filtered out on update) - CourseService.getCoursePrerequisites(): resolves configured prerequisite courses, annotates each with the caller's completion status (enrollments.completedAt IS NOT NULL), returns an overall met flag. Anonymous callers see every prerequisite as incomplete. ChainLearnOfficial#353 — POST/GET/PUT/DELETE /api/v1/admin/announcements + GET /api/v1/announcements - New announcements table (migration 0021): title, message, priority (normal/high/urgent), active, createdAt, expiresAt - New module (src/modules/announcements/): full admin CRUD (authGuard+adminGuard) plus a public GET that filters to active && (no expiry || expiry in the future) ChainLearnOfficial#367 — GET /api/v1/admin/dashboard - New module (src/modules/admin/dashboard.*): total users, new users (today/week/month), total enrollments, quiz completion rate (graded / total submissions), total credentials, total rewards claimed (SUM(rewardAmount) where claimed), plus week-over-week trend comparisons for new users and enrollments. Cached 5 minutes via the existing cache/index.ts helpers. Admin only. ChainLearnOfficial#366 — POST /api/v1/admin/courses/import - Accepts multipart/form-data with one JSON file part (reuses the already-registered @fastify/multipart), validates against a Zod schema (core course fields + an optional modules array), creates the course via the existing createCourse() path, then creates each module via the existing createModule() so IDs/locking/audit/cache-invalidation all match a manually-created module. Returns { courseId, modulesCreated }. Note: the issue's literal route was /admin/courses/:id/import, but its own scope/acceptance-criteria describe creating a *new* course from the file ("creates the course... returns the created course ID") — a target :id doesn't fit that, so implemented as the collection-level /admin/courses/import instead. Flagged for review below. Also included: a standalone build fix (see PR ChainLearnOfficial#444) this branch is based on top of, since course.routes.ts (one of the files ChainLearnOfficial#354/ChainLearnOfficial#366 touch) had a syntax error blocking the whole build. Verification: npm run build (tsc) is clean. Did not add new automated tests for these four endpoints given time constraints — flagging that honestly rather than claiming coverage that isn't there. Existing courses/admin test suites still reference the same service methods these changes extend (createCourse, createModule, toAdminCourse), so a schema/behavior regression there would likely surface on the existing suite even without new tests, but the new logic itself (prerequisite resolution, announcement active-filtering, dashboard aggregates, import parsing) has no dedicated coverage yet. Closes ChainLearnOfficial#354 Closes ChainLearnOfficial#353 Closes ChainLearnOfficial#367 Closes ChainLearnOfficial#366
…mport-354-353-367-366
|
@codemagician1949 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This was referenced Sep 1, 2026
DeFiVC
pushed a commit
that referenced
this pull request
Sep 1, 2026
main currently fails to typecheck: PR #450 left two files with mangled code — a stray semicolon splitting the AuditEvent union type in half (silently dropping "webhook.*" from the union), and a duplicated/ garbled fragment inside CourseService.updateCourse (two overlapping function bodies spliced together). Neither is related to #328-331; both are one-off syntax repairs, not behavior changes. This does not fix every pre-existing error on main — course.service.ts, course.controller.ts, course.routes.ts, and admin-course.controller.ts still reference several missing schema tables (courseShares, courseReviews) and controller methods (recommended, resolveShare, batchEnroll, reviews, share, archiveCourse, publishCourse, duplicateCourse) from the same bad merge. That's a separate, larger repair this PR intentionally does not attempt — see the PR description.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Heads up: based on the build-fix branch
This branch is based on #444 (main currently fails to build — 3 syntax errors from a recent merge, unrelated to this batch). Until #444 merges, this PR's diff will also show those 3 files (
course.routes.ts,user.routes.ts,admin-users.service.ts) — that's the build fix, not this feature work. Once #444 merges and this branch is rebased/main is pulled in, that noise will disappear from the diff.#354 —
GET /api/v1/courses/:id/prerequisitescourses.prerequisites: newjsonb string[]column (migration 0020), admin-configurable via the existingPOST/PUT /admin/courses(a course can't be its own prerequisite — filtered on update).getCoursePrerequisites()resolves the configured prerequisite courses and annotates each with the caller's completion status (enrollments.completedAt IS NOT NULL), plus an overallmetflag. Anonymous callers see every prerequisite as incomplete.#353 — Announcements
announcementstable (migration 0021): title, message, priority (normal/high/urgent), active, createdAt, expiresAt.src/modules/announcements/): full admin CRUD (POST/GET/PUT/DELETE /admin/announcements, admin-guarded) plus a publicGET /announcementsfiltered toactive && (no expiry || expiry in the future).#367 —
GET /api/v1/admin/dashboardsrc/modules/admin/dashboard.*): total users, new users (today/week/month), total enrollments, quiz completion rate (graded ÷ total submissions), total credentials, total rewards claimed (SUM(rewardAmount)where claimed), plus week-over-week trend comparisons for new users and enrollments. Cached 5 minutes via the existingcache/index.tshelpers. Admin only.#366 — Course import
POST /api/v1/admin/courses/import— multipart/form-data with one JSON file part (reuses the already-registered@fastify/multipart), validated against a Zod schema (core course fields + an optionalmodulesarray), creates the course via the existingcreateCourse()path, then creates each module via the existingcreateModule()so IDs/locking/audit/cache-invalidation all match a manually-created module. Returns{ courseId, modulesCreated }.Deviation from the issue, flagging explicitly: the issue's literal route is
/admin/courses/:id/import, but its own scope and acceptance criteria describe creating a new course from the file ("creates the course... returns the created course ID") — a target:iddoesn't fit that (there's no existing course to import into). Implemented as the collection-level/admin/courses/importinstead, matching the actual described behavior. Happy to add a path param back if the real intent was importing additional content into an existing course — wasn't sure which was meant, said so rather than guessing silently.Verification
npm run build(tsc) is clean.tests/unit/courses/*.test.tspattern). The new logic (prerequisite resolution, announcement active-filtering, dashboard aggregates, import parsing) has no dedicated test coverage yet — worth adding before/as part of review.Closes #354
Closes #353
Closes #367
Closes #366