mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 18:11:23 +08:00
fix(sessions): leave pending answers out of the quiz score
The [Quiz Performance] score counts only graded answers and states how many are not graded yet, instead of counting a pending photo answer as wrong. Refresh the router index for the router changes in this series. Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"fingerprint": "fa4a06aa1f5f2711229588b6eaba8bb307d90fe90a0dc31f19876cc900f1f7de",
|
||||
"fingerprint": "c0ca823892e8dce785b3b8518761ecf4f960cfaf38da2dda9b1112230ea06a1d",
|
||||
"routers": {
|
||||
"deeptutor.api.routers.auth:router": [
|
||||
{
|
||||
|
||||
@@ -147,8 +147,10 @@ class QuizResultsRequest(BaseModel):
|
||||
|
||||
|
||||
def _format_quiz_results_message(answers: list[QuizResultItem]) -> str:
|
||||
total = len(answers)
|
||||
correct = sum(1 for item in answers if item.is_correct)
|
||||
# A pending (ungraded) answer is neither right nor wrong in the score.
|
||||
ungraded = sum(1 for item in answers if item.result == "ungraded")
|
||||
total = len(answers) - ungraded
|
||||
correct = sum(1 for item in answers if item.is_correct and item.result != "ungraded")
|
||||
score_pct = round((correct / total) * 100) if total else 0
|
||||
lines = ["[Quiz Performance]"]
|
||||
for idx, item in enumerate(answers, 1):
|
||||
@@ -163,7 +165,8 @@ def _format_quiz_results_message(answers: list[QuizResultItem]) -> str:
|
||||
suffix = f" ({status}, correct: {(item.correct_answer or '').strip()})"
|
||||
qid = f"[{item.question_id}] " if item.question_id else ""
|
||||
lines.append(f"{idx}. {qid}Q: {question} -> Answered: {user_answer}{suffix}")
|
||||
lines.append(f"Score: {correct}/{total} ({score_pct}%)")
|
||||
pending = f", {ungraded} not graded" if ungraded else ""
|
||||
lines.append(f"Score: {correct}/{total} ({score_pct}%){pending}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
|
||||
@@ -618,6 +618,8 @@ def test_quiz_results_keep_a_judged_result(store: SQLiteSessionStore) -> None:
|
||||
in resp.json()["content"]
|
||||
)
|
||||
assert "(Partially correct" in resp.json()["content"]
|
||||
# A pending photo answer is neither right nor wrong in the score.
|
||||
assert resp.json()["content"].endswith("Score: 0/1 (0%), 1 not graded")
|
||||
items = client.get("/api/question-notebook/entries").json()["items"]
|
||||
|
||||
by_id = {item["question_id"]: item for item in items}
|
||||
|
||||
Reference in New Issue
Block a user