test(quiz): first unit coverage for the answer submission flow#86
Open
tongshu2023 wants to merge 1 commit into
Open
test(quiz): first unit coverage for the answer submission flow#86tongshu2023 wants to merge 1 commit into
tongshu2023 wants to merge 1 commit into
Conversation
…z456#32) submit_answer handles grading, LLM error classification, wrong-answer records, mastery updates, and background diagnostics, but had zero tests. These call the endpoint function directly against real in-memory SQLite (auth bypassed by passing the user; the LLM-backed classifier mocked for determinism). tests/test_quiz_submission.py (9 tests): - correct submission returns the proper grade with explanation, persists a correct PracticeResult, and creates no WrongAnswer record - grading is case- and whitespace-insensitive - an incorrect answer triggers error classification: the category lands on both the PracticeResult and the WrongAnswer record - classifier failure degrades gracefully with the error_classification_failed warning while still persisting the result - wrong answers schedule both background diagnostics (auto-derive + confusion detection); correct answers schedule the effective-review check - unknown problem id raises NotFoundError - a problem in another user's course is invisible (ownership join) - knowledge-pointed problems update LOOM ConceptMastery (real BKT path, not a mock): practice/correct counters and a positive mastery score Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Closes #32.
submit_answerhandles grading, LLM error classification, wrong-answer records, LOOM mastery updates, and background diagnostics — and had zero tests. This adds the first unit coverage, calling the endpoint function directly against a real in-memory SQLite database (auth dependency bypassed by passing the user object; the LLM-backed classifier mocked for determinism — no real API calls).Tests
tests/test_quiz_submission.py— 9 tests:Happy path
PracticeResult, and creates noWrongAnswerrecordWrong answers
PracticeResultand theWrongAnswerrecorderror_classification_failedwarning while still persisting the submissionError cases
NotFoundErrorMastery
ConceptMasterythrough the real BKT path (not a mock): practice/correct counters increment and the mastery score becomes positiveResults
pytest tests/test_quiz_submission.py -v: 9 passed locally.Acceptance criteria
pytest tests/test_quiz_submission.py -v🤖 Generated with Claude Code