From 522d6f5441a658f57cad3de57f79b6f3b6447123 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois <git@bhasher.com> Date: Sun, 28 Jul 2024 13:26:58 +0200 Subject: [PATCH] Implement #78 and #81 --- .../{surveys => tests}/[id]/+layout.server.ts | 0 .../routes/{surveys => tests}/[id]/+layout.ts | 0 .../{surveys => tests}/[id]/+page.svelte | 0 .../routes/{surveys => tests}/[id]/+page.ts | 0 frontend/src/routes/tests/typing/+page.svelte | 12 +++++ .../src/routes/tests/vocabulary/+page.svelte | 44 ------------------- 6 files changed, 12 insertions(+), 44 deletions(-) rename frontend/src/routes/{surveys => tests}/[id]/+layout.server.ts (100%) rename frontend/src/routes/{surveys => tests}/[id]/+layout.ts (100%) rename frontend/src/routes/{surveys => tests}/[id]/+page.svelte (100%) rename frontend/src/routes/{surveys => tests}/[id]/+page.ts (100%) create mode 100644 frontend/src/routes/tests/typing/+page.svelte delete mode 100644 frontend/src/routes/tests/vocabulary/+page.svelte diff --git a/frontend/src/routes/surveys/[id]/+layout.server.ts b/frontend/src/routes/tests/[id]/+layout.server.ts similarity index 100% rename from frontend/src/routes/surveys/[id]/+layout.server.ts rename to frontend/src/routes/tests/[id]/+layout.server.ts diff --git a/frontend/src/routes/surveys/[id]/+layout.ts b/frontend/src/routes/tests/[id]/+layout.ts similarity index 100% rename from frontend/src/routes/surveys/[id]/+layout.ts rename to frontend/src/routes/tests/[id]/+layout.ts diff --git a/frontend/src/routes/surveys/[id]/+page.svelte b/frontend/src/routes/tests/[id]/+page.svelte similarity index 100% rename from frontend/src/routes/surveys/[id]/+page.svelte rename to frontend/src/routes/tests/[id]/+page.svelte diff --git a/frontend/src/routes/surveys/[id]/+page.ts b/frontend/src/routes/tests/[id]/+page.ts similarity index 100% rename from frontend/src/routes/surveys/[id]/+page.ts rename to frontend/src/routes/tests/[id]/+page.ts diff --git a/frontend/src/routes/tests/typing/+page.svelte b/frontend/src/routes/tests/typing/+page.svelte new file mode 100644 index 00000000..dea89112 --- /dev/null +++ b/frontend/src/routes/tests/typing/+page.svelte @@ -0,0 +1,12 @@ +<script lang="ts"> + import Typingtest from '$lib/components/tests/typingtest.svelte'; + import { t } from '$lib/services/i18n'; + + let finished = false; +</script> + +{#if finished} + <p>{$t('surveys.complete')}</p> +{:else} + <Typingtest onFinish={() => (finished = true)} /> +{/if} diff --git a/frontend/src/routes/tests/vocabulary/+page.svelte b/frontend/src/routes/tests/vocabulary/+page.svelte deleted file mode 100644 index a87def1c..00000000 --- a/frontend/src/routes/tests/vocabulary/+page.svelte +++ /dev/null @@ -1,44 +0,0 @@ -<script> - import { onMount } from 'svelte'; - import { sendTestVocabularyAPI } from '$lib/api/tests'; - - import surveyJson from '$lib/data/vocabulary-survey.json'; - - onMount(() => { - const jq = window.$; - const survey = new Survey.Model(surveyJson); - survey.onComplete.add(surveyComplete); - jq(function () { - jq('#surveyContainer').Survey({ - model: survey - }); - }); - }); - - async function surveyComplete(survey, options) { - options.showSaveInProgress(); - - const res = await sendTestVocabularyAPI(JSON.stringify(survey.data)); - - if (res) { - options.showSaveSuccess(); - } else { - options.showSaveError(); - } - } -</script> - -<svelte:head> - <script - type="text/javascript" - src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" - ></script> - - <link href="https://unpkg.com/survey-jquery/defaultV2.min.css" type="text/css" rel="stylesheet" /> - <script - type="text/javascript" - src="https://unpkg.com/survey-jquery/survey.jquery.min.js" - ></script> -</svelte:head> - -<div id="surveyContainer"></div> -- GitLab