elkay: lesson.py 506-521
Browse files
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 |
-
|
| 513 |
-
|
|
|
|
| 514 |
|
| 515 |
-
plan = _topic_plan(level, module_id)
|
| 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:
|