boussole-pluss/frontend/repositories/quizRepository.ts

33 lines
868 B
TypeScript

import {RestResponse} from "~/repositories/models/rest-response.model";
import {Quiz, Response, ResponseWithQuestion, Score} from "~/repositories/models/quiz.model";
import {$axios} from "~/utils/api";
export default {
findMine() {
return $axios.get<RestResponse<Quiz>>("/quizzes/search/me", {
params: {
sort: "createdDate,desc"
}
});
},
findScores(quizId: number) {
return $axios.get<RestResponse<Score[]>>("/quizzes/" + quizId + "/scores", {});
},
findById(quizId: number) {
return $axios.get<RestResponse<Quiz>>("/quizzes/" + quizId, {});
},
findResponses(quizId: number) {
return $axios.get<RestResponse<ResponseWithQuestion>>("/quizzes/" + quizId + "/responses", {});
},
save(responses: Response[]) {
return $axios.post<RestResponse<Quiz>>("/quizzes/batch/", {
responses
}, {});
}
}