Sina Media Lab
commited on
Commit
Β·
2f63335
1
Parent(s):
e48e9e2
Updates
Browse files
app.py
CHANGED
@@ -37,10 +37,10 @@ def generate_pdf_report():
|
|
37 |
pdf.add_page()
|
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="
|
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")
|
@@ -76,14 +76,14 @@ def generate_pdf_report():
|
|
76 |
else:
|
77 |
pdf.set_text_color(0, 0, 0) # Default color for others
|
78 |
|
79 |
-
pdf.multi_cell(0,
|
80 |
|
81 |
pdf.set_text_color(0, 0, 0) # Reset color
|
82 |
-
pdf.multi_cell(0,
|
83 |
-
pdf.multi_cell(0,
|
84 |
-
pdf.ln(
|
85 |
|
86 |
-
return pdf.output(dest='S').encode('
|
87 |
|
88 |
def load_modules():
|
89 |
modules = {}
|
@@ -133,7 +133,7 @@ modules = load_modules()
|
|
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;'
|
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,15 +149,16 @@ if selected_category:
|
|
149 |
selected_module_data = module_data
|
150 |
break
|
151 |
|
152 |
-
# Display PDF report link
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
|
|
161 |
|
162 |
if selected_module != st.session_state.current_module:
|
163 |
st.session_state.current_module = selected_module
|
@@ -175,14 +176,6 @@ if selected_category:
|
|
175 |
|
176 |
current_question = st.session_state.current_question
|
177 |
|
178 |
-
# Display Category Title > Module Title with dark background and white font
|
179 |
-
st.markdown(
|
180 |
-
f"""
|
181 |
-
<div style='background-color: #333; padding: 10px; border-radius: 5px; color: white;'>
|
182 |
-
{selected_category} > {selected_module_data['title']}
|
183 |
-
</div>
|
184 |
-
""", unsafe_allow_html=True)
|
185 |
-
|
186 |
# Display the current question with larger font
|
187 |
st.markdown(f"<span style='font-size: 18px;'><b>Q{st.session_state.current_index + 1}: {current_question['question']}</b></span>", unsafe_allow_html=True)
|
188 |
|
|
|
37 |
pdf.add_page()
|
38 |
pdf.set_font("Arial", style='B', size=12)
|
39 |
|
40 |
+
# Header for PDF report (without emoji)
|
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")
|
|
|
76 |
else:
|
77 |
pdf.set_text_color(0, 0, 0) # Default color for others
|
78 |
|
79 |
+
pdf.multi_cell(0, 5, f"{options[j]}. {option}", border=1, fill=True) # Reduced vertical spacing
|
80 |
|
81 |
pdf.set_text_color(0, 0, 0) # Reset color
|
82 |
+
pdf.multi_cell(0, 5, f"Explanation: {entry['explanation']}", border=1, fill=True) # Reduced vertical spacing
|
83 |
+
pdf.multi_cell(0, 5, f"Step-by-Step Solution: {', '.join(entry['step_by_step_solution'])}", border=1, fill=True) # Reduced vertical spacing
|
84 |
+
pdf.ln(5)
|
85 |
|
86 |
+
return pdf.output(dest='S').encode('latin-1', 'replace')
|
87 |
|
88 |
def load_modules():
|
89 |
modules = {}
|
|
|
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 icon link in front of module title, always visible
|
153 |
+
st.markdown(
|
154 |
+
f"""
|
155 |
+
<div style="margin-top: 10px;">
|
156 |
+
<span style='font-size: 18px; color: #333;'>{selected_category} > {selected_module_data['title']}</span>
|
157 |
+
<a href='#' download='quiz_report.pdf' style='font-size: 18px; margin-left: 10px;' onclick='document.getElementById("pdf-link").click();'>π</a>
|
158 |
+
</div>
|
159 |
+
""",
|
160 |
+
unsafe_allow_html=True
|
161 |
+
)
|
162 |
|
163 |
if selected_module != st.session_state.current_module:
|
164 |
st.session_state.current_module = selected_module
|
|
|
176 |
|
177 |
current_question = st.session_state.current_question
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
# Display the current question with larger font
|
180 |
st.markdown(f"<span style='font-size: 18px;'><b>Q{st.session_state.current_index + 1}: {current_question['question']}</b></span>", unsafe_allow_html=True)
|
181 |
|