Sina Media Lab commited on
Commit
597bdbe
·
1 Parent(s): 86cc97a
Files changed (1) hide show
  1. app.py +23 -19
app.py CHANGED
@@ -174,25 +174,19 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
174
  submit_button = st.form_submit_button(label=st.session_state.button_label)
175
 
176
  # Handle button state and answer submission
177
- if submit_button:
178
- if st.session_state.button_label == "Next Question":
179
- # Move to the next question
180
- new_question = generate_new_question(selected_module, modules[selected_module])
181
- st.session_state.questions.append(new_question)
182
- st.session_state.current_index = len(st.session_state.questions) - 1
183
- st.session_state.button_label = "Submit"
184
- else:
185
- if selected_answer is not None:
186
- # Process the answer
187
- current_question['selected'] = selected_answer
188
- current_question['answered'] = True
189
- st.session_state.module_question_count[selected_module] += 1
190
-
191
- if selected_answer == current_question['correct_answer']:
192
- st.session_state.correct_count += 1
193
- st.session_state.module_correct_count[selected_module] += 1
194
-
195
- st.session_state.button_label = "Next Question"
196
 
197
  # Show correct/incorrect feedback after submission
198
  if current_question.get('answered', False):
@@ -209,3 +203,13 @@ if current_question.get('answered', False):
209
  st.write("**Step-by-Step Solution:**")
210
  for step in current_question['step_by_step_solution']:
211
  st.write(step)
 
 
 
 
 
 
 
 
 
 
 
174
  submit_button = st.form_submit_button(label=st.session_state.button_label)
175
 
176
  # Handle button state and answer submission
177
+ if submit_button and st.session_state.button_label == "Submit":
178
+ if selected_answer is not None:
179
+ # Process the answer
180
+ current_question['selected'] = selected_answer
181
+ current_question['answered'] = True
182
+ st.session_state.module_question_count[selected_module] += 1
183
+
184
+ if selected_answer == current_question['correct_answer']:
185
+ st.session_state.correct_count += 1
186
+ st.session_state.module_correct_count[selected_module] += 1
187
+
188
+ # Show correct/incorrect feedback and explanation
189
+ st.session_state.button_label = "Next Question"
 
 
 
 
 
 
190
 
191
  # Show correct/incorrect feedback after submission
192
  if current_question.get('answered', False):
 
203
  st.write("**Step-by-Step Solution:**")
204
  for step in current_question['step_by_step_solution']:
205
  st.write(step)
206
+
207
+ # Change the button label immediately after showing the solution
208
+ st.session_state.button_label = "Next Question"
209
+
210
+ # Handle "Next Question" action after submission
211
+ if submit_button and st.session_state.button_label == "Next Question":
212
+ new_question = generate_new_question(selected_module, modules[selected_module])
213
+ st.session_state.questions.append(new_question)
214
+ st.session_state.current_index = len(st.session_state.questions) - 1
215
+ st.session_state.button_label = "Submit"