Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(M4): auto-create initial repetition state when missing in submit_answer

unknown95ce77c721be
diff --git a/deeptutor/api/routers/guided_learning.py b/deeptutor/api/routers/guided_learning.py
index fa10a3383..7017d42a8 100644
--- a/deeptutor/api/routers/guided_learning.py
+++ b/deeptutor/api/routers/guided_learning.py
@@ -83,9 +83,12 @@ async def submit_answer(book_id: str, body: AnswerRequest):
kp_type = progress.knowledge_types.get(attempt.knowledge_point_id)
if kp_type is not None:
state = progress.repetition_states.get(attempt.knowledge_point_id)
- if state is not None:
- scheduler.schedule_next(state, kp_type, attempt.is_correct)
- progress.review_queue = scheduler.build_review_queue(progress)
+ if state is None:
+ # Auto-create initial repetition state for new knowledge points
+ state = scheduler.get_initial_state(kp_type)
+ progress.repetition_states[attempt.knowledge_point_id] = state
+ scheduler.schedule_next(state, kp_type, attempt.is_correct)
+ progress.review_queue = scheduler.build_review_queue(progress)
# Update mastery estimate
if attempt.mastery_estimate > 0: