fix(lms): Gate course completion and certificates on graded assignments#1162
Open
jeromehardaway wants to merge 1 commit into
Open
fix(lms): Gate course completion and certificates on graded assignments#1162jeromehardaway wants to merge 1 commit into
jeromehardaway wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
POST /api/lms/progresscomputed course completion from lesson progress alone (completedLessons / totalLessons). At 100% it marked the enrollmentCOMPLETEDand auto-generated + emailed a verifiable certificate without ever consulting theAssignment/Submissionmodels — a learner could earn a certificate without submitting any graded work.Solution
GRADEDsubmissions (one query via a filteredsubmissionsrelation select). All assignments of a course are treated as required.COMPLETEDenrollment transition and the certificate generation/email path only run when every assignment has aGRADEDsubmission. Courses with zero assignments keep current behavior.progressPercentage(the progress bar value) is unchanged; only the completion transition gains the gate.courseProgress.pendingAssignments(count+titles) so the UI can display what remains.@swaggerblock for the route (it previously had only a plain JSDoc comment).Verification
npx vitest run __tests__/pages/api/lms/progress.test.ts— 5 new tests pass: ungraded assignment blocks completion/certificate, non-GRADED submission blocks, all-GRADED completes and issues certificate, zero-assignment course keeps current behavior, below-100% lessons never query assignments.npm test— 42 files / 389 tests pass.npm run typecheck— 7 pre-existing errors in unrelated__tests__/pages/api/j0di3/*files; identical count on clean master, zero introduced by this change.npm run lint— 20 pre-existing findings, identical count on clean master; both changed files are clean apart from pre-existinganyannotations in untouched route code.npm run build— compiles;/api/lms/progressbuilds and the generated swagger spec picks up the new annotation (regeneratedpublic/swagger-spec.jsonnot committed, matching existing practice).Follow-up
POST /api/lms/progressresponse (courseProgressis referenced nowhere outside the route), so no UI wiring was done;pendingAssignmentsis ready for whichever component adopts it.COMPLETEDon their next progress update rather than at grading time. Worth a separate issue if certificates should issue immediately upon final grading.Closes #1149