refactor: improve quiz reliability and maintainability for a smoother learner experience - #1946
Merged
Merged
Conversation
its-gabo
marked this pull request as ready for review
September 2, 2026 13:05
This was referenced Sep 4, 2026
Japrolol
approved these changes
Sep 10, 2026
Japrolol
left a comment
Collaborator
There was a problem hiding this comment.
A little feedback, but overall good enough for merge
| lessonId: assessments.lessonId, | ||
| type: assessmentQuestions.questionType, | ||
| prompt: sql<LocalizedText>`${assessmentQuestions.prompt}`, | ||
| title: sql<LocalizedText | null>`${assessmentQuestions.title}`, |
Collaborator
There was a problem hiding this comment.
maybe we should type it directly in schema
| .select({ | ||
| id: assessmentQuestionChoiceOptions.id, | ||
| questionId: assessmentQuestionChoiceOptions.questionId, | ||
| optionText: sql<LocalizedText>`JSONB_BUILD_OBJECT( |
Collaborator
There was a problem hiding this comment.
cant we use our util for this
| target: assessmentQuestionBlanks.id, | ||
| set: { | ||
| questionId: values.questionId, | ||
| textComparisonMode: values.textComparisonMode as never, |
|
|
||
| if (!correctAnswers.length) return undefined; | ||
|
|
||
| return `Correct answer: ${correctAnswers.join(", ")}`; |
| return assessment ?? null; | ||
| } | ||
|
|
||
| async getQuizLessonForAuthoring( |
Collaborator
There was a problem hiding this comment.
Too much logic in repository
| return assessment; | ||
| } | ||
|
|
||
| private async insertAssessmentQuestions( |
Collaborator
There was a problem hiding this comment.
Also too much logic for repository
| } | ||
| } | ||
|
|
||
| private async replaceQuestionConfiguration( |
Collaborator
There was a problem hiding this comment.
Most of this code should be extracted to service.
Collaborator
There was a problem hiding this comment.
I believe there is too much logic here too, I prefer db operations in service to logic in repository
| .filter((answer): answer is string => Boolean(answer)), | ||
| ]; | ||
|
|
||
| return correctAnswers.length ? `Correct answer: ${correctAnswers.join(", ")}` : null; |
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.
Issue(s)
Overview
Refactors quizzes onto the new assessment-based data model while preserving the existing API contracts.
This change includes:
<blank-answer-{uuid}>markers.Business Value
Provides a semantically clearer and more maintainable foundation for quiz authoring, delivery, evaluation, localization, course sharing, and future quiz-engine versioning without requiring an immediate API contract migration.
It also keeps quiz behavior consistent across copied/shared courses and makes multilingual quiz content easier to manage.