Sina Media Lab
commited on
Commit
·
700a11e
1
Parent(s):
15d45d1
Updates
Browse files
app.py
CHANGED
@@ -32,10 +32,10 @@ def reset_pdf_cache():
|
|
32 |
def generate_pdf_report():
|
33 |
pdf = FPDF()
|
34 |
pdf.add_page()
|
35 |
-
pdf.set_font("Arial", size=
|
36 |
|
37 |
-
pdf.cell(200,
|
38 |
-
pdf.ln(
|
39 |
|
40 |
for i, entry in enumerate(st.session_state.questions):
|
41 |
# Zebra background
|
@@ -45,15 +45,15 @@ def generate_pdf_report():
|
|
45 |
pdf.set_fill_color(255, 255, 255) # White
|
46 |
|
47 |
# Module Title
|
48 |
-
pdf.set_font("Arial", style='B', size=
|
49 |
-
pdf.multi_cell(0,
|
50 |
|
51 |
# Question
|
52 |
-
pdf.set_font("Arial", style='B', size=
|
53 |
-
pdf.multi_cell(0,
|
54 |
|
55 |
# Options
|
56 |
-
pdf.set_font("Arial", size=
|
57 |
options = ['a', 'b', 'c', 'd']
|
58 |
for j, option in enumerate(entry['options']):
|
59 |
if option == entry['correct_answer']:
|
@@ -63,12 +63,12 @@ def generate_pdf_report():
|
|
63 |
else:
|
64 |
pdf.set_text_color(0, 0, 0) # Default color for others
|
65 |
|
66 |
-
pdf.multi_cell(0,
|
67 |
|
68 |
pdf.set_text_color(0, 0, 0) # Reset color
|
69 |
-
pdf.multi_cell(0,
|
70 |
-
pdf.multi_cell(0,
|
71 |
-
pdf.ln(
|
72 |
|
73 |
return pdf.output(dest='S').encode('latin1', 'replace')
|
74 |
|
@@ -129,9 +129,9 @@ if selected_module != st.session_state.current_module:
|
|
129 |
# Load the current module's question
|
130 |
current_question = st.session_state.questions[st.session_state.current_index]
|
131 |
|
132 |
-
# Display module title and description with smaller font
|
133 |
-
st.markdown(f"
|
134 |
-
st.markdown(f"<span style='font-size:
|
135 |
|
136 |
# Navigation and PDF report buttons
|
137 |
col1, col2, col3 = st.columns([1, 1, 2])
|
@@ -153,7 +153,7 @@ with col3:
|
|
153 |
)
|
154 |
|
155 |
# Display the current question with larger font
|
156 |
-
st.markdown(f"<span style='font-size:
|
157 |
|
158 |
# Create the form for the question
|
159 |
with st.form(key=f'question_form_{st.session_state.current_index}'):
|
@@ -184,7 +184,10 @@ if submit_button:
|
|
184 |
st.session_state.module_correct_count[selected_module] += 1
|
185 |
|
186 |
# Show correct/incorrect feedback, explanation, and step-by-step solution
|
187 |
-
st.markdown(
|
|
|
|
|
|
|
188 |
for i, option in enumerate(current_question['options']):
|
189 |
option_text = f"{options[i]}. {option}"
|
190 |
if option == current_question['correct_answer']:
|
|
|
32 |
def generate_pdf_report():
|
33 |
pdf = FPDF()
|
34 |
pdf.add_page()
|
35 |
+
pdf.set_font("Arial", size=10)
|
36 |
|
37 |
+
pdf.cell(200, 10, txt="Quiz Report", ln=True, align="C")
|
38 |
+
pdf.ln(10)
|
39 |
|
40 |
for i, entry in enumerate(st.session_state.questions):
|
41 |
# Zebra background
|
|
|
45 |
pdf.set_fill_color(255, 255, 255) # White
|
46 |
|
47 |
# Module Title
|
48 |
+
pdf.set_font("Arial", style='B', size=10)
|
49 |
+
pdf.multi_cell(0, 10, f"Module: {entry['module']}", border=1, fill=True)
|
50 |
|
51 |
# Question
|
52 |
+
pdf.set_font("Arial", style='B', size=10)
|
53 |
+
pdf.multi_cell(0, 10, f"Q{i+1}: {entry['question']}", border=1, fill=True)
|
54 |
|
55 |
# Options
|
56 |
+
pdf.set_font("Arial", size=10)
|
57 |
options = ['a', 'b', 'c', 'd']
|
58 |
for j, option in enumerate(entry['options']):
|
59 |
if option == entry['correct_answer']:
|
|
|
63 |
else:
|
64 |
pdf.set_text_color(0, 0, 0) # Default color for others
|
65 |
|
66 |
+
pdf.multi_cell(0, 10, f"{options[j]}. {option}", border=1, fill=True)
|
67 |
|
68 |
pdf.set_text_color(0, 0, 0) # Reset color
|
69 |
+
pdf.multi_cell(0, 10, f"Explanation: {entry['explanation']}", border=1, fill=True)
|
70 |
+
pdf.multi_cell(0, 10, f"Step-by-Step Solution: {', '.join(entry['step_by_step_solution'])}", border=1, fill=True)
|
71 |
+
pdf.ln(10)
|
72 |
|
73 |
return pdf.output(dest='S').encode('latin1', 'replace')
|
74 |
|
|
|
129 |
# Load the current module's question
|
130 |
current_question = st.session_state.questions[st.session_state.current_index]
|
131 |
|
132 |
+
# Display module title and description with smaller header and font
|
133 |
+
st.markdown(f"### {modules[selected_module]['title']}")
|
134 |
+
st.markdown(f"<span style='font-size: 12px;'>{modules[selected_module]['description']}</span>", unsafe_allow_html=True)
|
135 |
|
136 |
# Navigation and PDF report buttons
|
137 |
col1, col2, col3 = st.columns([1, 1, 2])
|
|
|
153 |
)
|
154 |
|
155 |
# Display the current question with larger font
|
156 |
+
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)
|
157 |
|
158 |
# Create the form for the question
|
159 |
with st.form(key=f'question_form_{st.session_state.current_index}'):
|
|
|
184 |
st.session_state.module_correct_count[selected_module] += 1
|
185 |
|
186 |
# Show correct/incorrect feedback, explanation, and step-by-step solution
|
187 |
+
st.markdown(
|
188 |
+
"""
|
189 |
+
<div style='background-color:#f0f0f0; padding: 10px; border-radius: 10px;'>
|
190 |
+
""", unsafe_allow_html=True)
|
191 |
for i, option in enumerate(current_question['options']):
|
192 |
option_text = f"{options[i]}. {option}"
|
193 |
if option == current_question['correct_answer']:
|