fixed so that you cant start the game untill you fill all the values anda ll

This commit is contained in:
RezHackXYZ 2025-06-05 16:29:51 +05:30
parent b2906bd53b
commit dd140e23d1
2 changed files with 35 additions and 1 deletions

View file

@ -0,0 +1,31 @@
import toast from "svelte-5-french-toast";
import { QuestionsData } from "./create.svelte.js";
export function IsAllValuesFilled() {
if (QuestionsData.v.length === 0) {
return false;
}
for (let i = 0; i < QuestionsData.v.length; i++) {
const question = QuestionsData.v[i];
if (!question.questionText || question.questionText.trim() === "") {
toast.error(`Please fill in the question text for question ${i + 1}.`);
return false;
}
for (let j = 0; j < question.options.length; j++) {
if (!question.options[j] || question.options[j].trim() === "") {
toast.error(`Please fill in all answers for question ${i + 1}.`);
return false;
}
}
if (question.CorrectOption.SingleAnswer === null) {
toast.error(`Please select in the correct answer text for question ${i + 1}.`);
return false;
}
}
return true;
}

View file

@ -1,8 +1,11 @@
import { supabase } from "$lib/supabase.js";
import { QuestionsData, wait } from "./create.svelte.js";
import { IsAllValuesFilled } from "./IsAllValuesFilled.js";
import toast from "svelte-5-french-toast";
export async function createGame() {
if (!IsAllValuesFilled()) return;
console.log("Creating game rn!");
if (wait.v) {