Bug fixes and correct answer count in results
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user