Updates
Browse files- app.py +8 -5
- static/script.js +3 -1
app.py
CHANGED
|
@@ -68,11 +68,14 @@ def load_quiz(data):
|
|
| 68 |
def start_quiz():
|
| 69 |
if participants and selected_questions:
|
| 70 |
current_question['started'] = True
|
| 71 |
-
index = current_question['index']
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
@socketio.on('restart_quiz')
|
| 78 |
def restart_quiz():
|
|
|
|
| 68 |
def start_quiz():
|
| 69 |
if participants and selected_questions:
|
| 70 |
current_question['started'] = True
|
| 71 |
+
index = current_question['index'] # Use the selected starting question index
|
| 72 |
+
if index < len(selected_questions): # Ensure index is within bounds
|
| 73 |
+
question = selected_questions[index]
|
| 74 |
+
# Send the starting question to all clients
|
| 75 |
+
emit('new_question', {"question": question["question"], "options": question["options"], "index": index + 1}, room='quiz')
|
| 76 |
+
emit('enable_end_quiz', room=request.sid) # Enable "End Quiz" for the host
|
| 77 |
+
else:
|
| 78 |
+
emit('error', {"message": "Starting question exceeds available questions."}, room=request.sid)
|
| 79 |
|
| 80 |
@socketio.on('restart_quiz')
|
| 81 |
def restart_quiz():
|
static/script.js
CHANGED
|
@@ -51,9 +51,11 @@ function updateSliderValue(value) {
|
|
| 51 |
}
|
| 52 |
|
| 53 |
function startQuiz() {
|
| 54 |
-
|
|
|
|
| 55 |
}
|
| 56 |
|
|
|
|
| 57 |
function checkAnswers() {
|
| 58 |
socket.emit('check_answers');
|
| 59 |
}
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
function startQuiz() {
|
| 54 |
+
const startQuestion = parseInt(document.getElementById('start-question-number').value, 10);
|
| 55 |
+
socket.emit('start_quiz', { start_question: startQuestion });
|
| 56 |
}
|
| 57 |
|
| 58 |
+
|
| 59 |
function checkAnswers() {
|
| 60 |
socket.emit('check_answers');
|
| 61 |
}
|