Sina Media Lab
commited on
Commit
·
6a35d67
1
Parent(s):
c11ab58
Updates
Browse files
app.py
CHANGED
@@ -169,46 +169,43 @@ selected_answer = st.radio(
|
|
169 |
index=None # Ensure no option is pre-selected
|
170 |
)
|
171 |
|
172 |
-
#
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
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 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|