srishtimaggo commited on
Commit
4d0f22a
Β·
1 Parent(s): 3a64d9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py CHANGED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import time
3
+ from io import StringIO
4
+
5
+ # Title and Description
6
+ st.set_page_config(page_title="AI Custom Quiz Generator", layout="centered")
7
+ st.title("🧠 AI Custom Quiz Generator")
8
+ st.markdown("""
9
+ Welcome to the AI-Powered Quiz Generator!
10
+ Enter your preferences below to generate personalized quizzes based on your topic, difficulty level, and question type.
11
+ """)
12
+
13
+ # Input Section
14
+ with st.container():
15
+ topic = st.text_input("πŸ“˜ Enter Topic :")
16
+ difficulty = st.selectbox("πŸ“Š Select Difficulty Level:", ["Easy", "Medium", "Hard"])
17
+ q_type = st.selectbox("❓ Question Type:", ["MCQ", "True/False", "Short Answer"])
18
+ num_questions = st.slider("πŸ”’ Number of Questions:", 1, 20, 5)
19
+
20
+ # Placeholder for generated quiz
21
+ quiz_output = ""
22
+
23
+ # Generate Quiz Button
24
+ if st.button("πŸš€ Generate Quiz"):
25
+ if topic.strip() == "":
26
+ st.warning("⚠️ Please enter a topic before generating the quiz.")
27
+ else:
28
+ with st.spinner("πŸ› οΈ Generating your quiz... Please wait..."):
29
+ try:
30
+ time.sleep(2)
31
+
32
+ # Fake quiz generation
33
+ quiz_output = f"Topic: {topic}\nDifficulty: {difficulty}\nType: {q_type}\n\n"
34
+ for i in range(1, num_questions + 1):
35
+ quiz_output += f"{i}. Sample question {i} on {topic} [{q_type} - {difficulty}]\n"
36
+
37
+ st.success("βœ… Quiz generated successfully!")
38
+ st.text_area("πŸ“„ Your Quiz:", quiz_output, height=200)
39
+
40
+ # Download button
41
+ st.download_button(
42
+ label="⬇️ Download Quiz as .txt",
43
+ data=quiz_output,
44
+ file_name=f"{topic.lower().replace(' ', '_')}_quiz.txt",
45
+ mime="text/plain"
46
+ )
47
+
48
+ except Exception as e:
49
+ st.error(f"❌ Something went wrong: {e}")
50
+
51
+ # Feedback Section
52
+ st.markdown("---")
53
+ st.subheader("πŸ’¬ Feedback")
54
+ feedback = st.text_area("Let us know your thoughts or any issues you faced:")
55
+ if st.button("πŸ“© Submit Feedback"):
56
+ if feedback.strip() == "":
57
+ st.info("✏️ Please write something before submitting.")
58
+ else:
59
+ st.success("πŸ™Œ Thank you for your feedback!")