Sina Media Lab
commited on
Commit
·
6962136
1
Parent(s):
d6d844d
Updates
Browse files
app.py
CHANGED
@@ -113,6 +113,9 @@ def navigate_question(direction):
|
|
113 |
new_question = generate_new_question(st.session_state.current_module, modules[st.session_state.current_module])
|
114 |
st.session_state.questions.append(new_question)
|
115 |
st.session_state.current_index = len(st.session_state.questions) - 1
|
|
|
|
|
|
|
116 |
|
117 |
# Load all modules dynamically
|
118 |
modules = load_modules()
|
@@ -151,8 +154,6 @@ with col1:
|
|
151 |
navigate_question("prev")
|
152 |
with col2:
|
153 |
if st.button("➡️ Next", disabled=st.session_state.next_disabled):
|
154 |
-
st.session_state.submit_disabled = True
|
155 |
-
st.session_state.next_disabled = True
|
156 |
navigate_question("next")
|
157 |
with col3:
|
158 |
if len(st.session_state.questions) > 0:
|
@@ -177,25 +178,27 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
|
|
177 |
)
|
178 |
submit_button = st.form_submit_button(label="Submit", disabled=st.session_state.submit_disabled)
|
179 |
|
180 |
-
|
|
|
181 |
st.session_state.submit_disabled = False
|
182 |
-
st.
|
183 |
|
184 |
if submit_button and not current_question.get('answered', False):
|
185 |
-
if
|
186 |
st.warning("Please select an answer before submitting.")
|
187 |
else:
|
188 |
# Process the answer
|
189 |
-
current_question['selected'] =
|
190 |
current_question['answered'] = True
|
191 |
st.session_state.module_question_count[selected_module] += 1
|
192 |
|
193 |
-
if
|
194 |
st.session_state.correct_count += 1
|
195 |
st.session_state.module_correct_count[selected_module] += 1
|
196 |
|
197 |
st.session_state.submit_disabled = True
|
198 |
st.session_state.next_disabled = False
|
|
|
199 |
|
200 |
# Show correct/incorrect feedback after submission
|
201 |
if current_question.get('answered', False):
|
|
|
113 |
new_question = generate_new_question(st.session_state.current_module, modules[st.session_state.current_module])
|
114 |
st.session_state.questions.append(new_question)
|
115 |
st.session_state.current_index = len(st.session_state.questions) - 1
|
116 |
+
st.session_state.submit_disabled = True
|
117 |
+
st.session_state.next_disabled = True
|
118 |
+
st.session_state.selected_answer = None
|
119 |
|
120 |
# Load all modules dynamically
|
121 |
modules = load_modules()
|
|
|
154 |
navigate_question("prev")
|
155 |
with col2:
|
156 |
if st.button("➡️ Next", disabled=st.session_state.next_disabled):
|
|
|
|
|
157 |
navigate_question("next")
|
158 |
with col3:
|
159 |
if len(st.session_state.questions) > 0:
|
|
|
178 |
)
|
179 |
submit_button = st.form_submit_button(label="Submit", disabled=st.session_state.submit_disabled)
|
180 |
|
181 |
+
# Activation logic for buttons based on selection
|
182 |
+
if selected_answer is not None:
|
183 |
st.session_state.submit_disabled = False
|
184 |
+
st.experimental_rerun()
|
185 |
|
186 |
if submit_button and not current_question.get('answered', False):
|
187 |
+
if selected_answer is None:
|
188 |
st.warning("Please select an answer before submitting.")
|
189 |
else:
|
190 |
# Process the answer
|
191 |
+
current_question['selected'] = selected_answer
|
192 |
current_question['answered'] = True
|
193 |
st.session_state.module_question_count[selected_module] += 1
|
194 |
|
195 |
+
if selected_answer == current_question['correct_answer']:
|
196 |
st.session_state.correct_count += 1
|
197 |
st.session_state.module_correct_count[selected_module] += 1
|
198 |
|
199 |
st.session_state.submit_disabled = True
|
200 |
st.session_state.next_disabled = False
|
201 |
+
st.session_state.selected_answer = None
|
202 |
|
203 |
# Show correct/incorrect feedback after submission
|
204 |
if current_question.get('answered', False):
|