Spaces:
Running
Running
srishtimaggo
commited on
Commit
Β·
4d0f22a
1
Parent(s):
3a64d9c
Update app.py
Browse files
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!")
|