Bug fixes and correct answer count in results

This commit is contained in:
Mawoka
2025-10-25 22:49:02 +02:00
parent 932f8dfbcf
commit caa2a6002f
37 changed files with 164 additions and 157 deletions
+1 -1
View File
@@ -322,7 +322,7 @@ SPDX-License-Identifier: MPL-2.0
</div>
<!--<div
class="m-2 rounded-lg p-2 bg-opacity-40 bg-white transition-all cursor-pointer lg:h-full"
on:click={() => {
onclick={() => {
selected_create_thing = SelectedCreateThing.Import;
}}
class:shadow-2xl={selected_create_thing === SelectedCreateThing.Import}
@@ -131,7 +131,7 @@ SPDX-License-Identifier: MPL-2.0
<div class="mx-auto">
<BrownButton
disabled={newest_version === controller.os_version}
on:click={allow_update_to_version}
onclick={allow_update_to_version}
>
{#if newest_version === controller.os_version}
{$t('controllers.already_latest_version')}
@@ -214,7 +214,7 @@ SPDX-License-Identifier: MPL-2.0
</form>
<div>
<div class="w-fit">
<BrownButton on:click={add_api_key}
<BrownButton onclick={add_api_key}
>{$t('settings_page.add_api_key')}</BrownButton
>
</div>
@@ -226,7 +226,7 @@ SPDX-License-Identifier: MPL-2.0
{key.key}
<div class="inline-block">
<BrownButton
on:click={() => {
onclick={() => {
delete_api_key(key.key);
}}
>{$t('words.delete')}
@@ -95,7 +95,7 @@ SPDX-License-Identifier: MPL-2.0
<div class="flex pl-2">
<div class="mr-auto">
<BrownButton
on:click={() => {
onclick={() => {
index = index - 1;
}}
disabled={index < 1}>{$t('words.back')}</BrownButton
@@ -150,12 +150,12 @@ SPDX-License-Identifier: MPL-2.0
/>
<div class="m-auto grid grid-cols-2 gap-4" in:fade|global={{ delay: 3500 }}>
<BrownButton
on:click={() => {
onclick={() => {
index = 0;
finished = false;
}}>{$t('avatar_settings.start_over')}</BrownButton
>
<BrownButton on:click={save_avatar} flex={true} disabled={save_finished === true}>
<BrownButton onclick={save_avatar} flex={true} disabled={save_finished === true}>
{#if save_finished === undefined}{$t('words.save')}
{:else if save_finished === true}
<svg
@@ -175,7 +175,7 @@ SPDX-License-Identifier: MPL-2.0
</BrownButton>
<BrownButton href="/account/settings">{$t('avatar_settings.go_back')}</BrownButton>
<BrownButton
on:click={() => {
onclick={() => {
finished = false;
}}>{$t('words.close')}</BrownButton
>
@@ -162,7 +162,7 @@ SPDX-License-Identifier: MPL-2.0
<h2 class="text-center text-2xl">{$t('security_settings.backup_code')}</h2>
<div class="flex h-full w-full justify-center">
<div class="m-auto">
<BrownButton on:click={get_backup_code}
<BrownButton onclick={get_backup_code}
>{$t('security_settings.get_backup_code')}</BrownButton
>
</div>
@@ -238,7 +238,7 @@ SPDX-License-Identifier: MPL-2.0
</div>
<div class="flex justify-center">
<div class="m-auto">
<BrownButton on:click={add_security_key}
<BrownButton onclick={add_security_key}
>{$t('security_settings.add_security_key')}</BrownButton
>
</div>
@@ -271,11 +271,11 @@ SPDX-License-Identifier: MPL-2.0
<div class="flex justify-center">
<div class="m-auto">
{#if totp_activated}
<BrownButton on:click={disable_totp}
<BrownButton onclick={disable_totp}
>{$t('security_settings.disable_totp')}</BrownButton
>
{:else}
<BrownButton on:click={enable_totp}
<BrownButton onclick={enable_totp}
>{$t('security_settings.enable_totp')}</BrownButton
>
{/if}
+2 -2
View File
@@ -165,7 +165,7 @@ SPDX-License-Identifier: MPL-2.0
<div class="w-screen flex justify-center mt-16">
<div class="w-fit">
{#if export_token === undefined}
<GrayButton on:click={request_answer_export}
<GrayButton onclick={request_answer_export}
>{$t('admin_page.request_export_results')}</GrayButton
>
{:else}
@@ -179,7 +179,7 @@ SPDX-License-Identifier: MPL-2.0
</div>
<div class="w-screen flex justify-center mt-2">
<div class="w-fit">
<GrayButton on:click={save_quiz} flex={true} disabled={results_saved}>
<GrayButton onclick={save_quiz} flex={true} disabled={results_saved}>
{#if results_saved}
<svg
class="w-4 h-4"
+5 -5
View File
@@ -161,7 +161,7 @@ SPDX-License-Identifier: MPL-2.0
</div>
{:else}
<BrownButton
on:click={() => {
onclick={() => {
create_button_clicked = true;
}}>{$t('words.create')}</BrownButton
>
@@ -267,7 +267,7 @@ SPDX-License-Identifier: MPL-2.0
</BrownButton>
<BrownButton
flex={true}
on:click={() => (analytics_quiz_selected = quiz)}
onclick={() => (analytics_quiz_selected = quiz)}
>
<!-- heroicons/legacy-outline/ChartBar -->
<svg
@@ -311,7 +311,7 @@ SPDX-License-Identifier: MPL-2.0
</BrownButton>
{#if quiz.type === 'quiz'}
<BrownButton
on:click={() => {
onclick={() => {
start_game = quiz.id;
}}
flex={true}
@@ -365,7 +365,7 @@ SPDX-License-Identifier: MPL-2.0
{/if}
<BrownButton
on:click={() => {
onclick={() => {
deleteQuiz(quiz.id, quiz.type);
}}
flex={true}
@@ -387,7 +387,7 @@ SPDX-License-Identifier: MPL-2.0
</svg>
</BrownButton>
<BrownButton
on:click={() => (download_id = quiz.id)}
onclick={() => (download_id = quiz.id)}
flex={true}
disabled={quiz.type !== 'quiz'}
><!-- heroicons/download -->
@@ -33,7 +33,7 @@ SPDX-License-Identifier: MPL-2.0
{#if quiz}
<div
class="fixed w-full h-full top-0 flex bg-black/50 z-50 overflow-scroll"
on:click={on_parent_click}
onclick={on_parent_click}
transition:fade={{ duration: 100 }}
>
<div
+2 -2
View File
@@ -104,14 +104,14 @@ SPDX-License-Identifier: MPL-2.0
</p>
<div class="flex flex-col gap-2">
<BrownButton
on:click={() => {
onclick={() => {
edit_popup = image;
}}
>{$t('file_dashboard.edit_details')}
</BrownButton>
{#if image.quiztivities.length === 0 && image.quizzes.length === 0}
<BrownButton
on:click={() => {
onclick={() => {
delete_image(image.id);
}}>{$t('file_dashboard.delete_image')}</BrownButton
>
+3 -3
View File
@@ -13,7 +13,7 @@ SPDX-License-Identifier: MPL-2.0
const { t } = getLocalization();
let file_input: HTMLInputElement = $state();
navbarVisible.visible= false;
navbarVisible.visible = false;
let stats: { progress: number; time_elapsed: number; speed: number } = $state({
progress: 0,
@@ -197,7 +197,7 @@ SPDX-License-Identifier: MPL-2.0
</div>
<div class="flex relative my-2">
<div class="w-full">
<BrownButton disabled={status !== Status.CompressDone} on:click={upload_video}>
<BrownButton disabled={status !== Status.CompressDone} onclick={upload_video}>
{$t('words.upload')}
{file_size_in_mi ? `(${file_size_in_mi.toFixed(2)} Mi)` : ''}</BrownButton
>
@@ -208,7 +208,7 @@ SPDX-License-Identifier: MPL-2.0
></span>
</div>
<div class="flex justify-center">
<BrownButton on:click={compress_video} disabled={status !== Status.Idle}
<BrownButton onclick={compress_video} disabled={status !== Status.Idle}
>{$t('words.submit')}</BrownButton
>
</div>
@@ -22,7 +22,7 @@ SPDX-License-Identifier: MPL-2.0
<div class="my-auto justify-start ml-4">
<BrownButton
disabled={current_slide_index < 1}
on:click={() => {
onclick={() => {
current_slide_index -= 1;
}}>{$t('words.back')}</BrownButton
>
@@ -33,7 +33,7 @@ SPDX-License-Identifier: MPL-2.0
<div class="my-auto justify-end mr-4">
<BrownButton
disabled={current_slide_index === 1}
on:click={() => {
onclick={() => {
current_slide_index += 1;
}}>{$t('words.next')}</BrownButton
>
+1 -1
View File
@@ -43,7 +43,7 @@ SPDX-License-Identifier: MPL-2.0
<tr class="text-left">
<td class="border-r dark:border-gray-500 p-1 border-gray-300"
><a href="/results/{result.id}" class="underline text-lg"
>{result.title}</a
>{@html result.title}</a
></td
>
<td class="border-r dark:border-gray-500 p-1 border-gray-300"
@@ -95,6 +95,7 @@ SPDX-License-Identifier: MPL-2.0
<PlayerOverview
custom_field={data.results.custom_field_data}
scores={data.results.player_scores}
answers={data.results.answers}
/>
</div>
{/if}
@@ -10,30 +10,23 @@ SPDX-License-Identifier: MPL-2.0
const { t } = getLocalization();
interface Props {
questions: Question[];
answers: {
username: string;
answer: string;
right: boolean;
tike_taken: number;
score: number;
}[][];
username: string;
answer: string;
right: boolean;
tike_taken: number;
score: number;
}[][];
scores: {
[key: string]: string;
};
[key: string]: string;
};
title: string;
timestamp: string;
}
let {
questions,
answers,
scores,
title,
timestamp
}: Props = $props();
let { questions, answers, scores, title, timestamp }: Props = $props();
const usernames = Object.keys(scores);
@@ -49,7 +42,7 @@ SPDX-License-Identifier: MPL-2.0
<div class="w-full">
<div class="flex justify-center w-full">
<p class="text-3xl w-5/6 text-center">
{$t('results_page.general_overview.sentence', {
{@html $t('results_page.general_overview.sentence', {
title,
date: new Date(timestamp).toLocaleString(),
player_count: usernames.length,
@@ -10,16 +10,29 @@ SPDX-License-Identifier: MPL-2.0
const { t } = getLocalization();
interface Props {
scores: {
[key: string]: string;
};
[key: string]: string;
};
custom_field: {
[key: string]: string;
};
[key: string]: string;
};
answers: { [key: string]: any }[];
}
let { scores, custom_field }: Props = $props();
let { scores, custom_field, answers }: Props = $props();
let usernames = Object.keys(scores);
const correctCounts = {};
answers.forEach((questionAnswers) => {
questionAnswers.forEach((answer) => {
const user = answer.username;
if (!correctCounts[user]) {
correctCounts[user] = 0;
}
if (answer.right) {
correctCounts[user] += 1;
}
});
});
console.log(custom_field);
</script>
@@ -31,6 +44,9 @@ SPDX-License-Identifier: MPL-2.0
<th class="border-r dark:border-gray-500 p-1 mx-auto border-gray-300"
>{$t('result_page.player_name')}
</th>
<th class="border-r dark:border-gray-500 p-1 mx-auto border-gray-300"
>{$t('result_page.player_correct_questions')}
</th>
<th class="p-1 mx-auto">{$t('result_page.player_score')}</th>
{#if Object.keys(custom_field).length !== 0}
<th class="border-l dark:border-gray-500 p-1 mx-auto border-gray-300"
@@ -43,6 +59,9 @@ SPDX-License-Identifier: MPL-2.0
{#each usernames as uname}
<tr class="text-left">
<td class="border-r dark:border-gray-500 p-1 border-gray-300">{uname}</td>
<td class="border-r dark:border-gray-500 p-1 border-gray-300"
>{correctCounts[uname]}</td
>
<td class="p-1">{scores[uname]}</td>
{#if custom_field[uname]}
<td class="border-l dark:border-gray-500 p-1 border-gray-300"
@@ -124,7 +124,7 @@ SPDX-License-Identifier: MPL-2.0
{#if logged_in}
<div class="w-full">
<GrayButton
on:click={() => {
onclick={() => {
start_game = quiz.id;
}}
flex={true}
@@ -188,7 +188,7 @@ SPDX-License-Identifier: MPL-2.0
</div>
<div class="w-full">
{#if logged_in}
<GrayButton flex={true} on:click={() => (download_id = quiz.id)}>
<GrayButton flex={true} onclick={() => (download_id = quiz.id)}>
<svg
class="w-5 h-5 inline-block"
fill="none"
@@ -35,25 +35,25 @@ SPDX-License-Identifier: MPL-2.0
<div class="rounded-sm border-2 border-[#B07156] flex flex-col w-fit gap-2 p-2">
<div class:opacity-50={mod_rating !== null && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = null)}>Not Checked</BrownButton>
<BrownButton onclick={() => (mod_rating = null)}>Not Checked</BrownButton>
</div>
<div class:opacity-50={mod_rating !== 0 && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = 0)}>Ok</BrownButton>
<BrownButton onclick={() => (mod_rating = 0)}>Ok</BrownButton>
</div>
<div class:opacity-50={mod_rating !== 1 && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = 1)}>Attention</BrownButton>
<BrownButton onclick={() => (mod_rating = 1)}>Attention</BrownButton>
</div>
<div class:opacity-50={mod_rating !== 2 && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = 2)}>NFSW</BrownButton>
<BrownButton onclick={() => (mod_rating = 2)}>NFSW</BrownButton>
</div>
<div class:opacity-50={mod_rating !== 3 && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = 3)}>Plausibility Checked</BrownButton>
<BrownButton onclick={() => (mod_rating = 3)}>Plausibility Checked</BrownButton>
</div>
<div class:opacity-50={mod_rating !== 4 && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = 4)}>Fact Checked</BrownButton>
<BrownButton onclick={() => (mod_rating = 4)}>Fact Checked</BrownButton>
</div>
<div class:opacity-50={mod_rating !== 5 && mod_rating !== undefined} class="transition">
<BrownButton on:click={() => (mod_rating = 5)}>Exceptional</BrownButton>
<BrownButton onclick={() => (mod_rating = 5)}>Exceptional</BrownButton>
</div>
<GrayButton on:click={submit} disabled={mod_rating === undefined}>Submit</GrayButton>
<GrayButton onclick={submit} disabled={mod_rating === undefined}>Submit</GrayButton>
</div>