Skip to content

Commit

Permalink
Добавляет нерабочий эндпоинт для автопроверки заданий
Browse files Browse the repository at this point in the history
  • Loading branch information
codEnjoyer committed Nov 21, 2023
1 parent 0e7a18b commit 748e3b5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/src/game/units/tasks/enums.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
8 changes: 8 additions & 0 deletions backend/src/game/units/tasks/questions/answers/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 13 additions & 2 deletions backend/src/game/units/tasks/questions/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion backend/src/game/units/tasks/questions/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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]
2 changes: 1 addition & 1 deletion backend/src/game/units/tasks/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 748e3b5

Please sign in to comment.