lanna_lalala;- commited on
Commit
d03d1fd
Β·
1 Parent(s): fdb7966

lesson css try

Browse files
Files changed (1) hide show
  1. phase/Student_view/lesson.py +37 -54
phase/Student_view/lesson.py CHANGED
@@ -273,14 +273,12 @@ def _render_catalog():
273
  margin-bottom: 1rem;
274
  height: 100%;
275
  }
276
-
277
  .card-header {
278
  display: flex;
279
  justify-content: space-between;
280
  align-items: flex-start;
281
  margin-bottom: 1rem;
282
  }
283
-
284
  .level-badge {
285
  background: #f8f9fa;
286
  color: #6c757d;
@@ -289,26 +287,18 @@ def _render_catalog():
289
  font-size: 0.875rem;
290
  font-weight: 500;
291
  }
292
-
293
- .card-icon {
294
- font-size: 1.5rem;
295
- color: #28a745;
296
- }
297
-
298
  .card-title {
299
  font-size: 1.25rem;
300
  font-weight: 600;
301
  color: #212529;
302
  margin: 0.5rem 0;
303
  }
304
-
305
  .card-description {
306
  color: #6c757d;
307
  font-size: 0.95rem;
308
  line-height: 1.4;
309
  margin-bottom: 1rem;
310
  }
311
-
312
  .card-meta {
313
  display: flex;
314
  justify-content: space-between;
@@ -317,17 +307,14 @@ def _render_catalog():
317
  color: #6c757d;
318
  font-size: 0.875rem;
319
  }
320
-
321
  .meta-item {
322
  display: flex;
323
  align-items: center;
324
  gap: 0.25rem;
325
  }
326
-
327
  .learn-section {
328
  margin: 1rem 0;
329
  }
330
-
331
  .learn-title {
332
  font-size: 0.75rem;
333
  font-weight: 600;
@@ -336,96 +323,92 @@ def _render_catalog():
336
  letter-spacing: 0.5px;
337
  margin-bottom: 0.5rem;
338
  }
339
-
340
  .learn-item {
341
  color: #28a745;
342
  font-size: 0.9rem;
343
  margin-bottom: 0.25rem;
344
  }
345
-
346
- .primary-button {
347
- background: #28a745 !important;
348
- color: white !important;
349
  border: none !important;
350
  border-radius: 6px !important;
351
  padding: 0.75rem 1.5rem !important;
352
  font-weight: 500 !important;
353
- width: 100% !important;
354
  margin-top: 1rem !important;
355
  }
356
-
 
 
 
357
  .secondary-button {
358
  background: #f8f9fa !important;
359
  color: #495057 !important;
360
  border: 1px solid #dee2e6 !important;
361
- border-radius: 6px !important;
362
- padding: 0.75rem 1.5rem !important;
363
- font-weight: 500 !important;
364
- width: 100% !important;
365
- margin-top: 1rem !important;
366
  }
367
  </style>
368
  """, unsafe_allow_html=True)
369
 
370
  level = st.session_state.get("level", "beginner")
371
 
372
- # Create columns for cards
373
  cols = st.columns(2, gap="large")
374
 
375
  for i, mod in enumerate(MODULES_META[level]):
376
  with cols[i % 2]:
377
- # Create card container
378
  with st.container():
379
  st.markdown(f"""
380
  <div class="card">
381
  <div class="card-header">
382
  <span class="level-badge">{mod['difficulty']}</span>
383
- <span class="card-icon">{mod['icon']}</span>
384
  </div>
385
-
386
  <h3 class="card-title">{mod['title']}</h3>
387
  <p class="card-description">{mod['description']}</p>
388
-
389
  <div class="card-meta">
390
- <div class="meta-item">
391
- <span>πŸ•’</span>
392
- <span>{mod['duration']}</span>
393
- </div>
394
-
395
  </div>
396
-
397
  <div class="learn-section">
398
- <div class="learn-title">YOU'LL LEARN</div>
399
  """, unsafe_allow_html=True)
400
-
401
- # Add learning objectives
402
- for topic in mod['topics']:
403
  st.markdown(f'<div class="learn-item">β€’ {topic}</div>', unsafe_allow_html=True)
404
-
405
  st.markdown("</div>", unsafe_allow_html=True)
406
-
407
- # Keep the expander as requested
408
  with st.expander("πŸ“‹ All Topics"):
409
  for topic in mod['topics']:
410
  st.write(f"β€’ {topic}")
 
 
 
 
 
 
 
 
411
 
412
- # Action button
413
- button_class = mod.get('button_style', 'primary')
414
- button_text = "Start Learning" if button_class == 'primary' else "Review Module"
415
-
416
- if st.button(
417
- f"{button_text} β†’",
418
- key=f"start_{level}_{mod['id']}",
419
- help=f"Begin the {mod['title']} module"
420
- ):
421
- # Your existing button logic here
 
 
 
 
422
  st.session_state.module_id = mod["id"]
423
  st.session_state.topic_idx = 0
424
  st.session_state.mode = "lesson"
425
  st.rerun()
426
-
427
  st.markdown("</div>", unsafe_allow_html=True)
428
 
 
429
  def _get_topics(level: str, module_id: int) -> List[Tuple[str, str]]:
430
  """
431
  Build the six-topic plan from metadata titles, try backend for each,
 
273
  margin-bottom: 1rem;
274
  height: 100%;
275
  }
 
276
  .card-header {
277
  display: flex;
278
  justify-content: space-between;
279
  align-items: flex-start;
280
  margin-bottom: 1rem;
281
  }
 
282
  .level-badge {
283
  background: #f8f9fa;
284
  color: #6c757d;
 
287
  font-size: 0.875rem;
288
  font-weight: 500;
289
  }
 
 
 
 
 
 
290
  .card-title {
291
  font-size: 1.25rem;
292
  font-weight: 600;
293
  color: #212529;
294
  margin: 0.5rem 0;
295
  }
 
296
  .card-description {
297
  color: #6c757d;
298
  font-size: 0.95rem;
299
  line-height: 1.4;
300
  margin-bottom: 1rem;
301
  }
 
302
  .card-meta {
303
  display: flex;
304
  justify-content: space-between;
 
307
  color: #6c757d;
308
  font-size: 0.875rem;
309
  }
 
310
  .meta-item {
311
  display: flex;
312
  align-items: center;
313
  gap: 0.25rem;
314
  }
 
315
  .learn-section {
316
  margin: 1rem 0;
317
  }
 
318
  .learn-title {
319
  font-size: 0.75rem;
320
  font-weight: 600;
 
323
  letter-spacing: 0.5px;
324
  margin-bottom: 0.5rem;
325
  }
 
326
  .learn-item {
327
  color: #28a745;
328
  font-size: 0.9rem;
329
  margin-bottom: 0.25rem;
330
  }
331
+ .primary-button, .secondary-button {
332
+ width: 100% !important;
 
 
333
  border: none !important;
334
  border-radius: 6px !important;
335
  padding: 0.75rem 1.5rem !important;
336
  font-weight: 500 !important;
 
337
  margin-top: 1rem !important;
338
  }
339
+ .primary-button {
340
+ background: #28a745 !important;
341
+ color: white !important;
342
+ }
343
  .secondary-button {
344
  background: #f8f9fa !important;
345
  color: #495057 !important;
346
  border: 1px solid #dee2e6 !important;
 
 
 
 
 
347
  }
348
  </style>
349
  """, unsafe_allow_html=True)
350
 
351
  level = st.session_state.get("level", "beginner")
352
 
 
353
  cols = st.columns(2, gap="large")
354
 
355
  for i, mod in enumerate(MODULES_META[level]):
356
  with cols[i % 2]:
 
357
  with st.container():
358
  st.markdown(f"""
359
  <div class="card">
360
  <div class="card-header">
361
  <span class="level-badge">{mod['difficulty']}</span>
 
362
  </div>
 
363
  <h3 class="card-title">{mod['title']}</h3>
364
  <p class="card-description">{mod['description']}</p>
 
365
  <div class="card-meta">
366
+ <div class="meta-item">πŸ•’ {mod['duration']}</div>
367
+ <div class="meta-item">πŸ‘₯ {2500 - i * 350}</div>
 
 
 
368
  </div>
 
369
  <div class="learn-section">
370
+ <div class="learn-title">You'll Learn</div>
371
  """, unsafe_allow_html=True)
372
+
373
+ for topic in mod['topics'][:2]:
 
374
  st.markdown(f'<div class="learn-item">β€’ {topic}</div>', unsafe_allow_html=True)
375
+
376
  st.markdown("</div>", unsafe_allow_html=True)
377
+
 
378
  with st.expander("πŸ“‹ All Topics"):
379
  for topic in mod['topics']:
380
  st.write(f"β€’ {topic}")
381
+
382
+ # Dynamic button styling based on completion
383
+ is_completed = mod.get("completed", False)
384
+ btn_label = "Review Module β†’" if is_completed else "Start Learning β†’"
385
+ btn_style = "secondary-button" if is_completed else "primary-button"
386
+
387
+ # Create unique key
388
+ btn_key = f"start_{level}_{mod['id']}"
389
 
390
+ # Render button with custom style
391
+ st.markdown(f"""
392
+ <form action="#">
393
+ <button class="{btn_style}" type="submit">{btn_label}</button>
394
+ </form>
395
+ """, unsafe_allow_html=True)
396
+
397
+ # Actual hidden Streamlit button to handle clicks
398
+ if st.button("", key=btn_key, help=f"Go to {mod['title']}"):
399
+ st.session_state.topics_cache.pop((level, mod["id"]), None)
400
+ try:
401
+ st.cache_data.clear()
402
+ except Exception:
403
+ pass
404
  st.session_state.module_id = mod["id"]
405
  st.session_state.topic_idx = 0
406
  st.session_state.mode = "lesson"
407
  st.rerun()
408
+
409
  st.markdown("</div>", unsafe_allow_html=True)
410
 
411
+
412
  def _get_topics(level: str, module_id: int) -> List[Tuple[str, str]]:
413
  """
414
  Build the six-topic plan from metadata titles, try backend for each,