#!/usr/bin/env python # -*- coding: utf-8 -*- from typing import List, Optional from pydantic import Field from pydantic.main import BaseModel from schemas.base import ListMixin, Datetime2Str, DetailMixin class NewMarkTask(BaseModel): mtype: str = Field(..., description="任务类型,work / exam") pid: Optional[int] = Field(..., description="试卷ID") school_id: int = Field(..., alias="sid", description="学校ID") grade_id: int = Field(..., alias="gid", description="年级ID") class_id: int = Field(..., alias="cid", description="班级ID") category_id: Optional[int] = Field(..., alias="ctgid", description="分类ID") name: Optional[str] = Field(..., description="试卷名称") #uploaded_amount: int = Field(0, alias="upload", description="上传数量") #status: int = Field(0, description="状态") class MarkTaskInDB(NewMarkTask): name: str pno: str pname: str school_id: int school_name: str grade_id: int grade_name: str class_id: int class_name: str category_id: int student_amount: int creator_id: int creator_name: str year: int class MarkTaskItem(BaseModel): id: int name: str score: int high_score: float avg_score: float pass_rate: float marked_amount: int student_amount: int uploaded_amount: int updated_at: Datetime2Str class Config: orm_mode = True class MarkTaskList(ListMixin): data: List[MarkTaskItem] = [] class MarkTaskDetail(DetailMixin): data: Optional[MarkTaskItem] = {} class UpdateMarkTaskInfo(BaseModel): name: Optional[str] = None pid: Optional[int] = None school_id: Optional[int] = Field(None, alias="sid", description="学校ID") grade_id: Optional[int] = Field(None, alias="gid", description="年级ID") class_id: Optional[int] = Field(None, alias="cid", description="班级ID") status: Optional[int] = None uploaded_amount: Optional[int] = None class Config: anystr_strip_whitespace = True class UpdateMarkTask(UpdateMarkTaskInfo): school_name: Optional[str] = None grade_name: Optional[str] = None class_name: Optional[str] = None student_amount: Optional[int] = None pno: Optional[str] = None pname: Optional[str] = None editor_id: int editor_name: str