123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from typing import List, Any, Dict
- from bgtask.problem import bgtask_create_student_error_statistic
- from crud.marktask import crud_student_task
- from db.asyncsession import LocalAsyncSession
- # 创建学生阅卷任务
- async def bgtask_create_student_mark_task(task_id: int, task_type: str, students: List[Any],
- paper: Dict[str, Any], uid: int, username: str):
- print("[bgTask] Create Student MarkTask Starting!")
- db = LocalAsyncSession()
- student_errors = []
- for stu in students:
- task = dict(
- **{
- "student_id": stu.id,
- "student_sno": stu.sno,
- "student_name": stu.name,
- "task_id": task_id,
- "mtype": task_type,
- "pid": paper["id"],
- "pno": paper["pno"],
- "pname": paper["pname"],
- "pimgs": paper["imgs"],
- "question_amount": paper["question_amount"],
- "school_name": stu.school_name,
- "grade_name": stu.grade_name,
- "class_name": stu.class_name
- })
- task["creator_id"] = task["editor_id"] = uid
- task["creator_name"] = task["editor_name"] = username
- db_student_task = await crud_student_task.insert_one(db, task)
- error = {
- "school_id": stu.school_id,
- "school_name": stu.school_name,
- "grade_id": stu.grade_id,
- "grade_name": stu.grade_name,
- "class_id": stu.class_id,
- "class_name": stu.class_name,
- "student_id": stu.id,
- "student_sno": stu.sno,
- "student_name": stu.name,
- "total_questions": paper["question_amount"],
- "task_id": task_id,
- "student_task_id": db_student_task.id
- }
- student_errors.append(error)
- print(f"the student_errors: {len(student_errors)}")
- await bgtask_create_student_error_statistic(student_errors)
- print("[bgTask] Create Student MarkTask Successfully!")
|