Kerikim commited on
Commit
abad1ed
·
1 Parent(s): e8cc6c5

elkay: lesson.py 506-521

Browse files
Files changed (1) hide show
  1. phase/Student_view/lesson.py +4 -8
phase/Student_view/lesson.py CHANGED
@@ -504,17 +504,13 @@ def _render_lesson():
504
  st.button(label, key=f"jump_{i}", on_click=lambda j=i: st.session_state.update({"topic_idx": j}) or st.rerun())
505
 
506
  def _get_topics(level: str, module_id: int) -> List[Tuple[str, str]]:
507
- """
508
- Build the six-topic plan from metadata titles, try backend for each,
509
- and if content is missing, provide a short fallback paragraph.
510
- """
511
  cache_key = (level, module_id)
512
- if cache_key in st.session_state.topics_cache:
513
- return st.session_state.topics_cache[cache_key]
 
514
 
515
- plan = _topic_plan(level, module_id) # six titles max
516
  out: List[Tuple[str, str]] = []
517
-
518
  for idx in range(len(plan)):
519
  title, content = _fetch_topic_from_backend(level, module_id, idx)
520
  if not content:
 
504
  st.button(label, key=f"jump_{i}", on_click=lambda j=i: st.session_state.update({"topic_idx": j}) or st.rerun())
505
 
506
  def _get_topics(level: str, module_id: int) -> List[Tuple[str, str]]:
 
 
 
 
507
  cache_key = (level, module_id)
508
+ cached = st.session_state.topics_cache.get(cache_key)
509
+ if isinstance(cached, list) and len(cached) > 0: # only trust non-empty cache
510
+ return cached
511
 
512
+ plan = _topic_plan(level, module_id)
513
  out: List[Tuple[str, str]] = []
 
514
  for idx in range(len(plan)):
515
  title, content = _fetch_topic_from_backend(level, module_id, idx)
516
  if not content: