🐛 Formatted and fixed stuff
This commit is contained in:
@@ -4,59 +4,56 @@
|
||||
let expanded = false;
|
||||
</script>
|
||||
|
||||
<div class='collapsible'>
|
||||
<div class="collapsible">
|
||||
<h3>
|
||||
<button aria-expanded={expanded} on:click={() => expanded = !expanded}>{headerText}
|
||||
<svg viewBox='0 0 20 20' fill='none'>
|
||||
<path class='vert' d='M10 1V19' stroke='black' stroke-width='2' />
|
||||
<path d='M1 10L19 10' stroke='black' stroke-width='2' />
|
||||
<button aria-expanded={expanded} on:click={() => (expanded = !expanded)}
|
||||
>{headerText}
|
||||
<svg viewBox="0 0 20 20" fill="none">
|
||||
<path class="vert" d="M10 1V19" stroke="black" stroke-width="2" />
|
||||
<path d="M1 10L19 10" stroke="black" stroke-width="2" />
|
||||
</svg>
|
||||
</button>
|
||||
</h3>
|
||||
|
||||
<div class='contents' class:hidden={!expanded}>
|
||||
<slot></slot>
|
||||
<div class="contents" class:hidden={!expanded}>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.collapsible {
|
||||
border-bottom: 1px solid var(--gray-light, #eee);
|
||||
}
|
||||
.collapsible {
|
||||
border-bottom: 1px solid var(--gray-light, #eee);
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: var(--background, #fff);
|
||||
color: var(--gray-darkest, #282828);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 1em 0.5em;
|
||||
}
|
||||
button {
|
||||
background-color: var(--background, #fff);
|
||||
color: var(--gray-darkest, #282828);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 1em 0.5em;
|
||||
}
|
||||
|
||||
button[aria-expanded="true"] {
|
||||
border-bottom: 1px solid var(--gray-light, #eee);
|
||||
}
|
||||
button[aria-expanded='true'] {
|
||||
border-bottom: 1px solid var(--gray-light, #eee);
|
||||
}
|
||||
|
||||
button[aria-expanded="true"] .vert {
|
||||
display: none;
|
||||
}
|
||||
button[aria-expanded='true'] .vert {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button:focus svg {
|
||||
outline: 2px solid;
|
||||
}
|
||||
button:focus svg {
|
||||
outline: 2px solid;
|
||||
}
|
||||
|
||||
button [aria-expanded="true"] rect {
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
svg {
|
||||
height: 0.7em;
|
||||
width: 0.7em;
|
||||
}
|
||||
</style>
|
||||
svg {
|
||||
height: 0.7em;
|
||||
width: 0.7em;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -16,145 +16,143 @@
|
||||
</script>
|
||||
|
||||
<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'>
|
||||
<a href='/' class='font-black tracking-tight text-xl text-black marck-script link-hover'
|
||||
>ClassQuiz</a
|
||||
<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"
|
||||
>ClassQuiz</a
|
||||
>
|
||||
|
||||
<button
|
||||
class='lg:hidden'
|
||||
id='open-menu'
|
||||
class="lg:hidden"
|
||||
id="open-menu"
|
||||
on:click={toggleMenu}
|
||||
class:hidden={!openMenu}
|
||||
aria-label='Open navbar'
|
||||
aria-label="Open navbar"
|
||||
>
|
||||
<svg
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='24'
|
||||
height='24'
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
stroke='currentColor'
|
||||
stroke-width='2'
|
||||
stroke-linecap='round'
|
||||
stroke-linejoin='round'
|
||||
display='block'
|
||||
id='TextAlignJustified'
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
display="block"
|
||||
id="TextAlignJustified"
|
||||
>
|
||||
<path d='M3 6h18M3 12h18M3 18h18' />
|
||||
<path d="M3 6h18M3 12h18M3 18h18" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- Close menu -->
|
||||
<button
|
||||
class='hidden'
|
||||
id='close-menu'
|
||||
class="hidden"
|
||||
id="close-menu"
|
||||
class:hidden={!closeMenu}
|
||||
on:click={toggleMenu}
|
||||
aria-label='Close navbar'
|
||||
aria-label="Close navbar"
|
||||
>
|
||||
<svg
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='14'
|
||||
height='14'
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
stroke='currentColor'
|
||||
stroke-width='3'
|
||||
stroke-linecap='round'
|
||||
stroke-linejoin='round'
|
||||
display='block'
|
||||
id='Cross'
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="3"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
display="block"
|
||||
id="Cross"
|
||||
>
|
||||
<path d='M20 20L4 4m16 0L4 20' />
|
||||
<path d="M20 20L4 4m16 0L4 20" />
|
||||
</svg>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<ul
|
||||
id='menu-items'
|
||||
class='lg:flex w-full flex-col lg:flex-row lg:pl-6'
|
||||
id="menu-items"
|
||||
class="lg:flex w-full flex-col lg:flex-row lg:pl-6"
|
||||
class:hidden={!menuItems}
|
||||
>
|
||||
{#if $signedIn}
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/play'>{$t('words.play')}</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/play">{$t('words.play')}</a
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/overview'>{$t('words.overview')}</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/overview">{$t('words.overview')}</a
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/explore'>Explore</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/explore">Explore</a
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/search'>Search</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/search">Search</a
|
||||
>
|
||||
<!--TODO: Add translation -->
|
||||
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
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
|
||||
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
|
||||
>
|
||||
</li>
|
||||
{:else}
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/play'>{$t('words.play')}</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/play">{$t('words.play')}</a
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/account/register'>{$t('words.register')}</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/account/register">{$t('words.register')}</a
|
||||
>
|
||||
</li>
|
||||
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/account/login'>{$t('words.login')}</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/account/login">{$t('words.login')}</a
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/explore'>Explore</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/explore">Explore</a
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/search'>Search</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/search">Search</a
|
||||
>
|
||||
<!--TODO: Add translation -->
|
||||
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
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
|
||||
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
|
||||
>
|
||||
</li>
|
||||
<li class='py-2'>
|
||||
<li class="py-2">
|
||||
<a
|
||||
class='text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover'
|
||||
href='/docs'>{$t('words.docs')}</a
|
||||
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
|
||||
href="/docs">{$t('words.docs')}</a
|
||||
>
|
||||
</li>
|
||||
{/if}
|
||||
|
||||
@@ -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 {
|
||||
title: string;
|
||||
description: string;
|
||||
|
||||
@@ -205,15 +205,15 @@
|
||||
{/each}
|
||||
{/if}
|
||||
</ul>
|
||||
<!--{#if players.length > 0}-->
|
||||
<button
|
||||
on:click={() => {
|
||||
socket.emit('start_game', '');
|
||||
game_started = true;
|
||||
}}
|
||||
>{$t('admin_page.start_game')}
|
||||
</button>
|
||||
<!--{/if}-->
|
||||
{#if players.length > 0}
|
||||
<button
|
||||
on:click={() => {
|
||||
socket.emit('start_game', '');
|
||||
game_started = true;
|
||||
}}
|
||||
>{$t('admin_page.start_game')}
|
||||
</button>
|
||||
{/if}
|
||||
{:else}
|
||||
{#if timer_res === undefined}
|
||||
<span>Select a question to start!</span>
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
<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://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>
|
||||
|
||||
<h4>Frontend</h4>
|
||||
@@ -60,8 +62,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
hcaptcha_key: str mail_address: str mail_password: str mail_username: str mail_server: str mail_port:
|
||||
int secret_key: str
|
||||
<li>
|
||||
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:
|
||||
@@ -73,6 +73,7 @@
|
||||
<li><code>mail_server</code></li>
|
||||
<li><code>mail_port</code></li>
|
||||
<li><code>secret_key</code></li>
|
||||
<li><code>meilisearch_url</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
@@ -91,6 +92,7 @@
|
||||
</ul>
|
||||
|
||||
<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>
|
||||
<p>Please format and lint your code with</p>
|
||||
<pre><code>pnpm run format && pnpm run lint</code></pre>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang='ts'>
|
||||
<script lang="ts">
|
||||
const getData = async () => {
|
||||
const response = await fetch('/api/v1/search/?q=*');
|
||||
return await response.json();
|
||||
@@ -6,31 +6,31 @@
|
||||
</script>
|
||||
|
||||
{#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
|
||||
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'
|
||||
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"
|
||||
/>
|
||||
<path
|
||||
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'
|
||||
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"
|
||||
/>
|
||||
</svg>
|
||||
{:then quizzes}
|
||||
<div class='grid grid-cols-3'>
|
||||
<div class="grid grid-cols-3">
|
||||
{#each quizzes.hits as quiz}
|
||||
<div class='flex justify-center'>
|
||||
<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="flex justify-center">
|
||||
<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='flex justify-center md:justify-end -mt-16'>
|
||||
<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'>
|
||||
</div>-->
|
||||
<div>
|
||||
<h2 class='text-gray-800 text-3xl font-semibold'>{quiz.title}</h2>
|
||||
<p class='mt-2 text-gray-600'>{quiz.description}</p>
|
||||
<h2 class="text-gray-800 text-3xl font-semibold">{quiz.title}</h2>
|
||||
<p class="mt-2 text-gray-600">{quiz.description}</p>
|
||||
</div>
|
||||
<div class='flex mt-4'>
|
||||
<div class="flex mt-4">
|
||||
<span>Made by {quiz.user}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -38,4 +38,4 @@
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/await}
|
||||
{/await}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang='ts'>
|
||||
<script lang="ts">
|
||||
let search_term = '';
|
||||
let resp_data = null;
|
||||
|
||||
@@ -11,42 +11,56 @@
|
||||
},
|
||||
body: JSON.stringify({
|
||||
q: search_term,
|
||||
attributesToHighlight: ["*"]
|
||||
attributesToHighlight: ['*']
|
||||
})
|
||||
});
|
||||
if (res.status === 200) {
|
||||
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);
|
||||
console.log('Success!', resp_data);
|
||||
} else {
|
||||
console.error('Error!', res.status);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
<div class='flex justify-center'>
|
||||
<div class='mb-3 xl:w-96'>
|
||||
<form class='input-group relative flex items-stretch flex-row w-full mb-4'
|
||||
on:submit|preventDefault={submit}>
|
||||
<input 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}>
|
||||
<div class="flex justify-center">
|
||||
<div class="mb-3 xl:w-96">
|
||||
<form
|
||||
class="input-group relative flex items-stretch flex-row w-full mb-4"
|
||||
on:submit|preventDefault={submit}
|
||||
>
|
||||
<input
|
||||
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
|
||||
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'>
|
||||
|
||||
<svg aria-hidden='true' 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'></path>
|
||||
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"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
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>
|
||||
</button>
|
||||
</form>
|
||||
@@ -54,22 +68,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{#if resp_data}
|
||||
<div class='grid grid-cols-3'>
|
||||
<div class="grid grid-cols-3">
|
||||
{#each resp_data.hits as quiz}
|
||||
<div class='flex justify-center'>
|
||||
<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="flex justify-center">
|
||||
<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='flex justify-center md:justify-end -mt-16'>
|
||||
<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'>
|
||||
</div>-->
|
||||
<div>
|
||||
<h2 class='text-gray-800 text-3xl font-semibold'>{@html quiz._formatted.title}</h2>
|
||||
<p class='mt-2 text-gray-600'>{@html quiz._formatted.description}</p>
|
||||
<h2 class="text-gray-800 text-3xl font-semibold">
|
||||
{@html quiz._formatted.title}
|
||||
</h2>
|
||||
<p class="mt-2 text-gray-600">{@html quiz._formatted.description}</p>
|
||||
</div>
|
||||
<div class='flex mt-4'>
|
||||
<div class="flex mt-4">
|
||||
<span>Made by {@html quiz._formatted.user}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,8 +94,8 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
<style>
|
||||
<style lang="scss">
|
||||
/* eslint-disable-next-line css-unused-selector */
|
||||
mark {
|
||||
background-color: #ff0;
|
||||
border-radius: 0.2em;
|
||||
@@ -89,4 +104,4 @@
|
||||
font-weight: bold;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang='ts' context='module'>
|
||||
|
||||
<script lang="ts" context="module">
|
||||
export async function load({ params, fetch, session }) {
|
||||
const { quiz_id } = params;
|
||||
const res = await fetch(`/api/v1/quiz/get/public/${quiz_id}`);
|
||||
@@ -23,7 +22,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang='ts'>
|
||||
<script lang="ts">
|
||||
import { getLocalization } from '$lib/i18n';
|
||||
import CollapsSection from '$lib/collapsible.svelte';
|
||||
import { createTippy } from 'svelte-tippy';
|
||||
@@ -63,7 +62,6 @@
|
||||
questions: Question[];
|
||||
}
|
||||
|
||||
|
||||
const startGame = async (id: string): Promise<void> => {
|
||||
console.log('start game', id);
|
||||
const res = await fetch(`/api/v1/quiz/start/${id}`, {
|
||||
@@ -80,77 +78,82 @@
|
||||
plausible('Started Game', { props: { quiz_id: id } });
|
||||
window.location.replace(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`);
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
<h1 class='text-4xl text-center'>{quiz.title}</h1>
|
||||
<div class='text-center'>
|
||||
<h1 class="text-4xl text-center">{quiz.title}</h1>
|
||||
<div class="text-center">
|
||||
<p>{quiz.description}</p>
|
||||
</div>
|
||||
|
||||
<div class='flex justify-center m-8'>
|
||||
<div class="flex justify-center m-8">
|
||||
{#if logged_in}
|
||||
<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={() => {
|
||||
startGame(quiz.id);
|
||||
}}>
|
||||
startGame(quiz.id);
|
||||
}}
|
||||
>
|
||||
{$t('words.start')}
|
||||
</button>
|
||||
{:else }
|
||||
{:else}
|
||||
<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'
|
||||
use:tippy={{content: "You need to be logged in to start a game"}}>
|
||||
|
||||
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' }}
|
||||
>
|
||||
{$t('words.start')}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{#each quiz.questions as question, index_question}
|
||||
<div class='px-4 py-1'>
|
||||
<div class="px-4 py-1">
|
||||
<CollapsSection headerText={question.question}>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<!-- <label class='m-1 flex flex-row gap-2 w-3/5'>-->
|
||||
<p
|
||||
class='text-black w-full bg-inherit'
|
||||
>{$t('words.question')}: {question.question}</p>
|
||||
<!-- </label>-->
|
||||
<!-- <label class='m-1 flex flex-row gap-2 w-3/5'>-->
|
||||
<p class="text-black w-full bg-inherit">
|
||||
{$t('words.question')}: {question.question}
|
||||
</p>
|
||||
<!-- </label>-->
|
||||
{#if question.image}
|
||||
<label class='m-1 flex flex-row gap-2 w-3/5'>
|
||||
<span>
|
||||
{$t('words.image')}:
|
||||
<img src='{question.image}' alt='Not provided'>
|
||||
</label>
|
||||
<img class="pl-8" src={question.image} alt="Not provided" />
|
||||
</span>
|
||||
{/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')}:
|
||||
<p>{question.time}</p>
|
||||
</label>
|
||||
</span>
|
||||
{#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'>
|
||||
<h1 class='text-3xl m-1'>{$t('words.answer')} {index_answer + 1}</h1>
|
||||
<p class='m-1'>
|
||||
<div
|
||||
class="ml-8 grid grid-cols-1 gap-2 m-2 border border-black border-2 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.question')}: {index_question + 1}
|
||||
</p>
|
||||
<p>{$t('words.answer')}
|
||||
: {quiz.questions[index_question].answers[index_answer].answer}</p>
|
||||
<label 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>
|
||||
<p>
|
||||
{$t('words.answer')}
|
||||
: {quiz.questions[index_question].answers[index_answer].answer}
|
||||
</p>
|
||||
<label
|
||||
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>
|
||||
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</CollapsSection>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user