questions.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from typing import List, Optional
  4. from pydantic import Field
  5. from pydantic.main import BaseModel
  6. from schemas.base import ListMixin, Datetime2Str, DetailMixin
  7. class QuestionInfo(BaseModel):
  8. id: Optional[int] = None
  9. pid: Optional[int] = None
  10. pno: str = Field(..., description="试卷编号")
  11. qno: str = Field(..., description="题号")
  12. sqno: str = Field(..., description="子题号")
  13. qtype: Optional[int] = None
  14. points: str = Field(..., description="试题标准点坐标")
  15. imgs: Optional[str] = None
  16. stuff_points: Optional[str] = None
  17. stuff_imgs: Optional[str] = None
  18. answer: Optional[str] = None
  19. analysis: Optional[str] = None
  20. score: Optional[float] = None
  21. stem: Optional[str] = None
  22. creator_name: Optional[str] = None
  23. created_at: Datetime2Str = None
  24. class Config:
  25. orm_mode = True
  26. anystr_strip_whitespace = True
  27. class QuestionList(ListMixin):
  28. data: List[QuestionInfo] = []
  29. class QuestionDetail(DetailMixin):
  30. data: Optional[QuestionInfo] = {}
  31. class Point(BaseModel):
  32. x: Optional[float] = None
  33. y: Optional[float] = None
  34. w: Optional[float] = None
  35. h: Optional[float] = None
  36. class QuestionPieceInfo(BaseModel):
  37. id: Optional[int] = None
  38. page: Optional[int] = None
  39. qno: str = Field(..., description="题号")
  40. sqno: str = Field(..., description="子题号")
  41. imgtype: Optional[int] = None
  42. points: List[Point] = None
  43. imgs: List[str] = []
  44. class SaveQuePieceInfo(BaseModel):
  45. id: Optional[int] = None
  46. pid: Optional[int] = None
  47. pno: Optional[str] = None
  48. ques: List[QuestionPieceInfo] = None