Sina Media Lab
commited on
Commit
Β·
e48e9e2
1
Parent(s):
3949aee
Updates
Browse files
app.py
CHANGED
@@ -38,11 +38,12 @@ def generate_pdf_report():
|
|
38 |
pdf.set_font("Arial", style='B', size=12)
|
39 |
|
40 |
# Header for PDF report
|
41 |
-
pdf.set_fill_color(
|
42 |
-
pdf.
|
|
|
43 |
pdf.ln(5)
|
44 |
pdf.set_font("Arial", size=8)
|
45 |
-
pdf.cell(0, 10, txt="
|
46 |
pdf.ln(10)
|
47 |
|
48 |
for i, entry in enumerate(st.session_state.questions):
|
@@ -131,8 +132,8 @@ modules = load_modules()
|
|
131 |
# Streamlit sidebar
|
132 |
st.sidebar.markdown(
|
133 |
"""
|
134 |
-
<div style='background-color:
|
135 |
-
<
|
136 |
<h6 style='margin: 0; font-size: 10px;'><a href="https://ghassem.com" target="_blank" style="color: black; text-decoration: none;'>By Ghassem Tofighi</a></h6>
|
137 |
</div>
|
138 |
""", unsafe_allow_html=True)
|
@@ -148,12 +149,13 @@ if selected_category:
|
|
148 |
selected_module_data = module_data
|
149 |
break
|
150 |
|
151 |
-
# Display PDF report link
|
152 |
-
|
|
|
153 |
pdf = generate_pdf_report()
|
154 |
st.session_state.pdf_data = pdf # Reset PDF cache
|
155 |
st.markdown(
|
156 |
-
f"<a href='#' download='quiz_report.pdf' style='font-size:
|
157 |
unsafe_allow_html=True
|
158 |
)
|
159 |
|
|
|
38 |
pdf.set_font("Arial", style='B', size=12)
|
39 |
|
40 |
# Header for PDF report
|
41 |
+
pdf.set_fill_color(255, 255, 255) # White background
|
42 |
+
pdf.set_text_color(0, 0, 0) # Black text
|
43 |
+
pdf.cell(0, 10, txt="πͺ Magic Math Quiz!", ln=True, align="C", fill=True)
|
44 |
pdf.ln(5)
|
45 |
pdf.set_font("Arial", size=8)
|
46 |
+
pdf.cell(0, 10, txt="By Ghassem Tofighi", ln=True, align="C", link="https://ghassem.com")
|
47 |
pdf.ln(10)
|
48 |
|
49 |
for i, entry in enumerate(st.session_state.questions):
|
|
|
132 |
# Streamlit sidebar
|
133 |
st.sidebar.markdown(
|
134 |
"""
|
135 |
+
<div style='background-color: white; padding: 10px; border-radius: 10px; text-align: center; color: black;'>
|
136 |
+
<h1 style='margin: 0;'>πͺ Magic Math Quiz!</h1>
|
137 |
<h6 style='margin: 0; font-size: 10px;'><a href="https://ghassem.com" target="_blank" style="color: black; text-decoration: none;'>By Ghassem Tofighi</a></h6>
|
138 |
</div>
|
139 |
""", unsafe_allow_html=True)
|
|
|
149 |
selected_module_data = module_data
|
150 |
break
|
151 |
|
152 |
+
# Display PDF report link as an icon in front of module title
|
153 |
+
pdf_button_disabled = not any(q['answered'] for q in st.session_state.questions)
|
154 |
+
if not pdf_button_disabled:
|
155 |
pdf = generate_pdf_report()
|
156 |
st.session_state.pdf_data = pdf # Reset PDF cache
|
157 |
st.markdown(
|
158 |
+
f"<a href='#' download='quiz_report.pdf' style='font-size: 18px;' onclick='document.getElementById(\"pdf-link\").click();'>π</a>",
|
159 |
unsafe_allow_html=True
|
160 |
)
|
161 |
|