🐛 Formatted and fixed stuff

This commit is contained in:
Mawoka
2022-04-14 15:45:17 +02:00
parent b726e021b5
commit 0ea8e06f1d
10 changed files with 3996 additions and 3012 deletions
+8
View File
@@ -59,5 +59,13 @@ services:
- ./Caddyfile-docker:/etc/caddy/Caddyfile - ./Caddyfile-docker:/etc/caddy/Caddyfile
ports: ports:
- "8000:8080" - "8000:8080"
meilisearch:
image: getmeili/meilisearch:latest
restart: always
environment:
MEILI_NO_ANALYTICS: true
volumes:
- meilisearch-data:/data.ms
volumes: volumes:
data: data:
meilisearch-data:
+3756 -2779
View File
File diff suppressed because it is too large Load Diff
+37 -40
View File
@@ -4,59 +4,56 @@
let expanded = false; let expanded = false;
</script> </script>
<div class='collapsible'> <div class="collapsible">
<h3> <h3>
<button aria-expanded={expanded} on:click={() => expanded = !expanded}>{headerText} <button aria-expanded={expanded} on:click={() => (expanded = !expanded)}
<svg viewBox='0 0 20 20' fill='none'> >{headerText}
<path class='vert' d='M10 1V19' stroke='black' stroke-width='2' /> <svg viewBox="0 0 20 20" fill="none">
<path d='M1 10L19 10' stroke='black' stroke-width='2' /> <path class="vert" d="M10 1V19" stroke="black" stroke-width="2" />
<path d="M1 10L19 10" stroke="black" stroke-width="2" />
</svg> </svg>
</button> </button>
</h3> </h3>
<div class='contents' class:hidden={!expanded}> <div class="contents" class:hidden={!expanded}>
<slot></slot> <slot />
</div> </div>
</div> </div>
<style> <style>
.collapsible { .collapsible {
border-bottom: 1px solid var(--gray-light, #eee); border-bottom: 1px solid var(--gray-light, #eee);
} }
h3 { h3 {
margin: 0; margin: 0;
} }
button { button {
background-color: var(--background, #fff); background-color: var(--background, #fff);
color: var(--gray-darkest, #282828); color: var(--gray-darkest, #282828);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
width: 100%; width: 100%;
border: none; border: none;
margin: 0; margin: 0;
padding: 1em 0.5em; padding: 1em 0.5em;
} }
button[aria-expanded="true"] { button[aria-expanded='true'] {
border-bottom: 1px solid var(--gray-light, #eee); border-bottom: 1px solid var(--gray-light, #eee);
} }
button[aria-expanded="true"] .vert { button[aria-expanded='true'] .vert {
display: none; display: none;
} }
button:focus svg { button:focus svg {
outline: 2px solid; outline: 2px solid;
} }
button [aria-expanded="true"] rect { svg {
fill: currentColor; height: 0.7em;
} width: 0.7em;
}
svg {
height: 0.7em;
width: 0.7em;
}
</style> </style>
+72 -74
View File
@@ -16,145 +16,143 @@
</script> </script>
<nav <nav
class='w-screen px-4 lg:px-10 py-2 flex flex-col lg:flex-row lg:items-center fixed backdrop-blur-sm bg-white/60 shadow-md z-50 top-0' class="w-screen px-4 lg:px-10 py-2 flex flex-col lg:flex-row lg:items-center fixed backdrop-blur-sm bg-white/60 shadow-md z-50 top-0"
> >
<section class='w-full lg:w-max flex justify-between'> <section class="w-full lg:w-max flex justify-between">
<a href='/' class='font-black tracking-tight text-xl text-black marck-script link-hover' <a href="/" class="font-black tracking-tight text-xl text-black marck-script link-hover"
>ClassQuiz</a >ClassQuiz</a
> >
<button <button
class='lg:hidden' class="lg:hidden"
id='open-menu' id="open-menu"
on:click={toggleMenu} on:click={toggleMenu}
class:hidden={!openMenu} class:hidden={!openMenu}
aria-label='Open navbar' aria-label="Open navbar"
> >
<svg <svg
xmlns='http://www.w3.org/2000/svg' xmlns="http://www.w3.org/2000/svg"
width='24' width="24"
height='24' height="24"
viewBox='0 0 24 24' viewBox="0 0 24 24"
fill='none' fill="none"
stroke='currentColor' stroke="currentColor"
stroke-width='2' stroke-width="2"
stroke-linecap='round' stroke-linecap="round"
stroke-linejoin='round' stroke-linejoin="round"
display='block' display="block"
id='TextAlignJustified' id="TextAlignJustified"
> >
<path d='M3 6h18M3 12h18M3 18h18' /> <path d="M3 6h18M3 12h18M3 18h18" />
</svg> </svg>
</button> </button>
<!-- Close menu --> <!-- Close menu -->
<button <button
class='hidden' class="hidden"
id='close-menu' id="close-menu"
class:hidden={!closeMenu} class:hidden={!closeMenu}
on:click={toggleMenu} on:click={toggleMenu}
aria-label='Close navbar' aria-label="Close navbar"
> >
<svg <svg
xmlns='http://www.w3.org/2000/svg' xmlns="http://www.w3.org/2000/svg"
width='14' width="14"
height='14' height="14"
viewBox='0 0 24 24' viewBox="0 0 24 24"
fill='none' fill="none"
stroke='currentColor' stroke="currentColor"
stroke-width='3' stroke-width="3"
stroke-linecap='round' stroke-linecap="round"
stroke-linejoin='round' stroke-linejoin="round"
display='block' display="block"
id='Cross' id="Cross"
> >
<path d='M20 20L4 4m16 0L4 20' /> <path d="M20 20L4 4m16 0L4 20" />
</svg> </svg>
</button> </button>
</section> </section>
<ul <ul
id='menu-items' id="menu-items"
class='lg:flex w-full flex-col lg:flex-row lg:pl-6' class="lg:flex w-full flex-col lg:flex-row lg:pl-6"
class:hidden={!menuItems} class:hidden={!menuItems}
> >
{#if $signedIn} {#if $signedIn}
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/play'>{$t('words.play')}</a href="/play">{$t('words.play')}</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/overview'>{$t('words.overview')}</a href="/overview">{$t('words.overview')}</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/explore'>Explore</a href="/explore">Explore</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/search'>Search</a href="/search">Search</a
> >
<!--TODO: Add translation --> <!--TODO: Add translation -->
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/api/v1/users/logout'>{$t('words.logout')}</a href="/api/v1/users/logout">{$t('words.logout')}</a
> >
</li> </li>
{:else} {:else}
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/play'>{$t('words.play')}</a href="/play">{$t('words.play')}</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/account/register'>{$t('words.register')}</a href="/account/register">{$t('words.register')}</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/account/login'>{$t('words.login')}</a href="/account/login">{$t('words.login')}</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/explore'>Explore</a href="/explore">Explore</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/search'>Search</a href="/search">Search</a
> >
<!--TODO: Add translation --> <!--TODO: Add translation -->
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='https://github.com/mawoka-myblock/classquiz'>GitHub</a href="https://github.com/mawoka-myblock/classquiz">GitHub</a
> >
</li> </li>
<li class='py-2'> <li class="py-2">
<a <a
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover' class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href='/docs'>{$t('words.docs')}</a href="/docs">{$t('words.docs')}</a
> >
</li> </li>
{/if} {/if}
-16
View File
@@ -1,19 +1,3 @@
/// <reference types="@sveltejs/kit" />
// See https://kit.svelte.dev/docs/types#the-app-namespace
// for information about these interfaces
declare namespace App {
// interface Locals {}
// interface Platform {}
interface Session {
authenticated: boolean;
token: string | null;
email: string | null;
}
// interface Stuff {}
}
export interface QuizData { export interface QuizData {
title: string; title: string;
description: string; description: string;
+9 -9
View File
@@ -205,15 +205,15 @@
{/each} {/each}
{/if} {/if}
</ul> </ul>
<!--{#if players.length > 0}--> {#if players.length > 0}
<button <button
on:click={() => { on:click={() => {
socket.emit('start_game', ''); socket.emit('start_game', '');
game_started = true; game_started = true;
}} }}
>{$t('admin_page.start_game')} >{$t('admin_page.start_game')}
</button> </button>
<!--{/if}--> {/if}
{:else} {:else}
{#if timer_res === undefined} {#if timer_res === undefined}
<span>Select a question to start!</span> <span>Select a question to start!</span>
+4 -2
View File
@@ -21,6 +21,8 @@
<li><a href="https://caddyserver.com/">Caddy</a></li> <li><a href="https://caddyserver.com/">Caddy</a></li>
<li><a href="https://pipenv.pypa.io/en/latest/">Pipenv</a></li> <li><a href="https://pipenv.pypa.io/en/latest/">Pipenv</a></li>
<li><a href="https://redis.io/">Redis</a></li> <li><a href="https://redis.io/">Redis</a></li>
<li><a href="https://meilisearch.com">Meilisearch</a></li>
<li><a href="https://caddyserver.com"><i>(Optional) Caddy</i></a></li>
</ul> </ul>
<h4>Frontend</h4> <h4>Frontend</h4>
@@ -60,8 +62,6 @@
</li> </li>
</ul> </ul>
</li> </li>
hcaptcha_key: str mail_address: str mail_password: str mail_username: str mail_server: str mail_port:
int secret_key: str
<li> <li>
Set your config up in your .env-file. What you have to set up can you see in the Set your config up in your .env-file. What you have to set up can you see in the
<code>classquiz/config.py</code>-file. The things you have to set are the following: <code>classquiz/config.py</code>-file. The things you have to set are the following:
@@ -73,6 +73,7 @@
<li><code>mail_server</code></li> <li><code>mail_server</code></li>
<li><code>mail_port</code></li> <li><code>mail_port</code></li>
<li><code>secret_key</code></li> <li><code>secret_key</code></li>
<li><code>meilisearch_url</code></li>
</ul> </ul>
</li> </li>
<li> <li>
@@ -91,6 +92,7 @@
</ul> </ul>
<h2>BEFORE you submit a Pull-Request</h2> <h2>BEFORE you submit a Pull-Request</h2>
<p>Please use <a href="https://gitmoji.dev">Gitmoji</a> for your commits.</p>
<h4>Frontend</h4> <h4>Frontend</h4>
<p>Please format and lint your code with</p> <p>Please format and lint your code with</p>
<pre><code>pnpm run format && pnpm run lint</code></pre> <pre><code>pnpm run format && pnpm run lint</code></pre>
+13 -13
View File
@@ -1,4 +1,4 @@
<script lang='ts'> <script lang="ts">
const getData = async () => { const getData = async () => {
const response = await fetch('/api/v1/search/?q=*'); const response = await fetch('/api/v1/search/?q=*');
return await response.json(); return await response.json();
@@ -6,31 +6,31 @@
</script> </script>
{#await getData()} {#await getData()}
<svg class='h-8 w-8 animate-spin mx-auto my-20' viewBox='3 3 18 18'> <svg class="h-8 w-8 animate-spin mx-auto my-20" viewBox="3 3 18 18">
<path <path
class='fill-black' class="fill-black"
d='M12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5ZM3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12Z' d="M12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5ZM3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12Z"
/> />
<path <path
class='fill-blue-100' class="fill-blue-100"
d='M16.9497 7.05015C14.2161 4.31648 9.78392 4.31648 7.05025 7.05015C6.65973 7.44067 6.02656 7.44067 5.63604 7.05015C5.24551 6.65962 5.24551 6.02646 5.63604 5.63593C9.15076 2.12121 14.8492 2.12121 18.364 5.63593C18.7545 6.02646 18.7545 6.65962 18.364 7.05015C17.9734 7.44067 17.3403 7.44067 16.9497 7.05015Z' d="M16.9497 7.05015C14.2161 4.31648 9.78392 4.31648 7.05025 7.05015C6.65973 7.44067 6.02656 7.44067 5.63604 7.05015C5.24551 6.65962 5.24551 6.02646 5.63604 5.63593C9.15076 2.12121 14.8492 2.12121 18.364 5.63593C18.7545 6.02646 18.7545 6.65962 18.364 7.05015C17.9734 7.44067 17.3403 7.44067 16.9497 7.05015Z"
/> />
</svg> </svg>
{:then quizzes} {:then quizzes}
<div class='grid grid-cols-3'> <div class="grid grid-cols-3">
{#each quizzes.hits as quiz} {#each quizzes.hits as quiz}
<div class='flex justify-center'> <div class="flex justify-center">
<a href='/view/{quiz.id}' class='h-max w-fit'> <a href="/view/{quiz.id}" class="h-max w-fit">
<div class='max-w-md py-4 px-8 bg-white shadow-lg rounded-lg my-20'> <div class="max-w-md py-4 px-8 bg-white shadow-lg rounded-lg my-20">
<!-- <div class='flex justify-center md:justify-end -mt-16'> <!-- <div class='flex justify-center md:justify-end -mt-16'>
<img class='w-20 h-20 object-cover rounded-full border-2 border-indigo-500' <img class='w-20 h-20 object-cover rounded-full border-2 border-indigo-500'
src='https://images.unsplash.com/photo-1499714608240-22fc6ad53fb2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80'> src='https://images.unsplash.com/photo-1499714608240-22fc6ad53fb2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80'>
</div>--> </div>-->
<div> <div>
<h2 class='text-gray-800 text-3xl font-semibold'>{quiz.title}</h2> <h2 class="text-gray-800 text-3xl font-semibold">{quiz.title}</h2>
<p class='mt-2 text-gray-600'>{quiz.description}</p> <p class="mt-2 text-gray-600">{quiz.description}</p>
</div> </div>
<div class='flex mt-4'> <div class="flex mt-4">
<span>Made by {quiz.user}</span> <span>Made by {quiz.user}</span>
</div> </div>
</div> </div>
+48 -33
View File
@@ -1,4 +1,4 @@
<script lang='ts'> <script lang="ts">
let search_term = ''; let search_term = '';
let resp_data = null; let resp_data = null;
@@ -11,42 +11,56 @@
}, },
body: JSON.stringify({ body: JSON.stringify({
q: search_term, q: search_term,
attributesToHighlight: ["*"] attributesToHighlight: ['*']
}) })
}); });
if (res.status === 200) { if (res.status === 200) {
let resp_data_temp: string = await res.text(); let resp_data_temp: string = await res.text();
resp_data_temp = resp_data_temp.replaceAll("<em>", "<mark>") resp_data_temp = resp_data_temp.replaceAll('<em>', '<mark>');
resp_data_temp = resp_data_temp.replaceAll("</em>", "</mark>") resp_data_temp = resp_data_temp.replaceAll('</em>', '</mark>');
resp_data = JSON.parse(resp_data_temp); resp_data = JSON.parse(resp_data_temp);
console.log('Success!', resp_data); console.log('Success!', resp_data);
} else { } else {
console.error('Error!', res.status); console.error('Error!', res.status);
} }
}; };
</script> </script>
<div> <div>
<div class='flex justify-center'> <div class="flex justify-center">
<div class='mb-3 xl:w-96'> <div class="mb-3 xl:w-96">
<form class='input-group relative flex items-stretch flex-row w-full mb-4' <form
on:submit|preventDefault={submit}> class="input-group relative flex items-stretch flex-row w-full mb-4"
<input type='search' on:submit|preventDefault={submit}
class='form-control relative flex-auto min-w-0 block w-full px-3 py-1.5 text-base font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none' >
placeholder='Search' aria-label='Search' aria-describedby='button-addon2' <input
bind:value={search_term}> type="search"
class="form-control relative flex-auto min-w-0 block w-full px-3 py-1.5 text-base font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none"
placeholder="Search"
aria-label="Search"
aria-describedby="button-addon2"
bind:value={search_term}
/>
<button <button
class='inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight uppercase rounded shadow-md hover:bg-blue-700 hover:shadow-lg focus:bg-blue-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out flex items-center disabled:opacity-50 disabled:cursor-not-allowed' class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight uppercase rounded shadow-md hover:bg-blue-700 hover:shadow-lg focus:bg-blue-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out flex items-center disabled:opacity-50 disabled:cursor-not-allowed"
id='button-addon2' disabled={search_term.length <= 2} type='submit'> id="button-addon2"
disabled={search_term.length <= 2}
<svg aria-hidden='true' focusable='false' data-prefix='fas' data-icon='search' class='w-4' type="submit"
role='img' >
xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'> <svg
<path fill='currentColor' aria-hidden="true"
d='M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z'></path> focusable="false"
data-prefix="fas"
data-icon="search"
class="w-4"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="currentColor"
d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
/>
</svg> </svg>
</button> </button>
</form> </form>
@@ -54,22 +68,23 @@
</div> </div>
</div> </div>
{#if resp_data} {#if resp_data}
<div class='grid grid-cols-3'> <div class="grid grid-cols-3">
{#each resp_data.hits as quiz} {#each resp_data.hits as quiz}
<div class='flex justify-center'> <div class="flex justify-center">
<a href='/view/{quiz.id}' class='h-max w-fit'> <a href="/view/{quiz.id}" class="h-max w-fit">
<div class='max-w-md py-4 px-8 bg-white shadow-lg rounded-lg my-20'> <div class="max-w-md py-4 px-8 bg-white shadow-lg rounded-lg my-20">
<!-- <div class='flex justify-center md:justify-end -mt-16'> <!-- <div class='flex justify-center md:justify-end -mt-16'>
<img class='w-20 h-20 object-cover rounded-full border-2 border-indigo-500' <img class='w-20 h-20 object-cover rounded-full border-2 border-indigo-500'
src='https://images.unsplash.com/photo-1499714608240-22fc6ad53fb2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80'> src='https://images.unsplash.com/photo-1499714608240-22fc6ad53fb2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80'>
</div>--> </div>-->
<div> <div>
<h2 class='text-gray-800 text-3xl font-semibold'>{@html quiz._formatted.title}</h2> <h2 class="text-gray-800 text-3xl font-semibold">
<p class='mt-2 text-gray-600'>{@html quiz._formatted.description}</p> {@html quiz._formatted.title}
</h2>
<p class="mt-2 text-gray-600">{@html quiz._formatted.description}</p>
</div> </div>
<div class='flex mt-4'> <div class="flex mt-4">
<span>Made by {@html quiz._formatted.user}</span> <span>Made by {@html quiz._formatted.user}</span>
</div> </div>
</div> </div>
@@ -79,8 +94,8 @@
</div> </div>
{/if} {/if}
<style lang="scss">
<style> /* eslint-disable-next-line css-unused-selector */
mark { mark {
background-color: #ff0; background-color: #ff0;
border-radius: 0.2em; border-radius: 0.2em;
+45 -42
View File
@@ -1,5 +1,4 @@
<script lang='ts' context='module'> <script lang="ts" context="module">
export async function load({ params, fetch, session }) { export async function load({ params, fetch, session }) {
const { quiz_id } = params; const { quiz_id } = params;
const res = await fetch(`/api/v1/quiz/get/public/${quiz_id}`); const res = await fetch(`/api/v1/quiz/get/public/${quiz_id}`);
@@ -23,7 +22,7 @@
} }
</script> </script>
<script lang='ts'> <script lang="ts">
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
import CollapsSection from '$lib/collapsible.svelte'; import CollapsSection from '$lib/collapsible.svelte';
import { createTippy } from 'svelte-tippy'; import { createTippy } from 'svelte-tippy';
@@ -63,7 +62,6 @@
questions: Question[]; questions: Question[];
} }
const startGame = async (id: string): Promise<void> => { const startGame = async (id: string): Promise<void> => {
console.log('start game', id); console.log('start game', id);
const res = await fetch(`/api/v1/quiz/start/${id}`, { const res = await fetch(`/api/v1/quiz/start/${id}`, {
@@ -80,77 +78,82 @@
plausible('Started Game', { props: { quiz_id: id } }); plausible('Started Game', { props: { quiz_id: id } });
window.location.replace(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`); window.location.replace(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`);
}; };
</script> </script>
<div> <div>
<h1 class='text-4xl text-center'>{quiz.title}</h1> <h1 class="text-4xl text-center">{quiz.title}</h1>
<div class='text-center'> <div class="text-center">
<p>{quiz.description}</p> <p>{quiz.description}</p>
</div> </div>
<div class='flex justify-center m-8'> <div class="flex justify-center m-8">
{#if logged_in} {#if logged_in}
<button <button
class='px-4 py-2 leading-5 text-white transition-colors duration-200 transform bg-gray-700 rounded text-center hover:bg-gray-600 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50' class="px-4 py-2 leading-5 text-white transition-colors duration-200 transform bg-gray-700 rounded text-center hover:bg-gray-600 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
on:click={() => { on:click={() => {
startGame(quiz.id); startGame(quiz.id);
}}> }}
>
{$t('words.start')} {$t('words.start')}
</button> </button>
{:else } {:else}
<button <button
class='px-4 py-2 leading-5 text-white transition-colors duration-200 transform bg-gray-700 rounded text-center hover:bg-gray-600 focus:outline-none cursor-not-allowed opacity-50' class="px-4 py-2 leading-5 text-white transition-colors duration-200 transform bg-gray-700 rounded text-center hover:bg-gray-600 focus:outline-none cursor-not-allowed opacity-50"
use:tippy={{content: "You need to be logged in to start a game"}}> use:tippy={{ content: 'You need to be logged in to start a game' }}
>
{$t('words.start')} {$t('words.start')}
</button> </button>
{/if} {/if}
</div> </div>
{#each quiz.questions as question, index_question} {#each quiz.questions as question, index_question}
<div class='px-4 py-1'> <div class="px-4 py-1">
<CollapsSection headerText={question.question}> <CollapsSection headerText={question.question}>
<div class='ml-8 grid grid-cols-1 gap-2 m-2 border border-black border-2'> <div class="ml-8 grid grid-cols-1 gap-2 m-2 border border-black border-2">
<h1 class='text-3xl m-1'>{$t('words.question')} {index_question + 1}</h1> <h1 class="text-3xl m-1">{$t('words.question')} {index_question + 1}</h1>
<!-- <label class='m-1 flex flex-row gap-2 w-3/5'>--> <!-- <label class='m-1 flex flex-row gap-2 w-3/5'>-->
<p <p class="text-black w-full bg-inherit">
class='text-black w-full bg-inherit' {$t('words.question')}: {question.question}
>{$t('words.question')}: {question.question}</p> </p>
<!-- </label>--> <!-- </label>-->
{#if question.image} {#if question.image}
<label class='m-1 flex flex-row gap-2 w-3/5'> <span>
{$t('words.image')}: {$t('words.image')}:
<img src='{question.image}' alt='Not provided'> <img class="pl-8" src={question.image} alt="Not provided" />
</label> </span>
{/if} {/if}
<label class='m-1 flex flex-row gap-2 w-3/5 flex-nowrap whitespace-nowrap'> <span class="m-1 flex flex-row gap-2 w-3/5 flex-nowrap whitespace-nowrap">
{$t('editor.time_in_seconds')}: {$t('editor.time_in_seconds')}:
<p>{question.time}</p> <p>{question.time}</p>
</label> </span>
{#each question.answers as answer, index_answer} {#each question.answers as answer, index_answer}
<div class='ml-8 grid grid-cols-1 gap-2 m-2 border border-black border-2 m-1'> <div
<h1 class='text-3xl m-1'>{$t('words.answer')} {index_answer + 1}</h1> class="ml-8 grid grid-cols-1 gap-2 m-2 border border-black border-2 m-1"
<p class='m-1'> >
<h1 class="text-3xl m-1">{$t('words.answer')} {index_answer + 1}</h1>
<p class="m-1">
{$t('words.answer')}: {index_answer + 1} {$t('words.answer')}: {index_answer + 1}
{$t('words.question')}: {index_question + 1} {$t('words.question')}: {index_question + 1}
</p> </p>
<p>{$t('words.answer')} <p>
: {quiz.questions[index_question].answers[index_answer].answer}</p> {$t('words.answer')}
<label class='m-1 flex flex-row gap-2 w-2/6 flex-nowrap whitespace-nowrap'> : {quiz.questions[index_question].answers[index_answer].answer}
<input type='checkbox' bind:checked={answer.right} class='text-black w-fit' </p>
disabled /> <label
<span class='w-fit'>{$t('editor.right_or_true?')}</span> class="m-1 flex flex-row gap-2 w-2/6 flex-nowrap whitespace-nowrap"
>
<input
type="checkbox"
bind:checked={answer.right}
class="text-black w-fit"
disabled
/>
<span class="w-fit">{$t('editor.right_or_true?')}</span>
</label> </label>
</div> </div>
{/each} {/each}
</div> </div>
</CollapsSection> </CollapsSection>
</div> </div>
{/each} {/each}
</div> </div>