diff --git a/frontend/src/components/Quiz.vue b/frontend/src/components/Quiz.vue index acc76b17..8c2923e3 100644 --- a/frontend/src/components/Quiz.vue +++ b/frontend/src/components/Quiz.vue @@ -19,7 +19,7 @@
{{ quiz.doc.title }}
- - {{ noOfAttempts.data }} -
- +
+
@@ -129,6 +129,7 @@ import { createDocumentResource, Button, createResource, ListView } from 'frappe import { ref, watch, reactive, inject } from 'vue'; import { createToast } from "@/utils/" import { CheckCircle, XCircle, MinusCircle } from "lucide-vue-next" +import { timeAgo } from "@/utils" const user = inject("$user"); const activeQuestion = ref(0); @@ -150,7 +151,7 @@ const quiz = createDocumentResource({ auto: true, }); -const noOfAttempts = createResource({ +const attempts = createResource({ url: "frappe.client.get_list", makeParams(values) { return { @@ -159,10 +160,17 @@ const noOfAttempts = createResource({ member: user.data?.name, quiz: quiz.doc?.name, }, - fields: ["name", "creation", "score"] + fields: ["name", "creation", "score", "score_out_of", "percentage", "passing_percentage"], + order_by: "creation desc", } }, auto: true, + transform(data) { + data.forEach((submission, index) => { + submission.creation = timeAgo(submission.creation); + submission.idx = index + 1; + }); + } }) const quizSubmission = createResource({ @@ -290,7 +298,7 @@ const submitQuiz = () => { const createSubmission = () => { quizSubmission.reload().then(() => { - noOfAttempts.reload(); + attempts.reload(); }); } @@ -304,14 +312,29 @@ const resetQuiz = () => { const getSubmissionColumns = () => { return [ { - label: "No." + label: "No.", + key: "idx", + }, { - label: "Score" + label: "Date", + key: "creation", }, { - label: "Date" - } + label: "Score", + key: "score", + align: "center" + }, + { + label: "Score out of", + key: "score_out_of", + align: "center" + }, + { + label: "Percentage", + key: "percentage", + align: "center" + }, ] } \ No newline at end of file diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index a5f6b104..6f23afe5 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -1,4 +1,5 @@ import { toast } from 'frappe-ui' +import { useDateFormat, useTimeAgo } from '@vueuse/core' export function createToast(options) { toast({ @@ -6,3 +7,7 @@ export function createToast(options) { ...options, }) } + +export function timeAgo(date) { + return useTimeAgo(date).value +}