feat: add frontend

This commit is contained in:
2022-10-07 16:15:53 +02:00
parent abfaf19c47
commit 97059d4c6e
72 changed files with 47026 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import AxeRepository from "./axeRepository";
import QuestionRepository from "~/repositories/questionRepository";
import QuizRepository from "~/repositories/quizRepository";
const repositories = {
axe: AxeRepository,
question: QuestionRepository,
quiz: QuizRepository,
// other repositories ...
};
export const RepositoryFactory = {
// @ts-ignore
get: (name: string) => repositories[name]
};

View File

@@ -0,0 +1,9 @@
import {Axe} from "~/repositories/models/axe.model";
import {RestResponse} from "~/repositories/models/rest-response.model";
import {$axios} from "~/utils/api";
export default {
findAll() {
return $axios.get<RestResponse<Axe>>("/axes");
}
}

View File

@@ -0,0 +1,8 @@
import {RestLinks} from "~/repositories/models/rest-response.model";
export interface Axe extends RestLinks {
identifier: number;
shortTitle: string;
title: string;
color: string;
}

View File

@@ -0,0 +1,6 @@
import {RestLinks} from "~/repositories/models/rest-response.model";
export interface Question extends RestLinks {
label: string;
description: string;
}

View File

@@ -0,0 +1,31 @@
import {RestLinks} from "~/repositories/models/rest-response.model";
export interface Score {
scoreAvg: number;
axeIdentifier: number;
}
export interface Quiz extends RestLinks {
id: number;
createdDate: string;
scores: Score[];
}
export interface Response {
axeId: number;
questionId: string;
score?: number;
comment?: string;
}
export interface ResponseWithQuestion extends RestLinks {
axeIdentifier: number;
question: string;
score: number;
comment: string;
}
export interface QuizRate {
score?: number;
comment?: string;
}

View File

@@ -0,0 +1,20 @@
export interface RestLinks {
"_links": {
"self": {
"href": string;
}
}
}
export interface Page {
"page": {
"size": number;
"totalElements": number;
"totalPages": number;
"number": number;
}
}
export interface RestResponse<T> extends RestLinks, Page {
_embedded: { [key: string]: T[] };
}

View File

@@ -0,0 +1,4 @@
export interface Token {
"name": string,
"password": "password"
}

View File

@@ -0,0 +1,13 @@
import {RestResponse} from "~/repositories/models/rest-response.model";
import {Question} from "~/repositories/models/question.model";
import {$axios} from "~/utils/api";
export default {
findAllByAxeId(axeId: number) {
return $axios.get<RestResponse<Question>>("/questions/search/byAxeId", {
params: {
id: axeId
}
});
}
}

View File

@@ -0,0 +1,32 @@
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
}, {});
}
}