+
{{ question.label }}
{{ question.description }}
+
+ {{ question.label }}
+
onRate(rate, question)" />
@@ -36,6 +40,11 @@ export default class Quiz extends Vue {
})
private title!: string;
+ @Prop({
+ required: false
+ })
+ private description!: string;
+
@Prop({
required: true
})
@@ -132,15 +141,26 @@ $size: 31px;
margin: $small;
}
+.description {
+ color: $gray_3;
+ font-weight: 400;
+ font-size: 0.875rem;
+}
+
.question {
width: 100%;
}
-.question details {
+.question details,
+.question .title {
margin-bottom: $x_small;
}
-.question details summary {
+.question details summary,
+.question .title {
font-weight: 700;
font-size: $title-font-size;
+}
+
+.question details summary {
margin-bottom: $xxx_small;
}
diff --git a/frontend/pages/dashboard.vue b/frontend/pages/dashboard.vue
index 3d05922..2d952d9 100644
--- a/frontend/pages/dashboard.vue
+++ b/frontend/pages/dashboard.vue
@@ -37,7 +37,7 @@ import {Component, Vue} from "vue-property-decorator";
import {AxiosResponse} from "axios";
import {RepositoryFactory} from "~/repositories/RepositoryFactory";
import {RestResponse} from "~/repositories/models/rest-response.model";
-import {Quiz, Score} from "~/repositories/models/quiz.model";
+import {Quiz} from "~/repositories/models/quiz.model";
@Component
export default class History extends Vue {
@@ -52,12 +52,6 @@ export default class History extends Vue {
await this.quizRepository.findMine().then((response: AxiosResponse>) => {
this.quizzes = response.data._embedded.quizzes;
});
- for (const quiz of this.quizzes) {
- await this.quizRepository.findScores(quiz.id)
- .then((value: AxiosResponse) => {
- quiz.scores = value.data;
- });
- }
this.currentResult = this.quizzes.length > 0 ? this.quizzes[0] : null;
this.loading = false;
}
diff --git a/frontend/pages/details.vue b/frontend/pages/details.vue
index 86f0585..f3c71ae 100644
--- a/frontend/pages/details.vue
+++ b/frontend/pages/details.vue
@@ -26,6 +26,7 @@ import {Quiz, ResponseWithQuestion, Score} from "~/repositories/models/quiz.mode
import QuizAxeDetails from "~/components/QuizAxeDetails.vue";
import {Axe} from "~/repositories/models/axe.model";
import {RestResponse} from "~/repositories/models/rest-response.model";
+
@Component({
components: {QuizAxeDetails}
})
@@ -36,7 +37,6 @@ export default class Result extends Vue {
private axes: Axe[] = [];
private quiz: Quiz | null = null;
- private scores: Score[] = [];
private responses: ResponseWithQuestion[] = [];
private loading = false;
@@ -50,28 +50,15 @@ export default class Result extends Vue {
this.quizRepository.findById(quizId)
.then((response: AxiosResponse) => {
this.quiz = response.data;
+ this.responses = response.data._embedded.responses;
return response;
})
- .then(() => {
- return this.quizRepository.findScores(quizId)
- .then((response: AxiosResponse) => {
- this.scores = response.data;
- return response;
- })
- })
- .then(() => {
- return this.quizRepository.findResponses(quizId)
- .then((response: AxiosResponse>) => {
- this.responses = response.data._embedded.responses;
- return response;
- })
- })
.then(() => {
return this.axeRepository.findAll()
.then((response: AxiosResponse>) => {
- this.axes = response.data._embedded.axes;
- return response;
- });
+ this.axes = response.data._embedded.axes;
+ return response;
+ });
})
.finally(() => {
this.loading = false;
@@ -82,8 +69,12 @@ export default class Result extends Vue {
}
}
- getScore(axe: Axe) {
- return this.scores.find(value => value.axeIdentifier === axe.identifier);
+ getScore(axe: Axe): Score {
+ const responses = this.getResponses(axe);
+ return {
+ axeIdentifier: axe.identifier,
+ scoreAvg: responses.reduce((total, response) => total + response.score, 0) / responses.length
+ };
}
getResponses(axe: Axe) {
diff --git a/frontend/pages/quiz.vue b/frontend/pages/quiz.vue
index 1b4a6ff..4c139b0 100644
--- a/frontend/pages/quiz.vue
+++ b/frontend/pages/quiz.vue
@@ -7,6 +7,7 @@
= new Map();
private loading = true;
@@ -67,28 +67,17 @@ export default class Login extends Vue {
this.loading = true;
this.axeRepository
.findAll()
- .then((response: AxiosResponse>) => {
+ .then((response: AxiosResponse>) => {
this.axes = response.data._embedded.axes;
- const promises: any[] = [];
this.axes.forEach(axe => {
- promises.push(
- this.questionRepository
- .findAllByAxeId(axe.identifier)
- .then((response: AxiosResponse>) => {
- return {
- axeId: axe.identifier,
- questions: response.data._embedded.questions
- };
- }));
- });
- Promise.all(promises).then((axeQuestions) => {
- axeQuestions.forEach(axeQuestion => {
- this.questions.set(axeQuestion.axeId, axeQuestion.questions)
- });
- quizStore.initialize(this.questions);
- this.initializeState();
- this.loading = false;
+ this.questions.set(axe.identifier, axe.questions);
});
+ this.initializeState();
+ quizStore.initialize(this.questions);
+
+ })
+ .finally(() => {
+ this.loading = false;
});
}
diff --git a/frontend/repositories/axeRepository.ts b/frontend/repositories/axeRepository.ts
index 57ea41e..894d2c4 100644
--- a/frontend/repositories/axeRepository.ts
+++ b/frontend/repositories/axeRepository.ts
@@ -1,9 +1,9 @@
-import {Axe} from "~/repositories/models/axe.model";
import {RestResponse} from "~/repositories/models/rest-response.model";
import {$axios} from "~/utils/api";
+import {AxeWithQuestions} from "~/repositories/models/axe.model";
export default {
findAll() {
- return $axios.get>("/axes");
+ return $axios.get>("/axes/search/me");
}
}
diff --git a/frontend/repositories/models/axe.model.ts b/frontend/repositories/models/axe.model.ts
index 3f1c772..6a30c5e 100644
--- a/frontend/repositories/models/axe.model.ts
+++ b/frontend/repositories/models/axe.model.ts
@@ -1,8 +1,19 @@
import {RestLinks} from "~/repositories/models/rest-response.model";
+import {Question} from "~/repositories/models/question.model";
export interface Axe extends RestLinks {
identifier: number;
shortTitle: string;
+ description: string;
title: string;
color: string;
}
+
+export interface AxeWithQuestions extends RestLinks {
+ identifier: number;
+ shortTitle: string;
+ description: string;
+ title: string;
+ color: string;
+ questions: Question[];
+}
diff --git a/frontend/repositories/models/quiz.model.ts b/frontend/repositories/models/quiz.model.ts
index a54d675..0a5ac9d 100644
--- a/frontend/repositories/models/quiz.model.ts
+++ b/frontend/repositories/models/quiz.model.ts
@@ -5,19 +5,6 @@ export interface Score {
axeIdentifier: number;
}
-export interface Quiz extends RestLinks {
- id: number;
- createdDate: string;
- scores: Score[];
-}
-
-export interface Response {
- axeId: number;
- questionId: number;
- score?: number;
- comment?: string;
-}
-
export interface ResponseWithQuestion extends RestLinks {
axeIdentifier: number;
question: string;
@@ -25,6 +12,22 @@ export interface ResponseWithQuestion extends RestLinks {
comment: string;
}
+export interface Quiz extends RestLinks {
+ id: number;
+ createdDate: string;
+ scores: Score[];
+ _embedded: {
+ responses: ResponseWithQuestion[]
+ };
+}
+
+export interface Response {
+ axeId: number;
+ questionId: number;
+ score?: number;
+ comment?: string;
+}
+
export interface QuizRate {
score?: number;
comment?: string;