Added Answer-Count to admin screen

This commit is contained in:
Mawoka
2023-06-14 17:44:50 +02:00
parent 60d0dee9c3
commit c0875e4c2a
5 changed files with 39 additions and 18 deletions
+2 -2
View File
@@ -471,5 +471,5 @@ class PrivateStorageItem(PublicStorageItem):
class UpdateStorageItem(BaseModel): class UpdateStorageItem(BaseModel):
filename: str filename: str | None
alt_text: str alt_text: str | None
+4
View File
@@ -197,6 +197,10 @@ async def update_image_data(
file_data = await StorageItem.objects.get_or_none(id=file_id, user=user, deleted_at=None) file_data = await StorageItem.objects.get_or_none(id=file_id, user=user, deleted_at=None)
if file_data is None: if file_data is None:
raise HTTPException(status_code=404, detail="File not found") raise HTTPException(status_code=404, detail="File not found")
if data.alt_text == "":
data.alt_text = None
if data.filename == "":
data.filename = None
file_data.filename = data.filename file_data.filename = data.filename
file_data.alt_text = data.alt_text file_data.alt_text = data.alt_text
await file_data.update() await file_data.update()
+1
View File
@@ -390,6 +390,7 @@ async def submit_answer(sid: str, data: dict):
answers, game_pin=session["game_pin"], data=answer_data, q_index=int(float(data.question_index)) answers, game_pin=session["game_pin"], data=answer_data, q_index=int(float(data.question_index))
) )
player_count = await redis.scard(f"game_session:{session['game_pin']}:players") player_count = await redis.scard(f"game_session:{session['game_pin']}:players")
await sio.emit("player_answer", {})
if len(answers.__root__) == player_count: if len(answers.__root__) == player_count:
# await sio.emit( # await sio.emit(
# "question_results", # "question_results",
+13 -1
View File
@@ -31,6 +31,7 @@
let shown_question_now: number; let shown_question_now: number;
let final_results_clicked = false; let final_results_clicked = false;
let timer_interval; let timer_interval;
let answer_count = 0;
export let control_visible: boolean; export let control_visible: boolean;
export let player_scores; export let player_scores;
@@ -53,6 +54,7 @@
shown_question_now = data.question_index; shown_question_now = data.question_index;
timer_res = quiz_data.questions[data.question_index].time; timer_res = quiz_data.questions[data.question_index].time;
selected_question = selected_question + 1; selected_question = selected_question + 1;
answer_count = 0;
timer(timer_res); timer(timer_res);
}); });
const get_question_results = () => { const get_question_results = () => {
@@ -95,6 +97,10 @@
} }
}); });
socket.on('player_answer', (_) => {
answer_count += 1;
});
const timer = (time: string) => { const timer = (time: string) => {
let seconds = Number(time); let seconds = Number(time);
timer_interval = setInterval(() => { timer_interval = setInterval(() => {
@@ -215,13 +221,19 @@
{@html quiz_data.questions[selected_question].question} {@html quiz_data.questions[selected_question].question}
</h1> </h1>
<!-- <span class='text-center py-2 text-lg'>{$t('admin_page.time_left')}: {timer_res}</span>--> <!-- <span class='text-center py-2 text-lg'>{$t('admin_page.time_left')}: {timer_res}</span>-->
<div class="mx-auto my-2"> <div class="grid grid-cols-3 my-2">
<span />
<div class="m-auto">
<CircularTimer <CircularTimer
bind:text={timer_res} bind:text={timer_res}
bind:progress={circular_progress} bind:progress={circular_progress}
color="#ef4444" color="#ef4444"
/> />
</div> </div>
<p class="m-auto text-3xl">
{$t('admin_page.answers_submitted', { answer_count: answer_count })}
</p>
</div>
</div> </div>
{#if quiz_data.questions[selected_question].image !== null} {#if quiz_data.questions[selected_question].image !== null}
<div class="flex w-full"> <div class="flex w-full">
+7 -3
View File
@@ -181,7 +181,10 @@
"progress": "Progress", "progress": "Progress",
"speed": "Speed", "speed": "Speed",
"upload": "Upload", "upload": "Upload",
"files_library": "Files Library" "files_library": "Files Library",
"answer_plural": "Answers",
"yes": "Yes",
"no": "no"
}, },
"editor": { "editor": {
"time_in_seconds": "Time in seconds", "time_in_seconds": "Time in seconds",
@@ -229,7 +232,8 @@
"next_question": "Next Question ({{question}})", "next_question": "Next Question ({{question}})",
"show_results": "Show results", "show_results": "Show results",
"stop_time_and_solutions": "Stop time and show solutions", "stop_time_and_solutions": "Stop time and show solutions",
"enter_answer_into_field": "Enter your answer into the input field!" "enter_answer_into_field": "Enter your answer into the input field!",
"answers_submitted": "{{answer_count}} Answers submitted"
}, },
"password_reset_page": { "password_reset_page": {
"reset_password": "Reset password" "reset_password": "Reset password"
@@ -407,7 +411,7 @@
"caption": "Caption: {{caption}}", "caption": "Caption: {{caption}}",
"filename": "Filename: {{filename}}", "filename": "Filename: {{filename}}",
"uploaded": "Uploaded: {{date}}", "uploaded": "Uploaded: {{date}}",
"Imported": "Imported: {{yes_or_no}}", "imported": "Imported: {{yes_or_no}}",
"edit_details": "Edit details", "edit_details": "Edit details",
"delete_image": "Delete image", "delete_image": "Delete image",
"edit_the_image": "Edit the image", "edit_the_image": "Edit the image",