NSamson1 commited on
Commit
2479d8a
Β·
verified Β·
1 Parent(s): cc9fbc0

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +187 -186
src/streamlit_app.py CHANGED
@@ -16,7 +16,7 @@ st.set_page_config(
16
  initial_sidebar_state="expanded"
17
  )
18
 
19
- # Custom CSS with LOTS of fun animations and styles
20
  st.markdown("""
21
  <style>
22
  @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
@@ -43,15 +43,9 @@ st.markdown("""
43
  text-align: center;
44
  font-family: 'Comic Neue', cursive;
45
  text-shadow: 3px 3px 0 #FFD93D, 6px 6px 0 #4ECDC4;
46
- animation: bounce 2s infinite;
47
  margin-bottom: 30px;
48
  }
49
 
50
- @keyframes bounce {
51
- 0%, 100% { transform: translateY(0); }
52
- 50% { transform: translateY(-20px); }
53
- }
54
-
55
  .question-box {
56
  border: 6px dotted #FF6B6B;
57
  padding: 25px;
@@ -60,13 +54,12 @@ st.markdown("""
60
  font-size: 22px;
61
  font-family: 'Comic Neue', cursive;
62
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
63
- animation: wiggle 3s ease-in-out infinite;
64
  margin: 20px 0;
 
65
  }
66
 
67
- @keyframes wiggle {
68
- 0%, 100% { transform: rotate(-1deg); }
69
- 50% { transform: rotate(1deg); }
70
  }
71
 
72
  .stButton > button {
@@ -83,7 +76,7 @@ st.markdown("""
83
  }
84
 
85
  .stButton > button:hover {
86
- transform: scale(1.1);
87
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
88
  }
89
 
@@ -95,37 +88,58 @@ st.markdown("""
95
  font-family: 'Comic Neue', cursive;
96
  }
97
 
98
- /* Fun elements */
99
- .emoji-rain {
100
- position: fixed;
101
- top: 0;
102
- left: 0;
103
- pointer-events: none;
104
- z-index: 9999;
 
 
 
 
 
105
  }
106
 
107
- .emoji {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  position: absolute;
109
  font-size: 24px;
110
- animation: fall linear forwards;
 
 
111
  }
112
 
113
- @keyframes fall {
114
- to { transform: translateY(100vh) rotate(360deg); }
115
  }
116
 
117
- .confetti {
118
- position: fixed;
119
- width: 15px;
120
- height: 15px;
121
- background: #FF6B6B;
122
- animation: confetti-fall 3s linear forwards;
123
  z-index: 9998;
124
  }
125
 
126
- @keyframes confetti-fall {
127
- 0% { transform: translateY(-100px) rotate(0deg); }
128
- 100% { transform: translateY(100vh) rotate(360deg); }
129
  }
130
 
131
  .progress-bar {
@@ -140,27 +154,6 @@ st.markdown("""
140
  justify-content: space-around;
141
  margin: 20px 0;
142
  font-size: 40px;
143
- animation: bounce 2s infinite;
144
- }
145
-
146
- /* Active animations */
147
- .pulse {
148
- animation: pulse 2s infinite;
149
- }
150
-
151
- @keyframes pulse {
152
- 0% { transform: scale(1); }
153
- 50% { transform: scale(1.05); }
154
- 100% { transform: scale(1); }
155
- }
156
-
157
- .rotate {
158
- animation: rotate 4s linear infinite;
159
- }
160
-
161
- @keyframes rotate {
162
- from { transform: rotate(0deg); }
163
- to { transform: rotate(360deg); }
164
  }
165
 
166
  /* Live activity indicator */
@@ -171,112 +164,106 @@ st.markdown("""
171
  background: #4ECDC4;
172
  border-radius: 50%;
173
  margin-right: 8px;
174
- animation: blink 1.5s infinite;
175
  }
176
 
177
- @keyframes blink {
178
  0%, 100% { opacity: 1; }
179
- 50% { opacity: 0.3; }
180
  }
181
 
182
- /* Celebration container */
183
- .celebration-container {
184
- position: fixed;
185
- top: 0;
186
- left: 0;
187
- width: 100%;
188
- height: 100%;
189
- pointer-events: none;
190
- z-index: 9999;
191
- animation: fadeOut 3s forwards;
192
  }
193
 
194
- @keyframes fadeOut {
195
- 0% { opacity: 1; }
196
- 80% { opacity: 1; }
197
- 100% { opacity: 0; display: none; }
 
 
 
 
 
198
  }
199
 
200
- /* Sidebar styling */
201
- .sidebar-content {
202
- padding: 20px;
203
  }
204
 
205
- .help-box {
206
- background: rgba(255, 255, 255, 0.9);
207
- padding: 20px;
208
- border-radius: 15px;
209
- border: 3px solid #FFD93D;
210
- margin-bottom: 20px;
 
211
  }
212
  </style>
213
  """, unsafe_allow_html=True)
214
 
215
- # JavaScript for animations and celebrations
216
  st.markdown("""
217
  <script>
218
- // Celebration functions with 3-second limit
219
- function createEmojiRain() {
220
- const container = document.createElement('div');
221
- container.className = 'celebration-container';
222
- document.body.appendChild(container);
223
-
224
- const emojis = ['πŸŽ‰', '🎈', '⭐', '🎊', '🌈', 'πŸš€', '🎨', '🐱', '🐢', 'πŸ¦„'];
225
 
226
- for (let i = 0; i < 30; i++) {
 
227
  setTimeout(() => {
228
  const emoji = document.createElement('div');
229
- emoji.className = 'emoji';
230
  emoji.textContent = emojis[Math.floor(Math.random() * emojis.length)];
231
  emoji.style.left = Math.random() * 100 + 'vw';
232
- emoji.style.animationDuration = (Math.random() * 2 + 1) + 's';
233
- container.appendChild(emoji);
234
- }, i * 100);
 
 
235
  }
236
 
237
- setTimeout(() => {
238
- container.remove();
239
- }, 3000);
240
- }
241
-
242
- function createConfetti() {
243
- const container = document.createElement('div');
244
- container.className = 'celebration-container';
245
- document.body.appendChild(container);
246
-
247
- const colors = ['#FF6B6B', '#4ECDC4', '#FFD93D', '#45B7D1', '#96CEB4'];
248
-
249
- for (let i = 0; i < 100; i++) {
250
  setTimeout(() => {
251
  const confetti = document.createElement('div');
252
- confetti.className = 'confetti';
253
  confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
254
  confetti.style.left = Math.random() * 100 + 'vw';
255
- confetti.style.animationDuration = (Math.random() * 2 + 1) + 's';
256
- container.appendChild(confetti);
257
- }, i * 30);
 
 
258
  }
259
-
260
- setTimeout(() => {
261
- container.remove();
262
- }, 3000);
263
  }
264
 
265
- function celebrate() {
266
- createEmojiRain();
267
- createConfetti();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
-
270
- // Continuous activity to prevent sleeping
271
- let lastActivity = Date.now();
272
- setInterval(() => {
273
- if (Date.now() - lastActivity > 10000) {
274
- lastActivity = Date.now();
275
- }
276
- }, 5000);
277
-
278
- document.addEventListener('click', () => lastActivity = Date.now());
279
- document.addEventListener('keypress', () => lastActivity = Date.now());
280
  </script>
281
  """, unsafe_allow_html=True)
282
 
@@ -292,24 +279,25 @@ def initialize_session_state():
292
  st.session_state.show_answer = False
293
  st.session_state.show_steps = False
294
  st.session_state.session_initialized = False
 
295
 
296
  initialize_session_state()
297
 
298
- # Welcome title with fun characters and live indicator
299
  st.markdown("""
300
  <div class="main-container">
301
  <div class="animal-characters">
302
- <span class="rotate">🐱</span>
303
- <span class="pulse">🐢</span>
304
- <span class="rotate">πŸ¦„</span>
305
- <span class="pulse">🐼</span>
306
- <span class="rotate">🐯</span>
307
  </div>
308
  <div class="fun-title">
309
  <span class="live-indicator"></span>πŸŽͺ Welcome to Math Adventure Land! πŸŽͺ
310
  </div>
311
  <div style="text-align: center; font-size: 24px; color: #FF6B6B; font-family: 'Comic Neue', cursive;">
312
- Where Numbers Become Friends! πŸ€— <span class="pulse">✨</span>
313
  </div>
314
  </div>
315
  """, unsafe_allow_html=True)
@@ -321,7 +309,7 @@ age_groups = {
321
  "🌟 Math Wizards (13-15)": {"dataset": "src/Datase_of_13-15_Age_Group.xlsx", "zip_file": "src/Image_for_group_13-15.zip", "image_folder": "Image_for_group_13-15", "emoji": "🌟"}
322
  }
323
 
324
- # SIDEBAR - Help and Controls (Calculator Removed)
325
  with st.sidebar:
326
  st.markdown("### 🎯 Quick Help Guide")
327
 
@@ -335,15 +323,14 @@ with st.sidebar:
335
  </div>
336
  """, unsafe_allow_html=True)
337
 
338
- st.markdown("""
339
- <div class="help-box">
340
- <h4>πŸ’‘ Math Tips:</h4>
341
- <p>β€’ Read questions carefully<br>
342
- β€’ Use scrap paper if needed<br>
343
- β€’ Check your work<br>
344
- β€’ Ask for hints when stuck!</p>
345
- </div>
346
- """, unsafe_allow_html=True)
347
 
348
  # Live activity monitor
349
  st.markdown("### πŸ“Š Activity Monitor")
@@ -363,7 +350,7 @@ with st.sidebar:
363
  st.info("""
364
  πŸ’« **Pro Tips:**
365
  - Take your time with each problem
366
- - Use the 'Show Steps' feature to learn
367
  - Celebrate every correct answer! πŸŽ‰
368
  - Practice makes perfect! 🌟
369
  """)
@@ -437,7 +424,7 @@ with col1:
437
  question = subset_df.iloc[st.session_state.question_index]
438
  progress = int((st.session_state.question_index / len(subset_df)) * 100)
439
 
440
- # Fun progress bar with animation
441
  st.markdown(f"""
442
  <div style="text-align: center; margin: 20px 0;">
443
  <div style="font-family: 'Comic Neue', cursive; color: #FF6B6B; font-size: 18px;">
@@ -449,7 +436,7 @@ with col1:
449
  </div>
450
  """, unsafe_allow_html=True)
451
 
452
- # Display question with fun styling
453
  category_emoji = category_emojis.get(selected_category, "❓")
454
  st.markdown(f"""
455
  <div class="question-box">
@@ -485,24 +472,21 @@ with col1:
485
 
486
  with col_btn1:
487
  if st.button("🎯 Submit Answer", key=f"submit_{st.session_state.question_index}", use_container_width=True):
488
- st.session_state.last_activity = time.time() # Update activity
489
  if str(user_ans).strip().lower() == str(question['answer']).strip().lower():
490
- # MEGA CELEBRATION FOR CORRECT ANSWER!
491
  st.markdown("""
492
  <script>
493
- celebrate();
494
  </script>
495
  """, unsafe_allow_html=True)
496
 
497
- st.success("""
498
- πŸŽ‰βœ¨ AMAZING! YOU'RE A MATH SUPERSTAR! βœ¨πŸŽ‰
499
- """)
500
 
501
- # Multiple balloons and effects
502
- for _ in range(3):
503
- st.balloons()
504
 
505
- # Fun success message with random emojis
506
  success_messages = [
507
  "🌟 You're shining brighter than a supernova!",
508
  "πŸš€ To infinity and beyond! Math genius detected!",
@@ -517,30 +501,27 @@ with col1:
517
  </div>
518
  """, unsafe_allow_html=True)
519
 
520
- # Wait exactly 3 seconds then continue
521
- time.sleep(3)
522
  st.session_state.question_index += 1
523
  st.session_state.show_answer = False
524
  st.session_state.show_steps = False
525
  st.session_state.last_activity = time.time()
526
  st.rerun()
527
  else:
528
- st.error("""
529
- ❌ Oops! That's not quite right, but don't give up!
530
- Every great math wizard makes mistakes sometimes! πŸ’«
531
- """)
532
  st.session_state.show_answer = True
533
  st.session_state.show_steps = False
534
 
535
  with col_btn2:
536
  if st.button("πŸ” Show Hint", key=f"hint_{st.session_state.question_index}", use_container_width=True):
537
- st.session_state.last_activity = time.time() # Update activity
538
  st.session_state.show_answer = True
539
  st.info("πŸ’‘ Here's a little help! You can do this! 🌟")
540
 
541
  with col_btn3:
542
  if st.button("⏭️ Skip Challenge", key=f"skip_{st.session_state.question_index}", use_container_width=True):
543
- st.session_state.last_activity = time.time() # Update activity
544
  st.session_state.question_index += 1
545
  st.session_state.show_answer = False
546
  st.session_state.show_steps = False
@@ -559,32 +540,25 @@ with col1:
559
 
560
  if selected_age_group in ["πŸš€ Math Adventurers (7-9)", "🌟 Math Wizards (13-15)"]:
561
  if st.button("πŸͺ„ Show Magic Steps", key=f"steps_{st.session_state.question_index}"):
562
- st.session_state.last_activity = time.time() # Update activity
563
  st.session_state.show_steps = True
564
  if st.session_state.show_steps and pd.notna(question.get("steps", None)):
565
- st.success(f"""
566
- ### πŸͺ„ Secret Math Magic:
567
- {question['steps']}
568
- """)
569
 
570
  elif subset_df.empty:
571
- st.warning("""
572
- ⚠️ Oh dear! No math adventures here yet!
573
- Try another magical category! πŸ§™
574
- """)
575
  else:
576
- # GRAND FINALE CELEBRATION!
577
  st.markdown("""
578
- <div style="text-align: center; padding: 40px;">
579
  <div style="font-size: 60px; margin-bottom: 20px;">
580
  πŸ†πŸŽ‰βœ¨
581
  </div>
582
- <h1 style="color: #FF6B6B; font-family: 'Comic Neue', cursive;">
583
  YOU DID IT! MATH CHAMPION! πŸ…
584
  </h1>
585
- <p style="font-size: 24px; color: #4ECDC4;">
586
  You've completed all the challenges in this category!<br>
587
- Ready for more adventures? πŸŽͺ
588
  </p>
589
  <div style="font-size: 40px; margin: 20px 0;">
590
  πŸŒŸπŸŽŠπŸ‘‘πŸŽˆπŸš€
@@ -592,23 +566,50 @@ with col1:
592
  </div>
593
  """, unsafe_allow_html=True)
594
 
595
- for _ in range(3):
596
- st.balloons()
597
 
598
- if st.button("πŸ”„ Start New Adventure", use_container_width=True):
599
- st.session_state.last_activity = time.time() # Update activity
 
 
 
 
 
 
 
 
 
 
 
 
600
  st.session_state.question_index = 0
601
  st.session_state.show_answer = False
602
  st.session_state.show_steps = False
 
 
 
 
 
 
 
 
603
  st.rerun()
 
 
 
 
 
 
 
 
604
 
605
  with col2:
606
  st.markdown("### 🎨 Fun Zone")
607
  st.markdown("""
608
  <div style="text-align: center; font-size: 40px; margin: 20px 0;">
609
- <span class="pulse">πŸŽͺ</span><br>
610
- <span class="rotate">✨</span><br>
611
- <span class="pulse">🌟</span>
612
  </div>
613
  """, unsafe_allow_html=True)
614
 
 
16
  initial_sidebar_state="expanded"
17
  )
18
 
19
+ # Custom CSS with controlled animations
20
  st.markdown("""
21
  <style>
22
  @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
 
43
  text-align: center;
44
  font-family: 'Comic Neue', cursive;
45
  text-shadow: 3px 3px 0 #FFD93D, 6px 6px 0 #4ECDC4;
 
46
  margin-bottom: 30px;
47
  }
48
 
 
 
 
 
 
49
  .question-box {
50
  border: 6px dotted #FF6B6B;
51
  padding: 25px;
 
54
  font-size: 22px;
55
  font-family: 'Comic Neue', cursive;
56
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
 
57
  margin: 20px 0;
58
+ transition: transform 0.3s ease;
59
  }
60
 
61
+ .question-box:hover {
62
+ transform: scale(1.02);
 
63
  }
64
 
65
  .stButton > button {
 
76
  }
77
 
78
  .stButton > button:hover {
79
+ transform: scale(1.05);
80
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
81
  }
82
 
 
88
  font-family: 'Comic Neue', cursive;
89
  }
90
 
91
+ /* Controlled animations */
92
+ .gentle-bounce {
93
+ animation: gentleBounce 3s ease-in-out infinite;
94
+ }
95
+
96
+ @keyframes gentleBounce {
97
+ 0%, 100% { transform: translateY(0); }
98
+ 50% { transform: translateY(-5px); }
99
+ }
100
+
101
+ .soft-pulse {
102
+ animation: softPulse 4s ease-in-out infinite;
103
  }
104
 
105
+ @keyframes softPulse {
106
+ 0%, 100% { transform: scale(1); opacity: 1; }
107
+ 50% { transform: scale(1.03); opacity: 0.9; }
108
+ }
109
+
110
+ .slow-rotate {
111
+ animation: slowRotate 8s linear infinite;
112
+ }
113
+
114
+ @keyframes slowRotate {
115
+ from { transform: rotate(0deg); }
116
+ to { transform: rotate(360deg); }
117
+ }
118
+
119
+ /* Celebration elements - only show during celebrations */
120
+ .celebration-emoji {
121
  position: absolute;
122
  font-size: 24px;
123
+ animation: celebrationFall 2s linear forwards;
124
+ pointer-events: none;
125
+ z-index: 9999;
126
  }
127
 
128
+ @keyframes celebrationFall {
129
+ to { transform: translateY(100vh) rotate(360deg); opacity: 0; }
130
  }
131
 
132
+ .celebration-confetti {
133
+ position: absolute;
134
+ width: 12px;
135
+ height: 12px;
136
+ animation: celebrationConfetti 2s linear forwards;
137
+ pointer-events: none;
138
  z-index: 9998;
139
  }
140
 
141
+ @keyframes celebrationConfetti {
142
+ to { transform: translateY(100vh) rotate(360deg); opacity: 0; }
 
143
  }
144
 
145
  .progress-bar {
 
154
  justify-content: space-around;
155
  margin: 20px 0;
156
  font-size: 40px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
158
 
159
  /* Live activity indicator */
 
164
  background: #4ECDC4;
165
  border-radius: 50%;
166
  margin-right: 8px;
167
+ animation: gentleBlink 2s infinite;
168
  }
169
 
170
+ @keyframes gentleBlink {
171
  0%, 100% { opacity: 1; }
172
+ 50% { opacity: 0.7; }
173
  }
174
 
175
+ /* Help box styling */
176
+ .help-box {
177
+ background: rgba(255, 255, 255, 0.95);
178
+ padding: 20px;
179
+ border-radius: 15px;
180
+ border: 3px solid #FFD93D;
181
+ margin-bottom: 20px;
182
+ font-family: 'Comic Neue', cursive;
 
 
183
  }
184
 
185
+ /* Completion celebration */
186
+ .completion-celebration {
187
+ text-align: center;
188
+ padding: 40px;
189
+ background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
190
+ border-radius: 25px;
191
+ color: white;
192
+ margin: 20px 0;
193
+ animation: completionPulse 2s ease-in-out;
194
  }
195
 
196
+ @keyframes completionPulse {
197
+ 0% { transform: scale(0.9); opacity: 0; }
198
+ 100% { transform: scale(1); opacity: 1; }
199
  }
200
 
201
+ /* Auto progress countdown */
202
+ .countdown {
203
+ font-size: 18px;
204
+ color: #FF6B6B;
205
+ font-weight: bold;
206
+ text-align: center;
207
+ margin: 10px 0;
208
  }
209
  </style>
210
  """, unsafe_allow_html=True)
211
 
212
+ # JavaScript for controlled celebrations
213
  st.markdown("""
214
  <script>
215
+ // Celebration functions with controlled timing
216
+ function createCelebration() {
217
+ const emojis = ['πŸŽ‰', '🎈', '⭐', '🎊', '🌈', 'πŸš€'];
218
+ const colors = ['#FF6B6B', '#4ECDC4', '#FFD93D', '#45B7D1', '#96CEB4'];
 
 
 
219
 
220
+ // Create emojis
221
+ for (let i = 0; i < 20; i++) {
222
  setTimeout(() => {
223
  const emoji = document.createElement('div');
224
+ emoji.className = 'celebration-emoji';
225
  emoji.textContent = emojis[Math.floor(Math.random() * emojis.length)];
226
  emoji.style.left = Math.random() * 100 + 'vw';
227
+ emoji.style.animationDuration = (Math.random() * 1 + 1.5) + 's';
228
+ document.body.appendChild(emoji);
229
+
230
+ setTimeout(() => emoji.remove(), 2500);
231
+ }, i * 150);
232
  }
233
 
234
+ // Create confetti
235
+ for (let i = 0; i < 50; i++) {
 
 
 
 
 
 
 
 
 
 
 
236
  setTimeout(() => {
237
  const confetti = document.createElement('div');
238
+ confetti.className = 'celebration-confetti';
239
  confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
240
  confetti.style.left = Math.random() * 100 + 'vw';
241
+ confetti.style.animationDuration = (Math.random() * 1 + 1.5) + 's';
242
+ document.body.appendChild(confetti);
243
+
244
+ setTimeout(() => confetti.remove(), 2500);
245
+ }, i * 50);
246
  }
 
 
 
 
247
  }
248
 
249
+ // Auto progression after completion
250
+ function startAutoProgression(seconds) {
251
+ let timeLeft = seconds;
252
+ const countdownElement = document.getElementById('countdown-timer');
253
+
254
+ const timer = setInterval(() => {
255
+ if (countdownElement) {
256
+ countdownElement.textContent = `Next adventure in: ${timeLeft} seconds`;
257
+ }
258
+ timeLeft--;
259
+
260
+ if (timeLeft < 0) {
261
+ clearInterval(timer);
262
+ // Trigger the Streamlit rerun
263
+ window.location.reload();
264
+ }
265
+ }, 1000);
266
  }
 
 
 
 
 
 
 
 
 
 
 
267
  </script>
268
  """, unsafe_allow_html=True)
269
 
 
279
  st.session_state.show_answer = False
280
  st.session_state.show_steps = False
281
  st.session_state.session_initialized = False
282
+ st.session_state.auto_progress = True # Auto-progress enabled by default
283
 
284
  initialize_session_state()
285
 
286
+ # Welcome title with controlled animations
287
  st.markdown("""
288
  <div class="main-container">
289
  <div class="animal-characters">
290
+ <span class="slow-rotate">🐱</span>
291
+ <span class="soft-pulse">🐢</span>
292
+ <span class="slow-rotate">πŸ¦„</span>
293
+ <span class="soft-pulse">🐼</span>
294
+ <span class="slow-rotate">🐯</span>
295
  </div>
296
  <div class="fun-title">
297
  <span class="live-indicator"></span>πŸŽͺ Welcome to Math Adventure Land! πŸŽͺ
298
  </div>
299
  <div style="text-align: center; font-size: 24px; color: #FF6B6B; font-family: 'Comic Neue', cursive;">
300
+ Where Numbers Become Friends! πŸ€— <span class="gentle-bounce">✨</span>
301
  </div>
302
  </div>
303
  """, unsafe_allow_html=True)
 
309
  "🌟 Math Wizards (13-15)": {"dataset": "src/Datase_of_13-15_Age_Group.xlsx", "zip_file": "src/Image_for_group_13-15.zip", "image_folder": "Image_for_group_13-15", "emoji": "🌟"}
310
  }
311
 
312
+ # SIDEBAR - Help and Controls
313
  with st.sidebar:
314
  st.markdown("### 🎯 Quick Help Guide")
315
 
 
323
  </div>
324
  """, unsafe_allow_html=True)
325
 
326
+ # Auto-progress toggle
327
+ st.markdown("### βš™οΈ Settings")
328
+ auto_progress = st.toggle("Auto-Progress", value=st.session_state.auto_progress,
329
+ help="Automatically move to next category when finished")
330
+
331
+ if auto_progress != st.session_state.auto_progress:
332
+ st.session_state.auto_progress = auto_progress
333
+ st.rerun()
 
334
 
335
  # Live activity monitor
336
  st.markdown("### πŸ“Š Activity Monitor")
 
350
  st.info("""
351
  πŸ’« **Pro Tips:**
352
  - Take your time with each problem
353
+ - Use the hints when you need help
354
  - Celebrate every correct answer! πŸŽ‰
355
  - Practice makes perfect! 🌟
356
  """)
 
424
  question = subset_df.iloc[st.session_state.question_index]
425
  progress = int((st.session_state.question_index / len(subset_df)) * 100)
426
 
427
+ # Fun progress bar
428
  st.markdown(f"""
429
  <div style="text-align: center; margin: 20px 0;">
430
  <div style="font-family: 'Comic Neue', cursive; color: #FF6B6B; font-size: 18px;">
 
436
  </div>
437
  """, unsafe_allow_html=True)
438
 
439
+ # Display question with controlled styling
440
  category_emoji = category_emojis.get(selected_category, "❓")
441
  st.markdown(f"""
442
  <div class="question-box">
 
472
 
473
  with col_btn1:
474
  if st.button("🎯 Submit Answer", key=f"submit_{st.session_state.question_index}", use_container_width=True):
475
+ st.session_state.last_activity = time.time()
476
  if str(user_ans).strip().lower() == str(question['answer']).strip().lower():
477
+ # Controlled celebration
478
  st.markdown("""
479
  <script>
480
+ createCelebration();
481
  </script>
482
  """, unsafe_allow_html=True)
483
 
484
+ st.success("πŸŽ‰βœ¨ AMAZING! YOU'RE A MATH SUPERSTAR! βœ¨πŸŽ‰")
 
 
485
 
486
+ # Gentle balloons
487
+ st.balloons()
 
488
 
489
+ # Success message
490
  success_messages = [
491
  "🌟 You're shining brighter than a supernova!",
492
  "πŸš€ To infinity and beyond! Math genius detected!",
 
501
  </div>
502
  """, unsafe_allow_html=True)
503
 
504
+ # Wait 2 seconds then continue
505
+ time.sleep(2)
506
  st.session_state.question_index += 1
507
  st.session_state.show_answer = False
508
  st.session_state.show_steps = False
509
  st.session_state.last_activity = time.time()
510
  st.rerun()
511
  else:
512
+ st.error("❌ Oops! That's not quite right, but don't give up! πŸ’«")
 
 
 
513
  st.session_state.show_answer = True
514
  st.session_state.show_steps = False
515
 
516
  with col_btn2:
517
  if st.button("πŸ” Show Hint", key=f"hint_{st.session_state.question_index}", use_container_width=True):
518
+ st.session_state.last_activity = time.time()
519
  st.session_state.show_answer = True
520
  st.info("πŸ’‘ Here's a little help! You can do this! 🌟")
521
 
522
  with col_btn3:
523
  if st.button("⏭️ Skip Challenge", key=f"skip_{st.session_state.question_index}", use_container_width=True):
524
+ st.session_state.last_activity = time.time()
525
  st.session_state.question_index += 1
526
  st.session_state.show_answer = False
527
  st.session_state.show_steps = False
 
540
 
541
  if selected_age_group in ["πŸš€ Math Adventurers (7-9)", "🌟 Math Wizards (13-15)"]:
542
  if st.button("πŸͺ„ Show Magic Steps", key=f"steps_{st.session_state.question_index}"):
543
+ st.session_state.last_activity = time.time()
544
  st.session_state.show_steps = True
545
  if st.session_state.show_steps and pd.notna(question.get("steps", None)):
546
+ st.success(f"### πŸͺ„ Secret Math Magic:\n{question['steps']}")
 
 
 
547
 
548
  elif subset_df.empty:
549
+ st.warning("⚠️ Oh dear! No math adventures here yet! Try another magical category! πŸ§™")
 
 
 
550
  else:
551
+ # COMPLETION CELEBRATION with Auto-Progress
552
  st.markdown("""
553
+ <div class="completion-celebration">
554
  <div style="font-size: 60px; margin-bottom: 20px;">
555
  πŸ†πŸŽ‰βœ¨
556
  </div>
557
+ <h1 style="font-family: 'Comic Neue', cursive;">
558
  YOU DID IT! MATH CHAMPION! πŸ…
559
  </h1>
560
+ <p style="font-size: 24px;">
561
  You've completed all the challenges in this category!<br>
 
562
  </p>
563
  <div style="font-size: 40px; margin: 20px 0;">
564
  πŸŒŸπŸŽŠπŸ‘‘πŸŽˆπŸš€
 
566
  </div>
567
  """, unsafe_allow_html=True)
568
 
569
+ st.balloons()
 
570
 
571
+ # Auto-progress logic
572
+ if st.session_state.auto_progress:
573
+ # Show countdown and auto-progress
574
+ st.markdown("""
575
+ <div class="countdown" id="countdown-timer">
576
+ Next adventure starting in: 5 seconds
577
+ </div>
578
+ <script>
579
+ startAutoProgression(5);
580
+ </script>
581
+ """, unsafe_allow_html=True)
582
+
583
+ # Wait and auto-progress
584
+ time.sleep(5)
585
  st.session_state.question_index = 0
586
  st.session_state.show_answer = False
587
  st.session_state.show_steps = False
588
+
589
+ # Move to next category or restart
590
+ current_idx = categories.index(selected_category)
591
+ if current_idx < len(categories) - 1:
592
+ st.session_state.category = categories[current_idx + 1]
593
+ else:
594
+ st.session_state.category = categories[0] # Restart from first category
595
+
596
  st.rerun()
597
+ else:
598
+ # Manual progression
599
+ if st.button("πŸ”„ Start New Adventure", use_container_width=True):
600
+ st.session_state.last_activity = time.time()
601
+ st.session_state.question_index = 0
602
+ st.session_state.show_answer = False
603
+ st.session_state.show_steps = False
604
+ st.rerun()
605
 
606
  with col2:
607
  st.markdown("### 🎨 Fun Zone")
608
  st.markdown("""
609
  <div style="text-align: center; font-size: 40px; margin: 20px 0;">
610
+ <span class="soft-pulse">πŸŽͺ</span><br>
611
+ <span class="slow-rotate">✨</span><br>
612
+ <span class="soft-pulse">🌟</span>
613
  </div>
614
  """, unsafe_allow_html=True)
615