From 5774dc20b7806c8a9e1b47675ed637a0204d720c Mon Sep 17 00:00:00 2001
From: Mawoka
Date: Sat, 21 Oct 2023 22:18:13 +0200
Subject: [PATCH] Formatted code
---
.../lib/play/admin/game_not_started.svelte | 6 +-
frontend/src/lib/play/question.svelte | 153 +++++++------
frontend/src/lib/play/questions/check.svelte | 29 +--
.../src/routes/view/[quiz_id]/+page.svelte | 211 +++++++++---------
4 files changed, 195 insertions(+), 204 deletions(-)
diff --git a/frontend/src/lib/play/admin/game_not_started.svelte b/frontend/src/lib/play/admin/game_not_started.svelte
index f911246..fc61142 100644
--- a/frontend/src/lib/play/admin/game_not_started.svelte
+++ b/frontend/src/lib/play/admin/game_not_started.svelte
@@ -9,14 +9,14 @@ SPDX-License-Identifier: MPL-2.0
import ControllerCodeDisplay from '$lib/components/controller/code.svelte';
import { getLocalization } from '$lib/i18n';
import GrayButton from '$lib/components/buttons/gray.svelte';
- import {fade} from 'svelte/transition';
+ import { fade } from 'svelte/transition';
export let game_pin: string;
export let players;
export let socket;
export let cqc_code: string;
- let fullscreen_open = false
+ let fullscreen_open = false;
const { t } = getLocalization();
let play_music = false;
@@ -52,7 +52,7 @@ SPDX-License-Identifier: MPL-2.0
fullscreen_open = true}
+ on:click={() => (fullscreen_open = true)}
alt="QR code to join the game"
src="/api/v1/utils/qr/{game_pin}"
class="block mx-auto w-1/2 dark:bg-white shadow-2xl rounded hover:cursor-pointer"
diff --git a/frontend/src/lib/play/question.svelte b/frontend/src/lib/play/question.svelte
index 2821496..59a8cbc 100644
--- a/frontend/src/lib/play/question.svelte
+++ b/frontend/src/lib/play/question.svelte
@@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
SPDX-License-Identifier: MPL-2.0
-->
-
-
+
{#if game_mode === 'normal'}
{@html question.question}
{#if question.image !== null && game_mode !== 'kahoot'}
-
+
{/if}
@@ -167,36 +167,36 @@ SPDX-License-Identifier: MPL-2.0
{/if}
{#if timer_res !== '0'}
{#if question.type === QuizQuestionType.ABCD || question.type === QuizQuestionType.VOTING}
-
+
-
+
{#each question.answers as answer, i}
selectAnswer(answer.answer)}
>
{#if game_mode === 'kahoot'}
{:else}
- {answer.answer}
+ {answer.answer}
{/if}
{/each}
@@ -204,57 +204,55 @@ SPDX-License-Identifier: MPL-2.0
{:else if question.type === QuizQuestionType.RANGE}
+ class="fixed top-0 bg-red-500 h-8 transition-all"
+ style="width: {(100 / parseInt(question.time)) * parseInt(timer_res)}vw"
+ />
{#await import('svelte-range-slider-pips')}
{:then c}
-
+
-
-
+
+
selectAnswer(slider_value[0])}
- >{$t('words.submit')}
+ >{$t('words.submit')}
{/await}
{:else if question.type === QuizQuestionType.TEXT}
-
-
-
Enter your answer
+
+
-
+
-
-
+
+
{
selectAnswer(text_input);
@@ -268,9 +266,9 @@ SPDX-License-Identifier: MPL-2.0
{#if solution === undefined}
{:else}
-
+
Every number between {solution.answers.min_correct} and {solution.answers
- .max_correct} was correct. You got {selected_answer}, so you have been
+ .max_correct} was correct. You got {selected_answer}, so you have been
{#if solution.answers.min_correct <= parseInt(selected_answer) && parseInt(selected_answer) <= solution.answers.max_correct}
correct
{:else}
@@ -283,14 +281,13 @@ SPDX-License-Identifier: MPL-2.0
{:else}-->
-
+
{#each question.answers as answer, i (answer.id)}
@@ -298,59 +295,59 @@ SPDX-License-Identifier: MPL-2.0
on:click={() => {
question.answers = swapArrayElements(question.answers, i, i - 1);
}}
- class='disabled:opacity-50 transition shadow-lg bg-black bg-opacity-30 w-full flex justify-center rounded-lg p-2 hover:bg-opacity-20 transition'
- type='button'
+ class="disabled:opacity-50 transition shadow-lg bg-black bg-opacity-30 w-full flex justify-center rounded-lg p-2 hover:bg-opacity-20 transition"
+ type="button"
disabled={i === 0 || selected_answer}
>
-
{answer.answer}
+
{answer.answer}
{
question.answers = swapArrayElements(question.answers, i, i + 1);
}}
- class='disabled:opacity-50 transition shadow-lg bg-black bg-opacity-30 w-full flex justify-center rounded-lg p-2 hover:bg-opacity-20 transition'
- type='button'
+ class="disabled:opacity-50 transition shadow-lg bg-black bg-opacity-30 w-full flex justify-center rounded-lg p-2 hover:bg-opacity-20 transition"
+ type="button"
disabled={i === question.answers.length - 1 || selected_answer}
>
{/each}
-
+
{
select_complex_answer(question.answers);
@@ -371,12 +368,12 @@ SPDX-License-Identifier: MPL-2.0
{timer_res}
{circular_progress}
/>
-
-
+
+
selectAnswer(selected_answer)}
- >{$t('words.submit')}
+ >{$t('words.submit')}
diff --git a/frontend/src/lib/play/questions/check.svelte b/frontend/src/lib/play/questions/check.svelte
index 917671e..39fa7f5 100644
--- a/frontend/src/lib/play/questions/check.svelte
+++ b/frontend/src/lib/play/questions/check.svelte
@@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
SPDX-License-Identifier: MPL-2.0
-->
-
-
+
-
+
-
-
+
{#each question.answers as answer, i}
selectAnswer(i)}
class:opacity-100={_selected_answers[i]}
class:opacity-50={!_selected_answers[i]}
>
{#if game_mode === 'kahoot'}
-
+
{:else}
- {answer.answer}
+ {answer.answer}
{/if}
{/each}
diff --git a/frontend/src/routes/view/[quiz_id]/+page.svelte b/frontend/src/routes/view/[quiz_id]/+page.svelte
index dd4b123..1cdd03a 100644
--- a/frontend/src/routes/view/[quiz_id]/+page.svelte
+++ b/frontend/src/routes/view/[quiz_id]/+page.svelte
@@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
SPDX-License-Identifier: MPL-2.0
-->
-