capradeepgujaran commited on
Commit
55cea31
·
verified ·
1 Parent(s): 033eb0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -636,44 +636,44 @@ def create_quiz_interface():
636
  certificate_display = gr.Image(label="Your Certificate")
637
  # Helper Functions
638
 
639
- def on_generate_questions(text, num_questions):
640
- success, questions = quiz_app.generate_questions(text, num_questions)
641
- tab_index = 1 # Index for "Take Assessment" tab
642
-
643
- if not success:
644
- return [
645
- "",
646
- gr.update(choices=[], visible=False),
647
- "",
648
- gr.update(visible=False),
649
- [],
650
- 0,
651
- [None] * 5,
652
- gr.update(selected=tab_index), # Force navigation
653
- gr.update(visible=False),
654
- gr.update(visible=False) # view_cert_btn visibility
655
- ]
656
-
657
- initial_answers = [None] * len(questions)
658
- question = questions[0]
659
-
660
- return [
661
- f"## Question 1\n{question.question}\n\nPlease select one answer:",
662
- gr.update(
663
- choices=question.options,
664
- value=None,
665
- visible=True,
666
- label="Select your answer for Question 1:"
667
- ),
668
- f"Question 1 of {len(questions)}",
669
- gr.update(visible=True),
670
- questions,
671
- 0,
672
- initial_answers,
673
- gr.update(selected=tab_index), # Force navigation
674
- gr.update(visible=False),
675
- gr.update(visible=False) # view_cert_btn visibility
676
- ]
677
 
678
  def on_submit(questions, answers, current_idx, current_answer):
679
  final_answers = list(answers)
 
636
  certificate_display = gr.Image(label="Your Certificate")
637
  # Helper Functions
638
 
639
+ def on_generate_questions(text, num_questions):
640
+ success, questions = quiz_app.generate_questions(text, num_questions)
641
+ tab_index = 1 # Index for "Take Assessment" tab
642
+
643
+ if not success:
644
+ return [
645
+ "",
646
+ gr.update(choices=[], visible=False),
647
+ "",
648
+ gr.update(visible=False),
649
+ [],
650
+ 0,
651
+ [None] * 5,
652
+ gr.update(selected=tab_index), # Force navigation
653
+ gr.update(visible=False),
654
+ gr.update(visible=False) # view_cert_btn visibility
655
+ ]
656
+
657
+ initial_answers = [None] * len(questions)
658
+ question = questions[0]
659
+
660
+ return [
661
+ f"## Question 1\n{question.question}\n\nPlease select one answer:",
662
+ gr.update(
663
+ choices=question.options,
664
+ value=None,
665
+ visible=True,
666
+ label="Select your answer for Question 1:"
667
+ ),
668
+ f"Question 1 of {len(questions)}",
669
+ gr.update(visible=True),
670
+ questions,
671
+ 0,
672
+ initial_answers,
673
+ gr.update(selected=tab_index), # Force navigation
674
+ gr.update(visible=False),
675
+ gr.update(visible=False) # view_cert_btn visibility
676
+ ]
677
 
678
  def on_submit(questions, answers, current_idx, current_answer):
679
  final_answers = list(answers)