Sina Media Lab
commited on
Commit
·
72b1ec2
1
Parent(s):
516f536
Updates
Browse files
app.py
CHANGED
@@ -166,10 +166,10 @@ with col3:
|
|
166 |
mime="application/pdf"
|
167 |
)
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
# Show Submit/Next button or Next button depending on the state
|
172 |
if not st.session_state.show_next_button:
|
|
|
|
|
173 |
# Create the form for the question
|
174 |
with st.form(key=f'question_form_{st.session_state.current_index}'):
|
175 |
selected_answer = st.radio(
|
@@ -189,7 +189,7 @@ if not st.session_state.show_next_button:
|
|
189 |
st.session_state.submit_click_count += 1
|
190 |
|
191 |
if st.session_state.submit_click_count == 1:
|
192 |
-
# First click: show solution and
|
193 |
if not current_question['answered']:
|
194 |
if selected_answer is not None:
|
195 |
# Process the answer
|
@@ -227,10 +227,12 @@ if not st.session_state.show_next_button:
|
|
227 |
|
228 |
st.markdown("</ol></div>", unsafe_allow_html=True)
|
229 |
|
230 |
-
# Replace Submit/Next with Next
|
231 |
st.session_state.show_next_button = True
|
232 |
-
|
233 |
-
|
|
|
|
|
234 |
if st.button("Next"):
|
235 |
# Generate a new question
|
236 |
new_question = generate_new_question(selected_module, modules[selected_module])
|
@@ -240,5 +242,4 @@ else:
|
|
240 |
st.session_state.submit_click_count = 0 # Reset the click count
|
241 |
st.session_state.selected_answer = None # Reset the selected answer
|
242 |
st.session_state.show_next_button = False # Hide the Next button
|
243 |
-
|
244 |
-
st.session_state['last_updated'] = str(uuid.uuid4())
|
|
|
166 |
mime="application/pdf"
|
167 |
)
|
168 |
|
169 |
+
# Show the question only if the "Next" button hasn't been clicked yet
|
|
|
|
|
170 |
if not st.session_state.show_next_button:
|
171 |
+
st.write(current_question["question"])
|
172 |
+
|
173 |
# Create the form for the question
|
174 |
with st.form(key=f'question_form_{st.session_state.current_index}'):
|
175 |
selected_answer = st.radio(
|
|
|
189 |
st.session_state.submit_click_count += 1
|
190 |
|
191 |
if st.session_state.submit_click_count == 1:
|
192 |
+
# First click: show solution and remove question
|
193 |
if not current_question['answered']:
|
194 |
if selected_answer is not None:
|
195 |
# Process the answer
|
|
|
227 |
|
228 |
st.markdown("</ol></div>", unsafe_allow_html=True)
|
229 |
|
230 |
+
# Replace question and Submit/Next with Next button
|
231 |
st.session_state.show_next_button = True
|
232 |
+
st.experimental_rerun()
|
233 |
+
|
234 |
+
# Show the Next button to generate a new question
|
235 |
+
if st.session_state.show_next_button:
|
236 |
if st.button("Next"):
|
237 |
# Generate a new question
|
238 |
new_question = generate_new_question(selected_module, modules[selected_module])
|
|
|
242 |
st.session_state.submit_click_count = 0 # Reset the click count
|
243 |
st.session_state.selected_answer = None # Reset the selected answer
|
244 |
st.session_state.show_next_button = False # Hide the Next button
|
245 |
+
st.experimental_rerun()
|
|