From 1d72fe222bab2c1d77f5331ff9e71a595f099fab Mon Sep 17 00:00:00 2001 From: exyi Date: Sun, 18 Oct 2020 09:15:24 +0000 Subject: [PATCH] Add "confirmation dialog" to show solution fix #47 --- frontend/src/SolutionCaptcha.svelte | 20 +++++++++++++++++ frontend/src/TaskDisplay.svelte | 34 ++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 frontend/src/SolutionCaptcha.svelte diff --git a/frontend/src/SolutionCaptcha.svelte b/frontend/src/SolutionCaptcha.svelte new file mode 100644 index 0000000..12ae47d --- /dev/null +++ b/frontend/src/SolutionCaptcha.svelte @@ -0,0 +1,20 @@ + + +
+

Úlohu zatím nemáš vyřešenou, opravdu si chceš vyzradit řešení?

+ {a} + {b} = newValue(+e.currentTarget.value)}> +
diff --git a/frontend/src/TaskDisplay.svelte b/frontend/src/TaskDisplay.svelte index 9700a57..087f211 100644 --- a/frontend/src/TaskDisplay.svelte +++ b/frontend/src/TaskDisplay.svelte @@ -5,14 +5,17 @@ import App from "./App.svelte"; import { taskStatuses } from "./task-status-cache"; import type { TaskDescriptor } from "./tasks"; -import Odevzdavatko from "./Odevzdavatko.svelte"; + import Odevzdavatko from "./Odevzdavatko.svelte"; + import SolutionCaptcha from "./SolutionCaptcha.svelte"; export let task: TaskDescriptor | null | undefined + let wantsSolution = false export let showSolution: boolean = false $: { task showSolution = false + wantsSolution = false } let referenceId: string | null @@ -33,6 +36,14 @@ import Odevzdavatko from "./Odevzdavatko.svelte"; updateLoginUrl() window.addEventListener("onhashchange", updateLoginUrl) + function maybeShowSolution() { + if (status && status.points > status.maxPoints - 0.01) { + showSolution = true + } else { + wantsSolution = true + } + } +