Sina Media Lab
commited on
Commit
·
b2ea00a
1
Parent(s):
8a51ec9
Updates
Browse files
app.py
CHANGED
@@ -172,38 +172,29 @@ with col3:
|
|
172 |
|
173 |
st.write(current_question["question"])
|
174 |
|
175 |
-
#
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
st.session_state.correct_count += 1
|
199 |
-
st.session_state.module_correct_count[selected_module] += 1
|
200 |
-
|
201 |
-
# Set answered to true to disable options
|
202 |
-
st.session_state.questions[st.session_state.current_index]['answered'] = True
|
203 |
-
st.session_state.selected_answer = selected_answer
|
204 |
-
|
205 |
-
# Show correct/incorrect feedback after submission
|
206 |
-
if current_question.get('answered', False):
|
207 |
for option in current_question['options']:
|
208 |
if option == current_question['correct_answer']:
|
209 |
st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
|
|
|
172 |
|
173 |
st.write(current_question["question"])
|
174 |
|
175 |
+
# Handle the selection of an option and check the answer immediately
|
176 |
+
selected_answer = st.radio(
|
177 |
+
"Choose an answer:",
|
178 |
+
options=current_question['options'],
|
179 |
+
index=current_question['options'].index(current_question['selected']) if current_question['answered'] else None,
|
180 |
+
key=f"question_{st.session_state.current_index}_options"
|
181 |
+
)
|
182 |
+
|
183 |
+
if selected_answer is not None and not current_question['answered']:
|
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 |
+
# Set answered to true to disable options
|
194 |
+
st.session_state.questions[st.session_state.current_index]['answered'] = True
|
195 |
+
st.session_state.selected_answer = selected_answer
|
196 |
+
|
197 |
+
# Show correct/incorrect feedback immediately
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
for option in current_question['options']:
|
199 |
if option == current_question['correct_answer']:
|
200 |
st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
|