First commit
Browse files- __pycache__/backend.cpython-312.pyc +0 -0
- app.py +6 -2
- backend.py +1 -1
__pycache__/backend.cpython-312.pyc
CHANGED
Binary files a/__pycache__/backend.cpython-312.pyc and b/__pycache__/backend.cpython-312.pyc differ
|
|
app.py
CHANGED
@@ -63,6 +63,8 @@ def start_quiz():
|
|
63 |
if participants and selected_questions:
|
64 |
current_question['started'] = True
|
65 |
emit('new_question', selected_questions[current_question['index']], room='quiz')
|
|
|
|
|
66 |
emit('enable_end_quiz', room='quiz')
|
67 |
|
68 |
@socketio.on('restart_quiz')
|
@@ -105,6 +107,8 @@ def next_question():
|
|
105 |
question = selected_questions[current_question['index']]
|
106 |
emit('clear_results', room='quiz')
|
107 |
emit('new_question', question, room='quiz')
|
|
|
|
|
108 |
else:
|
109 |
final_results = calculate_final_results()
|
110 |
emit('display_final_results', final_results, room='quiz')
|
@@ -115,7 +119,7 @@ def end_quiz():
|
|
115 |
emit('display_final_results', final_results, room='quiz')
|
116 |
|
117 |
def generate_chart(answers, options):
|
118 |
-
letters = [chr(65 + i) for i in range(len(options))]
|
119 |
counts = [list(answers.values()).count(option) for option in options]
|
120 |
plt.figure(figsize=(6, 4))
|
121 |
plt.bar(letters, counts)
|
@@ -141,4 +145,4 @@ def reset_quiz():
|
|
141 |
participant["score"] = 0
|
142 |
|
143 |
if __name__ == '__main__':
|
144 |
-
socketio.run(app, debug=True)
|
|
|
63 |
if participants and selected_questions:
|
64 |
current_question['started'] = True
|
65 |
emit('new_question', selected_questions[current_question['index']], room='quiz')
|
66 |
+
# Also emit the question to the host
|
67 |
+
emit('new_question', selected_questions[current_question['index']], room=request.sid)
|
68 |
emit('enable_end_quiz', room='quiz')
|
69 |
|
70 |
@socketio.on('restart_quiz')
|
|
|
107 |
question = selected_questions[current_question['index']]
|
108 |
emit('clear_results', room='quiz')
|
109 |
emit('new_question', question, room='quiz')
|
110 |
+
# Also emit the question to the host
|
111 |
+
emit('new_question', question, room=request.sid)
|
112 |
else:
|
113 |
final_results = calculate_final_results()
|
114 |
emit('display_final_results', final_results, room='quiz')
|
|
|
119 |
emit('display_final_results', final_results, room='quiz')
|
120 |
|
121 |
def generate_chart(answers, options):
|
122 |
+
letters = [chr(65 + i) for i in range(len(options))]
|
123 |
counts = [list(answers.values()).count(option) for option in options]
|
124 |
plt.figure(figsize=(6, 4))
|
125 |
plt.bar(letters, counts)
|
|
|
145 |
participant["score"] = 0
|
146 |
|
147 |
if __name__ == '__main__':
|
148 |
+
socketio.run(app, debug=True)
|
backend.py
CHANGED
@@ -20,4 +20,4 @@ def select_exam(exam_name):
|
|
20 |
return questions
|
21 |
except FileNotFoundError:
|
22 |
print(f"File {file_path} not found.")
|
23 |
-
return [] # Return an empty list if the file is not found
|
|
|
20 |
return questions
|
21 |
except FileNotFoundError:
|
22 |
print(f"File {file_path} not found.")
|
23 |
+
return [] # Return an empty list if the file is not found
|