From 748e3b546c77c9b78cfd5c06eae61572a9a12fe6 Mon Sep 17 00:00:00 2001 From: codEnjoyer Date: Tue, 21 Nov 2023 13:55:04 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D0=BD=D0=B5=D1=80=D0=B0=D0=B1=D0=BE=D1=87=D0=B8?= =?UTF-8?q?=D0=B9=20=D1=8D=D0=BD=D0=B4=D0=BF=D0=BE=D0=B8=D0=BD=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/game/units/tasks/enums.py | 4 ++-- .../game/units/tasks/questions/answers/schemas.py | 8 ++++++++ backend/src/game/units/tasks/questions/router.py | 15 +++++++++++++-- backend/src/game/units/tasks/questions/schemas.py | 11 ++++++++++- backend/src/game/units/tasks/schemas.py | 2 +- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/backend/src/game/units/tasks/enums.py b/backend/src/game/units/tasks/enums.py index 5ba4f57..35af84a 100644 --- a/backend/src/game/units/tasks/enums.py +++ b/backend/src/game/units/tasks/enums.py @@ -1,11 +1,11 @@ -from enum import Enum, auto, StrEnum +from enum import StrEnum, auto class TaskTypes(StrEnum): Test = auto() -class TaskStates(Enum): +class TaskStates(StrEnum): NotViewed = auto() Viewed = auto() Submitted = auto() diff --git a/backend/src/game/units/tasks/questions/answers/schemas.py b/backend/src/game/units/tasks/questions/answers/schemas.py index cd1a2ba..5d8fd66 100644 --- a/backend/src/game/units/tasks/questions/answers/schemas.py +++ b/backend/src/game/units/tasks/questions/answers/schemas.py @@ -19,3 +19,11 @@ class AnswerOptionCreate(__AnswerBase): class AnswerOptionUpdate(__AnswerBase): answer: str | None = None is_correct: bool | None = None + + +class EmployeeAnswerPost(__AnswerBase): + is_selected: bool + + +class EmployeeAnswerRead(__AnswerBase): + was_selected_correct: bool diff --git a/backend/src/game/units/tasks/questions/router.py b/backend/src/game/units/tasks/questions/router.py index 4730248..cad2d1d 100644 --- a/backend/src/game/units/tasks/questions/router.py +++ b/backend/src/game/units/tasks/questions/router.py @@ -2,8 +2,9 @@ from fastapi import APIRouter -from game.units.tasks.questions.schemas import QuestionRead, QuestionCreate, QuestionUpdate -from utils.types import QuestionServiceType +from game.units.tasks.questions.schemas import QuestionRead, QuestionCreate, QuestionUpdate, EmployeeQuestionPost, \ + EmployeeQuestionRead +from utils.types import QuestionServiceType, TaskUnitServiceType router = APIRouter(tags=["Questions"]) @@ -23,6 +24,16 @@ async def post_question_to_task_unit(map_id: UUID, return await question_service.create_one(task_id, question_create) +@router.post("/maps/{map_id}/modules/{module_id}/levels/{level_id}/tasks/{task_id}/check/") +async def autocheck_task_unit(map_id: UUID, + module_id: UUID, + level_id: UUID, + task_id: UUID, + employee_answers: list[EmployeeQuestionPost], + task_service: TaskUnitServiceType) -> list[EmployeeQuestionRead]: + return [] + + @router.delete("/maps/{map_id}/modules/{module_id}/levels/{level_id}/tasks/{task_id}/questions/{question_id}/") async def delete_question_from_task_unit(map_id: UUID, module_id: UUID, diff --git a/backend/src/game/units/tasks/questions/schemas.py b/backend/src/game/units/tasks/questions/schemas.py index d7d485f..1299eb0 100644 --- a/backend/src/game/units/tasks/questions/schemas.py +++ b/backend/src/game/units/tasks/questions/schemas.py @@ -2,7 +2,8 @@ from pydantic import BaseModel, ConfigDict -from game.units.tasks.questions.answers.schemas import AnswerOptionRead, AnswerOptionCreate +from game.units.tasks.questions.answers.schemas import AnswerOptionRead, AnswerOptionCreate, EmployeeAnswerPost, \ + EmployeeAnswerRead from game.units.tasks.questions.enums import QuestionTypes @@ -28,3 +29,11 @@ class QuestionUpdate(__QuestionBase): type: QuestionTypes | None = None question: str | None = None answer_options: list[AnswerOptionCreate] | None = None + + +class EmployeeQuestionPost(__QuestionBase): + answers: list[EmployeeAnswerPost] + + +class EmployeeQuestionRead(__QuestionBase): + results: list[EmployeeAnswerRead] diff --git a/backend/src/game/units/tasks/schemas.py b/backend/src/game/units/tasks/schemas.py index cde51ce..64414ee 100644 --- a/backend/src/game/units/tasks/schemas.py +++ b/backend/src/game/units/tasks/schemas.py @@ -2,7 +2,7 @@ from pydantic import BaseModel, ConfigDict -from game.units.tasks.questions.schemas import QuestionRead, QuestionCreate, QuestionUpdate +from game.units.tasks.questions.schemas import QuestionRead from game.units.tasks.enums import TaskTypes