🐛 Fixed play-screen
This commit is contained in:
@@ -57,7 +57,7 @@ async def join_game(sid, data):
|
||||
{"username": data["username"], "sid": sid},
|
||||
room=redis_res["admin"],
|
||||
)
|
||||
sio.enter_room(sid, data["game_pin"]) # TODO: make more secure
|
||||
sio.enter_room(sid, data["game_pin"])
|
||||
|
||||
|
||||
@sio.event
|
||||
|
||||
@@ -10,7 +10,7 @@ module.exports = {
|
||||
trans: false,
|
||||
|
||||
// Create and update files `en.json`, `fr.json`, `es.json`
|
||||
lngs: ['en', 'de', 'fr'],
|
||||
lngs: ['en'],
|
||||
|
||||
ns: [
|
||||
// The namespace I use
|
||||
|
||||
@@ -110,7 +110,9 @@
|
||||
"already_registered_as_admin": "There is already an admin registered for this game.",
|
||||
"start_game": "Start game",
|
||||
"time_left": "Time left",
|
||||
"get_results": "Get results"
|
||||
"get_results": "Get results",
|
||||
"get_results_and_stop_time": "Get results and stop time",
|
||||
"get_final_results": "Get final results"
|
||||
},
|
||||
"password_reset_page": {
|
||||
"reset_password": "Reset password"
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
{#if winners_arr.length >= 3}
|
||||
<div>
|
||||
<p class="text-xl text-center">
|
||||
2nd Place: <span class="underline">{winners_arr[3]}</span><span
|
||||
3nd Place: <span class="underline">{winners_arr[3]}</span><span
|
||||
>With {winners[winners_arr[3]]}</span
|
||||
>
|
||||
</p>
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
game_id: game_token,
|
||||
question_number: shown_question_now
|
||||
});
|
||||
timer_res = '0';
|
||||
};
|
||||
|
||||
const getWinnersSorted = () => {
|
||||
@@ -174,6 +175,17 @@
|
||||
event.preventDefault();
|
||||
event.returnValue = '';
|
||||
};
|
||||
|
||||
const get_question_title = (q_number: number): string => {
|
||||
if (q_number - 1 === quiz_data.questions.length) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
return quiz_data.questions[q_number].question;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window on:beforeunload={confirmUnload} />
|
||||
@@ -222,9 +234,10 @@
|
||||
{/if}
|
||||
<br />
|
||||
{#if timer_res === '0'}
|
||||
<button on:click={get_question_results}>{$t('admin_page.get_results')}</button>
|
||||
<br />
|
||||
{#if question_results !== null}
|
||||
{#if question_results === null}
|
||||
<button on:click={get_question_results}>{$t('admin_page.get_results')}</button>
|
||||
<br />
|
||||
{:else}
|
||||
<br />
|
||||
<ul>
|
||||
{#each question_results as result}
|
||||
@@ -232,6 +245,9 @@
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
{:else if timer_res !== undefined}
|
||||
<button on:click={get_question_results}>{$t('admin_page.get_results_and_stop_time')}</button
|
||||
>
|
||||
{/if}
|
||||
<br />
|
||||
<!--{#each quiz_data.questions as { question }, index}
|
||||
@@ -242,14 +258,20 @@
|
||||
>
|
||||
<br />
|
||||
{/each}-->
|
||||
<button
|
||||
disabled={!(timer_res === undefined || timer_res === '0')}
|
||||
on:click={() => {
|
||||
set_question_number(selected_question + 1);
|
||||
}}>{selected_question + 1}: {quiz_data.questions[selected_question + 1].question}</button
|
||||
>
|
||||
<br />
|
||||
{#if selected_question === quiz_data.questions.length}
|
||||
<button on:click={get_final_results}>Get final results</button>
|
||||
{#if get_question_title(selected_question + 1) !== ''}
|
||||
<button
|
||||
disabled={!(timer_res === undefined || timer_res === '0')}
|
||||
on:click={() => {
|
||||
set_question_number(selected_question + 1);
|
||||
}}>{selected_question + 1}: {get_question_title(selected_question + 1)}</button
|
||||
>
|
||||
<br />
|
||||
{:else}
|
||||
<button on:click={get_final_results}>{$t('admin_page.get_final_results')}</button>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if JSON.stringify(final_results) !== JSON.stringify([null])}
|
||||
{#await import('$lib/play/end.svelte') then c}
|
||||
<svelte:component this={c.default} bind:final_results bind:quiz_data />
|
||||
{/await}
|
||||
{/if}
|
||||
|
||||
+116
-109
@@ -117,125 +117,132 @@
|
||||
{$t('words.settings')}
|
||||
</a>
|
||||
</div>
|
||||
<div class="overflow-x-auto sm:-mx-8 lg:-mx-8">
|
||||
<div class="inline-block py-2 min-w-full sm:px-6 lg:px-8">
|
||||
<div class="overflow-hidden shadow-md sm:rounded-lg">
|
||||
<table class="min-w-full">
|
||||
<thead class="bg-gray-50 dark:bg-gray-700">
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('words.title')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('overview_page.created_at')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('overview_page.question_count')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('words.play')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('words.edit')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('words.delete')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{$t('words.public')}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each quizzes as quiz}
|
||||
<tr
|
||||
class="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
|
||||
>
|
||||
<td
|
||||
class="py-4 px-6 text-sm font-medium text-gray-900 whitespace-nowrap dark:text-white"
|
||||
{#if quizzes.length !== 0}
|
||||
<div class="overflow-x-auto sm:-mx-8 lg:-mx-8">
|
||||
<div class="inline-block py-2 min-w-full sm:px-6 lg:px-8">
|
||||
<div class="overflow-hidden shadow-md sm:rounded-lg">
|
||||
<table class="min-w-full">
|
||||
<thead class="bg-gray-50 dark:bg-gray-700">
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{quiz.title}
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
{$t('words.title')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{formatDate(quiz.created_at)}
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
{$t('overview_page.created_at')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{quiz.questions.length}
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
{$t('overview_page.question_count')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
<button
|
||||
on:click={() => {
|
||||
startGame(quiz.id);
|
||||
}}
|
||||
class="border border-green-600"
|
||||
>
|
||||
{$t('words.start')}
|
||||
</button>
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
{$t('words.play')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
<a
|
||||
href="/edit?quiz_id={quiz.id}"
|
||||
class="border border-yellow-600"
|
||||
>{$t('words.edit')}</a
|
||||
>
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
{$t('words.edit')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
<button
|
||||
on:click={() => {
|
||||
deleteQuiz(quiz.id);
|
||||
}}
|
||||
class="border border-red-600"
|
||||
>
|
||||
{$t('words.delete')}
|
||||
</button>
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
{$t('words.delete')}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
|
||||
>
|
||||
{#if quiz.public}
|
||||
✅
|
||||
{:else}
|
||||
❌
|
||||
{/if}
|
||||
</td>
|
||||
{$t('words.public')}
|
||||
</th>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each quizzes as quiz}
|
||||
<tr
|
||||
class="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
|
||||
>
|
||||
<td
|
||||
class="py-4 px-6 text-sm font-medium text-gray-900 whitespace-nowrap dark:text-white"
|
||||
>
|
||||
{quiz.title}
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
>
|
||||
{formatDate(quiz.created_at)}
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
>
|
||||
{quiz.questions.length}
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
>
|
||||
<button
|
||||
on:click={() => {
|
||||
startGame(quiz.id);
|
||||
}}
|
||||
class="border border-green-600"
|
||||
>
|
||||
{$t('words.start')}
|
||||
</button>
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
>
|
||||
<a
|
||||
href="/edit?quiz_id={quiz.id}"
|
||||
class="border border-yellow-600"
|
||||
>{$t('words.edit')}</a
|
||||
>
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
>
|
||||
<button
|
||||
on:click={() => {
|
||||
deleteQuiz(quiz.id);
|
||||
}}
|
||||
class="border border-red-600"
|
||||
>
|
||||
{$t('words.delete')}
|
||||
</button>
|
||||
</td>
|
||||
<td
|
||||
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
|
||||
>
|
||||
{#if quiz.public}
|
||||
✅
|
||||
{:else}
|
||||
❌
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<p>
|
||||
Looks like you don't have any quizzes. Wanna change that? Click the
|
||||
"Create"-button, or import a quiz from KAHOOT!
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{:catch err}
|
||||
<p>{err}</p>
|
||||
|
||||
Reference in New Issue
Block a user