diff --git a/backend/app/api/v1/exam.py b/backend/app/api/v1/exam.py index 442b6d3..032411d 100644 --- a/backend/app/api/v1/exam.py +++ b/backend/app/api/v1/exam.py @@ -260,20 +260,6 @@ async def get_mistakes( ) -@router.get("/{exam_id}", response_model=ResponseModel[ExamDetailResponse]) -async def get_exam_detail( - exam_id: int, - db: AsyncSession = Depends(get_db), - current_user: User = Depends(get_current_user), -): - """获取考试详情""" - exam_data = await ExamService.get_exam_detail( - db=db, user_id=current_user.id, exam_id=exam_id - ) - - return ResponseModel(code=200, data=ExamDetailResponse(**exam_data), message="获取成功") - - @router.get("/records", response_model=ResponseModel[dict]) async def get_exam_records( page: int = Query(1, ge=1), @@ -304,6 +290,21 @@ async def get_exam_statistics( return ResponseModel(code=200, data=stats, message="获取成功") +# 注意:动态路由 /{exam_id} 必须放在固定路由之后 +@router.get("/{exam_id}", response_model=ResponseModel[ExamDetailResponse]) +async def get_exam_detail( + exam_id: int, + db: AsyncSession = Depends(get_db), + current_user: User = Depends(get_current_user), +): + """获取考试详情""" + exam_data = await ExamService.get_exam_detail( + db=db, user_id=current_user.id, exam_id=exam_id + ) + + return ResponseModel(code=200, data=ExamDetailResponse(**exam_data), message="获取成功") + + # ==================== 试题生成接口 ==================== @router.post("/generate", response_model=ResponseModel[GenerateExamResponse]) diff --git a/backend/app/schemas/exam.py b/backend/app/schemas/exam.py index 92aeb9d..6b0c8c4 100644 --- a/backend/app/schemas/exam.py +++ b/backend/app/schemas/exam.py @@ -244,7 +244,7 @@ class RecentExamItem(BaseModel): total_score: float = Field(..., description="总分") is_passed: Optional[bool] = Field(None, description="是否通过") duration_seconds: Optional[int] = Field(None, description="考试用时(秒)") - start_time: str = Field(..., description="开始时间") + start_time: Optional[str] = Field(None, description="开始时间") end_time: Optional[str] = Field(None, description="结束时间") round_scores: RoundScores = Field(..., description="三轮得分")