✨ Closing #216
This commit is contained in:
@@ -226,12 +226,14 @@ async def register_as_admin(sid: str, data: dict):
|
||||
async def get_question_results(sid: str, data: dict):
|
||||
session = await sio.get_session(sid)
|
||||
if session["admin"]:
|
||||
redis_res = await redis.get(f"game_session:{session['game_pin']}:{data['question_number']}")
|
||||
redis_res = AnswerDataList.parse_raw(
|
||||
await redis.get(f"game_session:{session['game_pin']}:{data['question_number']}")
|
||||
)
|
||||
game_data = PlayGame.parse_raw(await redis.get(f"game:{session['game_pin']}"))
|
||||
game_data.question_show = False
|
||||
await redis.set(f"game:{session['game_pin']}", game_data.json())
|
||||
game_pin = session["game_pin"]
|
||||
await sio.emit("question_results", redis_res, room=game_pin)
|
||||
await sio.emit("question_results", redis_res.dict()["__root__"], room=game_pin)
|
||||
|
||||
|
||||
class ABCDQuizAnswerWithoutSolution(BaseModel):
|
||||
|
||||
@@ -44,10 +44,6 @@ SPDX-License-Identifier: MPL-2.0
|
||||
socket.on('get_question_results', () => {
|
||||
console.log('get_question_results');
|
||||
});
|
||||
socket.on('question_results', (_) => {
|
||||
timer_res = '0';
|
||||
clearInterval(timer_interval);
|
||||
});
|
||||
socket.on('set_question_number', (data) => {
|
||||
timer_res = '0';
|
||||
clearInterval(timer_interval);
|
||||
@@ -90,12 +86,9 @@ SPDX-License-Identifier: MPL-2.0
|
||||
});
|
||||
|
||||
socket.on('question_results', (data) => {
|
||||
try {
|
||||
question_results = JSON.parse(data);
|
||||
timer_res = '0';
|
||||
} catch {
|
||||
question_results = undefined;
|
||||
}
|
||||
console.log('question_results:', data);
|
||||
question_results = data;
|
||||
timer_res = '0';
|
||||
});
|
||||
|
||||
socket.on('player_answer', (_) => {
|
||||
@@ -295,8 +288,8 @@ SPDX-License-Identifier: MPL-2.0
|
||||
{/if}
|
||||
{/if}
|
||||
<br />
|
||||
{#if timer_res === '0' && JSON.stringify(final_results) === JSON.stringify( [null] ) && quiz_data.questions[selected_question].type !== QuizQuestionType.SLIDE}
|
||||
{#if question_results === null}{:else if question_results === undefined}
|
||||
{#if timer_res === '0' && JSON.stringify(final_results) === JSON.stringify( [null] ) && quiz_data.questions[selected_question].type !== QuizQuestionType.SLIDE && question_results !== null}
|
||||
{#if question_results === undefined}
|
||||
{#if !final_results_clicked}
|
||||
<div class="w-full flex justify-center">
|
||||
<h1 class="text-3xl">{$t('admin_page.no_answers')}</h1>
|
||||
@@ -319,13 +312,14 @@ SPDX-License-Identifier: MPL-2.0
|
||||
<svelte:component
|
||||
this={c.default}
|
||||
bind:data={player_scores}
|
||||
question={quiz_data.questions[selected_question]}
|
||||
bind:new_data={question_results}
|
||||
/>
|
||||
{/await}
|
||||
{/if}
|
||||
{:else if timer_res !== undefined}{/if}
|
||||
{/if}
|
||||
<br />
|
||||
{#if get_question_title(selected_question + 1, quiz_data) !== '' && selected_question + 1 !== 0}{:else if selected_question + 1 === 0}
|
||||
{#if get_question_title(selected_question + 1, quiz_data) === '' && selected_question + 1 === 0}
|
||||
<div class="flex flex-col justify-center w-screen h-full">
|
||||
<h1 class="text-7xl text-center">{@html quiz_data.title}</h1>
|
||||
<p class="text-3xl pt-8 text-center">{@html quiz_data.description}</p>
|
||||
|
||||
@@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
-->
|
||||
|
||||
<script lang='ts'>
|
||||
<script lang="ts">
|
||||
import type { Konva, ShapeModel } from 'pikaso';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
@@ -27,7 +27,7 @@ SPDX-License-Identifier: MPL-2.0
|
||||
available_modifiers.push('fill_color');
|
||||
break;
|
||||
case 'rect':
|
||||
available_modifiers.push("fill_color");
|
||||
available_modifiers.push('fill_color');
|
||||
break;
|
||||
}
|
||||
};
|
||||
@@ -67,11 +67,11 @@ SPDX-License-Identifier: MPL-2.0
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class='flex flex-row justify-evenly z-40'>
|
||||
<div class="flex flex-row justify-evenly z-40">
|
||||
<div>
|
||||
<button
|
||||
type='button'
|
||||
class='disabled:opacity-50 transition'
|
||||
type="button"
|
||||
class="disabled:opacity-50 transition"
|
||||
disabled={!(
|
||||
available_modifiers.includes('fill_color') ||
|
||||
available_modifiers.includes('text_color')
|
||||
@@ -82,35 +82,35 @@ SPDX-License-Identifier: MPL-2.0
|
||||
>
|
||||
<!-- iconoir/color-picker -->
|
||||
<svg
|
||||
class='w-6 h-6'
|
||||
stroke-width='2'
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
color='currentColor'
|
||||
class="w-6 h-6"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
color="currentColor"
|
||||
>
|
||||
<path
|
||||
d='M7 13.161l5.464-5.464a1 1 0 011.415 0l2.12 2.12a1 1 0 010 1.415l-1.928 1.929m-7.071 0l-2.172 2.172a.999.999 0 00-.218.327l-1.028 2.496c-.508 1.233.725 2.466 1.958 1.959l2.497-1.028c.122-.05.233-.125.326-.218l5.708-5.708m-7.071 0h7.071M13.878 3.454l2.121 2.121m4.243 4.243l-2.121-2.121m-2.122-2.122l1.414-1.414a1 1 0 011.415 0l.707.707a1 1 0 010 1.414L18.12 7.697m-2.122-2.122l2.122 2.122'
|
||||
stroke='currentColor'
|
||||
stroke-width='2'
|
||||
stroke-linecap='round'
|
||||
stroke-linejoin='round'
|
||||
d="M7 13.161l5.464-5.464a1 1 0 011.415 0l2.12 2.12a1 1 0 010 1.415l-1.928 1.929m-7.071 0l-2.172 2.172a.999.999 0 00-.218.327l-1.028 2.496c-.508 1.233.725 2.466 1.958 1.959l2.497-1.028c.122-.05.233-.125.326-.218l5.708-5.708m-7.071 0h7.071M13.878 3.454l2.121 2.121m4.243 4.243l-2.121-2.121m-2.122-2.122l1.414-1.414a1 1 0 011.415 0l.707.707a1 1 0 010 1.414L18.12 7.697m-2.122-2.122l2.122 2.122"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
{#if opened_dropdown === 'color'}
|
||||
<div
|
||||
class='bg-white m-auto rounded-lg shadow-lg p-4 dark:bg-gray-600 h-fit gap-2 w-fit auto-cols-min flex absolute z-40'
|
||||
class="bg-white m-auto rounded-lg shadow-lg p-4 dark:bg-gray-600 h-fit gap-2 w-fit auto-cols-min flex absolute z-40"
|
||||
transition:fade={{ duration: 100 }}
|
||||
>
|
||||
<input type='color' on:change={change_color} />
|
||||
<input type="color" on:change={change_color} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<button
|
||||
type='button'
|
||||
class='disabled:opacity-50 transition'
|
||||
type="button"
|
||||
class="disabled:opacity-50 transition"
|
||||
on:click={() => {
|
||||
toggle_switch('font_size');
|
||||
}}
|
||||
@@ -118,41 +118,41 @@ SPDX-License-Identifier: MPL-2.0
|
||||
>
|
||||
<!-- iconoir/font-size -->
|
||||
<svg
|
||||
class='w-6 h-6'
|
||||
stroke-width='2'
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
color='currentColor'
|
||||
class="w-6 h-6"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
color="currentColor"
|
||||
>
|
||||
<path
|
||||
d='M18 21V11m0 10l-2-2.5m2 2.5l2-2.5M18 11l-2 2m2-2l2 2M9 5v12m0 0H7m2 0h2M15 7V5H3v2'
|
||||
stroke='currentColor'
|
||||
stroke-width='2'
|
||||
stroke-linecap='round'
|
||||
stroke-linejoin='round'
|
||||
d="M18 21V11m0 10l-2-2.5m2 2.5l2-2.5M18 11l-2 2m2-2l2 2M9 5v12m0 0H7m2 0h2M15 7V5H3v2"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
{#if opened_dropdown === 'font_size'}
|
||||
<div
|
||||
class='bg-white m-auto rounded-lg shadow-lg p-4 dark:bg-gray-600 h-fit gap-2 w-fit auto-cols-min flex absolute z-40'
|
||||
class="bg-white m-auto rounded-lg shadow-lg p-4 dark:bg-gray-600 h-fit gap-2 w-fit auto-cols-min flex absolute z-40"
|
||||
transition:fade={{ duration: 100 }}
|
||||
>
|
||||
<input
|
||||
type='range'
|
||||
type="range"
|
||||
on:change={change_fontsize}
|
||||
value={selected_el?.node?.children?.[1]?.attrs?.fontSize}
|
||||
min='10'
|
||||
max='250'
|
||||
min="10"
|
||||
max="250"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class='flex flex-row gap-2'>
|
||||
<div class="flex flex-row gap-2">
|
||||
<button
|
||||
type='button'
|
||||
class='disabled:opacity-50 transition'
|
||||
type="button"
|
||||
class="disabled:opacity-50 transition"
|
||||
on:click={() => {
|
||||
selected_el.update({ zIndex: selected_el.node.getZIndex() + 1 });
|
||||
}}
|
||||
@@ -160,25 +160,25 @@ SPDX-License-Identifier: MPL-2.0
|
||||
>
|
||||
<!-- iconoir/priority-up -->
|
||||
<svg
|
||||
class='w-6 h-6'
|
||||
stroke-width='2'
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
color='currentColor'
|
||||
class="w-6 h-6"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
color="currentColor"
|
||||
>
|
||||
<path
|
||||
d='M11.576 1.424a.6.6 0 01.848 0l10.152 10.152a.6.6 0 010 .848L12.424 22.576a.6.6 0 01-.848 0L1.424 12.424a.6.6 0 010-.848L11.576 1.424zM12 7l4 4m-4-4l-4 4.167M12 7v9'
|
||||
stroke='currentColor'
|
||||
stroke-width='2'
|
||||
stroke-linecap='round'
|
||||
stroke-linejoin='round'
|
||||
d="M11.576 1.424a.6.6 0 01.848 0l10.152 10.152a.6.6 0 010 .848L12.424 22.576a.6.6 0 01-.848 0L1.424 12.424a.6.6 0 010-.848L11.576 1.424zM12 7l4 4m-4-4l-4 4.167M12 7v9"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
type='button'
|
||||
class='disabled:opacity-50 transition'
|
||||
type="button"
|
||||
class="disabled:opacity-50 transition"
|
||||
on:click={() => {
|
||||
selected_el.update({ zIndex: selected_el.node.getZIndex() - 1 });
|
||||
}}
|
||||
@@ -186,19 +186,19 @@ SPDX-License-Identifier: MPL-2.0
|
||||
>
|
||||
<!-- iconoir/priority-down -->
|
||||
<svg
|
||||
class='w-6 h-6'
|
||||
stroke-width='2'
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
color='currentColor'
|
||||
class="w-6 h-6"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
color="currentColor"
|
||||
>
|
||||
<path
|
||||
d='M11.576 1.424a.6.6 0 01.848 0l10.152 10.152a.6.6 0 010 .848L12.424 22.576a.6.6 0 01-.848 0L1.424 12.424a.6.6 0 010-.848L11.576 1.424zM12 16l4-4m-4 4l-4-4.167M12 16V7'
|
||||
stroke='currentColor'
|
||||
stroke-width='2'
|
||||
stroke-linecap='round'
|
||||
stroke-linejoin='round'
|
||||
d="M11.576 1.424a.6.6 0 01.848 0l10.152 10.152a.6.6 0 010 .848L12.424 22.576a.6.6 0 01-.848 0L1.424 12.424a.6.6 0 010-.848L11.576 1.424zM12 16l4-4m-4 4l-4-4.167M12 16V7"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
@@ -5,13 +5,16 @@ SPDX-License-Identifier: MPL-2.0
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import VotingResults from './voting_results.svelte';
|
||||
import { flip } from 'svelte/animate';
|
||||
import { fly } from 'svelte/transition';
|
||||
import { onMount } from 'svelte';
|
||||
import { getLocalization } from '$lib/i18n';
|
||||
import type { Question } from '$lib/quiz_types';
|
||||
const { t } = getLocalization();
|
||||
|
||||
export let data;
|
||||
export let question: Question;
|
||||
|
||||
export let new_data: Array<{
|
||||
username: string;
|
||||
@@ -89,7 +92,7 @@ SPDX-License-Identifier: MPL-2.0
|
||||
// https://svelte.dev/repl/96a58afdea2248a5b7e489160ffba887?version=3.44.2
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<div class="h-full flex flex-col">
|
||||
<div class="flex justify-center">
|
||||
<div>
|
||||
<table class="table-auto text-xl">
|
||||
@@ -124,4 +127,7 @@ SPDX-License-Identifier: MPL-2.0
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<div class="mt-12">
|
||||
<VotingResults data={new_data} {question} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,6 @@ SPDX-License-Identifier: MPL-2.0
|
||||
quiz_colors.push(i.color);
|
||||
}
|
||||
|
||||
console.log('mounted', question);
|
||||
let sorted_data = {};
|
||||
for (const i of quiz_answers) {
|
||||
sorted_data[i] = 0;
|
||||
@@ -28,27 +27,35 @@ SPDX-License-Identifier: MPL-2.0
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex justify-center h-full w-full">
|
||||
<div class="flex justify-center w-full">
|
||||
<div
|
||||
class="m-auto grid grid-rows-3 w-fit gap-4"
|
||||
class="m-auto w-fit gap-4 flex flex-col"
|
||||
style="grid-template-columns: repeat({quiz_answers.length}, minmax(0, 1fr));"
|
||||
>
|
||||
{#each quiz_answers as answer}
|
||||
<span class="text-center self-end"
|
||||
>{#if sorted_data[answer] > 0}{sorted_data[answer]}{/if}</span
|
||||
>
|
||||
{/each}
|
||||
{#each quiz_answers as answer, i}
|
||||
<div
|
||||
class="w-20 self-end flex justify-center"
|
||||
style="height: {(sorted_data[answer] * 20) /
|
||||
data.length}rem; background-color: {quiz_colors[i] ? quiz_colors[i] : 'black'}"
|
||||
/>
|
||||
{/each}
|
||||
{#each quiz_answers as answer}
|
||||
<div class="w-20">
|
||||
<p class="-rotate-45">{@html answer}</p>
|
||||
</div>
|
||||
{/each}
|
||||
<div class="flex gap-4">
|
||||
{#each quiz_answers as answer}
|
||||
<span class="text-center self-end mx-auto"
|
||||
>{#if sorted_data[answer] > 0}{sorted_data[answer]}{/if}</span
|
||||
>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
{#each quiz_answers as answer, i}
|
||||
<div
|
||||
class="w-20 self-end flex justify-center"
|
||||
style="height: {(sorted_data[answer] * 20) /
|
||||
data.length}rem; background-color: {quiz_colors[i]
|
||||
? quiz_colors[i]
|
||||
: 'black'}"
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
{#each quiz_answers as answer}
|
||||
<div class="w-20">
|
||||
<p class="-rotate-45">{@html answer}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user