lanna_lalala;- commited on
Commit
fa3f286
Β·
1 Parent(s): 1f8721e

lesson css try

Browse files
Files changed (1) hide show
  1. phase/Student_view/lesson.py +49 -52
phase/Student_view/lesson.py CHANGED
@@ -420,13 +420,16 @@ def _render_lesson():
420
  """Render the lesson interface"""
421
  level = st.session_state.get("level", "beginner")
422
  module_id = st.session_state.get("module_id")
423
-
424
  if module_id is None:
425
  st.session_state.mode = "catalog"
426
  st.rerun()
427
 
428
  mod = next(m for m in MODULES_META[level] if m["id"] == module_id)
429
 
 
 
 
430
  st.markdown("""
431
  <style>
432
  .lesson-header {
@@ -506,7 +509,7 @@ def _render_lesson():
506
  padding: 1.5rem;
507
  margin-bottom: 1rem;
508
  }
509
- .progress-section h4 {
510
  font-size: 1.1rem;
511
  font-weight: 600;
512
  color: #1f2937;
@@ -568,52 +571,48 @@ def _render_lesson():
568
 
569
  with col_main:
570
  t_title, t_text = topics[topic_idx]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
 
572
  st.markdown(f"""
573
- <div class="lesson-card">
574
- <div class="unit-header">
575
- <span class="unit-info">Unit {topic_idx + 1} of {len(topics)}</span>
576
- <div class="read-time">
577
- <span>πŸ•</span>
578
- <span>5-8 min read</span>
579
- </div>
580
- </div>
581
- <div class="lesson-content">
582
- {t_text.strip() if t_text else "<p>Content coming soon.</p>"}
583
- </div>
584
- """, unsafe_allow_html=True)
585
-
586
- # Conditionally render takeaways inside the card
587
- if t_text:
588
- takeaways = _extract_takeaways(t_text)
589
- if takeaways:
590
- st.markdown(f"""
591
- <div class="takeaways-section">
592
- <div class="takeaways-header">
593
- <span style="color: #10b981;">●</span>
594
- <span>Key Takeaways</span>
595
  </div>
596
- {''.join([
597
- f'<div class="takeaway-item"><span class="takeaway-check">βœ“</span><span>{tk}</span></div>'
598
- for tk in takeaways
599
- ])}
600
  </div>
601
- </div> <!-- Closing lesson-card -->
602
- """, unsafe_allow_html=True)
603
- else:
604
- st.markdown("</div>", unsafe_allow_html=True) # Close .lesson-card
605
- else:
606
- st.markdown("</div>", unsafe_allow_html=True) # Close .lesson-card if no takeaways
607
-
608
 
 
609
  st.markdown('<div class="nav-buttons">', unsafe_allow_html=True)
610
-
611
  col1, col2, col3 = st.columns([1, 1, 1])
612
  with col1:
613
  if st.button("← Previous", disabled=topic_idx == 0, key="prev_btn"):
614
  st.session_state.topic_idx -= 1
615
  st.rerun()
616
-
617
  with col3:
618
  is_last = topic_idx >= len(topics) - 1
619
  if is_last:
@@ -627,40 +626,37 @@ def _render_lesson():
627
  if st.button("Next Unit β†’", key="next_btn"):
628
  st.session_state.topic_idx += 1
629
  st.rerun()
630
-
631
  st.markdown('</div>', unsafe_allow_html=True)
632
 
 
 
 
633
  with col_sidebar:
634
- # Module Progress Card
635
  st.markdown("""
636
- <div class="sidebar-card" style="min-height: 120px;">
637
  <h4>Module Progress</h4>
638
  """, unsafe_allow_html=True)
639
-
640
  progress = (topic_idx + 1) / max(1, len(topics))
641
  st.progress(progress)
642
  st.markdown(f"<p style='color: #6b7280; font-size: 0.875rem; margin-top: 0.5rem;'>Unit {topic_idx + 1} of {len(topics)}</p>", unsafe_allow_html=True)
643
-
644
  st.markdown("</div>", unsafe_allow_html=True)
645
 
646
- # Module Units Card
647
  st.markdown("""
648
- <div class="sidebar-card" style="min-height: 300px;">
649
  <h4>Module Units</h4>
650
  """, unsafe_allow_html=True)
651
-
652
  for i, (tt, _) in enumerate(topics):
653
- is_current = i == topic_idx
654
- is_completed = i < topic_idx
655
-
656
- if is_current:
657
  st.markdown(f"""
658
  <div class="unit-item">
659
  <span style="background: #10b981; color: white; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem;">●</span>
660
  <span class="unit-active">{tt}</span>
661
  </div>
662
  """, unsafe_allow_html=True)
663
- elif is_completed:
664
  st.markdown(f"""
665
  <div class="unit-item">
666
  <span style="color: #10b981; font-size: 1.1rem;">βœ“</span>
@@ -674,10 +670,10 @@ def _render_lesson():
674
  <span class="unit-inactive">{tt}</span>
675
  </div>
676
  """, unsafe_allow_html=True)
677
-
678
  st.markdown("</div>", unsafe_allow_html=True)
679
 
680
- # Back to modules button
681
  if st.button("← Back to Modules", key="back_modules"):
682
  st.session_state.mode = "catalog"
683
  st.session_state.module_id = None
@@ -685,6 +681,7 @@ def _render_lesson():
685
  st.rerun()
686
 
687
 
 
688
  def _render_results():
689
  result = st.session_state.quiz_result or {}
690
  score = result.get("score", {})
 
420
  """Render the lesson interface"""
421
  level = st.session_state.get("level", "beginner")
422
  module_id = st.session_state.get("module_id")
423
+
424
  if module_id is None:
425
  st.session_state.mode = "catalog"
426
  st.rerun()
427
 
428
  mod = next(m for m in MODULES_META[level] if m["id"] == module_id)
429
 
430
+ # -------------------------
431
+ # Styles
432
+ # -------------------------
433
  st.markdown("""
434
  <style>
435
  .lesson-header {
 
509
  padding: 1.5rem;
510
  margin-bottom: 1rem;
511
  }
512
+ .sidebar-card h4 {
513
  font-size: 1.1rem;
514
  font-weight: 600;
515
  color: #1f2937;
 
571
 
572
  with col_main:
573
  t_title, t_text = topics[topic_idx]
574
+ takeaways_html = ""
575
+
576
+ if t_text:
577
+ takeaways = _extract_takeaways(t_text)
578
+ if takeaways:
579
+ takeaways_html = f"""
580
+ <div class="takeaways-section">
581
+ <div class="takeaways-header">
582
+ <span style="color: #10b981;">●</span>
583
+ <span>Key Takeaways</span>
584
+ </div>
585
+ {''.join([
586
+ f'<div class="takeaway-item"><span class="takeaway-check">βœ“</span><span>{tk}</span></div>'
587
+ for tk in takeaways
588
+ ])}
589
+ </div>
590
+ """
591
 
592
  st.markdown(f"""
593
+ <div class="lesson-card">
594
+ <div class="unit-header">
595
+ <span class="unit-info">Unit {topic_idx + 1} of {len(topics)}</span>
596
+ <div class="read-time">
597
+ <span>πŸ•</span>
598
+ <span>5-8 min read</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  </div>
 
 
 
 
600
  </div>
601
+ <div class="lesson-content">
602
+ {t_text.strip() if t_text else "<p>Content coming soon.</p>"}
603
+ </div>
604
+ {takeaways_html}
605
+ </div>
606
+ """, unsafe_allow_html=True)
 
607
 
608
+ # Navigation Buttons OUTSIDE lesson card
609
  st.markdown('<div class="nav-buttons">', unsafe_allow_html=True)
 
610
  col1, col2, col3 = st.columns([1, 1, 1])
611
  with col1:
612
  if st.button("← Previous", disabled=topic_idx == 0, key="prev_btn"):
613
  st.session_state.topic_idx -= 1
614
  st.rerun()
615
+
616
  with col3:
617
  is_last = topic_idx >= len(topics) - 1
618
  if is_last:
 
626
  if st.button("Next Unit β†’", key="next_btn"):
627
  st.session_state.topic_idx += 1
628
  st.rerun()
 
629
  st.markdown('</div>', unsafe_allow_html=True)
630
 
631
+ # -----------------------------
632
+ # Sidebar with Progress & Units
633
+ # -----------------------------
634
  with col_sidebar:
635
+ # Progress Card
636
  st.markdown("""
637
+ <div class="sidebar-card">
638
  <h4>Module Progress</h4>
639
  """, unsafe_allow_html=True)
 
640
  progress = (topic_idx + 1) / max(1, len(topics))
641
  st.progress(progress)
642
  st.markdown(f"<p style='color: #6b7280; font-size: 0.875rem; margin-top: 0.5rem;'>Unit {topic_idx + 1} of {len(topics)}</p>", unsafe_allow_html=True)
 
643
  st.markdown("</div>", unsafe_allow_html=True)
644
 
645
+ # Units Card
646
  st.markdown("""
647
+ <div class="sidebar-card">
648
  <h4>Module Units</h4>
649
  """, unsafe_allow_html=True)
650
+
651
  for i, (tt, _) in enumerate(topics):
652
+ if i == topic_idx:
 
 
 
653
  st.markdown(f"""
654
  <div class="unit-item">
655
  <span style="background: #10b981; color: white; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem;">●</span>
656
  <span class="unit-active">{tt}</span>
657
  </div>
658
  """, unsafe_allow_html=True)
659
+ elif i < topic_idx:
660
  st.markdown(f"""
661
  <div class="unit-item">
662
  <span style="color: #10b981; font-size: 1.1rem;">βœ“</span>
 
670
  <span class="unit-inactive">{tt}</span>
671
  </div>
672
  """, unsafe_allow_html=True)
673
+
674
  st.markdown("</div>", unsafe_allow_html=True)
675
 
676
+ # Back Button
677
  if st.button("← Back to Modules", key="back_modules"):
678
  st.session_state.mode = "catalog"
679
  st.session_state.module_id = None
 
681
  st.rerun()
682
 
683
 
684
+
685
  def _render_results():
686
  result = st.session_state.quiz_result or {}
687
  score = result.get("score", {})