added 3 things: min 2 max 8 options in quetion, the quetion and awnser in the host panle too, clour coded and symbol for awnsers.

This commit is contained in:
RezHackXYZ 2025-05-24 07:26:49 +05:30
parent 2a4102438a
commit ad959266a5
No known key found for this signature in database
24 changed files with 259 additions and 45 deletions

View file

@ -1,7 +1,7 @@
<script>
import DeleteQuestion from '../buttons/DeleteQuestion.svelte';
import Answers from './answers.svelte';
import { questions } from '../../logic/GameCreateData.svelte.js';
import DeleteQuestion from "../buttons/DeleteQuestion.svelte";
import Answers from "./answers.svelte";
import { questions } from "../../logic/GameCreateData.svelte.js";
let props = $props();
let index = props.index;
@ -17,10 +17,35 @@
placeholder="Question {index + 1}"
class="h-fit w-[500px] rounded-xl bg-gray-800 p-1 text-center text-2xl text-white"
/>
<select
bind:value={questions.v[index].answers.length}
onchange={(e) => {
const newLength = parseInt(e.target.value);
const currentAnswers = questions.v[index].answers;
if (newLength > currentAnswers.length) {
// Add more answers
while (questions.v[index].answers.length < newLength) {
questions.v[index].answers = [
...questions.v[index].answers,
{ text: "", correct: false },
];
}
} else if (newLength < currentAnswers.length) {
// Remove excess answers
questions.v[index].answers = currentAnswers.slice(0, newLength);
}
}}
class="h-fit rounded-xl bg-gray-800 p-1 text-center text-white"
>
<option disabled selected>Options</option>
{#each Array(7) as _, i}
<option value={i + 2}>{i + 2}</option>
{/each}
</select>
<DeleteQuestion {index} />
</div>
<div class="flex flex-col gap-2">
{#each questions.v[index].answers as answer, answersIndex}
<Answers questionsIndex={index} {answersIndex} />