Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- 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
|
| 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 |
-
|
| 68 |
-
|
| 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.
|
| 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 |
-
/*
|
| 99 |
-
.
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
position: absolute;
|
| 109 |
font-size: 24px;
|
| 110 |
-
animation:
|
|
|
|
|
|
|
| 111 |
}
|
| 112 |
|
| 113 |
-
@keyframes
|
| 114 |
-
to { transform: translateY(100vh) rotate(360deg); }
|
| 115 |
}
|
| 116 |
|
| 117 |
-
.confetti {
|
| 118 |
-
position:
|
| 119 |
-
width:
|
| 120 |
-
height:
|
| 121 |
-
|
| 122 |
-
|
| 123 |
z-index: 9998;
|
| 124 |
}
|
| 125 |
|
| 126 |
-
@keyframes
|
| 127 |
-
|
| 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:
|
| 175 |
}
|
| 176 |
|
| 177 |
-
@keyframes
|
| 178 |
0%, 100% { opacity: 1; }
|
| 179 |
-
50% { opacity: 0.
|
| 180 |
}
|
| 181 |
|
| 182 |
-
/*
|
| 183 |
-
.
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
z-index: 9999;
|
| 191 |
-
animation: fadeOut 3s forwards;
|
| 192 |
}
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
}
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
}
|
| 204 |
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
| 211 |
}
|
| 212 |
</style>
|
| 213 |
""", unsafe_allow_html=True)
|
| 214 |
|
| 215 |
-
# JavaScript for
|
| 216 |
st.markdown("""
|
| 217 |
<script>
|
| 218 |
-
// Celebration functions with
|
| 219 |
-
function
|
| 220 |
-
const
|
| 221 |
-
|
| 222 |
-
document.body.appendChild(container);
|
| 223 |
-
|
| 224 |
-
const emojis = ['π', 'π', 'β', 'π', 'π', 'π', 'π¨', 'π±', 'πΆ', 'π¦'];
|
| 225 |
|
| 226 |
-
|
|
|
|
| 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() *
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
| 235 |
}
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 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() *
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
| 258 |
}
|
| 259 |
-
|
| 260 |
-
setTimeout(() => {
|
| 261 |
-
container.remove();
|
| 262 |
-
}, 3000);
|
| 263 |
}
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 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="
|
| 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
|
| 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 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 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
|
| 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
|
| 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
|
| 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()
|
| 489 |
if str(user_ans).strip().lower() == str(question['answer']).strip().lower():
|
| 490 |
-
#
|
| 491 |
st.markdown("""
|
| 492 |
<script>
|
| 493 |
-
|
| 494 |
</script>
|
| 495 |
""", unsafe_allow_html=True)
|
| 496 |
|
| 497 |
-
st.success(""
|
| 498 |
-
πβ¨ AMAZING! YOU'RE A MATH SUPERSTAR! β¨π
|
| 499 |
-
""")
|
| 500 |
|
| 501 |
-
#
|
| 502 |
-
|
| 503 |
-
st.balloons()
|
| 504 |
|
| 505 |
-
#
|
| 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
|
| 521 |
-
time.sleep(
|
| 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()
|
| 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()
|
| 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()
|
| 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 |
-
#
|
| 577 |
st.markdown("""
|
| 578 |
-
<div
|
| 579 |
<div style="font-size: 60px; margin-bottom: 20px;">
|
| 580 |
ππβ¨
|
| 581 |
</div>
|
| 582 |
-
<h1 style="
|
| 583 |
YOU DID IT! MATH CHAMPION! π
|
| 584 |
</h1>
|
| 585 |
-
<p style="font-size: 24px;
|
| 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 |
-
|
| 596 |
-
st.balloons()
|
| 597 |
|
| 598 |
-
|
| 599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|