Sina Media Lab commited on
Commit
5ceb83b
·
1 Parent(s): 5bd3774
Files changed (1) hide show
  1. app.py +20 -23
app.py CHANGED
@@ -179,19 +179,26 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
179
  submit_button = st.form_submit_button(label=st.session_state.button_label)
180
 
181
  # Handle button state and answer submission
182
- if submit_button and st.session_state.button_label == "Submit":
183
- if selected_answer is not None:
184
- # Process the answer
185
- current_question['selected'] = selected_answer
186
- current_question['answered'] = True
187
- st.session_state.module_question_count[selected_module] += 1
188
-
189
- if selected_answer == current_question['correct_answer']:
190
- st.session_state.correct_count += 1
191
- st.session_state.module_correct_count[selected_module] += 1
192
-
193
- # Show correct/incorrect feedback and explanation
194
- st.session_state.button_label = "Next Question"
 
 
 
 
 
 
 
195
 
196
  # Show correct/incorrect feedback after submission
197
  if current_question.get('answered', False):
@@ -208,13 +215,3 @@ if current_question.get('answered', False):
208
  st.write("**Step-by-Step Solution:**")
209
  for step in current_question['step_by_step_solution']:
210
  st.write(step)
211
-
212
- # Change the button label immediately after showing the solution
213
- st.session_state.button_label = "Next Question"
214
-
215
- # Handle switching to the next question on button click
216
- if submit_button and st.session_state.button_label == "Next Question":
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"
 
179
  submit_button = st.form_submit_button(label=st.session_state.button_label)
180
 
181
  # Handle button state and answer submission
182
+ if submit_button:
183
+ if st.session_state.button_label == "Submit":
184
+ if selected_answer is not None:
185
+ # Process the answer
186
+ current_question['selected'] = selected_answer
187
+ current_question['answered'] = True
188
+ st.session_state.module_question_count[selected_module] += 1
189
+
190
+ if selected_answer == current_question['correct_answer']:
191
+ st.session_state.correct_count += 1
192
+ st.session_state.module_correct_count[selected_module] += 1
193
+
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):
 
215
  st.write("**Step-by-Step Solution:**")
216
  for step in current_question['step_by_step_solution']:
217
  st.write(step)