Приложение для тестирования сотрудников клиники методом один вопрос - до пяти ответов один из которых правильный. Сотрудник должен выбрать правильный вариант ответа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
1.5 KiB

import client from './client'
export interface AnswerForTest {
id: number
text: string
}
export interface QuestionForTest {
id: number
text: string
is_multiple: boolean // true → показываем чекбоксы, false → радио-кнопки
answers: AnswerForTest[]
}
export interface AttemptStarted {
id: number
test_id: number
test_title: string
test_description: string | null
started_at: string
time_limit: number | null // минуты
allow_navigation_back: boolean
questions: QuestionForTest[]
}
export interface QuestionAnswer {
question_id: number
answer_ids: number[]
}
export interface AnswerResult {
id: number
text: string
is_correct: boolean
is_selected: boolean
}
export interface QuestionResult {
id: number
text: string
is_answered_correctly: boolean
answers: AnswerResult[]
}
export interface AttemptResult {
id: number
test_id: number
test_title: string
started_at: string
finished_at: string
score: number
passed: boolean
passing_score: number
correct_count: number
total_count: number
questions: QuestionResult[]
}
export const attemptsApi = {
start: (test_id: number) =>
client.post<AttemptStarted>('/attempts', { test_id }),
submit: (attempt_id: number, answers: QuestionAnswer[]) =>
client.post<AttemptResult>(`/attempts/${attempt_id}/submit`, { answers }),
getResult: (attempt_id: number) =>
client.get<AttemptResult>(`/attempts/${attempt_id}/result`),
}