Update app.py
Browse files
app.py
CHANGED
@@ -79,17 +79,16 @@ def parse_quiz_content(quiz_content):
|
|
79 |
continue
|
80 |
|
81 |
if parsing_question_text:
|
82 |
-
if re.match(r'^Question\s+\d
|
83 |
-
|
84 |
-
|
|
|
85 |
parsing_question_text = False # Stop parsing question text, move to options
|
86 |
-
else:
|
87 |
-
|
88 |
-
|
89 |
-
parsing_question_text = False # Move to options parsing even if question text missing
|
90 |
else:
|
91 |
-
# If
|
92 |
-
# it might be the question text itself (in case of format variation)
|
93 |
question_text = line # Consider this line as question text
|
94 |
parsing_question_text = False # Move to options parsing
|
95 |
|
@@ -107,7 +106,7 @@ def parse_quiz_content(quiz_content):
|
|
107 |
st.write(f"- Options: {options}")
|
108 |
|
109 |
|
110 |
-
if question_text: # Only add question if we successfully extracted question text
|
111 |
questions.append({'question': question_text, 'options': options})
|
112 |
else:
|
113 |
st.warning(f"Warning: Could not parse question text for block (potential issue in question {question_number}). Block content:\n{block}")
|
|
|
79 |
continue
|
80 |
|
81 |
if parsing_question_text:
|
82 |
+
if re.match(r'^Question\s+\d+:\s*(.+)', line, re.IGNORECASE): # Check for "Question N:" and capture question text on same line
|
83 |
+
match = re.match(r'^Question\s+\d+:\s*(.+)', line, re.IGNORECASE)
|
84 |
+
if match:
|
85 |
+
question_text = match.group(1).strip() # Extract question text from the same line
|
86 |
parsing_question_text = False # Stop parsing question text, move to options
|
87 |
+
else: # Should not happen, but for robustness
|
88 |
+
question_text = ""
|
89 |
+
parsing_question_text = False
|
|
|
90 |
else:
|
91 |
+
# Fallback: If line doesn't start with "Question N:", consider it as question text
|
|
|
92 |
question_text = line # Consider this line as question text
|
93 |
parsing_question_text = False # Move to options parsing
|
94 |
|
|
|
106 |
st.write(f"- Options: {options}")
|
107 |
|
108 |
|
109 |
+
if question_text: # Only add question if we successfully extracted question text (and it's not empty)
|
110 |
questions.append({'question': question_text, 'options': options})
|
111 |
else:
|
112 |
st.warning(f"Warning: Could not parse question text for block (potential issue in question {question_number}). Block content:\n{block}")
|