Sina Media Lab
commited on
Commit
·
d6d844d
1
Parent(s):
58956eb
Updates
Browse files
app.py
CHANGED
@@ -25,6 +25,8 @@ if 'submit_disabled' not in st.session_state:
|
|
25 |
st.session_state.submit_disabled = True
|
26 |
if 'next_disabled' not in st.session_state:
|
27 |
st.session_state.next_disabled = True
|
|
|
|
|
28 |
|
29 |
def reset_pdf_cache():
|
30 |
st.session_state.pdf_data = None
|
@@ -133,6 +135,7 @@ if selected_module != st.session_state.current_module:
|
|
133 |
st.session_state.module_correct_count[selected_module] = 0
|
134 |
st.session_state.submit_disabled = True
|
135 |
st.session_state.next_disabled = True
|
|
|
136 |
|
137 |
# Load the current module's question
|
138 |
current_question = st.session_state.questions[st.session_state.current_index]
|
@@ -174,19 +177,20 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
|
|
174 |
)
|
175 |
submit_button = st.form_submit_button(label="Submit", disabled=st.session_state.submit_disabled)
|
176 |
|
177 |
-
if selected_answer
|
178 |
st.session_state.submit_disabled = False
|
|
|
179 |
|
180 |
if submit_button and not current_question.get('answered', False):
|
181 |
-
if selected_answer is None:
|
182 |
st.warning("Please select an answer before submitting.")
|
183 |
else:
|
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 |
|
|
|
25 |
st.session_state.submit_disabled = True
|
26 |
if 'next_disabled' not in st.session_state:
|
27 |
st.session_state.next_disabled = True
|
28 |
+
if 'selected_answer' not in st.session_state:
|
29 |
+
st.session_state.selected_answer = None
|
30 |
|
31 |
def reset_pdf_cache():
|
32 |
st.session_state.pdf_data = None
|
|
|
135 |
st.session_state.module_correct_count[selected_module] = 0
|
136 |
st.session_state.submit_disabled = True
|
137 |
st.session_state.next_disabled = True
|
138 |
+
st.session_state.selected_answer = None
|
139 |
|
140 |
# Load the current module's question
|
141 |
current_question = st.session_state.questions[st.session_state.current_index]
|
|
|
177 |
)
|
178 |
submit_button = st.form_submit_button(label="Submit", disabled=st.session_state.submit_disabled)
|
179 |
|
180 |
+
if selected_answer:
|
181 |
st.session_state.submit_disabled = False
|
182 |
+
st.session_state.selected_answer = selected_answer
|
183 |
|
184 |
if submit_button and not current_question.get('answered', False):
|
185 |
+
if st.session_state.selected_answer is None:
|
186 |
st.warning("Please select an answer before submitting.")
|
187 |
else:
|
188 |
# Process the answer
|
189 |
+
current_question['selected'] = st.session_state.selected_answer
|
190 |
current_question['answered'] = True
|
191 |
st.session_state.module_question_count[selected_module] += 1
|
192 |
|
193 |
+
if st.session_state.selected_answer == current_question['correct_answer']:
|
194 |
st.session_state.correct_count += 1
|
195 |
st.session_state.module_correct_count[selected_module] += 1
|
196 |
|