2023-04-29 22:45:52 +03:00
|
|
|
|
|
|
|
export interface SettingsDto {
|
|
|
|
randomizeQuestions: boolean,
|
|
|
|
randomizeOptions: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface OptionDto {
|
|
|
|
option: string,
|
|
|
|
value: number
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface QuestionDto {
|
|
|
|
group: string,
|
|
|
|
title: string,
|
|
|
|
question: string,
|
|
|
|
options: OptionDto[]
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SurveyDto {
|
|
|
|
title: string,
|
|
|
|
intro: string,
|
|
|
|
settings: SettingsDto,
|
2024-02-16 23:24:48 +03:00
|
|
|
questions: QuestionDto[],
|
|
|
|
resultsInfo?: string
|
2023-04-29 22:45:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const Api = {
|
|
|
|
loadSurvey: (uri: string,
|
|
|
|
onSuccess: (survey: SurveyDto) => void,
|
|
|
|
onError: (failure: string) => void) => {
|
|
|
|
fetch(uri)
|
|
|
|
.then(res => res.json())
|
|
|
|
.then(out => onSuccess(out as SurveyDto))
|
|
|
|
.catch(err => onError(err))
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Api;
|