Sina Media Lab
commited on
Commit
·
3b206b5
1
Parent(s):
acc5dec
Updates
Browse files
app.py
CHANGED
@@ -162,19 +162,18 @@ with col3:
|
|
162 |
st.write(current_question["question"])
|
163 |
|
164 |
# Create the form for the question
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
new_button = st.form_submit_button(label="New", disabled=not st.session_state.new_enabled)
|
178 |
|
179 |
# Handle button state and answer submission
|
180 |
if submit_button:
|
@@ -188,26 +187,26 @@ if submit_button:
|
|
188 |
st.session_state.correct_count += 1
|
189 |
st.session_state.module_correct_count[selected_module] += 1
|
190 |
|
|
|
191 |
st.session_state.submit_enabled = False
|
192 |
st.session_state.new_enabled = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
else:
|
194 |
st.warning("Please select an option before submitting.", icon="⚠️")
|
195 |
-
st.stop()
|
196 |
-
|
197 |
-
# Show correct/incorrect feedback after submission
|
198 |
-
if current_question.get('answered', False):
|
199 |
-
for option in current_question['options']:
|
200 |
-
if option == current_question['correct_answer']:
|
201 |
-
st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
|
202 |
-
elif option == current_question['selected']:
|
203 |
-
st.markdown(f"<span style='color:red;'>{option} ❌</span>", unsafe_allow_html=True)
|
204 |
-
else:
|
205 |
-
st.markdown(f"{option}")
|
206 |
-
|
207 |
-
st.write(f"**Explanation:** {current_question['explanation']}")
|
208 |
-
st.write("**Step-by-Step Solution:**")
|
209 |
-
for step in current_question['step_by_step_solution']:
|
210 |
-
st.write(step)
|
211 |
|
212 |
# Handle new question generation
|
213 |
if new_button:
|
@@ -216,3 +215,4 @@ if new_button:
|
|
216 |
st.session_state.current_index = len(st.session_state.questions) - 1
|
217 |
st.session_state.submit_enabled = True
|
218 |
st.session_state.new_enabled = False
|
|
|
|
162 |
st.write(current_question["question"])
|
163 |
|
164 |
# Create the form for the question
|
165 |
+
selected_answer = st.radio(
|
166 |
+
"Choose an answer:",
|
167 |
+
options=current_question['options'],
|
168 |
+
key=f"question_{st.session_state.current_index}_options",
|
169 |
+
index=None # Ensure no option is pre-selected
|
170 |
+
)
|
171 |
+
|
172 |
+
col1, col2 = st.columns(2)
|
173 |
+
with col1:
|
174 |
+
submit_button = st.button(label="Submit", disabled=not st.session_state.submit_enabled)
|
175 |
+
with col2:
|
176 |
+
new_button = st.button(label="New", disabled=not st.session_state.new_enabled)
|
|
|
177 |
|
178 |
# Handle button state and answer submission
|
179 |
if submit_button:
|
|
|
187 |
st.session_state.correct_count += 1
|
188 |
st.session_state.module_correct_count[selected_module] += 1
|
189 |
|
190 |
+
# Show the feedback immediately
|
191 |
st.session_state.submit_enabled = False
|
192 |
st.session_state.new_enabled = True
|
193 |
+
|
194 |
+
# Display correct/incorrect feedback
|
195 |
+
for option in current_question['options']:
|
196 |
+
if option == current_question['correct_answer']:
|
197 |
+
st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
|
198 |
+
elif option == current_question['selected']:
|
199 |
+
st.markdown(f"<span style='color:red;'>{option} ❌</span>", unsafe_allow_html=True)
|
200 |
+
else:
|
201 |
+
st.markdown(f"{option}")
|
202 |
+
|
203 |
+
st.write(f"**Explanation:** {current_question['explanation']}")
|
204 |
+
st.write("**Step-by-Step Solution:**")
|
205 |
+
for step in current_question['step_by_step_solution']:
|
206 |
+
st.write(step)
|
207 |
+
|
208 |
else:
|
209 |
st.warning("Please select an option before submitting.", icon="⚠️")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
# Handle new question generation
|
212 |
if new_button:
|
|
|
215 |
st.session_state.current_index = len(st.session_state.questions) - 1
|
216 |
st.session_state.submit_enabled = True
|
217 |
st.session_state.new_enabled = False
|
218 |
+
st.experimental_rerun()
|