🚑 Fixed #177
This commit is contained in:
@@ -341,11 +341,12 @@ async def submit_answer(sid: str, data: dict):
|
|||||||
answers = _AnswerDataList.parse_raw(await redis.get(f"game_session:{session['game_pin']}:{data.question_index}"))
|
answers = _AnswerDataList.parse_raw(await redis.get(f"game_session:{session['game_pin']}:{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")
|
||||||
if len(answers.__root__) == player_count:
|
if len(answers.__root__) == player_count:
|
||||||
await sio.emit(
|
# await sio.emit(
|
||||||
"question_results",
|
# "question_results",
|
||||||
await redis.get(f"game_session:{session['game_pin']}:{data.question_index}"),
|
# await redis.get(f"game_session:{session['game_pin']}:{data.question_index}"),
|
||||||
room=session["game_pin"],
|
# room=session["game_pin"],
|
||||||
)
|
# )
|
||||||
|
await sio.emit("everyone_answered", {})
|
||||||
# await redis.set(f"game_data:{session['game_pin']}", json.dumps(data))
|
# await redis.set(f"game_data:{session['game_pin']}", json.dumps(data))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
socket.emit('set_question_number', q_number.toString());
|
socket.emit('set_question_number', q_number.toString());
|
||||||
shown_question_now = q_number;
|
shown_question_now = q_number;
|
||||||
timer_res = quiz_data.questions[q_number].time;
|
timer_res = quiz_data.questions[q_number].time;
|
||||||
selected_question += 1;
|
selected_question = selected_question + 1;
|
||||||
timer(timer_res);
|
timer(timer_res);
|
||||||
};
|
};
|
||||||
const get_question_results = () => {
|
const get_question_results = () => {
|
||||||
@@ -60,10 +60,13 @@
|
|||||||
final_results = data;
|
final_results = data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('everyone_answered', (data) => {
|
||||||
|
timer_res = '0';
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('question_results', (data) => {
|
socket.on('question_results', (data) => {
|
||||||
try {
|
try {
|
||||||
question_results = JSON.parse(data);
|
question_results = JSON.parse(data);
|
||||||
final_results_clicked = true;
|
|
||||||
timer_res = '0';
|
timer_res = '0';
|
||||||
} catch {
|
} catch {
|
||||||
question_results = undefined;
|
question_results = undefined;
|
||||||
@@ -75,7 +78,7 @@
|
|||||||
let timer_interval = setInterval(() => {
|
let timer_interval = setInterval(() => {
|
||||||
if (timer_res === '0') {
|
if (timer_res === '0') {
|
||||||
clearInterval(timer_interval);
|
clearInterval(timer_interval);
|
||||||
socket.emit('show_solutions', {});
|
// socket.emit('show_solutions', {});
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
seconds--;
|
seconds--;
|
||||||
@@ -198,11 +201,11 @@
|
|||||||
class="text-center text-2xl px-2 py-4 w-full text-black"
|
class="text-center text-2xl px-2 py-4 w-full text-black"
|
||||||
class:text-4xl={answer.right &&
|
class:text-4xl={answer.right &&
|
||||||
timer_res === '0' &&
|
timer_res === '0' &&
|
||||||
quiz_data.questions[selected_question].type !==
|
quiz_data.questions[selected_question].type ===
|
||||||
QuizQuestionType.ABCD}
|
QuizQuestionType.ABCD}
|
||||||
class:underline={answer.right &&
|
class:underline={answer.right &&
|
||||||
timer_res === '0' &&
|
timer_res === '0' &&
|
||||||
quiz_data.questions[selected_question].type !==
|
quiz_data.questions[selected_question].type ===
|
||||||
QuizQuestionType.ABCD}>{answer.answer}</span
|
QuizQuestionType.ABCD}>{answer.answer}</span
|
||||||
>
|
>
|
||||||
<span class="pl-4 w-10" />
|
<span class="pl-4 w-10" />
|
||||||
|
|||||||
@@ -51,6 +51,9 @@
|
|||||||
timer_res = seconds.toString();
|
timer_res = seconds.toString();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
socket.on('everyone_answered', (data) => {
|
||||||
|
timer_res = '0';
|
||||||
|
});
|
||||||
|
|
||||||
timer(question.time);
|
timer(question.time);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user