{"version":3,"file":"useQuizSummary-D0AeloxX.js","sources":["../../../app/javascript/components/quiz/onboarding/quiz_see_more.vue","../../../app/javascript/components/quiz/onboarding/quiz_grading_info.vue","../../../app/javascript/composables/useQuizzesAttemptSummary.js","../../../app/javascript/composables/useQuizSummary.js"],"sourcesContent":["\n\n\n\n\n","\n\n\n\n\n","import { computed, ref } from \"vue\"\nimport { useStore } from \"@/store\"\nimport { useIntervalFn, useTimeoutFn } from \"@vueuse/core\"\nimport timeHelpers from \"@/helpers/time_helpers\"\n\nexport function useQuizzesAttemptSummary(quizzesAttemptSummary) {\n\n const store = useStore()\n\n const timeAccommodation = computed(() => {\n return store.getters.timeAccommodation(quizzesAttemptSummary?.time_accommodation_id)\n })\n\n const expectedSessionState = ref(\"not_started\")\n\n useTimeoutFn(() => {\n expectedSessionState.value = computeCurrentExpectedState()\n }, 1000)\n\n const computeCurrentExpectedState = () => {\n // update expectedSessionState regarding quizzesAttemptSummary.start_at and quizzesAttemptSummary.end_at vs current time. end_at may be null.\n // if start_at is in the future, return \"scheduled\"\n\n const now = new Date()\n const startAt = quizzesAttemptSummary?.start_at && new Date(quizzesAttemptSummary?.start_at)\n const endAt = quizzesAttemptSummary?.end_at && new Date(quizzesAttemptSummary?.end_at)\n\n if (startAt && startAt > now) return \"scheduled\"\n if (endAt && endAt < now) return \"closed\"\n return \"open\"\n }\n\n\n const timeOffset = store.getters.timeOffset\n const computeRemainingTimeMs = () => {\n if (!quizzesAttemptSummary?.submission_deadline_at) return\n return new Date(quizzesAttemptSummary.submission_deadline_at) - Date.now() - timeOffset\n }\n\n\n // TODO: check what happens if the submission_deadline_at changes\n useIntervalFn(() => {\n remainingTimeMs.value = computeRemainingTimeMs()\n }, 1000)\n\n const remainingTimeFormatted = computed(() => {\n return timeHelpers.formatDuration(remainingTimeMs.value)\n })\n\n const remainingTimeMs = ref(computeRemainingTimeMs())\n\n const remainingTime = computed(() => {\n return Math.round(remainingTimeMs.value / 1000)\n })\n\n const countdownProgress = computed(() => {\n const studentStartedAt = new Date(quizzesAttemptSummary?.student_started_at)\n const submissionDeadlineAt = new Date(quizzesAttemptSummary?.submission_deadline_at)\n const duration = submissionDeadlineAt - studentStartedAt\n\n return (duration - remainingTimeMs.value) / duration * 100\n })\n\n return {\n timeAccommodation,\n expectedSessionState,\n remainingTime,\n remainingTimeFormatted,\n countdownProgress,\n }\n}\n","import { computed } from \"vue\"\nimport timeHelpers from \"@/helpers/time_helpers\"\nimport vueI18n from \"@/plugins/i18n\"\nimport { useQuizzesAttemptSummary } from \"@/composables/useQuizzesAttemptSummary\"\n\n\nexport function useQuizSummary({ quiz, quizzesAttemptSummary, session }) {\n const instructions = computed(() => {\n const formattedDuration = timeHelpers.formatDuration((quizzesAttemptSummary?.time_limit_with_accommodation || quiz.time_limit) * 1000)\n\n const timeAccommodation = useQuizzesAttemptSummary(quizzesAttemptSummary)?.timeAccommodation\n\n const durationLabel = quiz.time_limit ?\n vueI18n.t(\"live.timer\", { timer: formattedDuration }) :\n vueI18n.t(\"live.examOnboarding.grading.noTimer\")\n\n return [\n {\n icon: \"mdi-format-list-checks\",\n label: vueI18n.t(\n \"live.examOnboarding.grading.questions\",\n { questions: quiz.questions_count }\n ),\n visible: true,\n },\n {\n icon: \"mdi-timer-outline\",\n label: durationLabel,\n visible: quiz.quiz_type === \"exam\",\n },\n {\n icon: \"mdi-undo\",\n label: quiz.allow_questions_navigation ?\n vueI18n.t(\"live.examOnboarding.grading.navigation\") :\n vueI18n.t(\"live.examOnboarding.grading.noNavigation\"),\n visible: quiz.quiz_type === \"exam\",\n },\n {\n icon: \"mdi-clock-outline\",\n label: `${vueI18n.t(\"live.startTime\")} ${ formatDate(quizzesAttemptSummary?.start_at) }`,\n visible: quizzesAttemptSummary?.start_at,\n },\n {\n icon: \"mdi-clock-outline\",\n label: `${vueI18n.t(\"live.startTime\")} ${ formatDate(session?.start_at) }`,\n visible: session?.start_at && !quizzesAttemptSummary,\n },\n {\n icon: \"mdi-clock-end\",\n label: `${vueI18n.t(\"live.stopTime\")} ${ formatDate(quizzesAttemptSummary?.end_at_with_accommodation) }`,\n visible: quizzesAttemptSummary?.end_at_with_accommodation,\n },\n {\n icon: \"mdi-clock-end\",\n label: `${vueI18n.t(\"live.stopTime\")} ${ formatDate(session?.end_at) }`,\n visible: session?.end_at && !quizzesAttemptSummary,\n },\n {\n icon: \"mdi-timer-plus-outline\",\n label: vueI18n.t(\n \"live.examOnboarding.grading.timeAccommodation\",\n { name: timeAccommodation.value.name }\n ),\n visible: quiz.time_accommodation && quizzesAttemptSummary,\n },\n ].filter(e => e.visible)\n })\n\n function formatDate(date) {\n return timeHelpers.formatDateTime(date) + \" - \" + Intl.DateTimeFormat().resolvedOptions().timeZone\n }\n\n return {\n instructions,\n }\n}\n"],"names":["_sfc_main","katexMd","props","collapsableText","ref","offsetHeight","scrollHeight","expanded","updateHeights","watch","useResizeObserver","canBeExpanded","computed","canBeCollapsed","textLength","QuizSeeMore","instructions","grading","useQuizzesAttemptSummary","quizzesAttemptSummary","store","useStore","timeAccommodation","expectedSessionState","useTimeoutFn","computeCurrentExpectedState","now","startAt","endAt","timeOffset","computeRemainingTimeMs","useIntervalFn","remainingTimeMs","remainingTimeFormatted","timeHelpers","remainingTime","countdownProgress","studentStartedAt","duration","useQuizSummary","quiz","session","formattedDuration","_a","durationLabel","vueI18n","formatDate","e","date"],"mappings":"2vBA4CA,MAAAA,EAAA,CACA,KAAA,cACA,WAAA,CAAAC,QAAAA,CAAA,EACA,MAAA,CACA,KAAA,CAAA,KAAA,OAAA,QAAA,EAAA,EACA,UAAA,CAAA,KAAA,OAAA,QAAA,EAAA,EACA,QAAA,CAAA,KAAA,OAAA,QAAA,EAAA,EACA,KAAA,CAAA,KAAA,OAAA,QAAA,EAAA,EACA,wBAAA,CAAA,KAAA,OAAA,QAAA,GAAA,EACA,MAAA,CAAA,KAAA,QAAA,QAAA,EAAA,CACA,EACA,MAAAC,EAAA,CACA,MAAAC,EAAAC,EAAA,IAAA,EAEAC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