Sina Media Lab
commited on
Commit
Β·
1596a24
1
Parent(s):
8aa4295
Updates
Browse files
app.py
CHANGED
@@ -163,26 +163,29 @@ if selected_category:
|
|
163 |
selected_module_data = module_data
|
164 |
break
|
165 |
|
166 |
-
#
|
167 |
-
st.
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
186 |
|
187 |
if selected_module != st.session_state.current_module:
|
188 |
st.session_state.current_module = selected_module
|
@@ -258,6 +261,9 @@ if submit_button:
|
|
258 |
# Generate the PDF report data after each submission
|
259 |
st.session_state.pdf_data = generate_pdf_report()
|
260 |
|
|
|
|
|
|
|
261 |
# Refresh the PDF button state
|
262 |
st.download_button(
|
263 |
label="π Download PDF Report",
|
|
|
163 |
selected_module_data = module_data
|
164 |
break
|
165 |
|
166 |
+
# Create a horizontal layout with the category title and the PDF download button
|
167 |
+
col1, col2 = st.columns([3, 1])
|
168 |
+
with col1:
|
169 |
+
st.markdown(
|
170 |
+
f"""
|
171 |
+
<div style="background-color: #333; padding: 10px; border-radius: 5px; margin-top: 20px;">
|
172 |
+
<span style='font-size: 18px; color: white;'>{selected_category} > {selected_module_data['title']}</span>
|
173 |
+
</div>
|
174 |
+
""",
|
175 |
+
unsafe_allow_html=True
|
176 |
+
)
|
177 |
|
178 |
+
with col2:
|
179 |
+
# Show PDF report button, initially disabled until a question is answered
|
180 |
+
pdf_disabled = len(st.session_state.questions) == 0
|
181 |
+
st.download_button(
|
182 |
+
label="π Download PDF Report",
|
183 |
+
data=st.session_state.pdf_data if not pdf_disabled else b'',
|
184 |
+
file_name="quiz_report.pdf",
|
185 |
+
mime="application/pdf",
|
186 |
+
disabled=pdf_disabled,
|
187 |
+
key="pdf_download_button"
|
188 |
+
)
|
189 |
|
190 |
if selected_module != st.session_state.current_module:
|
191 |
st.session_state.current_module = selected_module
|
|
|
261 |
# Generate the PDF report data after each submission
|
262 |
st.session_state.pdf_data = generate_pdf_report()
|
263 |
|
264 |
+
# Generate a new question for the next round
|
265 |
+
st.session_state.current_question = generate_new_question(selected_category, selected_module, selected_module_data)
|
266 |
+
|
267 |
# Refresh the PDF button state
|
268 |
st.download_button(
|
269 |
label="π Download PDF Report",
|