Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,38 +16,22 @@ def start_exam(exam_choice, start_question, audio_enabled):
|
|
16 |
"""Starts the exam by selecting questions, setting up UI."""
|
17 |
global selected_questions
|
18 |
selected_questions = select_exam_vce(exam_choice)
|
19 |
-
|
20 |
if start_question >= len(selected_questions):
|
21 |
start_question = 0 # Default to the first question if the input exceeds available questions
|
22 |
-
|
23 |
question, options, audio_path = display_question(start_question, audio_enabled)
|
24 |
-
|
25 |
return (
|
26 |
# Hide start screen elements
|
27 |
-
gr.update(visible=False),
|
28 |
-
gr.update(visible=False), # Hide
|
29 |
-
gr.update(visible=False), # Hide exam_selector
|
30 |
-
gr.update(visible=False), # Hide start_button
|
31 |
-
gr.update(visible=False), # Hide audio_checkbox
|
32 |
-
gr.update(visible=False), # Hide start_question_slider
|
33 |
# Show quiz elements
|
34 |
-
gr.update(visible=True),
|
35 |
-
|
36 |
-
gr.update(
|
37 |
-
gr.update(visible=True), # Show answer_button
|
38 |
-
gr.update(visible=True), # Show next_button
|
39 |
-
gr.update(visible=True), # Show prev_button
|
40 |
-
gr.update(visible=True), # Show home_button
|
41 |
-
start_question, # Update the question state
|
42 |
-
"", # Clear result_text
|
43 |
-
audio_path, # Provide the audio_path
|
44 |
-
gr.update(visible=True), # Show explain_button
|
45 |
-
gr.update(visible=True), # Ensure question_audio is shown
|
46 |
-
None # No need to stop any audio yet
|
47 |
)
|
48 |
|
49 |
-
|
50 |
-
|
51 |
def display_question(index, audio_enabled):
|
52 |
"""Displays a question with options and generates audio (if enabled)."""
|
53 |
if index < 0 or index >= len(selected_questions):
|
|
|
16 |
"""Starts the exam by selecting questions, setting up UI."""
|
17 |
global selected_questions
|
18 |
selected_questions = select_exam_vce(exam_choice)
|
19 |
+
|
20 |
if start_question >= len(selected_questions):
|
21 |
start_question = 0 # Default to the first question if the input exceeds available questions
|
22 |
+
|
23 |
question, options, audio_path = display_question(start_question, audio_enabled)
|
24 |
+
|
25 |
return (
|
26 |
# Hide start screen elements
|
27 |
+
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
28 |
+
gr.update(visible=False), # Hide the audio_checkbox
|
|
|
|
|
|
|
|
|
29 |
# Show quiz elements
|
30 |
+
gr.update(visible=True), question, gr.update(choices=options, visible=True), gr.update(visible=True),
|
31 |
+
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), start_question, "", audio_path, gr.update(visible=True),
|
32 |
+
gr.update(visible=True), None # None for the audio stop signal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
)
|
34 |
|
|
|
|
|
35 |
def display_question(index, audio_enabled):
|
36 |
"""Displays a question with options and generates audio (if enabled)."""
|
37 |
if index < 0 or index >= len(selected_questions):
|