Sina Media Lab
commited on
Commit
·
f5a14cf
1
Parent(s):
5ceb83b
Updates
Browse files
app.py
CHANGED
@@ -180,8 +180,10 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
|
|
180 |
|
181 |
# Handle button state and answer submission
|
182 |
if submit_button:
|
183 |
-
if
|
184 |
-
|
|
|
|
|
185 |
# Process the answer
|
186 |
current_question['selected'] = selected_answer
|
187 |
current_question['answered'] = True
|
@@ -194,12 +196,6 @@ if submit_button:
|
|
194 |
# Show correct/incorrect feedback and explanation
|
195 |
st.session_state.button_label = "Next"
|
196 |
|
197 |
-
elif st.session_state.button_label == "Next":
|
198 |
-
new_question = generate_new_question(selected_module, modules[selected_module])
|
199 |
-
st.session_state.questions.append(new_question)
|
200 |
-
st.session_state.current_index = len(st.session_state.questions) - 1
|
201 |
-
st.session_state.button_label = "Submit"
|
202 |
-
|
203 |
# Show correct/incorrect feedback after submission
|
204 |
if current_question.get('answered', False):
|
205 |
for option in current_question['options']:
|
@@ -215,3 +211,10 @@ if current_question.get('answered', False):
|
|
215 |
st.write("**Step-by-Step Solution:**")
|
216 |
for step in current_question['step_by_step_solution']:
|
217 |
st.write(step)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
# Handle button state and answer submission
|
182 |
if submit_button:
|
183 |
+
if selected_answer is None:
|
184 |
+
st.warning("Please select an option before submitting.")
|
185 |
+
else:
|
186 |
+
if st.session_state.button_label == "Submit":
|
187 |
# Process the answer
|
188 |
current_question['selected'] = selected_answer
|
189 |
current_question['answered'] = True
|
|
|
196 |
# Show correct/incorrect feedback and explanation
|
197 |
st.session_state.button_label = "Next"
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
# Show correct/incorrect feedback after submission
|
200 |
if current_question.get('answered', False):
|
201 |
for option in current_question['options']:
|
|
|
211 |
st.write("**Step-by-Step Solution:**")
|
212 |
for step in current_question['step_by_step_solution']:
|
213 |
st.write(step)
|
214 |
+
|
215 |
+
# Handle switching to the next question on button click
|
216 |
+
if submit_button and st.session_state.button_label == "Next":
|
217 |
+
new_question = generate_new_question(selected_module, modules[selected_module])
|
218 |
+
st.session_state.questions.append(new_question)
|
219 |
+
st.session_state.current_index = len(st.session_state.questions) - 1
|
220 |
+
st.session_state.button_label = "Submit"
|