Skip to content

Commit 98efc4c

Browse files
Merge pull request #470 from Bootstrap-Academy/feature/fix-quiz-progress-counter
Fix solved quiz counter on solve views
2 parents ca22257 + 8f74222 commit 98efc4c

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

pages/matchings/solve-[id].vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
>:
4343
{{
4444
t("Headings.AmountSolvedQuizzes", {
45-
amount: arrayOfSubtasks.filter((quiz: any) => !quiz.solved).length,
46-
total: arrayOfSubtasks?.length,
45+
amount: solvedSubtaskCount,
46+
total: totalSubtaskCount,
4747
})
4848
}}
4949
</p>
@@ -98,13 +98,7 @@
9898
/>
9999
</div>
100100
</main>
101-
<div
102-
v-if="
103-
!loading &&
104-
quizzesToShow.length > 0 &&
105-
arrayOfSubtasks.filter((quiz: any) => !quiz.solved).length == 0
106-
"
107-
>
101+
<div v-if="!loading && quizzesToShow.length > 0 && unsolvedSubtaskCount === 0">
108102
<CheckCircleIcon class="mx-auto mb-8 h-20 w-20 text-accent" />
109103
<p class="mb-20 w-full text-center text-xl">
110104
{{ t("Headings.AllSolved") }}
@@ -155,6 +149,12 @@ const buttonOptions = [
155149
{ name: "Buttons.Own" },
156150
];
157151
152+
const totalSubtaskCount = computed(() => arrayOfSubtasks.value.length);
153+
const solvedSubtaskCount = computed(
154+
() => arrayOfSubtasks.value.filter((quiz: any) => quiz.solved).length
155+
);
156+
const unsolvedSubtaskCount = computed(() => totalSubtaskCount.value - solvedSubtaskCount.value);
157+
158158
const id: any = computed(() => route?.params?.id ?? "");
159159
const querySubTaskId: any = computed(() => route.query?.querySubTaskId ?? "");
160160
const taskId = computed(() => route.query?.taskId ?? "");

pages/quizzes/solve-[id].vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
>:
4343
{{
4444
t("Headings.AmountSolvedQuizzes", {
45-
amount: arrayOfSubtasks.filter((quiz: any) => !quiz.solved).length,
46-
total: arrayOfSubtasks?.length,
45+
amount: solvedSubtaskCount,
46+
total: totalSubtaskCount,
4747
})
4848
}}
4949
</p>
@@ -99,13 +99,7 @@
9999
/>
100100
</div>
101101
</main>
102-
<div
103-
v-if="
104-
!loading &&
105-
quizzesToShow.length > 0 &&
106-
arrayOfSubtasks.filter((quiz: any) => !quiz.solved).length == 0
107-
"
108-
>
102+
<div v-if="!loading && quizzesToShow.length > 0 && unsolvedSubtaskCount === 0">
109103
<CheckCircleIcon class="mx-auto mb-8 h-20 w-20 text-accent" />
110104
<p class="mb-20 w-full text-center text-xl">
111105
{{ t("Headings.AllSolved") }}
@@ -329,6 +323,12 @@ export default defineComponent({
329323
return quiz.creator === user.value?.id;
330324
}
331325
326+
const totalSubtaskCount = computed(() => arrayOfSubtasks.value.length);
327+
const solvedSubtaskCount = computed(
328+
() => arrayOfSubtasks.value.filter((quiz: any) => quiz.solved).length
329+
);
330+
const unsolvedSubtaskCount = computed(() => totalSubtaskCount.value - solvedSubtaskCount.value);
331+
332332
function sortQuizzes() {
333333
return quizzesToShow.value.sort(
334334
(
@@ -406,6 +406,9 @@ export default defineComponent({
406406
breadcrumbs,
407407
querySubTaskId,
408408
sortQuizzes,
409+
totalSubtaskCount,
410+
solvedSubtaskCount,
411+
unsolvedSubtaskCount,
409412
};
410413
},
411414
});

0 commit comments

Comments
 (0)