mikaelJ46 commited on
Commit
2eeb0cb
·
verified ·
1 Parent(s): 6a552ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -5
app.py CHANGED
@@ -304,8 +304,22 @@ def generate_practice_questions(grade_level, subject, topic, num_questions=10):
304
  return None, "⚠️ Please select a topic first!"
305
 
306
  prompt = f"""Generate exactly {num_questions} UNEB-style {subject} questions for {grade_level} students on: \"{topic}\"\n\n"
307
- prompt += "Format your response EXACTLY like this:\nQ1. [Question text here]\nQ2. [Question text here]\nQ3. [Question text here]\n... and so on up to Q{num_questions}\n\n"
308
- prompt += f"Each question should be:\n- Clear and exam-like\n- Appropriate difficulty for {grade_level}\n- Self-contained (includes all necessary information)\n- Solvable in 2-5 minutes for short-answer questions\n\nStart immediately with Q1. Do not include any introduction or explanation."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
 
310
  response, source = ask_ai(prompt, temperature=0.6)
311
 
@@ -445,7 +459,7 @@ Good luck!
445
  with open(filepath, "w", encoding="utf-8") as f:
446
  f.write(content)
447
 
448
- return filepath
449
 
450
 
451
  def download_questions_pdf(questions_list, topic, grade_level, subject=None):
@@ -484,7 +498,7 @@ def download_questions_pdf(questions_list, topic, grade_level, subject=None):
484
 
485
  try:
486
  doc.build(elems)
487
- return filepath
488
  except Exception:
489
  return None
490
 
@@ -518,7 +532,7 @@ Practice similar questions to strengthen this topic.
518
  with open(filepath, "w", encoding="utf-8") as f:
519
  f.write(content)
520
 
521
- return filepath
522
 
523
  # ---------- 8. Gradio UI ----------
524
  css_styles = """
@@ -540,6 +554,10 @@ css_styles = """
540
  border-radius: 10px;
541
  border-left: 5px solid #667eea;
542
  margin: 15px 0;
 
 
 
 
543
  }
544
 
545
  .feedback-box {
@@ -547,6 +565,10 @@ css_styles = """
547
  padding: 20px;
548
  border-radius: 10px;
549
  border-left: 5px solid #10b981;
 
 
 
 
550
  }
551
 
552
  .answer-section {
@@ -555,6 +577,10 @@ css_styles = """
555
  border-radius: 10px;
556
  margin: 20px 0;
557
  }
 
 
 
 
558
  """
559
 
560
  with gr.Blocks(title="UNEB Exam Prep - Primary 6 & 7", theme=gr.themes.Soft(), css=css_styles) as app:
 
304
  return None, "⚠️ Please select a topic first!"
305
 
306
  prompt = f"""Generate exactly {num_questions} UNEB-style {subject} questions for {grade_level} students on: \"{topic}\"\n\n"
307
+ prompt = f"""Generate exactly {num_questions} UNEB-style {subject} questions for {grade_level} students on: "{topic}"
308
+
309
+ Format your response EXACTLY like this:
310
+ Q1. [Question text here]
311
+ Q2. [Question text here]
312
+ Q3. [Question text here]
313
+ ... and so on up to Q{num_questions}
314
+
315
+ Each question should be:
316
+ - Clear and exam-like
317
+ - Appropriate difficulty for {grade_level}
318
+ - Self-contained (includes all necessary information)
319
+ - Solvable in 2-5 minutes for short-answer questions
320
+
321
+ Start immediately with Q1. Do not include any introduction or explanation.
322
+ """
323
 
324
  response, source = ask_ai(prompt, temperature=0.6)
325
 
 
459
  with open(filepath, "w", encoding="utf-8") as f:
460
  f.write(content)
461
 
462
+ return os.path.abspath(filepath)
463
 
464
 
465
  def download_questions_pdf(questions_list, topic, grade_level, subject=None):
 
498
 
499
  try:
500
  doc.build(elems)
501
+ return os.path.abspath(filepath)
502
  except Exception:
503
  return None
504
 
 
532
  with open(filepath, "w", encoding="utf-8") as f:
533
  f.write(content)
534
 
535
+ return os.path.abspath(filepath)
536
 
537
  # ---------- 8. Gradio UI ----------
538
  css_styles = """
 
554
  border-radius: 10px;
555
  border-left: 5px solid #667eea;
556
  margin: 15px 0;
557
+ color: #111827;
558
+ font-size: 16px;
559
+ line-height: 1.5;
560
+ overflow-wrap: break-word;
561
  }
562
 
563
  .feedback-box {
 
565
  padding: 20px;
566
  border-radius: 10px;
567
  border-left: 5px solid #10b981;
568
+ color: #064e3b;
569
+ font-size: 16px;
570
+ line-height: 1.5;
571
+ overflow-wrap: break-word;
572
  }
573
 
574
  .answer-section {
 
577
  border-radius: 10px;
578
  margin: 20px 0;
579
  }
580
+ /* Slightly larger base text for smaller screens */
581
+ @media (max-width: 900px) {
582
+ .question-display, .feedback-box { font-size: 18px; }
583
+ }
584
  """
585
 
586
  with gr.Blocks(title="UNEB Exam Prep - Primary 6 & 7", theme=gr.themes.Soft(), css=css_styles) as app: