2022-10-10 08:29:25 +00:00
|
|
|
import {$axios} from "~/utils/api";
|
2022-10-07 14:15:53 +00:00
|
|
|
import {RestResponse} from "~/repositories/models/rest-response.model";
|
|
|
|
import {Quiz, Response, ResponseWithQuestion, Score} from "~/repositories/models/quiz.model";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
|
|
findMine() {
|
|
|
|
return $axios.get<RestResponse<Quiz>>("/quizzes/search/me", {
|
|
|
|
params: {
|
|
|
|
sort: "createdDate,desc"
|
|
|
|
}
|
2022-10-10 08:29:25 +00:00
|
|
|
})
|
2022-10-10 08:46:32 +00:00
|
|
|
.then((response) => {
|
2022-10-10 08:29:25 +00:00
|
|
|
response.data._embedded.quizzes.map(quiz => {
|
2022-10-10 14:14:00 +00:00
|
|
|
quiz.id = Number(quiz._links.self.href.split("/").reverse()[0]);
|
2022-10-10 08:29:25 +00:00
|
|
|
return quiz;
|
|
|
|
});
|
|
|
|
return response;
|
|
|
|
});
|
2022-10-07 14:15:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
}
|