ruslanmv commited on
Commit
5b4b177
·
verified ·
1 Parent(s): 6aaa3b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -45,7 +45,32 @@ def start_exam(exam_choice, start_question, audio_enabled):
45
  if start_question >= len(selected_questions):
46
  start_question = 0 # Default to the first question if the input exceeds available questions
47
 
48
- question, options, audio_path = display_question(start_question -1 if start_question > 0 else 0, audio_enabled, selected_questions) # Corrected index here to be 0-based
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  return (
51
  # Hide start screen elements
 
45
  if start_question >= len(selected_questions):
46
  start_question = 0 # Default to the first question if the input exceeds available questions
47
 
48
+ question_list = select_exam_vce(exam_choice) # Get the question list here
49
+ if not question_list: # handle case where select_exam_vce returns None or empty list
50
+ return (
51
+ gr.update(visible=True), # Show title
52
+ gr.update(value="**Error: No Questions Found for this Exam**", visible=True), # Update description to error message
53
+ gr.update(visible=True), # Show exam_selector
54
+ gr.update(visible=True), # Show start_button
55
+ gr.update(visible=True), # Show the audio_checkbox
56
+ gr.update(visible=True), # Show start_question_slider
57
+ # Hide quiz elements
58
+ gr.update(visible=False), # Hide question_text
59
+ "", # Question to display
60
+ gr.update(choices=[], visible=False), # Hide Radio choices
61
+ gr.update(visible=False), # Hide answer_button
62
+ gr.update(visible=False), # Hide next_button
63
+ gr.update(visible=False), # Hide prev_button
64
+ gr.update(visible=False), # Hide home_button
65
+ 0, "", # Update the question state
66
+ None, # Provide the audio_path
67
+ gr.update(visible=False), # Hide explain_button
68
+ gr.update(visible=False),
69
+ None # None for audio stop
70
+ )
71
+
72
+
73
+ question, options, audio_path = display_question(start_question -1 if start_question > 0 else 0, audio_enabled, selected_questions) # Corrected index here to be 0-based, using global selected_questions
74
 
75
  return (
76
  # Hide start screen elements