Added Kahoot!-Mode

This commit is contained in:
Mawoka
2022-09-17 22:32:18 +02:00
parent 4f2478c8e5
commit 1651cd7b2c
16 changed files with 161 additions and 28 deletions
+19 -5
View File
@@ -12,6 +12,7 @@
import type { PlayerAnswer, Player } from '$lib/admin.ts';
import SomeAdminScreen from '$lib/admin.svelte';
import { browser } from '$app/environment';
import { onMount } from 'svelte';
navbarVisible.set(false);
@@ -22,6 +23,7 @@
// game_pin: '66190765'
// };
export let data;
let game_mode;
let { game_pin, auto_connect, game_token } = data;
let players: Array<Player> = [];
@@ -35,15 +37,21 @@
let dataexport_download_a;
let warnToLeave = true;
const connect = () => {
const connect = async () => {
socket.emit('register_as_admin', {
game_pin: game_pin,
game_id: game_token
});
const res = await fetch(`/api/v1/quiz/play/check_captcha/${game_pin}`);
const json = await res.json();
game_mode = json.game_mode;
};
if (auto_connect) {
connect();
}
onMount(() => {
if (auto_connect) {
connect();
}
});
socket.on('registered_as_admin', (data) => {
quiz_data = JSON.parse(data['game']);
console.log(quiz_data);
@@ -152,7 +160,13 @@
</div>
{/if}
{:else}
<SomeAdminScreen bind:final_results bind:game_pin bind:game_token bind:quiz_data />
<SomeAdminScreen
bind:final_results
bind:game_pin
bind:game_token
bind:quiz_data
bind:game_mode
/>
{/if}
<a
+3 -1
View File
@@ -22,6 +22,7 @@
started: boolean;
}
let game_mode;
let final_results: Array<null> | Array<Array<PlayerAnswer>> = [null];
interface PlayerAnswer {
@@ -118,7 +119,7 @@
</svelte:head>
<div>
{#if !gameMeta.started && gameData === undefined}
<JoinGame {game_pin} />
<JoinGame {game_pin} bind:game_mode />
{:else if JSON.stringify(final_results) !== JSON.stringify([null])}
<ShowEndScreen bind:final_results bind:quiz_data={gameData} />
{:else if gameData !== undefined && question_index === ''}
@@ -130,6 +131,7 @@
{:else if gameMeta.started && gameData !== undefined && question_index !== '' && answer_results === undefined}
{#key unique}
<Question
bind:game_mode
bind:question={gameData.questions[parseInt(question_index)]}
bind:question_index
/>
@@ -9,7 +9,7 @@
import { createTippy } from 'svelte-tippy';
import ImportedOrNot from '$lib/view_quiz/imported_or_not.svelte';
import { QuizQuestionType } from '$lib/quiz_types.js';
import { start_game } from '$lib/dashboard/start_game';
import { start_game } from '../../../lib/dashboard/start_game.svelte';
const tippy = createTippy({
arrow: true,