Further cleanup, mostly with svelte 5 migration placeholder cleanup
This commit is contained in:
@@ -5,10 +5,6 @@ SPDX-License-Identifier: MPL-2.0
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
|
||||
|
||||
|
||||
function sortObjectbyValue(obj) {
|
||||
const ret = {};
|
||||
Object.keys(obj)
|
||||
@@ -20,12 +16,12 @@ SPDX-License-Identifier: MPL-2.0
|
||||
interface Props {
|
||||
scores: any;
|
||||
question_results: Array<{
|
||||
username: string;
|
||||
answer: string;
|
||||
right: boolean;
|
||||
time_taken: number;
|
||||
score: number;
|
||||
}>;
|
||||
username: string;
|
||||
answer: string;
|
||||
right: boolean;
|
||||
time_taken: number;
|
||||
score: number;
|
||||
}>;
|
||||
username: any;
|
||||
}
|
||||
|
||||
@@ -37,26 +33,14 @@ SPDX-License-Identifier: MPL-2.0
|
||||
scores[i.username] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
run(() => {
|
||||
console.log(score_by_username, scores, 'dieter');
|
||||
});
|
||||
for (const i of question_results) {
|
||||
score_by_username[i.username] = i.score;
|
||||
}
|
||||
|
||||
run(() => {
|
||||
scores = sortObjectbyValue(scores);
|
||||
});
|
||||
|
||||
const do_sth = () => {
|
||||
for (const i of Object.keys(score_by_username)) {
|
||||
scores[i] = (score_by_username[i] ?? 0) + (scores[i] ?? 0);
|
||||
}
|
||||
scores = scores;
|
||||
};
|
||||
|
||||
do_sth();
|
||||
for (const username of Object.keys(score_by_username)) {
|
||||
scores[username] = (score_by_username[username] ?? 0) + (scores[username] ?? 0);
|
||||
}
|
||||
scores = scores;
|
||||
let sorted_scores = $derived(sortObjectbyValue(scores));
|
||||
</script>
|
||||
|
||||
<div>
|
||||
@@ -65,7 +49,7 @@ SPDX-License-Identifier: MPL-2.0
|
||||
<p class="p-4 bg-black/40 rounded-lg text-2xl">
|
||||
+{score_by_username[username] ?? '0'}
|
||||
</p>
|
||||
<p>Total score: {scores[username] ?? '0'}</p>
|
||||
<p>Total score: {sorted_scores[username] ?? '0'}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user