2025-03-03 21:40:50 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import "7.css/dist/7.scoped.css";
|
|
|
|
|
|
|
|
useHead({
|
|
|
|
title: "Pytanie 1/20",
|
|
|
|
});
|
|
|
|
|
2025-03-03 22:21:18 +01:00
|
|
|
const {
|
|
|
|
data: dataBasic,
|
|
|
|
error: errorBasic,
|
|
|
|
status: statusBasic,
|
|
|
|
} = await useFetch<BasicQuestion[]>("/api/basic");
|
|
|
|
|
|
|
|
const {
|
|
|
|
data: dataAdvanced,
|
|
|
|
error: errorAdvanced,
|
|
|
|
status: statusAdvanced,
|
|
|
|
} = await useFetch<AdvancedQuestion[]>("/api/advanced");
|
2025-03-03 21:40:50 +01:00
|
|
|
|
2025-03-03 22:21:18 +01:00
|
|
|
const countBasic = ref(0);
|
|
|
|
const countAdvanced = ref(-1);
|
2025-03-03 21:40:50 +01:00
|
|
|
|
|
|
|
const tak_nie_model = ref();
|
|
|
|
|
|
|
|
async function next() {
|
2025-03-03 22:21:18 +01:00
|
|
|
if (countBasic.value + 1 < dataBasic.value?.length!) {
|
2025-03-03 21:40:50 +01:00
|
|
|
questionaries.value.push({
|
|
|
|
nr_pytania: question.value?.nr_pytania,
|
|
|
|
chosen_answer: tak_nie_model.value ?? "",
|
|
|
|
correct_answer: question.value?.poprawna_odp?.toLowerCase(),
|
|
|
|
chosen_is_correct:
|
|
|
|
tak_nie_model.value == question.value?.poprawna_odp?.toLowerCase(),
|
|
|
|
liczba_pkt: question.value?.liczba_pkt,
|
|
|
|
});
|
|
|
|
tak_nie_model.value = "";
|
2025-03-03 22:21:18 +01:00
|
|
|
countBasic.value++;
|
2025-03-03 21:40:50 +01:00
|
|
|
useHead({
|
2025-03-03 22:21:18 +01:00
|
|
|
title: `Pytanie ${countBasic.value + 1}/${dataBasic.value?.length}`,
|
2025-03-03 21:40:50 +01:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// await navigateTo("/advanced");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-03 22:21:18 +01:00
|
|
|
const question = computed(() => dataBasic.value?.at(countBasic.value));
|
2025-03-03 21:40:50 +01:00
|
|
|
const media = computed(() => {
|
|
|
|
const mediaSplit = question.value?.media?.split(".");
|
|
|
|
return {
|
|
|
|
fileType: mediaSplit?.pop()?.toLowerCase(),
|
|
|
|
fileName: mediaSplit?.join("."),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const questionaries: Ref<Array<any>> = ref([]);
|
|
|
|
|
|
|
|
// onMounted(() => {
|
|
|
|
// const progresInterval = setInterval(() => {
|
|
|
|
// progres.value.value = +progres.value.value + 1;
|
|
|
|
// if (progres.value.value >= 100) {
|
|
|
|
// clearInterval(progresInterval);
|
|
|
|
// }
|
|
|
|
// }, 100);
|
|
|
|
// });
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2025-03-03 22:21:18 +01:00
|
|
|
<div v-if="statusBasic === 'success'">
|
2025-03-03 21:40:50 +01:00
|
|
|
<div class="grid grid-cols-4 min-h-dvh">
|
|
|
|
<div class="col-span-3 flex flex-col gap-4 p-4">
|
|
|
|
<TopBar
|
|
|
|
:points="question?.liczba_pkt"
|
|
|
|
:category="`B`"
|
|
|
|
:time-remaining="`25:00`"
|
|
|
|
/>
|
|
|
|
<Media :media="media" />
|
|
|
|
<BasicQuestionBlock :question="question" v-model="tak_nie_model" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<RightBar
|
|
|
|
:questionaries="questionaries"
|
2025-03-03 22:21:18 +01:00
|
|
|
:data-basic="dataBasic"
|
|
|
|
:data-advanced="dataAdvanced"
|
|
|
|
:count-basic="countBasic"
|
|
|
|
:count-advanced="countAdvanced"
|
2025-03-03 21:40:50 +01:00
|
|
|
@next-question="next()"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-03-03 22:21:18 +01:00
|
|
|
<div v-else-if="statusBasic === 'error' || statusAdvanced === 'error'">
|
|
|
|
An API error occurred: {{ errorBasic }} {{ errorAdvanced }}
|
|
|
|
</div>
|
2025-03-03 21:40:50 +01:00
|
|
|
<div v-else>Loading...</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.btn {
|
|
|
|
@apply box-border text-white font-bold p-3 rounded-md w-fit cursor-pointer border-[4px] transition duration-100;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-answer {
|
|
|
|
@apply btn bg-blue-500 text-xl;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-answer:hover {
|
|
|
|
@apply bg-blue-300;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-answer:active {
|
|
|
|
@apply bg-blue-400 duration-0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-major {
|
|
|
|
@apply btn bg-orange-400 text-base;
|
|
|
|
}
|
|
|
|
|
|
|
|
.info-little-box {
|
|
|
|
@apply inline-block px-[15px] py-[8px] bg-blue-500 text-white font-bold;
|
|
|
|
}
|
|
|
|
</style>
|