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

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +50 -163
src/streamlit_app.py CHANGED
@@ -16,27 +16,19 @@ st.set_page_config(
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');
23
 
24
  .main-container {
25
  background: linear-gradient(45deg, #FF6B6B, #4ECDC4, #45B7D1, #96CEB4, #FFEAA7);
26
- background-size: 400% 400%;
27
- animation: gradientBG 15s ease infinite;
28
  padding: 20px;
29
  border-radius: 25px;
30
  border: 8px dashed #FFD93D;
31
  margin-bottom: 20px;
32
  }
33
 
34
- @keyframes gradientBG {
35
- 0% { background-position: 0% 50% }
36
- 50% { background-position: 100% 50% }
37
- 100% { background-position: 0% 50% }
38
- }
39
-
40
  .fun-title {
41
  font-size: 50px;
42
  color: #FF6B6B;
@@ -55,11 +47,6 @@ st.markdown("""
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 {
@@ -88,37 +75,9 @@ st.markdown("""
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;
@@ -130,7 +89,7 @@ st.markdown("""
130
  }
131
 
132
  .celebration-confetti {
133
- position: absolute;
134
  width: 12px;
135
  height: 12px;
136
  animation: celebrationConfetti 2s linear forwards;
@@ -156,22 +115,6 @@ st.markdown("""
156
  font-size: 40px;
157
  }
158
 
159
- /* Live activity indicator */
160
- .live-indicator {
161
- display: inline-block;
162
- width: 12px;
163
- height: 12px;
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);
@@ -190,12 +133,6 @@ st.markdown("""
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 */
@@ -209,10 +146,10 @@ st.markdown("""
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'];
@@ -259,7 +196,6 @@ function startAutoProgression(seconds) {
259
 
260
  if (timeLeft < 0) {
261
  clearInterval(timer);
262
- // Trigger the Streamlit rerun
263
  window.location.reload();
264
  }
265
  }, 1000);
@@ -267,7 +203,7 @@ function startAutoProgression(seconds) {
267
  </script>
268
  """, unsafe_allow_html=True)
269
 
270
- # Initialize session state with better management
271
  def initialize_session_state():
272
  if 'app_initialized' not in st.session_state:
273
  st.session_state.app_initialized = True
@@ -279,37 +215,37 @@ def initialize_session_state():
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)
304
 
305
- # Age group setup with fun descriptions
306
  age_groups = {
307
  "πŸ‘Ά Little Explorers (4-6)": {"dataset": "src/Datase_of_4-6_Age_Group.xlsx", "zip_file": "src/Image_for_group_4-6.zip", "image_folder": "Image_for_group_4-6", "emoji": "πŸ‘Ά"},
308
  "πŸš€ Math Adventurers (7-9)": {"dataset": "src/Datase_of_7-9_Age_Group.xlsx", "zip_file": "src/Image_for_group_7-9.zip", "image_folder": "Image_for_group_7-9", "emoji": "πŸš€"},
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
 
@@ -332,20 +268,6 @@ with st.sidebar:
332
  st.session_state.auto_progress = auto_progress
333
  st.rerun()
334
 
335
- # Live activity monitor
336
- st.markdown("### πŸ“Š Activity Monitor")
337
- activity_time = time.time() - st.session_state.last_activity
338
- if activity_time < 10:
339
- status = "🟒 Very Active"
340
- elif activity_time < 30:
341
- status = "🟑 Active"
342
- else:
343
- status = "πŸ”΄ Idle"
344
-
345
- st.metric("Session Status", status)
346
-
347
- st.markdown("---")
348
-
349
  st.markdown("### πŸ† Achievement Tips")
350
  st.info("""
351
  πŸ’« **Pro Tips:**
@@ -403,7 +325,7 @@ with col1:
403
  st.error(f"❌ Oh no! The math treasure got mixed up! {e}")
404
  st.stop()
405
 
406
- # Category selection with fun names
407
  categories = sorted(df['category'].dropna().unique())
408
  category_emojis = {"Addition": "βž•", "Subtraction": "βž–", "Multiplication": "βœ–οΈ", "Division": "βž—", "Geometry": "πŸ“", "Algebra": "πŸ“Š"}
409
  selected_category = st.selectbox("πŸ“š Choose Your Math Quest:", options=categories)
@@ -424,19 +346,19 @@ with col1:
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;">
431
  🎯 Adventure Progress: {st.session_state.question_index + 1} of {len(subset_df)}
432
  </div>
433
  <div class="progress-bar" style="width: 100%; background: #f0f0f0; border-radius: 10px; height: 25px;">
434
- <div style="width: {progress}%; background: linear-gradient(45deg, #FF6B6B, #FFD93D); height: 100%; border-radius: 10px; transition: width 0.5s;"></div>
435
  </div>
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">
@@ -462,37 +384,34 @@ with col1:
462
  except:
463
  pass
464
  if not image_found:
465
- st.warning("πŸ–ΌοΈ Oh no! The picture is playing hide and seek!")
466
 
467
- # Fun answer input
468
- user_ans = st.text_input("✏️ Your Magical Answer:", key=f"ans_{st.session_state.question_index}")
469
 
470
- # Submit button with celebration
471
  col_btn1, col_btn2, col_btn3 = st.columns([1, 1, 1])
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!",
493
- "🌈 You just painted the town with math brilliance!",
494
- "🎊 Party time! You nailed it!",
495
- "πŸ¦„ Unicorn-level math skills activated!"
496
  ]
497
 
498
  st.markdown(f"""
@@ -509,7 +428,7 @@ with col1:
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
 
@@ -517,48 +436,43 @@ with col1:
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
528
- st.info("πŸ’¨ Zooming to the next challenge! Get ready! πŸš€")
529
  time.sleep(1)
530
  st.rerun()
531
 
532
- # Show answer with encouragement
533
  if st.session_state.show_answer:
534
- st.info(f"""
535
- πŸ’‘ **Hint from Your Math Friend:**
536
- The magical answer is **{question['answer']}**
537
-
538
- Remember: Even math superheroes need help sometimes! 🦸
539
- """)
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
  πŸŒŸπŸŽŠπŸ‘‘πŸŽˆπŸš€
@@ -570,7 +484,6 @@ with col1:
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
@@ -580,22 +493,20 @@ with col1:
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
@@ -607,38 +518,14 @@ 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
 
616
- st.markdown("### πŸ† Your Achievements")
617
  if not subset_df.empty:
618
  completed = min(st.session_state.question_index, len(subset_df))
619
- st.metric("Challenges Completed", f"{completed}/{len(subset_df)}")
620
-
621
- if completed > 0:
622
- accuracy = "🎯 Perfect!" if completed == st.session_state.question_index else "🌟 Great!"
623
- st.metric("Accuracy", accuracy)
624
-
625
- st.markdown("### πŸ’« Pro Tip")
626
- st.info("""
627
- ✨ **Math Superpower:**
628
- Use scrap paper to work out
629
- tricky problems! It's like
630
- having a math sidekick! πŸ¦Έβ€β™‚οΈ
631
- """)
632
-
633
- # Add periodic invisible updates to prevent sleeping
634
- if 'update_counter' not in st.session_state:
635
- st.session_state.update_counter = 0
636
-
637
- st.session_state.update_counter += 1
638
-
639
- # This creates a very subtle continuous activity
640
- if st.session_state.update_counter % 10 == 0:
641
- st.markdown(f'<div style="display:none">{random.random()}</div>', unsafe_allow_html=True)
642
 
643
  # Cleanup function
644
  def cleanup():
 
16
  initial_sidebar_state="expanded"
17
  )
18
 
19
+ # Clean, stable CSS without excessive animations
20
  st.markdown("""
21
  <style>
22
  @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
23
 
24
  .main-container {
25
  background: linear-gradient(45deg, #FF6B6B, #4ECDC4, #45B7D1, #96CEB4, #FFEAA7);
 
 
26
  padding: 20px;
27
  border-radius: 25px;
28
  border: 8px dashed #FFD93D;
29
  margin-bottom: 20px;
30
  }
31
 
 
 
 
 
 
 
32
  .fun-title {
33
  font-size: 50px;
34
  color: #FF6B6B;
 
47
  font-family: 'Comic Neue', cursive;
48
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
49
  margin: 20px 0;
 
 
 
 
 
50
  }
51
 
52
  .stButton > button {
 
75
  font-family: 'Comic Neue', cursive;
76
  }
77
 
78
+ /* Only show animations during celebrations */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  .celebration-emoji {
80
+ position: fixed;
81
  font-size: 24px;
82
  animation: celebrationFall 2s linear forwards;
83
  pointer-events: none;
 
89
  }
90
 
91
  .celebration-confetti {
92
+ position: fixed;
93
  width: 12px;
94
  height: 12px;
95
  animation: celebrationConfetti 2s linear forwards;
 
115
  font-size: 40px;
116
  }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  /* Help box styling */
119
  .help-box {
120
  background: rgba(255, 255, 255, 0.95);
 
133
  border-radius: 25px;
134
  color: white;
135
  margin: 20px 0;
 
 
 
 
 
 
136
  }
137
 
138
  /* Auto progress countdown */
 
146
  </style>
147
  """, unsafe_allow_html=True)
148
 
149
+ # JavaScript for celebrations only (no initial animations)
150
  st.markdown("""
151
  <script>
152
+ // Celebration functions - ONLY during correct answers
153
  function createCelebration() {
154
  const emojis = ['πŸŽ‰', '🎈', '⭐', '🎊', '🌈', 'πŸš€'];
155
  const colors = ['#FF6B6B', '#4ECDC4', '#FFD93D', '#45B7D1', '#96CEB4'];
 
196
 
197
  if (timeLeft < 0) {
198
  clearInterval(timer);
 
199
  window.location.reload();
200
  }
201
  }, 1000);
 
203
  </script>
204
  """, unsafe_allow_html=True)
205
 
206
+ # Initialize session state
207
  def initialize_session_state():
208
  if 'app_initialized' not in st.session_state:
209
  st.session_state.app_initialized = True
 
215
  st.session_state.show_answer = False
216
  st.session_state.show_steps = False
217
  st.session_state.session_initialized = False
218
+ st.session_state.auto_progress = True
219
 
220
  initialize_session_state()
221
 
222
+ # Clean, stable welcome title - NO ANIMATIONS
223
  st.markdown("""
224
  <div class="main-container">
225
  <div class="animal-characters">
226
+ <span>🐱</span>
227
+ <span>🐢</span>
228
+ <span>πŸ¦„</span>
229
+ <span>🐼</span>
230
+ <span>🐯</span>
231
  </div>
232
  <div class="fun-title">
233
+ πŸŽͺ Welcome to Math Adventure Land! πŸŽͺ
234
  </div>
235
  <div style="text-align: center; font-size: 24px; color: #FF6B6B; font-family: 'Comic Neue', cursive;">
236
+ Where Numbers Become Friends! πŸ€— ✨
237
  </div>
238
  </div>
239
  """, unsafe_allow_html=True)
240
 
241
+ # Age group setup
242
  age_groups = {
243
  "πŸ‘Ά Little Explorers (4-6)": {"dataset": "src/Datase_of_4-6_Age_Group.xlsx", "zip_file": "src/Image_for_group_4-6.zip", "image_folder": "Image_for_group_4-6", "emoji": "πŸ‘Ά"},
244
  "πŸš€ Math Adventurers (7-9)": {"dataset": "src/Datase_of_7-9_Age_Group.xlsx", "zip_file": "src/Image_for_group_7-9.zip", "image_folder": "Image_for_group_7-9", "emoji": "πŸš€"},
245
  "🌟 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": "🌟"}
246
  }
247
 
248
+ # SIDEBAR - Clean and stable
249
  with st.sidebar:
250
  st.markdown("### 🎯 Quick Help Guide")
251
 
 
268
  st.session_state.auto_progress = auto_progress
269
  st.rerun()
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  st.markdown("### πŸ† Achievement Tips")
272
  st.info("""
273
  πŸ’« **Pro Tips:**
 
325
  st.error(f"❌ Oh no! The math treasure got mixed up! {e}")
326
  st.stop()
327
 
328
+ # Category selection
329
  categories = sorted(df['category'].dropna().unique())
330
  category_emojis = {"Addition": "βž•", "Subtraction": "βž–", "Multiplication": "βœ–οΈ", "Division": "βž—", "Geometry": "πŸ“", "Algebra": "πŸ“Š"}
331
  selected_category = st.selectbox("πŸ“š Choose Your Math Quest:", options=categories)
 
346
  question = subset_df.iloc[st.session_state.question_index]
347
  progress = int((st.session_state.question_index / len(subset_df)) * 100)
348
 
349
+ # Progress bar
350
  st.markdown(f"""
351
  <div style="text-align: center; margin: 20px 0;">
352
  <div style="font-family: 'Comic Neue', cursive; color: #FF6B6B; font-size: 18px;">
353
  🎯 Adventure Progress: {st.session_state.question_index + 1} of {len(subset_df)}
354
  </div>
355
  <div class="progress-bar" style="width: 100%; background: #f0f0f0; border-radius: 10px; height: 25px;">
356
+ <div style="width: {progress}%; background: linear-gradient(45deg, #FF6B6B, #FFD93D); height: 100%; border-radius: 10px;"></div>
357
  </div>
358
  </div>
359
  """, unsafe_allow_html=True)
360
 
361
+ # Display question - NO ANIMATIONS
362
  category_emoji = category_emojis.get(selected_category, "❓")
363
  st.markdown(f"""
364
  <div class="question-box">
 
384
  except:
385
  pass
386
  if not image_found:
387
+ st.warning("πŸ–ΌοΈ Image not found for this question")
388
 
389
+ # Answer input
390
+ user_ans = st.text_input("✏️ Your Answer:", key=f"ans_{st.session_state.question_index}")
391
 
392
+ # Action buttons
393
  col_btn1, col_btn2, col_btn3 = st.columns([1, 1, 1])
394
 
395
  with col_btn1:
396
  if st.button("🎯 Submit Answer", key=f"submit_{st.session_state.question_index}", use_container_width=True):
397
  st.session_state.last_activity = time.time()
398
  if str(user_ans).strip().lower() == str(question['answer']).strip().lower():
399
+ # CELEBRATION ONLY HAPPENS HERE - when answer is correct
400
  st.markdown("""
401
  <script>
402
  createCelebration();
403
  </script>
404
  """, unsafe_allow_html=True)
405
 
406
+ st.success("πŸŽ‰βœ¨ CORRECT! Amazing work! βœ¨πŸŽ‰")
 
 
407
  st.balloons()
408
 
 
409
  success_messages = [
410
+ "🌟 You're a math superstar!",
411
+ "πŸš€ Excellent work!",
412
+ "🌈 Brilliant answer!",
413
+ "🎊 Perfect!",
414
+ "πŸ¦„ Outstanding!"
415
  ]
416
 
417
  st.markdown(f"""
 
428
  st.session_state.last_activity = time.time()
429
  st.rerun()
430
  else:
431
+ st.error("❌ Not quite right. Try again! πŸ’«")
432
  st.session_state.show_answer = True
433
  st.session_state.show_steps = False
434
 
 
436
  if st.button("πŸ” Show Hint", key=f"hint_{st.session_state.question_index}", use_container_width=True):
437
  st.session_state.last_activity = time.time()
438
  st.session_state.show_answer = True
439
+ st.info("πŸ’‘ Need some help? Here's the answer below!")
440
 
441
  with col_btn3:
442
+ if st.button("⏭️ Skip", key=f"skip_{st.session_state.question_index}", use_container_width=True):
443
  st.session_state.last_activity = time.time()
444
  st.session_state.question_index += 1
445
  st.session_state.show_answer = False
446
  st.session_state.show_steps = False
447
+ st.info("Moving to next challenge...")
448
  time.sleep(1)
449
  st.rerun()
450
 
451
+ # Show answer
452
  if st.session_state.show_answer:
453
+ st.info(f"πŸ’‘ **Correct Answer:** **{question['answer']}**")
 
 
 
 
 
454
 
455
  if selected_age_group in ["πŸš€ Math Adventurers (7-9)", "🌟 Math Wizards (13-15)"]:
456
+ if st.button("πŸ“ Show Steps", key=f"steps_{st.session_state.question_index}"):
457
  st.session_state.last_activity = time.time()
458
  st.session_state.show_steps = True
459
  if st.session_state.show_steps and pd.notna(question.get("steps", None)):
460
+ st.success(f"### Step-by-Step Solution:\n{question['steps']}")
461
 
462
  elif subset_df.empty:
463
+ st.warning("⚠️ No questions available in this category. Try another one!")
464
  else:
465
+ # COMPLETION MESSAGE
466
  st.markdown("""
467
  <div class="completion-celebration">
468
  <div style="font-size: 60px; margin-bottom: 20px;">
469
  πŸ†πŸŽ‰βœ¨
470
  </div>
471
  <h1 style="font-family: 'Comic Neue', cursive;">
472
+ CONGRATULATIONS! πŸ…
473
  </h1>
474
  <p style="font-size: 24px;">
475
+ You've completed all challenges in this category!
476
  </p>
477
  <div style="font-size: 40px; margin: 20px 0;">
478
  πŸŒŸπŸŽŠπŸ‘‘πŸŽˆπŸš€
 
484
 
485
  # Auto-progress logic
486
  if st.session_state.auto_progress:
 
487
  st.markdown("""
488
  <div class="countdown" id="countdown-timer">
489
  Next adventure starting in: 5 seconds
 
493
  </script>
494
  """, unsafe_allow_html=True)
495
 
 
496
  time.sleep(5)
497
  st.session_state.question_index = 0
498
  st.session_state.show_answer = False
499
  st.session_state.show_steps = False
500
 
501
+ # Move to next category
502
  current_idx = categories.index(selected_category)
503
  if current_idx < len(categories) - 1:
504
  st.session_state.category = categories[current_idx + 1]
505
  else:
506
+ st.session_state.category = categories[0]
507
 
508
  st.rerun()
509
  else:
 
510
  if st.button("πŸ”„ Start New Adventure", use_container_width=True):
511
  st.session_state.last_activity = time.time()
512
  st.session_state.question_index = 0
 
518
  st.markdown("### 🎨 Fun Zone")
519
  st.markdown("""
520
  <div style="text-align: center; font-size: 40px; margin: 20px 0;">
521
+ πŸŽͺ<br>✨<br>🌟
 
 
522
  </div>
523
  """, unsafe_allow_html=True)
524
 
525
+ st.markdown("### πŸ† Progress")
526
  if not subset_df.empty:
527
  completed = min(st.session_state.question_index, len(subset_df))
528
+ st.metric("Completed", f"{completed}/{len(subset_df)}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
 
530
  # Cleanup function
531
  def cleanup():