Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -284,7 +284,10 @@ def main():
|
|
284 |
- Educational content works better than narrative
|
285 |
""")
|
286 |
|
287 |
-
# Generate Quiz button
|
|
|
|
|
|
|
288 |
if st.button("🧠 Generate Quiz"):
|
289 |
if passage and len(passage) > 50:
|
290 |
# Loading the model (with the cached resource)
|
@@ -313,7 +316,7 @@ def main():
|
|
313 |
st.session_state.user_answers = {}
|
314 |
st.session_state.quiz_submitted = False
|
315 |
st.session_state.show_explanations = False
|
316 |
-
st.
|
317 |
else:
|
318 |
st.error("Couldn't create valid quiz questions. Please try a different text or add more content.")
|
319 |
else:
|
@@ -381,11 +384,11 @@ def main():
|
|
381 |
|
382 |
# Restart button
|
383 |
if st.button("Generate Another Quiz"):
|
384 |
-
# Clear session state
|
385 |
-
for key in ["quiz_items", "user_answers", "quiz_submitted", "show_explanations"]:
|
386 |
if key in st.session_state:
|
387 |
del st.session_state[key]
|
388 |
-
|
389 |
|
390 |
if __name__ == "__main__":
|
391 |
main()
|
|
|
284 |
- Educational content works better than narrative
|
285 |
""")
|
286 |
|
287 |
+
# Generate Quiz button with automatic rerun logic
|
288 |
+
if "quiz_generated" not in st.session_state:
|
289 |
+
st.session_state.quiz_generated = False
|
290 |
+
|
291 |
if st.button("🧠 Generate Quiz"):
|
292 |
if passage and len(passage) > 50:
|
293 |
# Loading the model (with the cached resource)
|
|
|
316 |
st.session_state.user_answers = {}
|
317 |
st.session_state.quiz_submitted = False
|
318 |
st.session_state.show_explanations = False
|
319 |
+
st.session_state.quiz_generated = True
|
320 |
else:
|
321 |
st.error("Couldn't create valid quiz questions. Please try a different text or add more content.")
|
322 |
else:
|
|
|
384 |
|
385 |
# Restart button
|
386 |
if st.button("Generate Another Quiz"):
|
387 |
+
# Clear session state
|
388 |
+
for key in ["quiz_items", "user_answers", "quiz_submitted", "show_explanations", "quiz_generated"]:
|
389 |
if key in st.session_state:
|
390 |
del st.session_state[key]
|
391 |
+
# No need for rerun as page will refresh naturally with next event
|
392 |
|
393 |
if __name__ == "__main__":
|
394 |
main()
|