capradeepgujaran commited on
Commit
fba3933
1 Parent(s): 1b4472e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -36
app.py CHANGED
@@ -525,18 +525,36 @@ class QuizApp:
525
  self.quiz_generator = QuizGenerator(api_key)
526
  self.certificate_generator = CertificateGenerator()
527
  self.current_questions: List[Question] = []
528
- self.learning_content: Optional[str] = None # Store learning content
529
- self.logo_path = "atgc_logo.png" # Fixed path to ATGC logo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
- def set_learning_content(self, text: str) -> None:
532
- """Set the learning content if not already set"""
533
- if not self.learning_content:
534
- self.learning_content = text.strip()
535
 
536
- def clear_learning_content(self) -> None:
537
- """Clear the stored learning content"""
538
- self.learning_content = None
539
-
540
  def generate_questions(self, text: str, num_questions: int) -> Tuple[bool, List[Question]]:
541
  """
542
  Generate quiz questions using the QuizGenerator
@@ -728,10 +746,12 @@ def create_quiz_interface():
728
 
729
  text_input = gr.Textbox(
730
  label="Learning Content",
731
- placeholder="Enter the text content you want to be assessed on",
 
732
  lines=10
733
  )
734
 
 
735
  num_questions = gr.Slider(
736
  minimum=1,
737
  maximum=20,
@@ -825,28 +845,7 @@ def create_quiz_interface():
825
 
826
  # Helper Functions
827
  def on_generate_questions(text, num_questions):
828
- if not text.strip():
829
- return [
830
- "",
831
- gr.update(visible=False),
832
- gr.update(choices=[], visible=False),
833
- "",
834
- [],
835
- 0,
836
- [None] * 5,
837
- gr.update(selected=1),
838
- gr.update(visible=False),
839
- gr.update(visible=False)
840
- ]
841
-
842
- # Store content if not already stored
843
- if not quiz_app.learning_content:
844
- quiz_app.learning_content = text.strip()
845
-
846
- # Use stored content instead of new text if available
847
- content_to_use = quiz_app.learning_content or text
848
-
849
- success, questions = quiz_app.generate_questions(content_to_use, num_questions)
850
  if not success or not questions:
851
  return [
852
  "",
@@ -862,8 +861,7 @@ def create_quiz_interface():
862
  ]
863
 
864
  question = questions[0]
865
- question_md = f"""### Question 1
866
- {question.question}"""
867
 
868
  return [
869
  question_md,
@@ -883,6 +881,7 @@ def create_quiz_interface():
883
  gr.update(visible=False)
884
  ]
885
 
 
886
  def navigate(direction, current_idx, questions, answers, current_answer):
887
  if not questions:
888
  return [0, answers, "", gr.update(choices=[], visible=False), "", gr.update(visible=False)]
@@ -999,7 +998,7 @@ def create_quiz_interface():
999
 
1000
  # Event Handlers
1001
  generate_btn.click(
1002
- fn=on_generate_questions, # Using the same function name
1003
  inputs=[text_input, num_questions],
1004
  outputs=[
1005
  question_display,
 
525
  self.quiz_generator = QuizGenerator(api_key)
526
  self.certificate_generator = CertificateGenerator()
527
  self.current_questions: List[Question] = []
528
+ self.logo_path = "atgc_logo.png" # Fixed ATGC logo path
529
+
530
+ # Add fixed content here
531
+ self.fixed_content = """Decoding Data Science - ATGC: A Leader in AI Education and Innovation
532
+
533
+ Led by Mohammad Arshad Ahmad, a seasoned Principal Data Scientist with over 20+ years of industry experience, Decoding Data Science is at the forefront of AI education and consulting. Our mission is to empower individuals and organizations with cutting-edge data science skills and solutions.
534
+
535
+ Key Offerings:
536
+ 1. Comprehensive Data Science Programs
537
+ - Python Programming
538
+ - Machine Learning
539
+ - Deep Learning
540
+ - Natural Language Processing
541
+ - Computer Vision
542
+
543
+ 2. Industry Solutions
544
+ - AI Model Development
545
+ - Data Analytics
546
+ - Process Automation
547
+ - Custom AI Solutions
548
+
549
+ 3. Community Initiatives
550
+ - Regular Workshops
551
+ - Tech Meetups
552
+ - Hackathons
553
+ - Online Resources
554
+
555
+ Join us in shaping the future of AI education and innovation!"""
556
 
 
 
 
 
557
 
 
 
 
 
558
  def generate_questions(self, text: str, num_questions: int) -> Tuple[bool, List[Question]]:
559
  """
560
  Generate quiz questions using the QuizGenerator
 
746
 
747
  text_input = gr.Textbox(
748
  label="Learning Content",
749
+ value=quiz_app.fixed_content, # Set the fixed content
750
+ interactive=False, # Make it non-editable
751
  lines=10
752
  )
753
 
754
+
755
  num_questions = gr.Slider(
756
  minimum=1,
757
  maximum=20,
 
845
 
846
  # Helper Functions
847
  def on_generate_questions(text, num_questions):
848
+ success, questions = quiz_app.generate_questions(quiz_app.fixed_content, num_questions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
849
  if not success or not questions:
850
  return [
851
  "",
 
861
  ]
862
 
863
  question = questions[0]
864
+ question_md = f"""### Question 1\n{question.question}"""
 
865
 
866
  return [
867
  question_md,
 
881
  gr.update(visible=False)
882
  ]
883
 
884
+
885
  def navigate(direction, current_idx, questions, answers, current_answer):
886
  if not questions:
887
  return [0, answers, "", gr.update(choices=[], visible=False), "", gr.update(visible=False)]
 
998
 
999
  # Event Handlers
1000
  generate_btn.click(
1001
+ fn=on_generate_questions,
1002
  inputs=[text_input, num_questions],
1003
  outputs=[
1004
  question_display,