From e0db6427afc4863e5f9b78eabb95ce88921e7da7 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Mon, 19 Jun 2023 15:59:40 +0200 Subject: [PATCH] :bug: Fixed saving results not working if results were downloaded before --- frontend/src/lib/i18n/locales/en.json | 5 +-- frontend/src/routes/admin/+page.svelte | 44 +++++++++++++++----------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 8abbe8b..b82f3f4 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -229,7 +229,6 @@ "get_results": "Get results", "get_results_and_stop_time": "Get results and stop time", "get_final_results": "Get final results", - "export_results": "Export results", "show_next_question": "Show next question", "start_by_showing_first_question": "Start by showing the first question.", "no_answers": "No answers!", @@ -239,7 +238,9 @@ "show_results": "Show results", "stop_time_and_solutions": "Stop time and show solutions", "enter_answer_into_field": "Enter your answer into the input field!", - "answers_submitted": "{{answer_count}} Answers submitted" + "answers_submitted": "{{answer_count}} Answers submitted", + "request_export_results": "Request result download", + "download_export_results": "Download results" }, "password_reset_page": { "reset_password": "Reset password" diff --git a/frontend/src/routes/admin/+page.svelte b/frontend/src/routes/admin/+page.svelte index 4c096f2..4589558 100644 --- a/frontend/src/routes/admin/+page.svelte +++ b/frontend/src/routes/admin/+page.svelte @@ -28,7 +28,8 @@ // }; export let data; let game_mode; - let { game_pin, auto_connect, game_token } = data; + let { auto_connect, game_token } = data; + const game_pin = data.game_pin; let players: Array = []; let player_scores = {}; @@ -42,6 +43,7 @@ let success = false; let dataexport_download_a; let warnToLeave = true; + let export_token = undefined; const connect = async () => { socket.emit('register_as_admin', { @@ -81,18 +83,17 @@ }); /* socket.on('question_results', (int_data) => { - try { - int_data = JSON.parse(int_data); - } catch (e) { - console.error('Failed to parse question results'); - return; - } - question_results = int_data; - });*/ + try { + int_data = JSON.parse(int_data); + } catch (e) { + console.error('Failed to parse question results'); + return; + } + question_results = int_data; + });*/ socket.on('export_token', (int_data) => { warnToLeave = false; - dataexport_download_a.href = `/api/v1/quiz/export_data/${int_data}?ts=${new Date().getTime()}&game_pin=${game_pin}`; - dataexport_download_a.click(); + export_token = int_data; setTimeout(() => { warnToLeave = true; @@ -151,9 +152,17 @@ {#if control_visible}
- {$t('admin_page.export_results')} + {#if export_token === undefined} + {$t('admin_page.request_export_results')} + {:else} + {$t('admin_page.download_export_results')} + {/if}
@@ -183,9 +192,6 @@ {/if} {#if !success} - - - {#if errorMessage !== ''}

{errorMessage}

{/if} @@ -199,7 +205,7 @@ {:else} Download