Sina Media Lab
commited on
Commit
Β·
5eeb228
1
Parent(s):
3c35d02
Updates
Browse files
app.py
CHANGED
@@ -234,14 +234,20 @@ if submit_button:
|
|
234 |
current_question['time_taken'] = int(time.time() - st.session_state.start_time)
|
235 |
|
236 |
# Process the answer
|
237 |
-
selected_answer_text = selected_answer.split(". ", 1)[1] # Extract the text part
|
238 |
current_question['selected'] = selected_answer_text
|
239 |
current_question['answered'] = True
|
240 |
st.session_state.module_question_count[selected_module] += 1
|
241 |
|
|
|
242 |
if selected_answer_text == current_question['correct_answer']:
|
243 |
st.session_state.correct_count += 1
|
244 |
st.session_state.module_correct_count[selected_module] += 1
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
# Show correct/incorrect feedback, explanation, and step-by-step solution
|
247 |
col1, col2 = st.columns(2)
|
@@ -251,7 +257,7 @@ if submit_button:
|
|
251 |
if option == current_question['correct_answer']:
|
252 |
st.markdown(f"<span style='color:green;'>{option_text} β
</span>", unsafe_allow_html=True)
|
253 |
elif option == selected_answer_text:
|
254 |
-
st.markdown(f"<span style='color:
|
255 |
else:
|
256 |
st.markdown(f"{option_text}", unsafe_allow_html=True)
|
257 |
|
|
|
234 |
current_question['time_taken'] = int(time.time() - st.session_state.start_time)
|
235 |
|
236 |
# Process the answer
|
237 |
+
selected_answer_text = selected_answer.split(". ", 1)[1] # Extract the text part after "a. ", "b. ", etc.
|
238 |
current_question['selected'] = selected_answer_text
|
239 |
current_question['answered'] = True
|
240 |
st.session_state.module_question_count[selected_module] += 1
|
241 |
|
242 |
+
# Check if the answer is correct
|
243 |
if selected_answer_text == current_question['correct_answer']:
|
244 |
st.session_state.correct_count += 1
|
245 |
st.session_state.module_correct_count[selected_module] += 1
|
246 |
+
feedback_text = "Correct! β
"
|
247 |
+
feedback_color = "green"
|
248 |
+
else:
|
249 |
+
feedback_text = "Incorrect β"
|
250 |
+
feedback_color = "red"
|
251 |
|
252 |
# Show correct/incorrect feedback, explanation, and step-by-step solution
|
253 |
col1, col2 = st.columns(2)
|
|
|
257 |
if option == current_question['correct_answer']:
|
258 |
st.markdown(f"<span style='color:green;'>{option_text} β
</span>", unsafe_allow_html=True)
|
259 |
elif option == selected_answer_text:
|
260 |
+
st.markdown(f"<span style='color:{feedback_color};'>{option_text} β</span>", unsafe_allow_html=True)
|
261 |
else:
|
262 |
st.markdown(f"{option_text}", unsafe_allow_html=True)
|
263 |
|