diff --git a/src/lib/config.js b/src/lib/config.js index 45391e8..04de99a 100644 --- a/src/lib/config.js +++ b/src/lib/config.js @@ -1,59 +1,59 @@ export let AnswersSymbolAndColorScheme = [ { - color: "#6E0000", - selectedColor: "#AA2222", - hoverBorderColor: "#FF5D5D", - selectedBorderColor: "#FF0000", - symbol: "nf-md-triangle", + Color: "#6E0000", + SelectedColor: "#AA2222", + HoverBorderColor: "#FF5D5D", + SelectedBorderColor: "#FF0000", + Symbol: "nf-md-triangle", }, { - color: "#00316E", - selectedColor: "#2255AA", - hoverBorderColor: "#5D9CFF", - selectedBorderColor: "#0000FF", - symbol: "nf-fa-square", + Color: "#00316E", + SelectedColor: "#2255AA", + HoverBorderColor: "#5D9CFF", + SelectedBorderColor: "#0000FF", + Symbol: "nf-fa-square", }, { - color: "#6E6E00", - selectedColor: "#AAAA22", - hoverBorderColor: "#FFFF5D", - selectedBorderColor: "#DDFF00", - symbol: "nf-fa-circle", + Color: "#6E6E00", + SelectedColor: "#AAAA22", + HoverBorderColor: "#FFFF5D", + SelectedBorderColor: "#DDFF00", + Symbol: "nf-fa-circle", }, { - color: "#006E00", - selectedColor: "#22AA22", - hoverBorderColor: "#5DFF5D", - selectedBorderColor: "#00FF00", - symbol: "nf-fa-diamond", + Color: "#006E00", + SelectedColor: "#22AA22", + HoverBorderColor: "#5DFF5D", + SelectedBorderColor: "#00FF00", + Symbol: "nf-fa-diamond", }, { - color: "#4B0082", - selectedColor: "#7F33B5", - hoverBorderColor: "#B066FF", - selectedBorderColor: "#9932CC", - symbol: "nf-md-star", + Color: "#4B0082", + SelectedColor: "#7F33B5", + HoverBorderColor: "#B066FF", + SelectedBorderColor: "#9932CC", + Symbol: "nf-md-star", }, { - color: "#FF8C00", - selectedColor: "#FFB347", - hoverBorderColor: "#FFD580", - selectedBorderColor: "#FFA500", - symbol: "nf-md-hexagon", + Color: "#FF8C00", + SelectedColor: "#FFB347", + HoverBorderColor: "#FFD580", + SelectedBorderColor: "#FFA500", + Symbol: "nf-md-hexagon", }, { - color: "#008B8B", - selectedColor: "#33CCCC", - hoverBorderColor: "#66FFFF", - selectedBorderColor: "#00CED1", - symbol: "nf-md-octagon", + Color: "#008B8B", + SelectedColor: "#33CCCC", + HoverBorderColor: "#66FFFF", + SelectedBorderColor: "#00CED1", + Symbol: "nf-md-octagon", }, { - color: "#8B4513", - selectedColor: "#CD853F", - hoverBorderColor: "#DEB887", - selectedBorderColor: "#A0522D", - symbol: "nf-md-heart", + Color: "#8B4513", + SelectedColor: "#CD853F", + HoverBorderColor: "#DEB887", + SelectedBorderColor: "#A0522D", + Symbol: "nf-md-heart", }, ]; @@ -108,7 +108,7 @@ JUST PROVIDE THE JSON AND NOTHING ELSE. The user's topic of interest is: [topic]`, -GenerateOptionsUsingAI: ` + GenerateOptionsUsingAI: ` You are the AI of a quiz game. Generate a list of answers relevant to the Question the correct answer index. generate 2 things for the question: @@ -129,5 +129,5 @@ JUST PROVIDE THE JSON AND NOTHING ELSE. The user's Question that they want to generate options for is: [question] -` -}; \ No newline at end of file +`, +}; diff --git a/src/routes/+layout.js b/src/routes/+layout.js index c8cacf0..189f71e 100644 --- a/src/routes/+layout.js +++ b/src/routes/+layout.js @@ -1 +1 @@ -export const prerender = true; \ No newline at end of file +export const prerender = true; diff --git a/src/routes/+page.server.js b/src/routes/+page.server.js new file mode 100644 index 0000000..5829b7e --- /dev/null +++ b/src/routes/+page.server.js @@ -0,0 +1 @@ +export const ssr = false; \ No newline at end of file diff --git a/src/routes/kahootclone/create/components/Questions/question.svelte b/src/routes/kahootclone/create/components/Questions/question.svelte index 96245d6..6472bc5 100644 --- a/src/routes/kahootclone/create/components/Questions/question.svelte +++ b/src/routes/kahootclone/create/components/Questions/question.svelte @@ -53,6 +53,13 @@ {/each} - UpLoadFiles(files[0])} bind:files accept="image/*,video/*" /> + { + questions.v[index].media = await UpLoadFiles(files[0]); + }} + bind:files + accept="image/*,video/*" + /> diff --git a/src/routes/kahootclone/create/logic/GameCreateData.svelte.js b/src/routes/kahootclone/create/logic/GameCreateData.svelte.js index ff78726..978ad8f 100644 --- a/src/routes/kahootclone/create/logic/GameCreateData.svelte.js +++ b/src/routes/kahootclone/create/logic/GameCreateData.svelte.js @@ -1,4 +1,6 @@ + import { DefaultQuestions } from "$lib/config.js"; +import toast from "svelte-5-french-toast"; export let Wait = $state({ v: false }); export let questions = $state({ @@ -29,6 +31,6 @@ export function DeleteQuestion(index) { questions.v.splice(index, 1); } } else { - alert("You need at least one question."); + toast.error("You need at least one question."); } } diff --git a/src/routes/kahootclone/create/logic/GenerateOptionsUsingAI.js b/src/routes/kahootclone/create/logic/GenerateOptionsUsingAI.js index 147561b..10e5f00 100644 --- a/src/routes/kahootclone/create/logic/GenerateOptionsUsingAI.js +++ b/src/routes/kahootclone/create/logic/GenerateOptionsUsingAI.js @@ -1,5 +1,6 @@ import { questions } from "./GameCreateData.svelte.js"; import { AiPrompts } from "$lib/config.js"; +import toast from "svelte-5-french-toast"; export function GenerateOptionsUsingAI(index) { fetch("https://ai.hackclub.com/chat/completions", { @@ -26,9 +27,9 @@ export function GenerateOptionsUsingAI(index) { questions.v[index].name = question; }) .catch((error) => { - alert("Error:" + error); + toast.error("Error:" + error); return; }); - alert("added!"); + toast.success("added!"); } diff --git a/src/routes/kahootclone/create/logic/GenerateQuestionsUsingAI.js b/src/routes/kahootclone/create/logic/GenerateQuestionsUsingAI.js index 1938d10..627164a 100644 --- a/src/routes/kahootclone/create/logic/GenerateQuestionsUsingAI.js +++ b/src/routes/kahootclone/create/logic/GenerateQuestionsUsingAI.js @@ -1,5 +1,6 @@ import { questions } from "./GameCreateData.svelte.js"; import { AiPrompts } from "$lib/config.js"; +import toast from "svelte-5-french-toast"; export function GenerateQuestionsUsingAI() { let topic = window.prompt( @@ -30,9 +31,9 @@ export function GenerateQuestionsUsingAI() { questions.v = JSON.parse(data.choices[0].message.content); }) .catch((error) => { - alert("Error:" + error); + toast.error("Error:" + error); return; }); - alert("added!"); + toast.success("added!"); } \ No newline at end of file diff --git a/src/routes/kahootclone/create/logic/InsertGameInDB.js b/src/routes/kahootclone/create/logic/InsertGameInDB.js index 39f8d0b..7f0824f 100644 --- a/src/routes/kahootclone/create/logic/InsertGameInDB.js +++ b/src/routes/kahootclone/create/logic/InsertGameInDB.js @@ -1,4 +1,6 @@ import { supabase } from "$lib/supabase"; +import toast from "svelte-5-french-toast"; + export async function createGame(questions, gamePin) { const { data: gameData, error: gameError } = await supabase.from("games").insert({ @@ -9,7 +11,7 @@ export async function createGame(questions, gamePin) { }); if (gameError) { - alert("Failed to create game: " + gameError.message + "\n\nPlease try again."); + toast.error("Failed to create game: " + gameError.message + "\n\nPlease try again."); return; } @@ -18,6 +20,7 @@ export async function createGame(questions, gamePin) { gameid: gamePin, questionstext: q.name, correctanswer: q.correctAnswer, + media: q.media || null, })); const { data: questionsResult, error: questionsError } = await supabase @@ -26,7 +29,7 @@ export async function createGame(questions, gamePin) { .select("id"); if (questionsError) { - alert("Failed to insert questions: " + questionsError.message + "\n\nPlease try again."); + toast.error("Failed to insert questions: " + questionsError.message + "\n\nPlease try again."); return; } @@ -43,9 +46,9 @@ export async function createGame(questions, gamePin) { const { error: answersError } = await supabase.from("answers").insert(answersData); if (answersError) { - alert("Failed to insert answers: " + answersError.message + "\n\nPlease try again."); + toast.error("Failed to insert answers: " + answersError.message + "\n\nPlease try again."); return; } - window.location.href = `/host?gamepin=${gamePin}` ; + window.location.href = `/kahootclone/host?gamepin=${gamePin}`; } diff --git a/src/routes/kahootclone/create/logic/StartGame.js b/src/routes/kahootclone/create/logic/StartGame.js index c7a8456..6060fac 100644 --- a/src/routes/kahootclone/create/logic/StartGame.js +++ b/src/routes/kahootclone/create/logic/StartGame.js @@ -1,11 +1,12 @@ import { createGame } from "./InsertGameInDB.js"; import { questions,Wait } from "./GameCreateData.svelte.js"; +import toast from "svelte-5-french-toast"; export async function startGame() { - if (questions.v.some((q) => q.name === "")) return alert("Please fill all questions"); - if (questions.v.some((q) => q.answers.some((a) => a === ""))) return alert("Fill all options"); + if (questions.v.some((q) => q.name === "")) return toast.error("Please fill all questions"); + if (questions.v.some((q) => q.answers.some((a) => a === ""))) return toast.error("Fill all options"); if (questions.v.some((q) => q.correctAnswer === undefined)) - return alert("Select correct answers"); + return toast.error("Select correct answers"); const gamePin = Math.floor(Math.random() * 1000000) .toString() diff --git a/src/routes/kahootclone/create/logic/UpLoadFiles.js b/src/routes/kahootclone/create/logic/UpLoadFiles.js index 70a9b54..df42794 100644 --- a/src/routes/kahootclone/create/logic/UpLoadFiles.js +++ b/src/routes/kahootclone/create/logic/UpLoadFiles.js @@ -27,5 +27,5 @@ export async function UpLoadFiles(file) { // Retrieve public URL const { data: publicData } = supabase.storage.from("useruploadedcontent").getPublicUrl(filePath); - toast.success(publicData.publicUrl); + return publicData.publicUrl; } diff --git a/src/routes/kahootclone/host/+page.svelte b/src/routes/kahootclone/host/+page.svelte index 2fd96bb..e54c2bc 100644 --- a/src/routes/kahootclone/host/+page.svelte +++ b/src/routes/kahootclone/host/+page.svelte @@ -2,18 +2,20 @@ import PlayingDisplay from "./components/DuringGame/display.svelte"; import LobbyDisplay from "./components/lobby/display.svelte"; - import { Status } from "./logic/HostsData.svelte.js"; + import { Status,gamePin } from "./logic/HostsData.svelte.js"; import { AutoUpdatePlayersList } from "./logic/UpdatePlayersList.js"; import { GetCurrentPlayers } from "./logic/GetCurrentPlayers.js"; import { onMount } from "svelte"; - - let gamePin; - + onMount(() => { - gamePin = new URLSearchParams(new URL(window.location.href).search).get("gamepin"); - - GetCurrentPlayers(gamePin); - AutoUpdatePlayersList(gamePin); + gamePin.v = new URLSearchParams(new URL(window.location.href).search).get("gamepin"); + + + + console.log("Game Pin: " + gamePin.v); + + GetCurrentPlayers(gamePin.v); + AutoUpdatePlayersList(gamePin.v); }); @@ -22,7 +24,7 @@ class="flex max-w-[700px] flex-col items-center justify-center gap-1 rounded-lg bg-gray-900 p-8 shadow-lg" > {#if Status.v == "lobby"} - + {:else if Status.v == "started"} {/if} diff --git a/src/routes/kahootclone/host/components/DuringGame/PeopleAwnsered.svelte b/src/routes/kahootclone/host/components/DuringGame/PeopleAwnsered.svelte index c94ad33..5c02b48 100644 --- a/src/routes/kahootclone/host/components/DuringGame/PeopleAwnsered.svelte +++ b/src/routes/kahootclone/host/components/DuringGame/PeopleAwnsered.svelte @@ -1,5 +1,5 @@
diff --git a/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/ProgressBar.svelte b/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/ProgressBar.svelte index c2eed42..34cb551 100644 --- a/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/ProgressBar.svelte +++ b/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/ProgressBar.svelte @@ -1,5 +1,5 @@
diff --git a/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/display.svelte b/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/display.svelte index b92f42b..5643130 100644 --- a/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/display.svelte +++ b/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/display.svelte @@ -6,4 +6,6 @@ + + diff --git a/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/text/Quetion.svelte b/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/text/Quetion.svelte index 8fd3606..8ba9f89 100644 --- a/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/text/Quetion.svelte +++ b/src/routes/kahootclone/host/components/DuringGame/awnseringQuetions/text/Quetion.svelte @@ -5,3 +5,20 @@

Q{currentQuestion.v + 1}. {CurrentQuestionDetails.v.question}

+{#if CurrentQuestionDetails.v.media != null} +
+ {#if CurrentQuestionDetails.v.media.match(/\.(mp4|webm|ogg|mov|avi|mkv)$/i)} +
+{/if} diff --git a/src/routes/kahootclone/host/components/lobby/display.svelte b/src/routes/kahootclone/host/components/lobby/display.svelte index 3cccce9..37b2a34 100644 --- a/src/routes/kahootclone/host/components/lobby/display.svelte +++ b/src/routes/kahootclone/host/components/lobby/display.svelte @@ -2,14 +2,15 @@ import StartGame from "./buttons/startGame.svelte"; import Players from "./PlayersGUI/players.svelte"; - let props = $props(); - let gamePin = props.gamePin; + import { gamePin } from "../../logic/HostsData.svelte.js"; + + console.log("Game Pin: " + gamePin.v);

HOSTING

Game Pin:

- {gamePin} + {gamePin.v}

- + diff --git a/src/routes/kahootclone/host/logic/GameOver.js b/src/routes/kahootclone/host/logic/GameOver.js index 48d22cb..f0275b0 100644 --- a/src/routes/kahootclone/host/logic/GameOver.js +++ b/src/routes/kahootclone/host/logic/GameOver.js @@ -3,5 +3,5 @@ import { supabase } from "$lib/supabase.js"; export async function GameOver(GamePin) { await supabase.from("games").update({ status: `completed` }).eq("gamepin", GamePin); - window.location.replace("/results?gamepin=" + GamePin + "&playerID=host-null"); + window.location.replace("/kahootclone/results?gamepin=" + GamePin + "&playerID=host-null"); } diff --git a/src/routes/kahootclone/host/logic/GetCurrentPlayers.js b/src/routes/kahootclone/host/logic/GetCurrentPlayers.js index 1eac14a..20e0e39 100644 --- a/src/routes/kahootclone/host/logic/GetCurrentPlayers.js +++ b/src/routes/kahootclone/host/logic/GetCurrentPlayers.js @@ -14,5 +14,5 @@ export async function GetCurrentPlayers(gamePin) { return; } - players.v = data ? data.map(player => player.playername) : []; + players.v = data ? data.map((player) => player.playername) : []; } diff --git a/src/routes/kahootclone/host/logic/HostsData.svelte.js b/src/routes/kahootclone/host/logic/HostsData.svelte.js index f384d09..82e4d56 100644 --- a/src/routes/kahootclone/host/logic/HostsData.svelte.js +++ b/src/routes/kahootclone/host/logic/HostsData.svelte.js @@ -8,3 +8,5 @@ export let PeopleAwnseredQ = $state({ v: 0 }); export let Totalplayers = $state({ v: 3 }); export let CurrentQuestionDetails = $state({ v: {} }); + +export let gamePin = $state({ v: "" }); \ No newline at end of file diff --git a/src/routes/kahootclone/host/logic/WaitForAwnser.js b/src/routes/kahootclone/host/logic/WaitForAwnser.js index 39f6cce..7fd2e9a 100644 --- a/src/routes/kahootclone/host/logic/WaitForAwnser.js +++ b/src/routes/kahootclone/host/logic/WaitForAwnser.js @@ -32,7 +32,7 @@ export async function WaitForAwnser(questionid, gamePin) { const { data: questionsData } = await supabase .from("questions") - .select("id,questionstext,correctanswer") + .select("*") .eq("gameid", Number(gamePin)) .order("id", { ascending: true }); @@ -47,5 +47,6 @@ export async function WaitForAwnser(questionid, gamePin) { correctAnswer: questionsData[currentQuestion.v].correctanswer, answers: answers.map((answer) => answer.content), questionid: questionsData[currentQuestion.v].id, + media: questionsData[currentQuestion.v].media || null, }; } diff --git a/src/routes/kahootclone/host/logic/startGame.js b/src/routes/kahootclone/host/logic/startGame.js index cbc2edc..a54e163 100644 --- a/src/routes/kahootclone/host/logic/startGame.js +++ b/src/routes/kahootclone/host/logic/startGame.js @@ -1,18 +1,15 @@ import { supabase } from "$lib/supabase.js"; import { LobbyConnection } from "./UpdatePlayersList.js"; -import { - questions, - Status, - Totalplayers, - totalQuetions, - players, -} from "./HostsData.svelte.js"; +import { questions, Status, Totalplayers, totalQuetions, players } from "./HostsData.svelte.js"; import { WaitForAwnser } from "./WaitForAwnser.js"; +import toast from "svelte-5-french-toast"; export async function startGame(gamePin) { if (players.v.length == 0) { - alert("you need at least 1 person to start the game!"); + toast.error("you need at least 1 person to start the game!"); return; + + } await supabase.removeChannel(LobbyConnection); diff --git a/src/routes/kahootclone/join/+page.svelte b/src/routes/kahootclone/join/+page.svelte index f92c8b0..9962e89 100644 --- a/src/routes/kahootclone/join/+page.svelte +++ b/src/routes/kahootclone/join/+page.svelte @@ -1,6 +1,8 @@
@@ -15,6 +15,25 @@ {#if CurrentQuestion.v != null} + + {#if questions.v.media != null} +
+ {#if questions.v.media.match(/\.(mp4|webm|ogg|mov|avi|mkv)$/i)} +
+ {/if} + {#if Selected.v != null} diff --git a/src/routes/kahootclone/play/logic/NewStatus.js b/src/routes/kahootclone/play/logic/NewStatus.js index 9dc22d7..622a0a1 100644 --- a/src/routes/kahootclone/play/logic/NewStatus.js +++ b/src/routes/kahootclone/play/logic/NewStatus.js @@ -11,7 +11,7 @@ import { supabase } from "$lib/supabase.js"; export async function NewStatus(NewStatus, gamePin) { if (NewStatus == "completed") { - window.location.replace("/results?gamepin" + gamePin + "&playerID=" + playerid.v); + window.location.replace("/kahootclone/results?gamepin=" + gamePin + "&playerID=" + playerid.v); return; } @@ -20,7 +20,7 @@ export async function NewStatus(NewStatus, gamePin) { const { data: questionsData } = await supabase .from("questions") - .select("id,questionstext,correctanswer") + .select("*") .eq("gameid", Number(gamePin)) .order("id", { ascending: true }); @@ -37,6 +37,7 @@ export async function NewStatus(NewStatus, gamePin) { correctAnswer: questionsData[CurrentQuestion.v].correctanswer, answers: answers.map((answer) => answer.content), questionid: questionsData[CurrentQuestion.v].id, + media: questionsData[CurrentQuestion.v].media || null, }; isWait.v = false; diff --git a/src/routes/randomname/+page.svelte b/src/routes/randomname/+page.svelte index e599a68..b3ab9ef 100644 --- a/src/routes/randomname/+page.svelte +++ b/src/routes/randomname/+page.svelte @@ -2,8 +2,7 @@ import Selector from "./selector.svelte"; import TopDisplay from "./TopDisplay.svelte"; import EditNameOfStudents from "./EditNameOfStudents.svelte"; - //import {ShowAlert} from "../+page.svelte"; - + import toast from "svelte-5-french-toast"; export let RandomNamesState = $state({ NotSelectedYet: [], Selected: [], @@ -25,7 +24,7 @@ ]; RandomNamesState.NotSelectedYet.splice(randomIndex, 1); } else { - //ShowAlert("All students have been selected.", "warning"); + toast.error("All students have been selected.", "warning"); } } diff --git a/src/routes/wordle/logic.svelte.js b/src/routes/wordle/logic.svelte.js index 96eba7c..91b0e7a 100644 --- a/src/routes/wordle/logic.svelte.js +++ b/src/routes/wordle/logic.svelte.js @@ -86,7 +86,6 @@ export function newGame() { } function GameWin() { - //ShowAlert("You win!", "success"); toast.success("You win!"); data.value[WordLegnth.v].push(words.v.length); @@ -165,7 +164,7 @@ export function ButtonPressed(key) { SendWord(CurrentWord.v); CurrentWord.v = []; } else { - //ShowAlert("Not a valid word", "error"); + toast.error("Not a valid word"); } } return;