Sina Media Lab commited on
Commit
6a35d67
·
1 Parent(s): c11ab58
Files changed (1) hide show
  1. app.py +39 -42
app.py CHANGED
@@ -169,46 +169,43 @@ selected_answer = st.radio(
169
  index=None # Ensure no option is pre-selected
170
  )
171
 
172
- # Set the action based on the user's selection
173
- action_col1, action_col2, go_col = st.columns([1, 1, 1])
174
- with action_col1:
175
- if st.button("Submit"):
176
- st.session_state.action = "Submit"
177
- with action_col2:
178
- if st.button("New"):
179
- st.session_state.action = "New"
180
- with go_col:
181
- if st.button("Go!"):
182
- if st.session_state.action == "Submit":
183
- if selected_answer is None:
184
- st.warning("Please select an option before submitting.", icon="⚠️")
185
- else:
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
- # Display correct/incorrect feedback
196
- for option in current_question['options']:
197
- if option == current_question['correct_answer']:
198
- st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
199
- elif option == current_question['selected']:
200
- st.markdown(f"<span style='color:red;'>{option} ❌</span>", unsafe_allow_html=True)
201
- else:
202
- st.markdown(f"{option}")
203
-
204
- st.write(f"**Explanation:** {current_question['explanation']}")
205
- st.write("**Step-by-Step Solution:**")
206
- for step in current_question['step_by_step_solution']:
207
- st.write(step)
208
-
209
- # Reset action after submission
210
- st.session_state.action = None
211
 
212
- elif st.session_state.action == "New":
213
- navigate_question("new")
214
- st.session_state.action = None # Reset action after generating a new question
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  index=None # Ensure no option is pre-selected
170
  )
171
 
172
+ # Radio buttons for selecting the action
173
+ action = st.radio(
174
+ "Choose an action:",
175
+ ("Submit", "New"),
176
+ index=None, # Do not pre-select any action
177
+ key="action_radio",
178
+ horizontal=True
179
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
+ # Go! button to execute the selected action
182
+ if st.button("Go!"):
183
+ if action == "Submit":
184
+ if selected_answer is None:
185
+ st.warning("Please select an option before submitting.", icon="⚠️")
186
+ else:
187
+ # Process the answer
188
+ current_question['selected'] = selected_answer
189
+ current_question['answered'] = True
190
+ st.session_state.module_question_count[selected_module] += 1
191
+
192
+ if selected_answer == current_question['correct_answer']:
193
+ st.session_state.correct_count += 1
194
+ st.session_state.module_correct_count[selected_module] += 1
195
+
196
+ # Display correct/incorrect feedback
197
+ for option in current_question['options']:
198
+ if option == current_question['correct_answer']:
199
+ st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
200
+ elif option == current_question['selected']:
201
+ st.markdown(f"<span style='color:red;'>{option} ❌</span>", unsafe_allow_html=True)
202
+ else:
203
+ st.markdown(f"{option}")
204
+
205
+ st.write(f"**Explanation:** {current_question['explanation']}")
206
+ st.write("**Step-by-Step Solution:**")
207
+ for step in current_question['step_by_step_solution']:
208
+ st.write(step)
209
+
210
+ elif action == "New":
211
+ navigate_question("new")