commit
7934a705fc
@ -0,0 +1,3 @@
|
||||
__pycache__
|
||||
.venv
|
||||
scheme
|
||||
@ -0,0 +1,21 @@
|
||||
from fastapi import FastAPI
|
||||
import json
|
||||
import random
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
with open("questions.json", "r", encoding="UTF-8") as f:
|
||||
content = json.load(f)
|
||||
questions_with_answers = content["questions"]
|
||||
remove_keys = ["author", "answer", "topic"]
|
||||
questions_without_answers = [{key: value for key, value in q.items() if key not in remove_keys} for q in questions_with_answers]
|
||||
|
||||
@app.get("/")
|
||||
def give_quiz(student: str):
|
||||
quiz_questions = random.sample(questions_without_answers, len(questions_without_answers)) # questions selection would be more complicated
|
||||
return {
|
||||
"version": 1,
|
||||
"student": student,
|
||||
"attempt": 0, # TODO how to count attempts?
|
||||
"questions": quiz_questions
|
||||
}
|
||||
|
After Width: | Height: | Size: 75 KiB |
@ -0,0 +1,33 @@
|
||||
{
|
||||
"version": 1,
|
||||
"questions": [
|
||||
{
|
||||
"id": 1,
|
||||
"topic": "теодолит",
|
||||
"author": "GT",
|
||||
"question": "Что такое теодолит?",
|
||||
"picture": "pictures/teodolit.png",
|
||||
"options": [
|
||||
"Прибор для измерения земли",
|
||||
"Прибор для измерения углов",
|
||||
"Прибор для измерения расстояний",
|
||||
"Прибор для измерения высот"
|
||||
],
|
||||
"answer": "Прибор для измерения углов"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"topic": "геометрия",
|
||||
"author": "GT",
|
||||
"question": "Сумма углов выпуклого пятиугольника составляет?",
|
||||
"answer": 520
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"topic": "нивелир",
|
||||
"author": "GT",
|
||||
"question": "Как называется прибор для измерения превышений?",
|
||||
"answer": "нивелир"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": 1,
|
||||
"students": [
|
||||
{
|
||||
"name": "Екатерина Александровна Щербацкая",
|
||||
"professor": "Михаил Иванович Кознышев"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue