elkay: undo lesson.py 506-521
Browse files
phase/Student_view/lesson.py
CHANGED
|
@@ -504,13 +504,17 @@ 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 |
cache_key = (level, module_id)
|
| 508 |
-
|
| 509 |
-
|
| 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:
|
|
|
|
| 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:
|