marktask.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 NewMarkTask(BaseModel):
  8. mtype: str = Field(..., description="任务类型,work / exam")
  9. pid: Optional[int] = Field(..., description="试卷ID")
  10. school_id: int = Field(..., alias="sid", description="学校ID")
  11. grade_id: int = Field(..., alias="gid", description="年级ID")
  12. class_id: int = Field(..., alias="cid", description="班级ID")
  13. category_id: Optional[int] = Field(..., alias="ctgid", description="分类ID")
  14. name: Optional[str] = Field(..., description="试卷名称")
  15. #uploaded_amount: int = Field(0, alias="upload", description="上传数量")
  16. #status: int = Field(0, description="状态")
  17. class MarkTaskInDB(NewMarkTask):
  18. name: str
  19. pno: str
  20. pname: str
  21. school_id: int
  22. school_name: str
  23. grade_id: int
  24. grade_name: str
  25. class_id: int
  26. class_name: str
  27. category_id: int
  28. student_amount: int
  29. creator_id: int
  30. creator_name: str
  31. year: int
  32. class MarkTaskItem(BaseModel):
  33. id: int
  34. name: str
  35. score: int
  36. high_score: float
  37. avg_score: float
  38. pass_rate: float
  39. marked_amount: int
  40. student_amount: int
  41. uploaded_amount: int
  42. updated_at: Datetime2Str
  43. class Config:
  44. orm_mode = True
  45. class MarkTaskList(ListMixin):
  46. data: List[MarkTaskItem] = []
  47. class MarkTaskDetail(DetailMixin):
  48. data: Optional[MarkTaskItem] = {}
  49. class UpdateMarkTaskInfo(BaseModel):
  50. name: Optional[str] = None
  51. pid: Optional[int] = None
  52. school_id: Optional[int] = Field(None, alias="sid", description="学校ID")
  53. grade_id: Optional[int] = Field(None, alias="gid", description="年级ID")
  54. class_id: Optional[int] = Field(None, alias="cid", description="班级ID")
  55. status: Optional[int] = None
  56. uploaded_amount: Optional[int] = None
  57. class Config:
  58. anystr_strip_whitespace = True
  59. class UpdateMarkTask(UpdateMarkTaskInfo):
  60. school_name: Optional[str] = None
  61. grade_name: Optional[str] = None
  62. class_name: Optional[str] = None
  63. student_amount: Optional[int] = None
  64. pno: Optional[str] = None
  65. pname: Optional[str] = None
  66. editor_id: int
  67. editor_name: str