A practice test with nothing started draws all the material instead of refusing
Browse filesThe refusal replaced the whole page, so the test card's bypass buttons were
never in reach (and the home page links straight to the practice test).
Now the server falls back to the simulation's draw over every skill of the
test's lessons; the refusal stays only when those lessons have no questions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Files changed (2)
317 unmodified lines318319320321322323317 unmodified linesreturn view(request, row)drawn = exam.draw(bank, test["lessons"], facts["states"], test["questions"], share=share, weak_before=facts["weak_before"], used=facts["used"],include_unstarted=include_unstarted)if not drawn["questions"]:raise HTTPException(409, "注讜讚 诇讗 讛转讞诇转诐 诪讬讜诪谞讜讬讜转 讘砖讬注讜专讬诐 砖诇 讛诪讘讞谉. 拽讜讚诐 诪转专讙诇讬诐 讘诪住诇讜诇.")row = store.create_attempt(user["id"], kind, scope, now, now + timedelta(minutes=test["minutes"]), drawn["questions"])317 unmodified lines318319320321322323324325326317 unmodified linesreturn view(request, row)drawn = exam.draw(bank, test["lessons"], facts["states"], test["questions"], share=share, weak_before=facts["weak_before"], used=facts["used"],include_unstarted=include_unstarted)if not drawn["questions"] and kind == "exercise_test" and not include_unstarted: # nothing started yet: all the material, like the simulationdrawn = exam.draw(bank, test["lessons"], facts["states"], test["questions"], share=0.0, weak_before=facts["weak_before"],used=facts["used"], include_unstarted=True)if not drawn["questions"]:raise HTTPException(409, "注讜讚 诇讗 讛转讞诇转诐 诪讬讜诪谞讜讬讜转 讘砖讬注讜专讬诐 砖诇 讛诪讘讞谉. 拽讜讚诐 诪转专讙诇讬诐 讘诪住诇讜诇.")row = store.create_attempt(user["id"], kind, scope, now, now + timedelta(minutes=test["minutes"]), drawn["questions"])
335 unmodified lines336337338339340341342343344345335 unmodified linesassert result["lost_skills"] and all(s["id"] and s["name"] for s in result["lost_skills"]) and '"correct"' not in json.dumps(result)def test_an_exercise_test_with_nothing_started_is_refused_and_a_weak_skill_is_remembered(world):client, store, lessons = worldtest = set_test(client, lessons, days=14).json()assert start_ex(client, test["id"]).status_code == 409assert start_ex(client, test["id"], 3).status_code == 404335 unmodified lines336337338339340341342343344345346335 unmodified linesassert result["lost_skills"] and all(s["id"] and s["name"] for s in result["lost_skills"]) and '"correct"' not in json.dumps(result)def test_an_exercise_test_with_nothing_started_draws_all_the_material_and_a_weak_skill_is_remembered(world):client, store, lessons = worldtest = set_test(client, lessons, days=14, questions=6).json()got = start_ex(client, test["id"])assert got.status_code == 200 and len(got.json()["questions"]) == 6 # not refused: drawn like the simulationassert start_ex(client, test["id"], 3).status_code == 404
mathly2/realtests.py+3
mathly2/tests/test_realtests_api.py+4-3