Update app.py
Browse files
app.py
CHANGED
@@ -118,7 +118,7 @@ def parse_quiz_content(quiz_content):
|
|
118 |
|
119 |
|
120 |
# --- Answer Key Parsing (No change needed) ---
|
121 |
-
answer_lines = answer_key_section.strip(
|
122 |
for line in answer_lines:
|
123 |
line = line.strip()
|
124 |
match = re.match(r'(\d+)\.\s*([A-D])', line)
|
@@ -243,6 +243,10 @@ if topic:
|
|
243 |
else:
|
244 |
st.error("Failed to generate quiz content. Please try again or check your API key.")
|
245 |
|
|
|
|
|
|
|
|
|
246 |
# Quiz Display Logic
|
247 |
if st.session_state.quiz_data:
|
248 |
if not st.session_state.quiz_completed:
|
|
|
118 |
|
119 |
|
120 |
# --- Answer Key Parsing (No change needed) ---
|
121 |
+
answer_lines = answer_key_section.strip('\n')
|
122 |
for line in answer_lines:
|
123 |
line = line.strip()
|
124 |
match = re.match(r'(\d+)\.\s*([A-D])', line)
|
|
|
243 |
else:
|
244 |
st.error("Failed to generate quiz content. Please try again or check your API key.")
|
245 |
|
246 |
+
except Exception as e:
|
247 |
+
st.error(f"An error occurred: {e}")
|
248 |
+
st.error("Please check your API key and network connection. If the problem persists, try a different topic or try again later.")
|
249 |
+
|
250 |
# Quiz Display Logic
|
251 |
if st.session_state.quiz_data:
|
252 |
if not st.session_state.quiz_completed:
|