Sina Media Lab commited on
Commit
46a3abd
·
1 Parent(s): 2a66585
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -145,27 +145,6 @@ current_question = st.session_state.questions[st.session_state.current_index]
145
  st.title(modules[selected_module]["title"])
146
  st.write(modules[selected_module]["description"])
147
 
148
- # Navigation and PDF report buttons
149
- col1, col2, col3 = st.columns([1, 1, 2])
150
- with col1:
151
- if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
152
- navigate_question("prev")
153
- with col2:
154
- if st.button("➡️ Next", disabled=st.session_state.current_index >= len(st.session_state.answered_questions) - 1):
155
- navigate_question("next")
156
- with col3:
157
- if len(st.session_state.answered_questions) > 0:
158
- pdf = generate_pdf_report()
159
- st.session_state.pdf_data = pdf # Reset PDF cache
160
- st.download_button(
161
- label="Download PDF Report 📄",
162
- data=st.session_state.pdf_data,
163
- file_name="quiz_report.pdf",
164
- mime="application/pdf"
165
- )
166
-
167
- st.write(current_question["question"])
168
-
169
  # Disable options and submit if the question is answered
170
  option_disabled = current_question['answered']
171
 
@@ -185,9 +164,30 @@ action = st.radio(
185
  index=None, # Do not pre-select any action
186
  key="action_radio",
187
  horizontal=True,
188
- disabled=option_disabled and action != "New" # Disable submit when the question is already answered, but not "New"
189
  )
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  # Go! button to execute the selected action
192
  if st.button("Go!"):
193
  if action == "Submit":
 
145
  st.title(modules[selected_module]["title"])
146
  st.write(modules[selected_module]["description"])
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  # Disable options and submit if the question is answered
149
  option_disabled = current_question['answered']
150
 
 
164
  index=None, # Do not pre-select any action
165
  key="action_radio",
166
  horizontal=True,
167
+ disabled=option_disabled and (st.session_state.action != "New") # Disable submit when the question is already answered, but not "New"
168
  )
169
 
170
+ # Navigation and PDF report buttons
171
+ col1, col2, col3 = st.columns([1, 1, 2])
172
+ with col1:
173
+ if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
174
+ navigate_question("prev")
175
+ with col2:
176
+ if st.button("➡️ Next", disabled=st.session_state.current_index >= len(st.session_state.answered_questions) - 1):
177
+ navigate_question("next")
178
+ with col3:
179
+ if len(st.session_state.answered_questions) > 0:
180
+ pdf = generate_pdf_report()
181
+ st.session_state.pdf_data = pdf # Reset PDF cache
182
+ st.download_button(
183
+ label="Download PDF Report 📄",
184
+ data=st.session_state.pdf_data,
185
+ file_name="quiz_report.pdf",
186
+ mime="application/pdf"
187
+ )
188
+
189
+ st.write(current_question["question"])
190
+
191
  # Go! button to execute the selected action
192
  if st.button("Go!"):
193
  if action == "Submit":