From 1186a2106b143a9cd3faa1df528b7d38fa96f44d Mon Sep 17 00:00:00 2001 From: Iamhexi Date: Tue, 29 Oct 2024 20:45:44 +0100 Subject: [PATCH] feat(frontend): add step to UI flow with paragraph reading --- frontend/src/routes/+page.svelte | 64 ++------------------ frontend/src/routes/answer/+page.svelte | 71 +++++++++++++++++++++++ frontend/src/routes/evaluate/+page.svelte | 1 - 3 files changed, 75 insertions(+), 61 deletions(-) create mode 100644 frontend/src/routes/answer/+page.svelte diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 3372cd7..2bcf5ca 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -4,21 +4,6 @@ import { goto } from '$app/navigation'; let formData = { context: '', userAnswer: '', correctAnswer: '', question: '' }; - const minimumAnswerLength = 5; - - const handleSubmit = () => { - const answerInput = document.querySelector('.answer-input'); - const answer = String(answerInput.value); - if (answer.length < minimumAnswerLength) { - alert(`Answer is too short. Minimum length: ${minimumAnswerLength}.`) - return; - } - - if (typeof window !== 'undefined') { - sessionStorage.setItem('formData', JSON.stringify(formData)); - goto('/evaluate'); - } - }; /** * @type {any[]} @@ -72,16 +57,7 @@ question = result.data.question; } - /** - * Make Ctrl + Enter send a form. - * @param {{ key: any; }} event - */ - function handleKeyDown(event) { - // @ts-ignore - if (event.ctrlKey && event.key === 'Enter') { - handleSubmit(); - } - } + @@ -98,45 +74,13 @@ {/each} {:else} -
-

- Question: -
- {question} -

- - - - - -
+

Read a paragraph

+

{formData.context}

+ {/if}