capradeepgujaran commited on
Commit
8eb5ba4
1 Parent(s): f74ec38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -68
app.py CHANGED
@@ -729,7 +729,8 @@ def create_quiz_interface():
729
  f"Question {new_idx + 1} of {len(questions)}",
730
  gr.update(visible=True)
731
  ]
732
-
 
733
  def on_submit(questions, answers, current_idx, current_answer):
734
  """Handle quiz submission with proper HTML rendering"""
735
  final_answers = list(answers)
@@ -791,73 +792,7 @@ def create_quiz_interface():
791
  gr.update(visible=passed), # view_cert_btn
792
  gr.update(visible=True), # back_to_assessment
793
  gr.update(visible=False) # profile_tab
794
- ]
795
-
796
- def create_quiz_interface():
797
- if not os.getenv("GROQ_API_KEY"):
798
- raise EnvironmentError("Please set your GROQ_API_KEY environment variable")
799
-
800
- quiz_app = QuizApp(os.getenv("GROQ_API_KEY"))
801
-
802
- with gr.Blocks(title="CertifyMe AI", theme=gr.themes.Soft()) as demo:
803
- # State management
804
- current_questions = gr.State([])
805
- current_question_idx = gr.State(0)
806
- answer_state = gr.State([None] * 5)
807
-
808
- with gr.Tabs() as tabs:
809
- # Profile Setup Tab
810
- with gr.Tab(id=1, label="📋 Step 1: Profile Setup"):
811
- # ... (previous profile setup code remains the same)
812
- pass
813
-
814
- # Assessment Tab
815
- with gr.Tab(id=2, label="📝 Step 2: Take Assessment") as assessment_tab:
816
- with gr.Column() as main_container:
817
- # Questions Section
818
- with gr.Column(visible=True) as question_box:
819
- question_display = gr.Markdown("")
820
- current_options = gr.Radio(
821
- choices=[],
822
- label="Select your answer:",
823
- visible=False
824
- )
825
-
826
- with gr.Row():
827
- prev_btn = gr.Button("← Previous", variant="secondary")
828
- question_counter = gr.Markdown("Question 1")
829
- next_btn = gr.Button("Next →", variant="secondary")
830
-
831
- submit_btn = gr.Button(
832
- "Submit Assessment",
833
- variant="primary",
834
- size="lg"
835
- )
836
-
837
- # Results Section
838
- with gr.Column(visible=False) as results_group:
839
- feedback_box = gr.Markdown("")
840
- with gr.Row():
841
- reset_btn = gr.Button(
842
- "Reset Quiz",
843
- variant="secondary",
844
- size="lg",
845
- visible=False
846
- )
847
- view_cert_btn = gr.Button(
848
- "View Certificate",
849
- variant="primary",
850
- size="lg",
851
- visible=False
852
- )
853
-
854
- # Certification Tab
855
- with gr.Tab(id=3, label="🎓 Step 3: Get Certified"):
856
- score_display = gr.Number(label="Your Score", visible=False)
857
- certificate_display = gr.Image(label="Your Certificate")
858
-
859
-
860
-
861
  # Event Handlers
862
  generate_btn.click(
863
  fn=on_generate_questions,
@@ -933,6 +868,7 @@ def create_quiz_interface():
933
  )
934
 
935
  return demo
 
936
  if __name__ == "__main__":
937
  demo = create_quiz_interface()
938
  demo.launch()
 
729
  f"Question {new_idx + 1} of {len(questions)}",
730
  gr.update(visible=True)
731
  ]
732
+
733
+
734
  def on_submit(questions, answers, current_idx, current_answer):
735
  """Handle quiz submission with proper HTML rendering"""
736
  final_answers = list(answers)
 
792
  gr.update(visible=passed), # view_cert_btn
793
  gr.update(visible=True), # back_to_assessment
794
  gr.update(visible=False) # profile_tab
795
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  # Event Handlers
797
  generate_btn.click(
798
  fn=on_generate_questions,
 
868
  )
869
 
870
  return demo
871
+
872
  if __name__ == "__main__":
873
  demo = create_quiz_interface()
874
  demo.launch()