ruslanmv commited on
Commit
b2d259f
·
1 Parent(s): 6a6fa31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -16,24 +16,38 @@ 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), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
28
- gr.update(visible=False), # Hide the audio_checkbox
29
- gr.update(visible=False), # Hide the start_question_slider
 
 
 
30
  # Show quiz elements
31
- gr.update(visible=True), question, gr.update(choices=options, visible=True), gr.update(visible=True),
32
- gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), start_question, "", audio_path, gr.update(visible=True),
33
- gr.update(visible=True), None # None for the audio stop signal
 
 
 
 
 
 
 
 
 
 
34
  )
35
 
36
 
 
37
  def display_question(index, audio_enabled):
38
  """Displays a question with options and generates audio (if enabled)."""
39
  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), # Hide title
28
+ gr.update(visible=False), # Hide description
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), # Show question_text
35
+ question, # Question to display
36
+ gr.update(choices=options, visible=True), # Update Radio choices and make visible
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):