Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +86 -68
src/streamlit_app.py
CHANGED
|
@@ -11,12 +11,12 @@ import random
|
|
| 11 |
|
| 12 |
# Page config with optimized settings
|
| 13 |
st.set_page_config(
|
| 14 |
-
page_title="
|
| 15 |
layout="wide",
|
| 16 |
initial_sidebar_state="expanded"
|
| 17 |
)
|
| 18 |
|
| 19 |
-
# COMPLETELY CLEAN CSS - NO ANIMATIONS, NO
|
| 20 |
st.markdown("""
|
| 21 |
<style>
|
| 22 |
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
|
|
@@ -34,7 +34,6 @@ st.markdown("""
|
|
| 34 |
color: #FF6B6B;
|
| 35 |
text-align: center;
|
| 36 |
font-family: 'Comic Neue', cursive;
|
| 37 |
-
text-shadow: 3px 3px 0 #FFD93D, 6px 6px 0 #4ECDC4;
|
| 38 |
margin-bottom: 30px;
|
| 39 |
}
|
| 40 |
|
|
@@ -45,13 +44,12 @@ st.markdown("""
|
|
| 45 |
background-color: rgba(255, 255, 255, 0.9);
|
| 46 |
font-size: 22px;
|
| 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 {
|
| 53 |
font-size: 20px;
|
| 54 |
-
background:
|
| 55 |
color: white;
|
| 56 |
border-radius: 15px;
|
| 57 |
padding: 12px 25px;
|
|
@@ -76,7 +74,7 @@ st.markdown("""
|
|
| 76 |
}
|
| 77 |
|
| 78 |
.progress-fill {
|
| 79 |
-
background:
|
| 80 |
border-radius: 10px;
|
| 81 |
height: 100%;
|
| 82 |
}
|
|
@@ -100,7 +98,7 @@ st.markdown("""
|
|
| 100 |
.completion-message {
|
| 101 |
text-align: center;
|
| 102 |
padding: 40px;
|
| 103 |
-
background:
|
| 104 |
border-radius: 25px;
|
| 105 |
color: white;
|
| 106 |
margin: 20px 0;
|
|
@@ -113,6 +111,13 @@ st.markdown("""
|
|
| 113 |
text-align: center;
|
| 114 |
margin: 10px 0;
|
| 115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
</style>
|
| 117 |
""", unsafe_allow_html=True)
|
| 118 |
|
|
@@ -139,19 +144,36 @@ function startAutoProgression(seconds) {
|
|
| 139 |
</script>
|
| 140 |
""", unsafe_allow_html=True)
|
| 141 |
|
| 142 |
-
# Initialize session state
|
| 143 |
def initialize_session_state():
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
st.session_state
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
initialize_session_state()
|
| 157 |
|
|
@@ -166,10 +188,10 @@ st.markdown("""
|
|
| 166 |
<span>🐯</span>
|
| 167 |
</div>
|
| 168 |
<div class="fun-title">
|
| 169 |
-
|
| 170 |
</div>
|
| 171 |
<div style="text-align: center; font-size: 24px; color: #FF6B6B; font-family: 'Comic Neue', cursive;">
|
| 172 |
-
Where Numbers Become Friends!
|
| 173 |
</div>
|
| 174 |
</div>
|
| 175 |
""", unsafe_allow_html=True)
|
|
@@ -183,11 +205,11 @@ age_groups = {
|
|
| 183 |
|
| 184 |
# SIDEBAR - Clean and stable
|
| 185 |
with st.sidebar:
|
| 186 |
-
st.markdown("###
|
| 187 |
|
| 188 |
st.markdown("""
|
| 189 |
<div class="help-box">
|
| 190 |
-
<h4
|
| 191 |
<p>1. Choose your age group<br>
|
| 192 |
2. Pick a math category<br>
|
| 193 |
3. Solve the fun problems!<br>
|
|
@@ -196,7 +218,7 @@ with st.sidebar:
|
|
| 196 |
""", unsafe_allow_html=True)
|
| 197 |
|
| 198 |
# Auto-progress toggle
|
| 199 |
-
st.markdown("###
|
| 200 |
auto_progress = st.toggle("Auto-Progress", value=st.session_state.auto_progress,
|
| 201 |
help="Automatically move to next category when finished")
|
| 202 |
|
|
@@ -204,12 +226,12 @@ with st.sidebar:
|
|
| 204 |
st.session_state.auto_progress = auto_progress
|
| 205 |
st.rerun()
|
| 206 |
|
| 207 |
-
st.markdown("###
|
| 208 |
st.info("""
|
| 209 |
-
|
| 210 |
- Take your time with each problem
|
| 211 |
- Use the hints when you need help
|
| 212 |
-
- Practice makes perfect!
|
| 213 |
""")
|
| 214 |
|
| 215 |
# MAIN CONTENT AREA
|
|
@@ -220,16 +242,17 @@ with col1:
|
|
| 220 |
st.session_state.last_activity = time.time()
|
| 221 |
|
| 222 |
# Age group selection
|
| 223 |
-
selected_age_group = st.selectbox("
|
| 224 |
|
| 225 |
-
#
|
| 226 |
-
if
|
| 227 |
st.session_state.age_group = selected_age_group
|
| 228 |
st.session_state.category = None
|
| 229 |
st.session_state.question_index = 0
|
| 230 |
st.session_state.show_answer = False
|
| 231 |
st.session_state.show_steps = False
|
| 232 |
st.session_state.session_initialized = True
|
|
|
|
| 233 |
|
| 234 |
# Load dataset
|
| 235 |
group_info = age_groups[selected_age_group]
|
|
@@ -247,23 +270,23 @@ with col1:
|
|
| 247 |
with zipfile.ZipFile(zip_path, "r") as zip_ref:
|
| 248 |
zip_ref.extractall(temp_image_folder)
|
| 249 |
except Exception as e:
|
| 250 |
-
st.warning(f"
|
| 251 |
|
| 252 |
if not os.path.exists(dataset_path):
|
| 253 |
-
st.error(f"
|
| 254 |
st.stop()
|
| 255 |
|
| 256 |
try:
|
| 257 |
df = pd.read_excel(dataset_path)
|
| 258 |
df['category'] = df['category'].astype(str).str.strip()
|
| 259 |
except Exception as e:
|
| 260 |
-
st.error(f"
|
| 261 |
st.stop()
|
| 262 |
|
| 263 |
# Category selection
|
| 264 |
categories = sorted(df['category'].dropna().unique())
|
| 265 |
-
category_emojis = {"Addition": "
|
| 266 |
-
selected_category = st.selectbox("
|
| 267 |
|
| 268 |
# Update session if category changes
|
| 269 |
if st.session_state.category != selected_category:
|
|
@@ -276,7 +299,7 @@ with col1:
|
|
| 276 |
# Filter questions by selected category only
|
| 277 |
subset_df = df[df['category'] == selected_category].reset_index(drop=True)
|
| 278 |
|
| 279 |
-
#
|
| 280 |
if not subset_df.empty and st.session_state.question_index < len(subset_df):
|
| 281 |
question = subset_df.iloc[st.session_state.question_index]
|
| 282 |
progress = int((st.session_state.question_index / len(subset_df)) * 100)
|
|
@@ -285,7 +308,7 @@ with col1:
|
|
| 285 |
st.markdown(f"""
|
| 286 |
<div style="text-align: center; margin: 20px 0;">
|
| 287 |
<div style="font-family: 'Comic Neue', cursive; color: #FF6B6B; font-size: 18px;">
|
| 288 |
-
|
| 289 |
</div>
|
| 290 |
<div class="progress-bar">
|
| 291 |
<div class="progress-fill" style="width: {progress}%;"></div>
|
|
@@ -294,13 +317,13 @@ with col1:
|
|
| 294 |
""", unsafe_allow_html=True)
|
| 295 |
|
| 296 |
# Display question - NO ANIMATIONS
|
| 297 |
-
category_emoji = category_emojis.get(selected_category, "
|
| 298 |
st.markdown(f"""
|
| 299 |
<div class="question-box">
|
| 300 |
<div style="text-align: center; font-size: 30px; margin-bottom: 15px;">
|
| 301 |
-
|
| 302 |
</div>
|
| 303 |
-
|
| 304 |
{question['problem']}
|
| 305 |
</div>
|
| 306 |
""", unsafe_allow_html=True)
|
|
@@ -319,27 +342,27 @@ with col1:
|
|
| 319 |
except:
|
| 320 |
pass
|
| 321 |
if not image_found:
|
| 322 |
-
st.warning("
|
| 323 |
|
| 324 |
# Answer input
|
| 325 |
-
user_ans = st.text_input("
|
| 326 |
|
| 327 |
# Action buttons
|
| 328 |
col_btn1, col_btn2, col_btn3 = st.columns([1, 1, 1])
|
| 329 |
|
| 330 |
with col_btn1:
|
| 331 |
-
if st.button("
|
| 332 |
st.session_state.last_activity = time.time()
|
| 333 |
if str(user_ans).strip().lower() == str(question['answer']).strip().lower():
|
| 334 |
-
# SIMPLE SUCCESS MESSAGE - NO ANIMATIONS
|
| 335 |
-
st.success("
|
| 336 |
|
| 337 |
success_messages = [
|
| 338 |
-
"
|
| 339 |
-
"
|
| 340 |
-
"
|
| 341 |
-
"
|
| 342 |
-
"
|
| 343 |
]
|
| 344 |
|
| 345 |
st.markdown(f"""
|
|
@@ -356,18 +379,18 @@ with col1:
|
|
| 356 |
st.session_state.last_activity = time.time()
|
| 357 |
st.rerun()
|
| 358 |
else:
|
| 359 |
-
st.error("
|
| 360 |
st.session_state.show_answer = True
|
| 361 |
st.session_state.show_steps = False
|
| 362 |
|
| 363 |
with col_btn2:
|
| 364 |
-
if st.button("
|
| 365 |
st.session_state.last_activity = time.time()
|
| 366 |
st.session_state.show_answer = True
|
| 367 |
-
st.info("
|
| 368 |
|
| 369 |
with col_btn3:
|
| 370 |
-
if st.button("
|
| 371 |
st.session_state.last_activity = time.time()
|
| 372 |
st.session_state.question_index += 1
|
| 373 |
st.session_state.show_answer = False
|
|
@@ -378,26 +401,23 @@ with col1:
|
|
| 378 |
|
| 379 |
# Show answer
|
| 380 |
if st.session_state.show_answer:
|
| 381 |
-
st.info(f"
|
| 382 |
|
| 383 |
if selected_age_group in ["🚀 Math Adventurers (7-9)", "🌟 Math Wizards (13-15)"]:
|
| 384 |
-
if st.button("
|
| 385 |
st.session_state.last_activity = time.time()
|
| 386 |
st.session_state.show_steps = True
|
| 387 |
if st.session_state.show_steps and pd.notna(question.get("steps", None)):
|
| 388 |
-
st.success(f"
|
| 389 |
|
| 390 |
elif subset_df.empty:
|
| 391 |
-
st.warning("
|
| 392 |
else:
|
| 393 |
-
# COMPLETION MESSAGE - NO ANIMATIONS
|
| 394 |
st.markdown("""
|
| 395 |
<div class="completion-message">
|
| 396 |
-
<div style="font-size: 60px; margin-bottom: 20px;">
|
| 397 |
-
🏆
|
| 398 |
-
</div>
|
| 399 |
<h1 style="font-family: 'Comic Neue', cursive;">
|
| 400 |
-
CONGRATULATIONS!
|
| 401 |
</h1>
|
| 402 |
<p style="font-size: 24px;">
|
| 403 |
You've completed all challenges in this category!
|
|
@@ -405,8 +425,6 @@ with col1:
|
|
| 405 |
</div>
|
| 406 |
""", unsafe_allow_html=True)
|
| 407 |
|
| 408 |
-
# NO BALLOONS - completely removed
|
| 409 |
-
|
| 410 |
# Auto-progress logic
|
| 411 |
if st.session_state.auto_progress:
|
| 412 |
st.markdown("""
|
|
@@ -432,7 +450,7 @@ with col1:
|
|
| 432 |
|
| 433 |
st.rerun()
|
| 434 |
else:
|
| 435 |
-
if st.button("
|
| 436 |
st.session_state.last_activity = time.time()
|
| 437 |
st.session_state.question_index = 0
|
| 438 |
st.session_state.show_answer = False
|
|
@@ -440,14 +458,14 @@ with col1:
|
|
| 440 |
st.rerun()
|
| 441 |
|
| 442 |
with col2:
|
| 443 |
-
st.markdown("###
|
| 444 |
st.markdown("""
|
| 445 |
<div style="text-align: center; font-size: 40px; margin: 20px 0;">
|
| 446 |
🎪<br>✨<br>🌟
|
| 447 |
</div>
|
| 448 |
""", unsafe_allow_html=True)
|
| 449 |
|
| 450 |
-
st.markdown("###
|
| 451 |
if not subset_df.empty:
|
| 452 |
completed = min(st.session_state.question_index, len(subset_df))
|
| 453 |
st.metric("Completed", f"{completed}/{len(subset_df)}")
|
|
|
|
| 11 |
|
| 12 |
# Page config with optimized settings
|
| 13 |
st.set_page_config(
|
| 14 |
+
page_title="Math Adventure Land",
|
| 15 |
layout="wide",
|
| 16 |
initial_sidebar_state="expanded"
|
| 17 |
)
|
| 18 |
|
| 19 |
+
# COMPLETELY CLEAN CSS - NO ANIMATIONS, NO MOVEMENTS, NO TRANSITIONS
|
| 20 |
st.markdown("""
|
| 21 |
<style>
|
| 22 |
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
|
|
|
|
| 34 |
color: #FF6B6B;
|
| 35 |
text-align: center;
|
| 36 |
font-family: 'Comic Neue', cursive;
|
|
|
|
| 37 |
margin-bottom: 30px;
|
| 38 |
}
|
| 39 |
|
|
|
|
| 44 |
background-color: rgba(255, 255, 255, 0.9);
|
| 45 |
font-size: 22px;
|
| 46 |
font-family: 'Comic Neue', cursive;
|
|
|
|
| 47 |
margin: 20px 0;
|
| 48 |
}
|
| 49 |
|
| 50 |
.stButton > button {
|
| 51 |
font-size: 20px;
|
| 52 |
+
background: #FF6B6B;
|
| 53 |
color: white;
|
| 54 |
border-radius: 15px;
|
| 55 |
padding: 12px 25px;
|
|
|
|
| 74 |
}
|
| 75 |
|
| 76 |
.progress-fill {
|
| 77 |
+
background: #FF6B6B;
|
| 78 |
border-radius: 10px;
|
| 79 |
height: 100%;
|
| 80 |
}
|
|
|
|
| 98 |
.completion-message {
|
| 99 |
text-align: center;
|
| 100 |
padding: 40px;
|
| 101 |
+
background: #FF6B6B;
|
| 102 |
border-radius: 25px;
|
| 103 |
color: white;
|
| 104 |
margin: 20px 0;
|
|
|
|
| 111 |
text-align: center;
|
| 112 |
margin: 10px 0;
|
| 113 |
}
|
| 114 |
+
|
| 115 |
+
/* DISABLE ALL ANIMATIONS GLOBALLY */
|
| 116 |
+
* {
|
| 117 |
+
animation: none !important;
|
| 118 |
+
transition: none !important;
|
| 119 |
+
transform: none !important;
|
| 120 |
+
}
|
| 121 |
</style>
|
| 122 |
""", unsafe_allow_html=True)
|
| 123 |
|
|
|
|
| 144 |
</script>
|
| 145 |
""", unsafe_allow_html=True)
|
| 146 |
|
| 147 |
+
# Initialize session state with complete reset
|
| 148 |
def initialize_session_state():
|
| 149 |
+
required_keys = [
|
| 150 |
+
'app_initialized', 'temp_dir', 'last_activity', 'age_group',
|
| 151 |
+
'category', 'question_index', 'show_answer', 'show_steps',
|
| 152 |
+
'session_initialized', 'auto_progress'
|
| 153 |
+
]
|
| 154 |
+
|
| 155 |
+
for key in required_keys:
|
| 156 |
+
if key not in st.session_state:
|
| 157 |
+
if key == 'app_initialized':
|
| 158 |
+
st.session_state.app_initialized = True
|
| 159 |
+
elif key == 'temp_dir':
|
| 160 |
+
st.session_state.temp_dir = tempfile.mkdtemp()
|
| 161 |
+
elif key == 'last_activity':
|
| 162 |
+
st.session_state.last_activity = time.time()
|
| 163 |
+
elif key == 'age_group':
|
| 164 |
+
st.session_state.age_group = None
|
| 165 |
+
elif key == 'category':
|
| 166 |
+
st.session_state.category = None
|
| 167 |
+
elif key == 'question_index':
|
| 168 |
+
st.session_state.question_index = 0
|
| 169 |
+
elif key == 'show_answer':
|
| 170 |
+
st.session_state.show_answer = False
|
| 171 |
+
elif key == 'show_steps':
|
| 172 |
+
st.session_state.show_steps = False
|
| 173 |
+
elif key == 'session_initialized':
|
| 174 |
+
st.session_state.session_initialized = False
|
| 175 |
+
elif key == 'auto_progress':
|
| 176 |
+
st.session_state.auto_progress = True
|
| 177 |
|
| 178 |
initialize_session_state()
|
| 179 |
|
|
|
|
| 188 |
<span>🐯</span>
|
| 189 |
</div>
|
| 190 |
<div class="fun-title">
|
| 191 |
+
Welcome to Math Adventure Land!
|
| 192 |
</div>
|
| 193 |
<div style="text-align: center; font-size: 24px; color: #FF6B6B; font-family: 'Comic Neue', cursive;">
|
| 194 |
+
Where Numbers Become Friends!
|
| 195 |
</div>
|
| 196 |
</div>
|
| 197 |
""", unsafe_allow_html=True)
|
|
|
|
| 205 |
|
| 206 |
# SIDEBAR - Clean and stable
|
| 207 |
with st.sidebar:
|
| 208 |
+
st.markdown("### Quick Help Guide")
|
| 209 |
|
| 210 |
st.markdown("""
|
| 211 |
<div class="help-box">
|
| 212 |
+
<h4>How to Play:</h4>
|
| 213 |
<p>1. Choose your age group<br>
|
| 214 |
2. Pick a math category<br>
|
| 215 |
3. Solve the fun problems!<br>
|
|
|
|
| 218 |
""", unsafe_allow_html=True)
|
| 219 |
|
| 220 |
# Auto-progress toggle
|
| 221 |
+
st.markdown("### Settings")
|
| 222 |
auto_progress = st.toggle("Auto-Progress", value=st.session_state.auto_progress,
|
| 223 |
help="Automatically move to next category when finished")
|
| 224 |
|
|
|
|
| 226 |
st.session_state.auto_progress = auto_progress
|
| 227 |
st.rerun()
|
| 228 |
|
| 229 |
+
st.markdown("### Achievement Tips")
|
| 230 |
st.info("""
|
| 231 |
+
Pro Tips:
|
| 232 |
- Take your time with each problem
|
| 233 |
- Use the hints when you need help
|
| 234 |
+
- Practice makes perfect!
|
| 235 |
""")
|
| 236 |
|
| 237 |
# MAIN CONTENT AREA
|
|
|
|
| 242 |
st.session_state.last_activity = time.time()
|
| 243 |
|
| 244 |
# Age group selection
|
| 245 |
+
selected_age_group = st.selectbox("Choose Your Adventure Level:", list(age_groups.keys()))
|
| 246 |
|
| 247 |
+
# Force reset when age group changes
|
| 248 |
+
if st.session_state.age_group != selected_age_group:
|
| 249 |
st.session_state.age_group = selected_age_group
|
| 250 |
st.session_state.category = None
|
| 251 |
st.session_state.question_index = 0
|
| 252 |
st.session_state.show_answer = False
|
| 253 |
st.session_state.show_steps = False
|
| 254 |
st.session_state.session_initialized = True
|
| 255 |
+
st.rerun()
|
| 256 |
|
| 257 |
# Load dataset
|
| 258 |
group_info = age_groups[selected_age_group]
|
|
|
|
| 270 |
with zipfile.ZipFile(zip_path, "r") as zip_ref:
|
| 271 |
zip_ref.extractall(temp_image_folder)
|
| 272 |
except Exception as e:
|
| 273 |
+
st.warning(f"Could not extract images: {e}")
|
| 274 |
|
| 275 |
if not os.path.exists(dataset_path):
|
| 276 |
+
st.error(f"Dataset not found: {dataset_path}")
|
| 277 |
st.stop()
|
| 278 |
|
| 279 |
try:
|
| 280 |
df = pd.read_excel(dataset_path)
|
| 281 |
df['category'] = df['category'].astype(str).str.strip()
|
| 282 |
except Exception as e:
|
| 283 |
+
st.error(f"Error loading dataset: {e}")
|
| 284 |
st.stop()
|
| 285 |
|
| 286 |
# Category selection
|
| 287 |
categories = sorted(df['category'].dropna().unique())
|
| 288 |
+
category_emojis = {"Addition": "+", "Subtraction": "-", "Multiplication": "×", "Division": "÷", "Geometry": "📐", "Algebra": "📊"}
|
| 289 |
+
selected_category = st.selectbox("Choose Your Math Quest:", options=categories)
|
| 290 |
|
| 291 |
# Update session if category changes
|
| 292 |
if st.session_state.category != selected_category:
|
|
|
|
| 299 |
# Filter questions by selected category only
|
| 300 |
subset_df = df[df['category'] == selected_category].reset_index(drop=True)
|
| 301 |
|
| 302 |
+
# MATH QUESTIONS SECTION
|
| 303 |
if not subset_df.empty and st.session_state.question_index < len(subset_df):
|
| 304 |
question = subset_df.iloc[st.session_state.question_index]
|
| 305 |
progress = int((st.session_state.question_index / len(subset_df)) * 100)
|
|
|
|
| 308 |
st.markdown(f"""
|
| 309 |
<div style="text-align: center; margin: 20px 0;">
|
| 310 |
<div style="font-family: 'Comic Neue', cursive; color: #FF6B6B; font-size: 18px;">
|
| 311 |
+
Progress: {st.session_state.question_index + 1} of {len(subset_df)}
|
| 312 |
</div>
|
| 313 |
<div class="progress-bar">
|
| 314 |
<div class="progress-fill" style="width: {progress}%;"></div>
|
|
|
|
| 317 |
""", unsafe_allow_html=True)
|
| 318 |
|
| 319 |
# Display question - NO ANIMATIONS
|
| 320 |
+
category_emoji = category_emojis.get(selected_category, "?")
|
| 321 |
st.markdown(f"""
|
| 322 |
<div class="question-box">
|
| 323 |
<div style="text-align: center; font-size: 30px; margin-bottom: 15px;">
|
| 324 |
+
Challenge {st.session_state.question_index + 1}
|
| 325 |
</div>
|
| 326 |
+
<b>Math Quest:</b><br><br>
|
| 327 |
{question['problem']}
|
| 328 |
</div>
|
| 329 |
""", unsafe_allow_html=True)
|
|
|
|
| 342 |
except:
|
| 343 |
pass
|
| 344 |
if not image_found:
|
| 345 |
+
st.warning("Image not available")
|
| 346 |
|
| 347 |
# Answer input
|
| 348 |
+
user_ans = st.text_input("Your Answer:", key=f"ans_{st.session_state.question_index}")
|
| 349 |
|
| 350 |
# Action buttons
|
| 351 |
col_btn1, col_btn2, col_btn3 = st.columns([1, 1, 1])
|
| 352 |
|
| 353 |
with col_btn1:
|
| 354 |
+
if st.button("Submit Answer", key=f"submit_{st.session_state.question_index}", use_container_width=True):
|
| 355 |
st.session_state.last_activity = time.time()
|
| 356 |
if str(user_ans).strip().lower() == str(question['answer']).strip().lower():
|
| 357 |
+
# SIMPLE SUCCESS MESSAGE - NO ANIMATIONS
|
| 358 |
+
st.success("CORRECT! Great job!")
|
| 359 |
|
| 360 |
success_messages = [
|
| 361 |
+
"You're a math superstar!",
|
| 362 |
+
"Excellent work!",
|
| 363 |
+
"Brilliant answer!",
|
| 364 |
+
"Perfect!",
|
| 365 |
+
"Outstanding!"
|
| 366 |
]
|
| 367 |
|
| 368 |
st.markdown(f"""
|
|
|
|
| 379 |
st.session_state.last_activity = time.time()
|
| 380 |
st.rerun()
|
| 381 |
else:
|
| 382 |
+
st.error("Not quite right. Try again!")
|
| 383 |
st.session_state.show_answer = True
|
| 384 |
st.session_state.show_steps = False
|
| 385 |
|
| 386 |
with col_btn2:
|
| 387 |
+
if st.button("Show Hint", key=f"hint_{st.session_state.question_index}", use_container_width=True):
|
| 388 |
st.session_state.last_activity = time.time()
|
| 389 |
st.session_state.show_answer = True
|
| 390 |
+
st.info("Need some help? Here's the answer below!")
|
| 391 |
|
| 392 |
with col_btn3:
|
| 393 |
+
if st.button("Skip", key=f"skip_{st.session_state.question_index}", use_container_width=True):
|
| 394 |
st.session_state.last_activity = time.time()
|
| 395 |
st.session_state.question_index += 1
|
| 396 |
st.session_state.show_answer = False
|
|
|
|
| 401 |
|
| 402 |
# Show answer
|
| 403 |
if st.session_state.show_answer:
|
| 404 |
+
st.info(f"Correct Answer: {question['answer']}")
|
| 405 |
|
| 406 |
if selected_age_group in ["🚀 Math Adventurers (7-9)", "🌟 Math Wizards (13-15)"]:
|
| 407 |
+
if st.button("Show Steps", key=f"steps_{st.session_state.question_index}"):
|
| 408 |
st.session_state.last_activity = time.time()
|
| 409 |
st.session_state.show_steps = True
|
| 410 |
if st.session_state.show_steps and pd.notna(question.get("steps", None)):
|
| 411 |
+
st.success(f"Step-by-Step Solution:\n{question['steps']}")
|
| 412 |
|
| 413 |
elif subset_df.empty:
|
| 414 |
+
st.warning("No questions available in this category. Try another one!")
|
| 415 |
else:
|
| 416 |
+
# COMPLETION MESSAGE - NO ANIMATIONS
|
| 417 |
st.markdown("""
|
| 418 |
<div class="completion-message">
|
|
|
|
|
|
|
|
|
|
| 419 |
<h1 style="font-family: 'Comic Neue', cursive;">
|
| 420 |
+
CONGRATULATIONS!
|
| 421 |
</h1>
|
| 422 |
<p style="font-size: 24px;">
|
| 423 |
You've completed all challenges in this category!
|
|
|
|
| 425 |
</div>
|
| 426 |
""", unsafe_allow_html=True)
|
| 427 |
|
|
|
|
|
|
|
| 428 |
# Auto-progress logic
|
| 429 |
if st.session_state.auto_progress:
|
| 430 |
st.markdown("""
|
|
|
|
| 450 |
|
| 451 |
st.rerun()
|
| 452 |
else:
|
| 453 |
+
if st.button("Start New Adventure", use_container_width=True):
|
| 454 |
st.session_state.last_activity = time.time()
|
| 455 |
st.session_state.question_index = 0
|
| 456 |
st.session_state.show_answer = False
|
|
|
|
| 458 |
st.rerun()
|
| 459 |
|
| 460 |
with col2:
|
| 461 |
+
st.markdown("### Fun Zone")
|
| 462 |
st.markdown("""
|
| 463 |
<div style="text-align: center; font-size: 40px; margin: 20px 0;">
|
| 464 |
🎪<br>✨<br>🌟
|
| 465 |
</div>
|
| 466 |
""", unsafe_allow_html=True)
|
| 467 |
|
| 468 |
+
st.markdown("### Progress")
|
| 469 |
if not subset_df.empty:
|
| 470 |
completed = min(st.session_state.question_index, len(subset_df))
|
| 471 |
st.metric("Completed", f"{completed}/{len(subset_df)}")
|