Spaces:
Runtime error
Runtime error
Update app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173import gradio as gr from datetime import datetime from io import BytesIO import tempfileTry to import FPDF for PDF generation; if missing, app still runs (no-PDF fallback)HAS_FPDF = True try: from fpdf import FPDF except Exception: HAS_FPDF = False------------------------------Question Banks (100 total)------------------------------Each question: {"q": str, "options": [str, str, str, str], "answer": str}ENG_Q = [ {"q": "1) Which word is a noun?", "options": ["Quickly", "Beautiful", "Chair", "Running"], "answer": "Chair"}, {"q": "2) Choose the correct plural of 'Child':", "options": ["Childs", "Children", "Childes", "Childer"], "answer": "Children"}, {"q": "3) The opposite of 'Hot' is:", "options": ["Warm", "Cool", "Boil", "Heat"], "answer": "Cool"}, {"q": "4) What is the past tense of 'Go'?", "options": ["Goed", "Going", "Went", "Gone"], "answer": "Went"}, {"q": "5) Which sentence is correct?", "options": ["She are happy.", "She is happy.", "She happy is.", "She be happy."], "answer": "She is happy."}, {"q": "6) Choose the synonym of 'Big':", "options": ["Small", "Large", "Short", "Tiny"], "answer": "Large"}, {"q": "7) The sun rises in the :", "options": ["West", "North", "East", "South"], "answer": "East"}, {"q": "8) Which is an adjective?", "options": ["Slowly", "Beautiful", "Jump", "Swim"], "answer": "Beautiful"}, {"q": "9) Fill in the blank: 'I ___ a book.'", "options": ["Reads", "Read", "Reading", "Reader"], "answer": "Read"}, {"q": "10) Antonym of 'Fast':", "options": ["Speedy", "Quick", "Slow", "Rapid"], "answer": "Slow"}, {"q": "11) Which is a pronoun?", "options": ["He", "Book", "Run", "Chair"], "answer": "He"}, {"q": "12) Choose the correct spelling:", "options": ["Calender", "Calendar", "Calindar", "Clander"], "answer": "Calendar"}, {"q": "13) The plural of 'Leaf' is:", "options": ["Leafs", "Leaves", "Leafes", "Leves"], "answer": "Leaves"}, {"q": "14) Which word means the same as 'Begin'?", "options": ["Start", "Stop", "End", "Close"], "answer": "Start"}, {"q": "15) 'I like to ___ football.'", "options": ["Plays", "Play", "Played", "Playing"], "answer": "Play"}, {"q": "16) Opposite of 'Happy':", "options": ["Glad", "Sad", "Joyful", "Cheerful"], "answer": "Sad"}, {"q": "17) Which is a verb?", "options": ["Jump", "Sky", "Mountain", "Blue"], "answer": "Jump"}, {"q": "18) 'She ___ reading a book now.'", "options": ["is", "are", "was", "be"], "answer": "is"}, {"q": "19) Choose the correct sentence:", "options": ["They is running.", "They are running.", "They running.", "They runs."], "answer": "They are running."}, {"q": "20) Which is a question word?", "options": ["When", "Book", "Run", "Quickly"], "answer": "When"}, {"q": "21) Fill in: 'He ___ to school yesterday.'", "options": ["go", "went", "goes", "going"], "answer": "went"}, {"q": "22) Synonym of 'Happy':", "options": ["Sad", "Glad", "Angry", "Cry"], "answer": "Glad"}, {"q": "23) Choose the correct article: ' apple a day keeps the doctor away.'", "options": ["A", "An", "The", "None"], "answer": "An"}, {"q": "24) Which is a preposition?", "options": ["Under", "Play", "Run", "Chair"], "answer": "Under"}, {"q": "25) The opposite of 'day' is:", "options": ["Morning", "Night", "Evening", "Afternoon"], "answer": "Night"}, {"q": "26) Which is a proper noun?", "options": ["Boy", "Pakistan", "City", "Country"], "answer": "Pakistan"}, {"q": "27) Fill in: 'The birds ___ flying.'", "options": ["is", "are", "was", "be"], "answer": "are"}, {"q": "28) Antonym of 'Old':", "options": ["Young", "Aged", "Ancient", "Elder"], "answer": "Young"}, {"q": "29) Which is a compound word?", "options": ["Sunflower", "Flower", "Sun", "Tree"], "answer": "Sunflower"}, {"q": "30) Choose the correct form: 'We ___ at home now.'", "options": ["am", "are", "is", "be"], "answer": "are"}, {"q": "31) Which is a conjunction?", "options": ["And", "Quickly", "Run", "Book"], "answer": "And"}, {"q": "32) Past tense of 'Eat':", "options": ["Eated", "Ate", "Eats", "Eating"], "answer": "Ate"}, {"q": "33) 'The sky is ___.',", "options": ["blue", "jump", "play", "walk"], "answer": "blue"}, {"q": "34) Opposite of 'Come':", "options": ["Go", "Arrive", "Stay", "Reach"], "answer": "Go"}, ]MATH_Q = [ {"q": "35) 125 + 248 = ?", "options": ["343", "373", "383", "413"], "answer": "373"}, {"q": "36) 600 − 375 = ?", "options": ["125", "215", "225", "235"], "answer": "225"}, {"q": "37) 45 × 8 = ?", "options": ["320", "360", "380", "400"], "answer": "360"}, {"q": "38) 924 ÷ 4 = ?", "options": ["221", "231", "241", "246"], "answer": "231"}, {"q": "39) Which fraction is larger?", "options": ["1/4", "1/3", "1/5", "1/6"], "answer": "1/3"}, {"q": "40) 3/4 + 2/4 = ?", "options": ["3/8", "1/4", "5/4", "1"], "answer": "5/4"}, {"q": "41) 5.6 + 2.45 = ?", "options": ["7.95", "8.05", "8.15", "8.25"], "answer": "8.05"}, {"q": "42) 7.8 − 3.25 = ?", "options": ["4.45", "4.55", "4.65", "4.75"], "answer": "4.55"}, {"q": "43) 1/3 of 12 is:", "options": ["2", "3", "4", "5"], "answer": "4"}, {"q": "44) Area of rectangle 12cm × 8cm:", "options": ["20 cm²", "80 cm²", "96 cm²", "100 cm²"], "answer": "96 cm²"}, {"q": "45) 9 × 7 = ?", "options": ["56", "60", "63", "72"], "answer": "63"}, {"q": "46) 1000 − 435 = ?", "options": ["455", "565", "575", "585"], "answer": "565"}, {"q": "47) 6 × (5 + 3) = ?", "options": ["48", "30", "36", "18"], "answer": "48"}, {"q": "48) 2.5 × 4 = ?", "options": ["8", "9", "10", "12"], "answer": "10"}, {"q": "49) 500 ÷ 25 = ?", "options": ["10", "15", "20", "25"], "answer": "20"}, {"q": "50) 1/2 + 1/4 = ?", "options": ["1/4", "1/2", "3/4", "1"], "answer": "3/4"}, {"q": "51) 4² + 3² = ?", "options": ["12", "16", "18", "25"], "answer": "25"}, {"q": "52) Perimeter of square (side 5 cm) = ?", "options": ["10 cm", "15 cm", "20 cm", "25 cm"], "answer": "20 cm"}, {"q": "53) 15% of 200 = ?", "options": ["20", "25", "30", "35"], "answer": "30"}, {"q": "54) 0.75 as a fraction = ?", "options": ["1/2", "3/4", "4/5", "2/3"], "answer": "3/4"}, {"q": "55) 7 × 12 = ?", "options": ["72", "74", "82", "84"], "answer": "84"}, {"q": "56) 84 ÷ 7 = ?", "options": ["10", "11", "12", "14"], "answer": "12"}, {"q": "57) 3/5 + 1/10 = ?", "options": ["2/5", "7/10", "3/10", "4/5"], "answer": "7/10"}, {"q": "58) 2 km = ? meters", "options": ["20", "200", "2000", "20000"], "answer": "2000"}, {"q": "59) Angle in a straight line = ?", "options": ["90°", "120°", "150°", "180°"], "answer": "180°"}, {"q": "60) 9² = ?", "options": ["18", "81", "72", "92"], "answer": "81"}, {"q": "61) 1 liter = ? milliliters", "options": ["10", "100", "1000", "10000"], "answer": "1000"}, {"q": "62) 0.6 + 0.15 = ?", "options": ["0.65", "0.70", "0.75", "0.80"], "answer": "0.75"}, {"q": "63) Area of square (side 9 cm) = ?", "options": ["18 cm²", "27 cm²", "36 cm²", "81 cm²"], "answer": "81 cm²"}, {"q": "64) 14 + 29 + 7 = ?", "options": ["46", "48", "50", "52"], "answer": "50"}, {"q": "65) 105 − 68 = ?", "options": ["35", "37", "39", "41"], "answer": "37"}, {"q": "66) 8 × 11 = ?", "options": ["80", "82", "88", "98"], "answer": "88"}, {"q": "67) 2/3 of ninety is:", "options": ["30", "45", "60", "75"], "answer": "60"}, ]ISL_Q = [ {"q": "68) How many pillars of Islam are there?", "options": ["3", "4", "5", "6"], "answer": "5"}, {"q": "69) First Kalimah is called:", "options": ["Kalimah Tayyiba", "Kalimah Shahadat", "Kalimah Tamjeed", "Kalimah Tauheed"], "answer": "Kalimah Tayyiba"}, {"q": "70) The holy book of Muslims is:", "options": ["Torah", "Bible", "Quran", "Zaboor"], "answer": "Quran"}, {"q": "71) Number of Surahs in the Quran:", "options": ["100", "110", "114", "124"], "answer": "114"}, {"q": "72) The first Prophet is:", "options": ["Hazrat Ibrahim (A.S)", "Hazrat Adam (A.S)", "Hazrat Nuh (A.S)", "Hazrat Musa (A.S)"], "answer": "Hazrat Adam (A.S)"}, {"q": "73) The last Prophet is:", "options": ["Hazrat Isa (A.S)", "Hazrat Musa (A.S)", "Hazrat Muhammad (S.A.W)", "Hazrat Yusuf (A.S)"], "answer": "Hazrat Muhammad (S.A.W)"}, {"q": "74) How many Rak'ah in Fajr (Farz)?", "options": ["1", "2", "3", "4"], "answer": "2"}, {"q": "75) The city of Prophet's migration (Hijrah) is:", "options": ["Makkah", "Madinah", "Taif", "Jerusalem"], "answer": "Madinah"}, {"q": "76) Laylat-ul-Qadr is in month of:", "options": ["Muharram", "Rabi-ul-Awwal", "Ramadan", "Zilhajj"], "answer": "Ramadan"}, {"q": "77) Zakat is obligatory on:", "options": ["Poor", "Traveler", "Eligible wealth", "Children"], "answer": "Eligible wealth"}, {"q": "78) The first revelation came in cave:", "options": ["Saur", "Hira", "Arafat", "Uhud"], "answer": "Hira"}, {"q": "79) How many daily prayers (Salah) are obligatory?", "options": ["3", "4", "5", "6"], "answer": "5"}, {"q": "80) The direction Muslims face during prayer is called:", "options": ["Qiblah", "Mehrab", "Minbar", "Rukun"], "answer": "Qiblah"}, {"q": "81) The month of Hajj is:", "options": ["Shawwal", "Zilqa'dah", "Zilhajj", "Safar"], "answer": "Zilhajj"}, {"q": "82) The father of Prophet Ibrahim (A.S) is known as:", "options": ["Azar", "Imran", "Yaqoob", "Amran"], "answer": "Azar"}, {"q": "83) The city where Ka'bah is located:", "options": ["Madinah", "Makkah", "Taif", "Arafat"], "answer": "Makkah"}, {"q": "84) Roza means:", "options": ["Prayer", "Charity", "Fasting", "Pilgrimage"], "answer": "Fasting"}, {"q": "85) The language of the Quran is:", "options": ["Arabic", "Persian", "Urdu", "Hebrew"], "answer": "Arabic"}, {"q": "86) The night journey (Isra) was to:", "options": ["Arafat", "Taif", "Masjid Al-Aqsa", "Uhud"], "answer": "Masjid Al-Aqsa"}, {"q": "87) The fast-breaking meal is called:", "options": ["Suhoor", "Iftar", "Dinner", "Lunch"], "answer": "Iftar"}, {"q": "88) Charity given to poor (obligatory) is:", "options": ["Sadaqah", "Zakat", "Khairat", "Fitrana"], "answer": "Zakat"}, {"q": "89) Muslims pray facing:", "options": ["Masjid Al-Aqsa", "Ka'bah", "Madinah", "Uhud"], "answer": "Ka'bah"}, {"q": "90) The call to prayer is called:", "options": ["Iqamah", "Adhan", "Takbir", "Khutbah"], "answer": "Adhan"}, {"q": "91) The 'Sunnah' means:", "options": ["Obligatory", "Recommended practice", "Forbidden", "None"], "answer": "Recommended practice"}, {"q": "92) The Prophet's (S.A.W) birthplace is:", "options": ["Madinah", "Makkah", "Taif", "Badr"], "answer": "Makkah"}, {"q": "93) The month after Ramadan is:", "options": ["Shawwal", "Muharram", "Safar", "Rabi-ul-Awwal"], "answer": "Shawwal"}, {"q": "94) The festival after Hajj is:", "options": ["Eid-ul-Fitr", "Eid-ul-Adha", "Eid Milad", "Shab-e-Barat"], "answer": "Eid-ul-Adha"}, {"q": "95) The first revelation word was:", "options": ["Iqra", "Qul", "Qad", "Kun"], "answer": "Iqra"}, {"q": "96) The battle fought in 2 AH was:", "options": ["Uhud", "Badr", "Khandaq", "Hunain"], "answer": "Badr"}, {"q": "97) The mother of Prophet Ismail (A.S) is:", "options": ["Sarah", "Hajra", "Maryam", "Aasiyah"], "answer": "Hajra"}, {"q": "98) The Zamzam well appeared near:", "options": ["Safa", "Marwah", "Ka'bah", "Arafat"], "answer": "Ka'bah"}, {"q": "99) 'Salah' means:", "options": ["Fasting", "Prayer", "Charity", "Pilgrimage"], "answer": "Prayer"}, {"q": "100) The animal sacrificed on Eid-ul-Adha is called:", "options": ["Fidya", "Qurbani", "Aqiqa", "Udhiyah"], "answer": "Qurbani"}, ]------------------------------Utility functions------------------------------def evaluate(name, father, roll, *answers): total_q = len(ENG_Q) + len(MATH_Q) + len(ISL_Q) # 100 # Split answers by section eng_ans = answers[0:len(ENG_Q)] math_ans = answers[len(ENG_Q):len(ENG_Q)+len(MATH_Q)] isl_ans = answers[len(ENG_Q)+len(MATH_Q):]eng_correct = sum(1 for i, q in enumerate(ENG_Q) if eng_ans[i] == q["answer"]) if eng_ans else 0math_correct = sum(1 for i, q in enumerate(MATH_Q) if math_ans[i] == q["answer"]) if math_ans else 0isl_correct = sum(1 for i, q in enumerate(ISL_Q) if isl_ans[i] == q["answer"]) if isl_ans else 0total_correct = eng_correct + math_correct + isl_correctpercentage = round((total_correct / total_q) * 100, 2)# Build summary textsummary = (f"Student: {name}\n"f"Father's Name: {father}\n"f"Roll Number: {roll}\n\n"f"English: {eng_correct}/{len(ENG_Q)}\n"f"Math: {math_correct}/{len(MATH_Q)}\n"f"Islamiat: {isl_correct}/{len(ISL_Q)}\n"f"Total: {total_correct}/{total_q} | Percentage: {percentage}%\n")pdf_path = Noneif HAS_FPDF:try:pdf = FPDF()pdf.add_page()pdf.set_auto_page_break(auto=True, margin=12)pdf.set_font("Arial", "B", 16)pdf.cell(0, 10, "Grade 5 Test - Result Card", ln=True, align="C")pdf.ln(2)pdf.set_font("Arial", size=12)pdf.cell(0, 8, f"Name: {name}", ln=True)pdf.cell(0, 8, f"Father's Name: {father}", ln=True)pdf.cell(0, 8, f"Roll Number: {roll}", ln=True)pdf.cell(0, 8, f"Date & Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ln=True)pdf.ln(4)pdf.set_font("Arial", "B", 13)pdf.cell(0, 8, "Scores", ln=True)pdf.set_font("Arial", size=12)pdf.cell(0, 8, f"English: {eng_correct}/{len(ENG_Q)}", ln=True)pdf.cell(0, 8, f"Math: {math_correct}/{len(MATH_Q)}", ln=True)pdf.cell(0, 8, f"Islamiat: {isl_correct}/{len(ISL_Q)}", ln=True)pdf.cell(0, 8, f"Total: {total_correct}/{total_q}", ln=True)pdf.cell(0, 8, f"Percentage: {percentage}%", ln=True)with tempfile.NamedTemporaryFile(delete=False, suffix=f"_{roll}.pdf") as tmp:pdf.output(tmp.name)pdf_path = tmp.nameexcept Exception:pdf_path = Nonereturn summary, pdf_path------------------------------Build Gradio UI------------------------------with gr.Blocks(title="Grade 5 Test — 100 MCQs", theme=gr.themes.Soft()) as demo: gr.Markdown(""" # 🧮 Grade 5 Test — 100 MCQs Fill student info, answer all questions in three sections, then submit to get scores, percentage, and a PDF result card. """)with gr.Box():name = gr.Textbox(label="Student Name", placeholder="Enter full name")father = gr.Textbox(label="Father's Name", placeholder="Enter father's name")roll = gr.Textbox(label="Roll Number", placeholder="e.g., 5A-023")with gr.Tab("English (34)"):eng_inputs = [gr.Radio(choices=q["options"], label=q["q"], type="value") for q in ENG_Q]with gr.Tab("Math (33)"):math_inputs = [gr.Radio(choices=q["options"], label=q["q"], type="value") for q in MATH_Q]with gr.Tab("Islamiat (33)"):isl_inputs = [gr.Radio(choices=q["options"], label=q["q"], type="value") for q in ISL_Q]submit = gr.Button("Submit Test ✅")result = gr.Textbox(label="Result Summary", lines=10)pdf_file = gr.File(label="Download Result Card (PDF)")all_inputs = [name, father, roll] + eng_inputs + math_inputs + isl_inputssubmit.click(fn=evaluate, inputs=all_inputs, outputs=[result, pdf_file])gr.Markdown("""---**Notes:** If the PDF file does not appear, ensure the Space has `fpdf` installed via `requirements.txt`.""")if name == "main": demo.launch()import gradio as gr# ----------------------------# Data: Questions# ----------------------------QUESTIONS = [{"q": "1) 125 + 248 = ?", "options": ["343", "373", "383", "413"], "answer": "373"},{"q": "2) 600 − 375 = ?", "options": ["125", "215", "225", "235"], "answer": "225"},{"q": "3) 45 × 8 = ?", "options": ["320", "360", "380", "400"], "answer": "360"},{"q": "4) 924 ÷ 4 = ?", "options": ["221", "231", "241", "246"], "answer": "231"},{"q": "5) Which fraction is larger?", "options": ["1/4", "1/3", "1/5", "1/6"], "answer": "1/3"},{"q": "6) 3/4 + 2/4 = ?", "options": ["3/8", "1/4", "5/4", "1"], "answer": "5/4"},{"q": "7) 5.6 + 2.45 = ?", "options": ["7.95", "8.05", "8.15", "8.25"], "answer": "8.05"},{"q": "8) 7.8 − 3.25 = ?", "options": ["4.45", "4.55", "4.65", "4.75"], "answer": "4.55"},{"q": "9) 1/3 of 12 is:", "options": ["2", "3", "4", "5"], "answer": "4"},{"q": "10) Area of rectangle 12cm × 8cm:", "options": ["20 cm²", "80 cm²", "96 cm²", "100 cm²"], "answer": "96 cm²"},]# ----------------------------# Function# ----------------------------def evaluate(name, father_name, roll_no, *user_answers):correct = 0total = len(QUESTIONS)for i, q in enumerate(QUESTIONS):if user_answers[i] == q["answer"]:correct += 1percent = round((correct / total) * 100, 2)return f"Student: {name}\nFather's Name: {father_name}\nRoll No: {roll_no}\nScore: {correct}/{total}\nPercentage: {percent}%"# ----------------------------# UI# ----------------------------inputs = [gr.Textbox(label="Student Name"),gr.Textbox(label="Father's Name"),gr.Textbox(label="Roll Number")]for q in QUESTIONS:inputs.append(gr.Radio(choices=q["options"], label=q["q"], type="value"))outputs = gr.Textbox(label="Result Summary")demo = gr.Interface(fn=evaluate,inputs=inputs,outputs=outputs,title="🧮 5th Class Test",description="Answer the questions to get your score and percentage.")if __name__ == "__main__":demo.launch()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136import gradio as grfrom fpdf import FPDFimport tempfileimport datetime# --------------------------# Questions Bank# --------------------------english_questions = [{"question": "Choose the correct synonym of 'Happy':","options": ["Sad", "Joyful", "Angry", "Tired"],"answer": "Joyful"},{"question": "Choose the correct antonym of 'Cold':","options": ["Hot", "Freezing", "Cool", "Chilly"],"answer": "Hot"},{"question": "Fill in the blank: She _____ to school every day.","options": ["go", "goes", "gone", "going"],"answer": "goes"}] * 10 # Repeat to make 30 for exampleislamiat_questions = [{"question": "Who was the first Caliph of Islam?","options": ["Hazrat Umar (RA)", "Hazrat Abu Bakr (RA)", "Hazrat Ali (RA)", "Hazrat Usman (RA)"],"answer": "Hazrat Abu Bakr (RA)"},{"question": "How many times Muslims pray in a day?","options": ["3", "4", "5", "6"],"answer": "5"},{"question": "Which Surah is the shortest in the Quran?","options": ["Al-Fatiha", "Al-Ikhlas", "Al-Kawthar", "Al-Nas"],"answer": "Al-Kawthar"}] * 10 # Repeat to make 30math_questions = [{"question": "What is 15 + 6?","options": ["21", "20", "22", "19"],"answer": "21"},{"question": "What is 9 × 7?","options": ["63", "72", "56", "49"],"answer": "63"},{"question": "What is 100 ÷ 4?","options": ["20", "25", "24", "30"],"answer": "25"}] * 10 # Repeat to make 30questions_bank = {"English": english_questions,"Islamiat": islamiat_questions,"Math": math_questions}# --------------------------# PDF Generation Function# --------------------------def generate_pdf(name, father_name, roll_number, score, total):percentage = (score / total) * 100pdf = FPDF()pdf.add_page()pdf.set_font("Arial", size=16)pdf.cell(200, 10, txt="5th Class Test Result Card", ln=True, align='C')pdf.ln(10)pdf.set_font("Arial", size=12)pdf.cell(200, 10, txt=f"Name: {name}", ln=True)pdf.cell(200, 10, txt=f"Father's Name: {father_name}", ln=True)pdf.cell(200, 10, txt=f"Roll Number: {roll_number}", ln=True)pdf.cell(200, 10, txt=f"Score: {score}/{total}", ln=True)pdf.cell(200, 10, txt=f"Percentage: {percentage:.2f}%", ln=True)pdf.cell(200, 10, txt=f"Date: {datetime.date.today()}", ln=True)temp_pdf = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")pdf.output(temp_pdf.name)return temp_pdf.name# --------------------------# Test Logic# --------------------------def test_app(name, father_name, roll_number, *answers):score = 0total = sum(len(q_list) for q_list in questions_bank.values())# Check answersidx = 0for section in questions_bank:for q in questions_bank[section]:if answers[idx] == q["answer"]:score += 1idx += 1pdf_path = generate_pdf(name, father_name, roll_number, score, total)return f"You scored {score}/{total} ({(score/total)*100:.2f}%)", pdf_path# --------------------------# Build Gradio Interface# --------------------------inputs = [gr.Textbox(label="Name"),gr.Textbox(label="Father's Name"),gr.Textbox(label="Roll Number")]# Add questions dynamicallyfor section, q_list in questions_bank.items():inputs.append(gr.Label(value=f"--- {section} Section ---"))for q in q_list:inputs.append(gr.Radio(choices=q["options"], label=q["question"]))outputs = [gr.Textbox(label="Result"),gr.File(label="Download Result PDF")]demo = gr.Interface(fn=test_app, inputs=inputs, outputs=outputs, title="5th Class Test")if __name__ == "__main__":demo.launch()
app.py+124-161