Sina Media Lab
commited on
Commit
·
10939a2
1
Parent(s):
413c8fc
Updates
Browse files
app.py
CHANGED
@@ -167,9 +167,9 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
|
|
167 |
selected_answer = st.radio(
|
168 |
"Choose an answer:",
|
169 |
options=current_question['options'],
|
170 |
-
key=f"question_{st.session_state.current_index}_options",
|
171 |
index=current_question['options'].index(current_question['selected']) if current_question['answered'] else None,
|
172 |
-
disabled=current_question['answered'] # Disable if the question has been answered
|
|
|
173 |
)
|
174 |
|
175 |
submit_button = st.form_submit_button(label="Submit/Next")
|
@@ -187,9 +187,9 @@ if submit_button:
|
|
187 |
st.session_state.correct_count += 1
|
188 |
st.session_state.module_correct_count[selected_module] += 1
|
189 |
|
190 |
-
#
|
191 |
-
st.session_state.answered = True
|
192 |
-
st.
|
193 |
|
194 |
else:
|
195 |
# If already answered, move to the next question
|
@@ -197,7 +197,6 @@ if submit_button:
|
|
197 |
st.session_state.questions.append(new_question)
|
198 |
st.session_state.current_index = len(st.session_state.questions) - 1
|
199 |
st.session_state.answered = False
|
200 |
-
st.experimental_rerun() # Rerun to update the interface
|
201 |
|
202 |
# Show correct/incorrect feedback after submission
|
203 |
if current_question.get('answered', False):
|
|
|
167 |
selected_answer = st.radio(
|
168 |
"Choose an answer:",
|
169 |
options=current_question['options'],
|
|
|
170 |
index=current_question['options'].index(current_question['selected']) if current_question['answered'] else None,
|
171 |
+
disabled=current_question['answered'], # Disable if the question has been answered
|
172 |
+
key=f"question_{st.session_state.current_index}_options"
|
173 |
)
|
174 |
|
175 |
submit_button = st.form_submit_button(label="Submit/Next")
|
|
|
187 |
st.session_state.correct_count += 1
|
188 |
st.session_state.module_correct_count[selected_module] += 1
|
189 |
|
190 |
+
# Set answered to true to disable options
|
191 |
+
st.session_state.questions[st.session_state.current_index]['answered'] = True
|
192 |
+
st.session_state.selected_answer = selected_answer
|
193 |
|
194 |
else:
|
195 |
# If already answered, move to the next question
|
|
|
197 |
st.session_state.questions.append(new_question)
|
198 |
st.session_state.current_index = len(st.session_state.questions) - 1
|
199 |
st.session_state.answered = False
|
|
|
200 |
|
201 |
# Show correct/incorrect feedback after submission
|
202 |
if current_question.get('answered', False):
|