Sina Media Lab commited on
Commit
bbd4c6d
Β·
1 Parent(s): 320fd5e
Files changed (1) hide show
  1. app.py +25 -23
app.py CHANGED
@@ -37,7 +37,7 @@ def generate_pdf_report():
37
  pdf.add_page()
38
  pdf.set_font("Arial", size=10)
39
 
40
- pdf.cell(200, 10, txt="Quiz Report", ln=True, align="C")
41
  pdf.ln(10)
42
 
43
  for i, entry in enumerate(st.session_state.questions):
@@ -136,29 +136,34 @@ if selected_module != st.session_state.current_module:
136
 
137
  current_question = st.session_state.current_question
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  # Display module title and description with a larger font for description
140
  st.markdown(f"### {modules[selected_module]['title']}")
141
  st.markdown(f"<span style='font-size: 14px;'>{modules[selected_module]['description']}</span>", unsafe_allow_html=True)
142
 
143
- # Create a horizontal layout for the clock and PDF report button
144
- col1, col2 = st.columns([1, 3])
145
-
146
- # Live ticking clock
147
- with col1:
148
- clock_placeholder = st.empty()
149
-
150
- # Display the PDF report button
151
- with col2:
152
- if any(q['answered'] for q in st.session_state.questions):
153
- pdf = generate_pdf_report()
154
- st.session_state.pdf_data = pdf # Reset PDF cache
155
- st.download_button(
156
- label="Download PDF Report πŸ“„",
157
- data=st.session_state.pdf_data,
158
- file_name="quiz_report.pdf",
159
- mime="application/pdf"
160
- )
161
-
162
  # Display the current question with larger font
163
  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)
164
 
@@ -174,9 +179,6 @@ with st.form(key=f'question_form_{st.session_state.current_index}'):
174
 
175
  submit_button = st.form_submit_button(label="Submit/New")
176
 
177
- # Update the clock every second
178
- clock_placeholder.markdown(f"⏱️ {int(time.time() - st.session_state.start_time)} seconds")
179
-
180
  # Handle button state and answer submission
181
  if submit_button:
182
  if selected_answer is None:
 
37
  pdf.add_page()
38
  pdf.set_font("Arial", size=10)
39
 
40
+ pdf.cell(200, 10, txt="Magic Math Quiz Report", ln=True, align="C")
41
  pdf.ln(10)
42
 
43
  for i, entry in enumerate(st.session_state.questions):
 
136
 
137
  current_question = st.session_state.current_question
138
 
139
+ # Title header with rounded corners
140
+ st.markdown(
141
+ """
142
+ <div style='background-color: #4CAF50; padding: 10px; border-radius: 10px; text-align: center; color: white;'>
143
+ <h3 style='margin: 0;'>Magic Math Quiz!</h3>
144
+ </div>
145
+ """, unsafe_allow_html=True)
146
+
147
+ # Display the PDF report button next to the title header if at least one question is answered
148
+ if any(q['answered'] for q in st.session_state.questions):
149
+ pdf = generate_pdf_report()
150
+ st.session_state.pdf_data = pdf # Reset PDF cache
151
+ st.markdown(
152
+ """
153
+ <div style='text-align: right; margin-top: -30px;'>
154
+ """, unsafe_allow_html=True)
155
+ st.download_button(
156
+ label="Download PDF Report πŸ“„",
157
+ data=st.session_state.pdf_data,
158
+ file_name="quiz_report.pdf",
159
+ mime="application/pdf"
160
+ )
161
+ st.markdown("</div>", unsafe_allow_html=True)
162
+
163
  # Display module title and description with a larger font for description
164
  st.markdown(f"### {modules[selected_module]['title']}")
165
  st.markdown(f"<span style='font-size: 14px;'>{modules[selected_module]['description']}</span>", unsafe_allow_html=True)
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  # Display the current question with larger font
168
  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)
169
 
 
179
 
180
  submit_button = st.form_submit_button(label="Submit/New")
181
 
 
 
 
182
  # Handle button state and answer submission
183
  if submit_button:
184
  if selected_answer is None: