keeps the markup one raw HTML block for Markdown.
st.markdown(
- f'
\n{radar_chart_svg(axes)}\n
',
+ f'
\n{radar_chart_svg(axes, size=size)}\n
',
unsafe_allow_html=True,
)
@@ -378,6 +378,7 @@ def render_course_radar_chart(
*,
focus_topic_id: str | None = None,
limit: int = 6,
+ size: int = 320,
key: str,
) -> None:
"""Draw the course's Learning Radar chart with its captions."""
@@ -387,7 +388,7 @@ def render_course_radar_chart(
with st.container(key=key):
if not axes:
return
- _render_svg(axes)
+ _render_svg(axes, size)
st.caption(tr("Students stuck per topic"))
if not any(axis.value > 0 for axis in axes):
st.caption(tr("No topics have been flagged yet."))
diff --git a/components/topic_explanation.py b/components/topic_explanation.py
index 52b7bca..02e41a8 100644
--- a/components/topic_explanation.py
+++ b/components/topic_explanation.py
@@ -1,4 +1,5 @@
"""On-demand topic teaching, with existing course examples available offline."""
+from services.ui_help import help_tip
import hashlib
import streamlit as st
@@ -18,48 +19,86 @@ def render_topic_explanation(course: StudyPackage, topic_id: str) -> None:
(course.model_dump_json() + topic_id + str(chinese)).encode()
).hexdigest()
with st.container(key="topic_teaching_content"):
- st.caption(tr("Go beyond the summary: understand the idea, then work through an example."))
- if st.button(tr("Explain step by step"), key=f"graph_explain_{fingerprint}"):
- language = "Simplified Chinese" if chinese else "English"
- prompt = (
- f"Explain this selected topic in {language} for a student who found the summary too abstract. "
- "Use short numbered sections: 1. Intuition in everyday language; "
- "2. Key conditions or steps and why each matters; "
- "3. One simple worked example with each reasoning step; "
- "4. A common mistake and how to avoid it; 5. One self-check question. "
- "Label any illustrative example as an example, not a quotation from the course. "
- "Use only the supported concepts; explicitly acknowledge missing context. "
- "Do not merely repeat the summary."
- )
- with st.spinner(tr("Preparing the explanation…")):
- result = ask_tutor(course.model_dump(mode="json"), prompt, topic_id)
- if result.get("ok") and result.get("answer", "").strip():
- st.session_state["graph_topic_explanation"] = {
- "fingerprint": fingerprint, "answer": result["answer"]
- }
- else:
- st.warning(tr("The explanation is unavailable. You can still read the course example below, or try again."))
- saved = st.session_state.get("graph_topic_explanation", {})
- if saved.get("fingerprint") == fingerprint:
- st.caption(tr("AI explanation · check it against your course material."))
- st.write(saved["answer"])
+ from services.demo_teaching import calculus_lesson
+ from services.demo_updates import FILES
+ lesson = calculus_lesson(topic_id, chinese) if course.course_id == 'calculus-i-demo' else None
+ if lesson:
+ steps, worked, mistake = lesson
+ st.subheader(tr("Step-by-step explanation"))
+ for number, step in enumerate(steps, 1):
+ st.write(f"{number}. {step}")
+ with st.container(border=True, key="topic_worked_example"):
+ st.markdown('**' + tr('Worked example') + '**')
+ st.write(worked)
+ st.caption(tr('Common mistake') + ': ' + mistake)
+ elif course.course_id in FILES:
+ st.subheader(tr("Step-by-step explanation"))
+ st.write(topic.summary)
+ first = next((q for q in course.questions if q.topic_id == topic_id), None)
+ if first:
+ st.markdown('**' + tr('Worked example') + '**')
+ st.write(first.question)
+ st.write(first.explanation)
+ else:
+ st.caption(tr("Go beyond the summary: understand the idea, then work through an example."))
+ if st.button(tr("Explain step by step"), key=f"graph_explain_{fingerprint}"):
+ language = "Simplified Chinese" if chinese else "English"
+ prompt = (
+ f"Explain this selected topic in {language} for a student who found the summary too abstract. "
+ "Use short numbered sections: 1. Intuition in everyday language; "
+ "2. Key conditions or steps and why each matters; "
+ "3. One simple worked example with each reasoning step; "
+ "4. A common mistake and how to avoid it; 5. One self-check question. "
+ "Label any illustrative example as an example, not a quotation from the course. "
+ "Use only the supported concepts; explicitly acknowledge missing context. "
+ "Do not merely repeat the summary."
+ )
+ with st.spinner(tr("Preparing the explanation…")):
+ result = ask_tutor(course.model_dump(mode="json"), prompt, topic_id)
+ if result.get("ok") and result.get("answer", "").strip():
+ st.session_state["graph_topic_explanation"] = {
+ "fingerprint": fingerprint, "answer": result["answer"]
+ }
+ else:
+ st.warning(tr("The explanation is unavailable. You can still read the course example below, or try again."))
+ saved = st.session_state.get("graph_topic_explanation", {})
+ if saved.get("fingerprint") == fingerprint:
+ st.caption(tr("AI explanation · check it against your course material."))
+ st.write(saved["answer"])
examples = [question for question in course.questions if question.topic_id == topic_id]
- st.markdown(tr("**Example from this course**"))
- st.caption(tr("Original course wording is preserved. Reading examples does not count as a graded attempt."))
+ st.subheader(tr("Example from this course"))
if not examples:
st.caption(tr("There is no example for this topic in the current course yet."))
return
- example = st.selectbox(
- tr("Choose an example"), examples,
- format_func=lambda item: item.question,
- key=f"graph_example_{fingerprint}",
- )
- st.write(example.question)
- for index, option in enumerate(example.options):
- st.write(f"{chr(65 + index)}. {option}")
- if st.checkbox(tr("Show answer and explanation"), key=f"graph_solution_{fingerprint}_{example.id}"):
- st.markdown(tr("**Answer**"))
- st.write(f"{chr(65 + example.correct_index)}. {example.options[example.correct_index]}")
- st.markdown(tr("**Why this answer**"))
- st.write(example.explanation)
+ by_id = {item.id: item for item in examples}
+ selected_key = f'graph_selected_example_{fingerprint}'
+ selected = st.session_state.get(selected_key)
+ if selected not in by_id:
+ def choose_example():
+ st.session_state[selected_key] = st.session_state.get(f'graph_example_{fingerprint}')
+ st.selectbox(
+ tr("Choose an example"), list(by_id), index=None,
+ format_func=lambda item: by_id[item].question,
+ key=f"graph_example_{fingerprint}", on_change=choose_example,
+ placeholder=tr('Choose an example'),
+ )
+ return
+ example = by_id[selected]
+ from services.practice_pages_ui import render_question_heading
+ with st.container(border=True, key=f"topic_example_card_{fingerprint}"):
+ render_question_heading(examples.index(example) + 1, example.question)
+ st.radio(tr('Choose an answer'), list(range(len(example.options))), index=None,
+ format_func=lambda i: f"{chr(65+i)}. {example.options[i]}",
+ key=f'graph_example_answer_{fingerprint}_{example.id}')
+ if st.checkbox(tr("Show answer and explanation"), key=f"graph_solution_{fingerprint}_{example.id}"):
+ st.markdown(tr("**Answer**"))
+ st.write(f"{chr(65 + example.correct_index)}. {example.options[example.correct_index]}")
+ st.markdown(tr("**Why this answer**"))
+ st.write(example.explanation)
+ with st.container(key='example_footer'):
+ help_tip(tr("Original course wording is preserved. Reading examples does not count as a graded attempt."))
+ def change_example():
+ st.session_state.pop(selected_key, None)
+ st.session_state.pop(f'graph_example_{fingerprint}', None)
+ st.button(tr('Change example'), key=f'graph_change_example_{fingerprint}', on_click=change_example)
diff --git a/design-system/exampilot/MASTER.md b/design-system/exampilot/MASTER.md
index bee4d36..2f5e280 100644
--- a/design-system/exampilot/MASTER.md
+++ b/design-system/exampilot/MASTER.md
@@ -28,6 +28,18 @@ Design Token provides primitive → semantic → component architecture. Heurist
## Verification
+## Content and motion refinement
+
+The next heuristic pass prioritizes an uninterrupted demo (severity 3), explicit example selection (3), oversized chart labels (2), competing Lab actions (2), and redundant persistent explanations (2). All 15 Calculus topics now have offline bilingual reasoning steps, a worked example and a common mistake. Other demo topics retain their own course examples and explanation. No sample history is written into personal results.
+
+Optional instructions use a small question-mark tooltip with a native focus target and associated tooltip text. Hover/focus reveals it; leaving the target or focusing elsewhere hides it. Counts, errors, selected-course context and sample-data attribution remain visible. Topic examples start unselected, hide their picker after choosing, and offer Change example beneath the familiar question card.
+
+Practice progress follows a winding dotted route using the shared SVG plane. A single central loading layer replaces the header flight, with a blurred backdrop, operation text and a parked-plane reduced-motion fallback. The transparent practice margin fades while retaining its grid space, so the question and fixed landscape do not stretch or jump. Lab practice appears after self-assessment, before a left/right Back/Start again row. Home orders My courses, totals, course cards, Create course; Learning DNA remains available through Progress.
+
+Validation for this pass: 1574 passed, 20 skipped on Python 3.12. Browser checks covered example selection, offline teaching, self-check gating, tooltip focus/show/hide, 375px portrait and 812px landscape bounds, and both login/study loading states with a controlled local delay. Practice panel measurements before/after hiding were identical (x, y, width and background position). No real account database or AI calls were made. The app keeps its light paper theme; OS reduced-motion switching and system text enlargement were not emulated. Reduced-motion rules were reviewed in source.
+
+Skill search fit: the focused loading-feedback/reduced-motion results matched this work. The progressive-disclosure search was too broad; disclosure decisions use the user's explicit instructions and the general recognition/minimalism heuristics rather than an unrelated result.
+
Follow-up section review: topic details now open a dedicated teaching page with offline course examples and optional AI explanation; the map focus survives the return. Learning DNA cards use a paper surface, a top rule and wider gutters. Concept Lab prediction choices have a bordered panel, followed by a separated primary action. Learning Radar uses a 2:1 chart/picker layout and a keyboard-focusable ranking region below; five 8rem rows fit its 40rem viewport. Counts, privacy thresholds and sample-data labelling are unchanged. Desktop and 375px browser checks confirmed the layout, five-row geometry and no horizontal overflow.
Full Python 3.12 suite after integrating main: 1560 passed, 20 skipped. Browser walkthroughs cover desktop, 375px portrait and 812px landscape, including pause/return, retained answers, retained Pilot draft, mobile navigation, panel bounds and focused controls. Reduced-motion rules were inspected in source; OS preference switching was not emulated. No live AI request or production account data was used.
diff --git a/pages/0_Dashboard.py b/pages/0_Dashboard.py
index a977dbd..33884db 100644
--- a/pages/0_Dashboard.py
+++ b/pages/0_Dashboard.py
@@ -1,3 +1,4 @@
+from services.ui_help import help_tip
from hashlib import sha256
from pathlib import Path
from uuid import uuid4
@@ -44,7 +45,7 @@ def load_demo_package(filename: str, expected_course_id: str) -> StudyPackage:
apply_app_styles()
st.title(tr("Your study space"))
-st.caption(tr("Start with one question, or open a course you already study."))
+help_tip(tr("Start with one question, or open a course you already study."))
initialize_courses(st.session_state)
@@ -102,6 +103,146 @@ def load_demo_package(filename: str, expected_course_id: str) -> StudyPackage:
st.session_state.pop(f"practice_entry_{selected_course.course_id}", None)
st.switch_page("pages/2_Practice_Center.py")
+with st.container(key="dashboard_courses_header"):
+ st.subheader(tr("My courses"))
+overview = st.container(key="dashboard_overview")
+
+courses = st.session_state.courses
+# Course creation reruns the page, updating these totals before the course cards.
+with overview:
+ overview_columns = st.columns(3)
+ with overview_columns[0]:
+ st.metric(tr("Courses"), len(courses))
+ with overview_columns[1]:
+ st.metric(
+ tr("Knowledge points"),
+ sum(len(course.topics) for course in courses),
+ )
+ with overview_columns[2]:
+ st.metric(
+ tr("Practice sessions"),
+ sum(
+ len(
+ st.session_state.get(
+ f"practice_history_{course.course_id}", {}
+ )
+ )
+ for course in courses
+ ),
+ )
+
+if not courses:
+ st.info(tr("Create a course to get started."))
+else:
+ for row_start in range(0, len(courses), 2):
+ card_columns = st.columns(2)
+
+ for column, course in zip(
+ card_columns,
+ courses[row_start : row_start + 2],
+ ):
+ with column:
+ with st.container(
+ border=True,
+ key=f"dashboard_course_card_{course.course_id}",
+ ):
+ stage = st.session_state.get(
+ f"course_stage_{course.course_id}"
+ )
+ is_demo = any(
+ course.course_id == demo_id
+ for _, _, demo_id in DEMO_COURSES
+ )
+ st.caption(tr(
+ "Generated course"
+ if stage
+ else ("Demo course" if is_demo else "Your course")
+ ))
+ course_icon, course_details = st.columns([1, 3.5], vertical_alignment="center")
+ with course_icon:
+ st.markdown(
+ '
',
- unsafe_allow_html=True,
- )
- with course_details:
- st.subheader(course.course_name)
- st.caption(
- tr(f"{len(course.topics)} topics · "
- f"{len(course.questions)} practice questions")
- )
-
- if stage == "topics_only":
- st.caption(tr("Next: review topics and choose your exam scope."))
- action_columns = st.columns([1, 1])
- with action_columns[0]:
- if st.button(
- tr("Open course"),
- type="primary",
- key=f"open_course_{course.course_id}",
- use_container_width=True,
- ):
- st.session_state.pop(
- f"pending_course_removal_{course.course_id}", None
- )
- select_course(
- st.session_state,
- course.course_id,
- )
- st.switch_page("pages/1_Study_Hub.py")
-
- if not is_demo:
- with action_columns[1]:
- if st.button(
- tr("Delete course"),
- icon=":material/delete:",
- key=f"remove_course_{course.course_id}",
- type="secondary",
- use_container_width=True,
- help=tr("Review a confirmation before deleting this course."),
- ):
- st.session_state[
- f"pending_course_removal_{course.course_id}"
- ] = True
- st.rerun()
- if not is_demo and st.session_state.get(
- f"pending_course_removal_{course.course_id}", False
- ):
- st.warning(tr(
- f"Delete {course.course_name}? Its materials and practice "
- "progress will be removed from this session."
- ))
- confirmation_columns = st.columns(2)
- with confirmation_columns[0]:
- cancel_removal = st.button(
- tr("Cancel"),
- key=f"cancel_remove_course_{course.course_id}",
- type="secondary",
- use_container_width=True,
- )
- with confirmation_columns[1]:
- confirm_removal = st.button(
- tr("Confirm delete"),
- key=f"confirm_remove_course_{course.course_id}",
- type="secondary",
- use_container_width=True,
- )
- if cancel_removal:
- st.session_state.pop(
- f"pending_course_removal_{course.course_id}", None
- )
- st.rerun()
- if confirm_removal:
- st.session_state.pop(
- f"pending_course_removal_{course.course_id}", None
- )
- remove_course(
- st.session_state,
- course.course_id,
- )
- st.rerun()
diff --git a/pages/12_Learning_Evidence.py b/pages/12_Learning_Evidence.py
index 2a9fb1b..d1577af 100644
--- a/pages/12_Learning_Evidence.py
+++ b/pages/12_Learning_Evidence.py
@@ -3,6 +3,7 @@
Opened from a topic's "View answers" button on Progress. Real practice only:
the example report on the demo courses has no answers to show.
"""
+from services.ui_help import help_tip
import streamlit as st
from components.page_links import back_button
@@ -26,7 +27,7 @@
st.page_link("pages/0_Dashboard.py", label=tr("Back to Dashboard"))
st.stop()
-st.caption(tr("Your latest answer to each question behind your Learning DNA, topic by topic."))
+help_tip(tr("Your latest answer to each question behind your Learning DNA, topic by topic."))
# The same widget key as on Progress, so the chosen mode carries over: the
# "View answers" button keeps that key's value for this page as it switches.
diff --git a/pages/1_Study_Hub.py b/pages/1_Study_Hub.py
index 3b77217..e2e1d40 100644
--- a/pages/1_Study_Hub.py
+++ b/pages/1_Study_Hub.py
@@ -1,3 +1,4 @@
+from services.ui_help import help_tip
from services.i18n import tr
import streamlit as st
@@ -16,7 +17,7 @@
apply_app_styles()
st.title(tr("Study Plan"))
-st.caption(tr("Review course topics and choose the scope for your exam."))
+help_tip(tr("Review course topics and choose the scope for your exam."))
course = st.session_state.get("current_course")
@@ -97,7 +98,7 @@ def render_most_flagged_topics(course, confirmed_key: str) -> None:
with st.container(border=True, key="study_radar_panel"):
st.subheader(tr("Most flagged topics · Top 3"))
- st.caption(tr("Topics students marked \"I'm stuck here\" on the Knowledge Map."))
+ help_tip(tr("Topics students marked \"I'm stuck here\" on the Knowledge Map."))
if not most_flagged:
st.caption(tr("No topics have been flagged yet."))
for rank, topic_radar in enumerate(most_flagged, start=1):
diff --git a/pages/2_Practice_Center.py b/pages/2_Practice_Center.py
index e296679..3e02185 100644
--- a/pages/2_Practice_Center.py
+++ b/pages/2_Practice_Center.py
@@ -1,6 +1,6 @@
+from services.ui_help import help_tip
from services.i18n import tr
from html import escape
-from services.ui_style import BRAND_PLANE
import time
import streamlit as st
@@ -287,7 +287,7 @@ def follow_question(active, question_id):
def setup_heading():
st.title(tr("Practice"))
- st.caption(tr("Choose a mode, then focus on one question at a time."))
+ help_tip(tr("Choose a mode, then focus on one question at a time."))
def choose_topic(course_id, confirmed_topic_ids, topic_names):
@@ -410,7 +410,8 @@ def render_question_screen(course, active, topic_names):
has_panel = radar_on or notes
panel_shown = has_panel and st.session_state.get(f"practice_side_panel_{course.course_id}", True)
- if panel_shown:
+ if has_panel:
+ st.markdown(f'', unsafe_allow_html=True)
paper, margin = st.columns([3, 1], gap="large")
else:
paper, margin = st.container(key="practice_main_full"), None
@@ -449,17 +450,11 @@ def render_question_screen(course, active, topic_names):
with st.container(key="flight_progress_count", width="content"):
st.caption(tr("Question") + f" {index + 1:02} / {len(questions):02}")
with st.container(key="flight_progress_track"):
- stops = min(len(questions), 12)
- current_stop = index * (stops - 1) // max(1, len(questions) - 1)
- markers = "".join(
- '' + BRAND_PLANE.read_text(encoding='utf-8') + '' if step == current_stop
- else ''
- for step in range(stops)
- )
- st.markdown(
- f'
{markers}
',
- unsafe_allow_html=True,
- )
+ from services.paper_progress import progress_route
+ route_key = f'practice_route_index_{sid}'
+ st.markdown(progress_route(index, len(questions), st.session_state.get(route_key)),
+ unsafe_allow_html=True)
+ st.session_state[route_key] = index
with st.container(
key="flight_progress_clock", horizontal=True, width="content", vertical_alignment="center",
gap="xsmall",
diff --git a/pages/3_Performance.py b/pages/3_Performance.py
index b923aee..f316c84 100644
--- a/pages/3_Performance.py
+++ b/pages/3_Performance.py
@@ -1,3 +1,4 @@
+from services.ui_help import help_tip
from services.i18n import tr
import streamlit as st
@@ -18,7 +19,7 @@
apply_app_styles()
st.title(tr("Progress"))
-st.caption(tr("Review practice results and see which topics need more evidence."))
+help_tip(tr("Review practice results and see which topics need more evidence."))
course = st.session_state.get("current_course")
@@ -145,7 +146,7 @@ def heading(text):
kind="mastery",
empty_text="This course has no topics yet.",
)
- st.caption(tr("Mastery uses each distinct question’s latest answer. Total accuracy still includes every graded attempt."))
+ help_tip(tr("Mastery uses each distinct question’s latest answer. Total accuracy still includes every graded attempt."))
with st.container(border=True, key="progress_sessions"):
st.subheader(heading("Accuracy by session"))
@@ -156,7 +157,7 @@ def heading(text):
title=heading("Accuracy by session"),
empty_text="No graded sessions in this mode yet.",
)
- st.caption(tr("Each dot is one graded session, oldest on the left."))
+ help_tip(tr("Each dot is one graded session, oldest on the left."))
with dna_block:
render_learning_dna(
@@ -165,7 +166,7 @@ def heading(text):
)
render_history_insights(report_course, history, mode, example=example is not None)
-st.caption(
+help_tip(
tr("Insufficient evidence means fewer than 3 different questions for that topic "
"in the selected mode. "
"Below 60%: Weak · 60–79.99%: Developing · 80% or above: Mastered.")
diff --git a/pages/4_Knowledge_Graph.py b/pages/4_Knowledge_Graph.py
index e7d9647..0c2e19c 100644
--- a/pages/4_Knowledge_Graph.py
+++ b/pages/4_Knowledge_Graph.py
@@ -1,3 +1,4 @@
+from services.ui_help import help_tip
from services.i18n import tr
from pathlib import Path
@@ -33,7 +34,7 @@
apply_app_styles()
st.title(tr("Knowledge Map"))
-st.caption(tr("Explore connected ideas. Click a topic to read its summary and learning progress."))
+help_tip(tr("Explore connected ideas. Click a topic to read its summary and learning progress."))
course = st.session_state.get("current_course")
@@ -113,7 +114,7 @@
st.session_state[zoom_key] = 0
st.rerun()
with graph_controls[1]:
- st.caption(tr("Click for details · Drag to rearrange · Scroll to zoom"))
+ help_tip(tr("Click for details · Drag to rearrange · Scroll to zoom"))
history_key = f"practice_history_{course.course_id}"
history = st.session_state.get(history_key, {})
@@ -332,16 +333,6 @@
if details is not None:
links = related_topics(course, selected_node_id)
st.divider()
- st.markdown(tr("**Connected topics**"))
- for label, group in (("Prerequisites", "prerequisites"), ("Leads to", "next_topics"), ("Related", "related")):
- if links[group]:
- st.caption(tr(label) + ":" + ", ".join(topic_names[item] for item in links[group]))
- if not any(links.values()):
- st.caption(tr("No connections recorded for this topic."))
- for linked_id in links["prerequisites"]:
- if st.button(tr("Review ") + topic_names[linked_id], key=f"graph_prerequisite_{course.course_id}_{linked_id}"):
- st.session_state[pending_key] = linked_id
- st.rerun()
if st.button(tr("Practise this topic"), key=f"graph_practice_{course.course_id}_{selected_node_id}", type="primary"):
try:
stage_practice(st.session_state, course, selected_node_id)
diff --git a/pages/5_Export_Anki.py b/pages/5_Export_Anki.py
index 10c2efb..ba5e404 100644
--- a/pages/5_Export_Anki.py
+++ b/pages/5_Export_Anki.py
@@ -1,4 +1,5 @@
"""Flashcards: review one card at a time; the Anki export opens on its own page."""
+from services.ui_help import help_tip
from html import escape
import streamlit as st
@@ -61,7 +62,7 @@ def _render_question(card: Flashcard, side: str) -> None:
f'
{options}
',
unsafe_allow_html=True,
)
- st.caption(tr("Think of your answer first, then flip the card."))
+ help_tip(tr("Think of your answer first, then flip the card."))
return
note = ""
@@ -89,7 +90,7 @@ def _render_idea(card: Flashcard, side: str) -> None:
f'
{_text(card.topic_name)}
',
unsafe_allow_html=True,
)
- st.caption(tr("Recall what you know about this idea, then flip the card."))
+ help_tip(tr("Recall what you know about this idea, then flip the card."))
return
st.markdown(
f'
{_text(card.topic_name)}
'
@@ -101,7 +102,7 @@ def _render_idea(card: Flashcard, side: str) -> None:
apply_app_styles()
st.title(tr("Flashcards"))
-st.caption(tr("One card at a time, from your mistakes, weak topics and key ideas."))
+help_tip(tr("One card at a time, from your mistakes, weak topics and key ideas."))
course = st.session_state.get("current_course")
diff --git a/pages/6_Concept_Lab.py b/pages/6_Concept_Lab.py
index 7b9ed8a..9877226 100644
--- a/pages/6_Concept_Lab.py
+++ b/pages/6_Concept_Lab.py
@@ -3,7 +3,7 @@
Each tab keeps its chart on the right and walks through one step at a time on
the left: predict, explore, explain (services/concept_lab_ui.py).
"""
-
+from services.ui_help import help_tip
from services.i18n import tr
import altair as alt
@@ -23,7 +23,7 @@
def practice_topic(topic_id: str, suffix: str = "") -> None:
"""Use the Practice page's existing course-scoped widget contract."""
- if not st.button(tr("Practice this topic"), key=f"concept_lab_practice_{topic_id}{suffix}"):
+ if not st.button(tr("Practice this topic"), key=f"concept_lab_practice_{topic_id}{suffix}", type="primary"):
return
course = st.session_state.get("current_course")
if course is None or course.course_id != "calculus-i-demo":
@@ -48,7 +48,7 @@ def start_step(topic: str) -> int:
apply_app_styles()
st.title(tr("Concept Lab"))
-st.caption(tr("Predict, move the controls, then explain what changed."))
+help_tip(tr("Predict, move the controls, then explain what changed."))
# Values of steps that are not on screen (or were set before leaving the page).
restore_values()
# Written again on every run, not only the first: the browser shows a control's
@@ -87,8 +87,7 @@ def start_step(topic: str) -> int:
observation("limits", "concept_lab_limit_distance")
explore_navigation("limits")
else:
- explanation("limits")
- practice_topic("calc_limits")
+ explanation("limits", lambda: practice_topic("calc_limits"))
# The slider's value, also in the steps that do not draw the slider.
distance = st.session_state["concept_lab_limit_distance"]
selected = limit_table([float(distance)])[0]
@@ -146,7 +145,7 @@ def start_step(topic: str) -> int:
alt.layer(curve, selected_points, hole).properties(height=320),
width="stretch",
)
- st.caption(tr("The open circle at (2, 4) marks a point where f(x) is undefined."))
+ help_tip(tr("The open circle at (2, 4) marks a point where f(x) is undefined."))
left_column, right_column = st.columns(2)
left_column.metric(
@@ -202,8 +201,7 @@ def start_step(topic: str) -> int:
st.session_state['lab_saved_secant'] = {'x0': x0, 'h': h, 'slope': secant_slope(x0, h)}
explore_navigation("derivatives")
else:
- explanation("derivatives")
- practice_topic("calc_derivatives")
+ explanation("derivatives", lambda: practice_topic("calc_derivatives"))
# The controls' values, also in the steps that do not draw them.
x0 = st.session_state["concept_lab_x0"]
h = float(st.session_state["concept_lab_h"])
@@ -251,7 +249,7 @@ def start_step(topic: str) -> int:
])).mark_text(align="left", dx=8, dy=-14, fontSize=13).encode(x="x:Q", y="y:Q", text="Point:N")
with visual:
st.altair_chart(alt.layer(lines, points, labels).properties(height=360), width="stretch")
- st.caption(tr("Blue: function · Green dashed: secant · Red: tangent. Hover over the two points to inspect their coordinates."))
+ help_tip(tr("Blue: function · Green dashed: secant · Red: tangent. Hover over the two points to inspect their coordinates."))
secant_column, derivative_column = st.columns(2)
secant_column.metric(tr("Secant slope"), f"{slope:.6f}")
derivative_column.metric(tr("Derivative f′(x₀)"), f"{cubic_derivative(x0):.6f}")
@@ -281,8 +279,7 @@ def start_step(topic: str) -> int:
observation("corner", "concept_lab_corner_h")
explore_navigation("corner")
else:
- explanation("corner")
- practice_topic('calc_derivatives', '_corner')
+ explanation("corner", lambda: practice_topic("calc_derivatives", "_corner"))
distance = st.session_state["concept_lab_corner_h"]
left, right = corner_slopes(float(distance))
samples = [{'x': -1.2 + i*2.4/200, 'y': abs(-1.2+i*2.4/200)} for i in range(201)]
diff --git a/pages/7_Learning_Radar.py b/pages/7_Learning_Radar.py
index 4a6e815..dcbc753 100644
--- a/pages/7_Learning_Radar.py
+++ b/pages/7_Learning_Radar.py
@@ -1,5 +1,5 @@
"""Learning Radar: where students of the built-in demo courses get stuck."""
-
+from services.ui_help import help_tip
from services.i18n import tr
import streamlit as st
@@ -16,7 +16,7 @@
apply_app_styles()
st.title(tr("Learning Radar"))
-st.caption(tr("See where students get stuck, and mark the topics that stop you."))
+help_tip(tr("See where students get stuck, and mark the topics that stop you."))
course = st.session_state.get("current_course")
@@ -45,7 +45,7 @@
with chart_column:
with st.container(border=True, key="learning_radar_chart_panel"):
render_course_radar_chart(
- course, radar, focus_topic_id=picked, limit=8,
+ course, radar, focus_topic_id=picked, limit=8, size=680,
key="learning_radar_page_chart",
)
with mark_column:
diff --git a/services/concept_lab_ui.py b/services/concept_lab_ui.py
index 6fbbb12..cd8ee67 100644
--- a/services/concept_lab_ui.py
+++ b/services/concept_lab_ui.py
@@ -5,6 +5,7 @@
step. Nothing here adds an exam attempt, a score or a mastery change, and
nothing leaves the session.
"""
+from services.ui_help import help_tip
import html
import streamlit as st
@@ -218,7 +219,7 @@ def _prediction_outcome(topic):
st.info(tr(f'Your prediction was “{tr(checked)}”; the experiment shows “{tr(correct)}”.'))
-def explanation(topic):
+def explanation(topic, practice_action=None):
"""The question, an optional private note, and the answer behind a button.
Nothing of the answer is on the page until "Show answer" is clicked, so the
@@ -231,7 +232,7 @@ def explanation(topic):
st.markdown(f"##### {tr(question)}")
st.text_area(tr('Your explanation'), key=f'lab_{topic}_explanation',
on_change=keep_value, args=(f'lab_{topic}_explanation',))
- st.caption(tr('Only you see this. Write it first, then compare.'))
+ help_tip(tr('Only you see this. Write it first, then compare.'))
st.button(tr('Hide answer') if shown else tr('Show answer'), key=f'lab_{topic}_show_answer',
width='content', on_click=_set_answer_shown, args=(topic, not shown))
if shown:
@@ -239,14 +240,16 @@ def explanation(topic):
st.latex(formula)
st.write(tr(answer))
_prediction_outcome(topic)
+ st.markdown('**' + tr('Self-check') + '**')
with st.container(horizontal=True, horizontal_alignment='left', key=f'lab_{topic}_self_check_row'):
for choice, label in SELF_CHECKS.items():
st.button(tr(label), key=f'lab_{topic}_self_{choice}',
+ type='primary' if st.session_state.get(f'lab_{topic}_self_check') == choice else 'secondary',
on_click=_set_self_check, args=(topic, choice))
- chosen = st.session_state.get(f'lab_{topic}_self_check')
- if chosen in SELF_CHECKS:
- st.caption(tr('Your self-check: ') + tr(SELF_CHECKS[chosen]))
- with st.container(horizontal=True, horizontal_alignment='left', key=f'lab_{topic}_explain_nav'):
+ if st.session_state.get(f'lab_{topic}_self_check') in SELF_CHECKS and practice_action is not None:
+ with st.container(key=f'lab_{topic}_practice_action'):
+ practice_action()
+ with st.container(horizontal=True, horizontal_alignment='distribute', key=f'lab_{topic}_explain_nav'):
_back_button(topic, 2)
st.button(tr('Start again'), key=f'lab_{topic}_start_again',
on_click=reset_experiment, args=(topic,))
diff --git a/services/demo_teaching.py b/services/demo_teaching.py
new file mode 100644
index 0000000..cbfb8bd
--- /dev/null
+++ b/services/demo_teaching.py
@@ -0,0 +1,117 @@
+"""Reviewed offline calculus lessons. No account state or generation required."""
+
+# Three reasoning steps, a worked example and a common mistake, in each UI language.
+LESSONS = {
+ 'calc_limits': (
+ ['A limit describes nearby values, even when the function has a hole.', 'Try substitution first. If it produces 0/0, simplify for nearby inputs.', 'Compare both sides; a two-sided limit requires the same value.'],
+ 'For (x² − 4)/(x − 2), factor the numerator into (x − 2)(x + 2). For x ≠ 2, cancel x − 2. The nearby values equal x + 2, so the limit at 2 is 4.',
+ 'Do not confuse an undefined f(2) with a nonexistent limit.',
+ ['极限描述附近的函数值,即使目标点有空洞也可以有极限。', '先代入;若得到 0/0,再对附近的输入进行化简。', '分别观察左右两侧,双侧极限要求两侧趋向同一个值。'],
+ '(x² − 4)/(x − 2) 的分子分解为 (x − 2)(x + 2)。当 x ≠ 2 时约去 x − 2,附近的函数值等于 x + 2,所以 x 趋近 2 时极限为 4。',
+ 'f(2) 未定义不代表极限不存在。'),
+ 'calc_derivatives': (
+ ['The derivative measures instantaneous change, represented by a tangent slope.', 'Start with the secant quotient [f(x+h) − f(x)]/h, where h ≠ 0.', 'Simplify first, then take h → 0.'],
+ 'For f(x)=x², [(x+h)²−x²]/h = 2x+h. Taking h → 0 gives f′(x)=2x; at x=3 the tangent slope is 6.',
+ 'Substituting h=0 before simplifying creates an undefined quotient.',
+ ['导数是瞬时变化率,也就是切线斜率。', '从割线斜率 [f(x+h) − f(x)]/h 开始,h ≠ 0。', '先化简,再令 h 趋近 0。'],
+ '对 f(x)=x²,差商 [(x+h)²−x²]/h = 2x+h。令 h 趋近 0 得 f′(x)=2x;x=3 处的切线斜率为 6。',
+ '不要在化简之前直接令 h=0。'),
+ 'calc_derivative_applications': (
+ ['A derivative tells whether a function is increasing or decreasing.', 'Find interior critical points where f′=0 or the derivative is undefined.', 'Use sign changes to classify them; check endpoints when finding absolute extrema.'],
+ 'For f(x)=x²−4x on [0,5], f′(x)=2x−4 vanishes at 2. Compare f(0)=0, f(2)=−4 and f(5)=5: the minimum is −4 at 2, and the maximum is 5 at 5.',
+ 'A stationary point is only a candidate; f(x)=x³ has no extremum at 0.',
+ ['导数的符号告诉我们函数在增加还是减少。', '先找区间内部 f′=0 或导数不存在的临界点。', '用符号变化分类;求绝对最值时也要检查端点。'],
+ 'f(x)=x²−4x 在 [0,5] 上的导数为 2x−4,在 x=2 处为零。比较 f(0)=0、f(2)=−4、f(5)=5,最小值是 −4,最大值是 5。',
+ '驻点只是候选点;x³ 在 0 处导数为零但没有极值。'),
+ 'calc_limit_laws': (
+ ['Limits distribute over sums and products when the component limits exist.', 'A quotient law also requires a nonzero denominator limit.', 'If direct substitution is indeterminate, simplify before applying the laws.'],
+ 'As x → 2, x² → 4 and 3x → 6. Therefore x²+3x → 10. For 1/(x−2), the denominator tends to zero, so the quotient law cannot be used.',
+ '0/0 is an indeterminate form, not a value.',
+ ['各部分极限存在时,可以对和、差、积分别取极限。', '商法则还要求分母的极限不为零。', '直接代入出现未定式时,应先化简。'],
+ 'x 趋近 2 时,x² 趋近 4,3x 趋近 6,所以 x²+3x 趋近 10。1/(x−2) 的分母极限为零,不能直接套用商法则。',
+ '0/0 是未定式,不是一个答案。'),
+ 'calc_continuity': (
+ ['Continuity joins the value at a point to the limit around it.', 'Check that f(a) exists and that the two-sided limit exists.', 'Then check that the limit equals f(a).'],
+ 'Let f(x)=(x²−4)/(x−2) for x≠2 and f(2)=k. The limit at 2 is 4, so continuity requires k=4.',
+ 'Matching only one side does not establish continuity.',
+ ['连续性把某点的函数值与附近的极限连接起来。', '检查 f(a) 有定义,且双侧极限存在。', '最后检查极限等于 f(a)。'],
+ '当 x≠2 时令 f(x)=(x²−4)/(x−2),并定义 f(2)=k。因为附近的极限为 4,所以只有 k=4 时函数在 2 处连续。',
+ '只检查一侧是不够的。'),
+ 'calc_trig_limits': (
+ ['The standard limit sin(u)/u → 1 uses radians.', 'Rewrite the expression so the numerator angle and denominator match.', 'Track the extra scale factors outside the standard ratio.'],
+ 'sin(3x)/x = 3·sin(3x)/(3x). As x → 0, the ratio tends to 1, giving a limit of 3.',
+ 'The standard formula is not valid with degree measure.',
+ ['标准极限 sin(u)/u → 1 使用弧度制。', '将式子改写,使分子的角度与分母一致。', '把额外的倍数放在标准比值外面。'],
+ 'sin(3x)/x = 3·sin(3x)/(3x)。x 趋近 0 时,后面的比值趋近 1,所以极限为 3。',
+ '使用角度制时不能直接套用这个标准极限。'),
+ 'calc_differentiation_rules': (
+ ['Identify whether the expression is a sum, product or quotient.', 'Differentiate each part with the corresponding rule.', 'Simplify after applying the rule and respect the original domain.'],
+ 'For f(x)=x²sin(x), use the product rule: f′(x)=2x sin(x)+x² cos(x). Both factors contribute a term.',
+ 'The derivative of a product is not the product of the derivatives.',
+ ['先判断表达式是和、积还是商。', '用对应法则对每个部分求导。', '应用法则后再化简,并保留原定义域的限制。'],
+ 'f(x)=x²sin(x) 使用乘积法则:f′(x)=2x sin(x)+x²cos(x)。两个因子分别求导,得到两项。',
+ '乘积的导数不等于两个导数的乘积。'),
+ 'calc_chain_rule': (
+ ['Identify the outer function and the inner function.', 'Differentiate the outer function while keeping its input unchanged.', 'Multiply by the derivative of the inner function.'],
+ 'For y=(3x²+1)⁴, the outer derivative is 4(3x²+1)³ and the inner derivative is 6x. Therefore y′=24x(3x²+1)³.',
+ 'Do not omit the inner derivative.',
+ ['辨认外层函数和内层函数。', '对外层求导时暂时保留内层不变。', '最后乘以内层函数的导数。'],
+ 'y=(3x²+1)⁴ 的外层求导得到 4(3x²+1)³,内层导数是 6x,因此 y′=24x(3x²+1)³。',
+ '不要漏乘内层导数。'),
+ 'calc_implicit_differentiation': (
+ ['Treat y as a function of x even when it is not isolated.', 'Differentiate both sides, using the chain rule on every y term.', 'Collect the y′ terms and solve where their coefficient is nonzero.'],
+ 'From x²+y²=25, differentiation gives 2x+2y y′=0. Thus y′=−x/y for y≠0. At (3,4), the slope is −3/4.',
+ 'Differentiating y² gives 2y y′, not just 2y.',
+ ['即使没有解出 y,也要把 y 当作 x 的函数。', '两边对 x 求导,含 y 的项使用链式法则。', '收集 y′ 并求解,注意不能除以零。'],
+ '由 x²+y²=25 得 2x+2y y′=0,所以 y≠0 时 y′=−x/y。在 (3,4) 处斜率为 −3/4。',
+ 'y² 对 x 求导是 2y y′,不能漏掉 y′。'),
+ 'calc_related_rates': (
+ ['Write an equation connecting quantities that change with time.', 'Differentiate the equation with respect to time before substituting the snapshot values.', 'Insert the given rates and state units for the unknown rate.'],
+ 'For a circle A=πr², dA/dt=2πr·dr/dt. At r=3 cm and dr/dt=2 cm/s, dA/dt=12π cm²/s.',
+ 'Substituting a changing radius as a constant before differentiating loses its rate.',
+ ['写出随时间变化的量之间的关系式。', '先对时间求导,再代入某一时刻的数值。', '代入已知变化率,求出未知变化率并写上单位。'],
+ '圆面积 A=πr²,所以 dA/dt=2πr·dr/dt。当 r=3 cm、dr/dt=2 cm/s 时,面积变化率为 12π cm²/s。',
+ '不要在求导前就把变化中的半径替换成常数。'),
+ 'calc_mean_value_theorem': (
+ ['Verify continuity on [a,b] and differentiability on (a,b).', 'Compute the average slope [f(b)−f(a)]/(b−a).', 'Find an interior point c with f′(c) equal to that average.'],
+ 'For f(x)=x² on [1,3], the average slope is (9−1)/2=4. Since f′(c)=2c, c=2 satisfies the theorem.',
+ 'Without the hypotheses the theorem does not guarantee such a point.',
+ ['先验证在闭区间 [a,b] 上连续,在开区间 (a,b) 内可导。', '计算平均斜率 [f(b)−f(a)]/(b−a)。', '寻找内部点 c,使 f′(c) 等于平均斜率。'],
+ 'f(x)=x² 在 [1,3] 上的平均斜率为 (9−1)/2=4。由 f′(c)=2c=4 得 c=2。',
+ '不满足条件时,中值定理不能保证这个点存在。'),
+ 'calc_curve_sketching': (
+ ['Check domain, intercepts and limiting behavior.', 'Use f′ to find increasing/decreasing intervals and extrema.', 'Use changes in the sign of f″ to identify concavity and inflection points.'],
+ 'For f(x)=x³−3x, f′=3(x²−1) gives critical points −1 and 1. Its signs are +,−,+, so there is a local maximum at −1 and minimum at 1. f″=6x changes sign at 0, giving an inflection point.',
+ 'f″=0 alone does not guarantee an inflection point; concavity must change.',
+ ['先检查定义域、截距和极限行为。', '用 f′ 的符号判断增减区间及极值。', '用 f″ 的符号变化判断凹凸性和拐点。'],
+ 'f(x)=x³−3x 的导数为 3(x²−1),临界点是 −1 和 1。导数符号依次为正、负、正,所以 −1 处极大,1 处极小。f″=6x 在 0 两侧变号,因此 0 是拐点。',
+ '仅有 f″=0 不够,凹凸性必须发生变化。'),
+ 'calc_antiderivatives': (
+ ['An antiderivative reverses differentiation.', 'For xⁿ with n≠−1, increase the exponent by one and divide by the new exponent.', 'Add the constant C and differentiate your result to check it.'],
+ '∫(3x²+2) dx = x³+2x+C. Differentiating x³+2x+C gives 3x²+2, confirming the result.',
+ 'The power rule excludes x⁻¹; its antiderivative is ln|x|+C on intervals away from 0.',
+ ['原函数是求导的逆过程。', '对 xⁿ 且 n≠−1,指数加一,再除以新指数。', '加上常数 C,最后求导检查。'],
+ '∫(3x²+2) dx = x³+2x+C。对结果求导重新得到 3x²+2,说明计算正确。',
+ '幂函数积分公式不适用于 x⁻¹;远离 0 的区间上其原函数为 ln|x|+C。'),
+ 'calc_definite_integrals': (
+ ['A definite integral accumulates signed contributions over an interval.', 'Approximate it with sums of height times width, or use an antiderivative.', 'Regions below the axis contribute negatively; distinguish signed accumulation from geometric area.'],
+ '∫₀² x dx = [x²/2]₀² = 2. In contrast, ∫₋₁¹ x dx=0 because the negative and positive contributions cancel.',
+ 'A zero integral does not imply there is no area between the graph and the axis.',
+ ['定积分是在一个区间内累积有符号的贡献。', '可以用高乘宽的和近似,也可以用原函数求值。', '横轴以下贡献为负,要区分净累积与几何面积。'],
+ '∫₀² x dx = [x²/2]₀² = 2。而 ∫₋₁¹ x dx=0,因为两侧的正负贡献抵消。',
+ '积分为零不代表图像与横轴之间没有面积。'),
+ 'calc_fundamental_theorem': (
+ ['For continuous f, the derivative of ∫ₐˣ f(t)dt is f(x).', 'When the upper endpoint is g(x), multiply f(g(x)) by g′(x).', 'For numerical bounds, evaluate an antiderivative as F(b)−F(a).'],
+ 'If G(x)=∫₀ˣ² cos(t)dt, then G′(x)=cos(x²)·2x. For a numerical integral, ∫₀¹ 2t dt=[t²]₀¹=1.',
+ 'Do not forget the chain rule when the endpoint is a function of x.',
+ ['f 连续时,∫ₐˣ f(t)dt 对 x 的导数就是 f(x)。', '上限若为 g(x),结果还要乘以 g′(x)。', '上下限都是数值时,用原函数的 F(b)−F(a) 求定积分。'],
+ '若 G(x)=∫₀ˣ² cos(t)dt,则 G′(x)=cos(x²)·2x。数值积分 ∫₀¹ 2t dt=[t²]₀¹=1。',
+ '积分上限是复合函数时,不要漏掉链式法则。'),
+}
+
+
+def calculus_lesson(topic_id, chinese=False):
+ lesson = LESSONS.get(topic_id)
+ if lesson is None:
+ return None
+ return lesson[3:] if chinese else lesson[:3]
diff --git a/services/guided_limits_ui.py b/services/guided_limits_ui.py
index 0a5e603..176f9b9 100644
--- a/services/guided_limits_ui.py
+++ b/services/guided_limits_ui.py
@@ -91,6 +91,7 @@ def render_guided_review(course, session, questions, result) -> bool:
st.success(tr("8 · Correct"))
st.caption(tr("Solved after a retry." if progress["retried"] else "Solved on your first try."))
st.caption(tr("You practised factoring a difference of squares before taking the limit."))
+ _share_blocker(course, progress, key)
return True
st.markdown(tr("**First answer:** ") + first_answer)
@@ -108,24 +109,10 @@ def render_guided_review(course, session, questions, result) -> bool:
else:
progress["reason"] = reason
st.rerun()
+ _share_blocker(course, progress, key)
return True
st.info(tr(REASONS[progress["reason"]][1]))
- user = current_user(st.session_state)
- if user is not None and progress["reason"] in learning_radar.REASON_LABELS:
- with st.expander(tr("Learning Radar · share this blocker")):
- st.caption(tr("Add this topic and reason to the anonymous course totals."))
- if progress.get("flag_saved"):
- st.caption(tr("Shared with Learning Radar."))
- elif st.button(tr("Share anonymously"), key=f"{key}_flag"):
- outcome = learning_radar.set_flag(user.user_id, course.course_id, TOPIC_ID, progress["reason"])
- if outcome.success:
- progress["flag_saved"] = True
- forget_course_radar(st.session_state, course.course_id)
- st.rerun()
- else:
- st.warning(tr("Learning Radar is unavailable. You can still finish this review."))
-
if not progress.get("step_done"):
factor = st.radio(
tr("Which expression equals x² − 4?"),
@@ -141,6 +128,7 @@ def render_guided_review(course, session, questions, result) -> bool:
st.warning(tr("Choose an expression first."))
else:
st.warning(tr("Expand your choice. Does the middle term cancel?"))
+ _share_blocker(course, progress, key)
return True
st.markdown(tr("**The step you repaired:** x² − 4 = (x − 2)(x + 2)"))
@@ -162,4 +150,24 @@ def render_guided_review(course, session, questions, result) -> bool:
else:
progress["retried"] = True
st.warning(tr("Try rewriting x² − 16 as a difference of squares."))
+ _share_blocker(course, progress, key)
return True
+
+
+def _share_blocker(course, progress, key):
+ if "reason" not in progress:
+ return
+ user = current_user(st.session_state)
+ if user is not None and progress["reason"] in learning_radar.REASON_LABELS:
+ with st.expander(tr("Learning Radar · share this blocker")):
+ st.caption(tr("Add this topic and reason to the anonymous course totals."))
+ if progress.get("flag_saved"):
+ st.caption(tr("Shared with Learning Radar."))
+ elif st.button(tr("Share anonymously"), key=f"{key}_flag"):
+ outcome = learning_radar.set_flag(user.user_id, course.course_id, TOPIC_ID, progress["reason"])
+ if outcome.success:
+ progress["flag_saved"] = True
+ forget_course_radar(st.session_state, course.course_id)
+ st.rerun()
+ else:
+ st.warning(tr("Learning Radar is unavailable. You can still finish this review."))
diff --git a/services/i18n.py b/services/i18n.py
index dff14f3..bc32b30 100644
--- a/services/i18n.py
+++ b/services/i18n.py
@@ -20,6 +20,13 @@ def remember_language() -> None:
_TRANSLATIONS = {
+ "Help": "帮助",
+ "Step-by-step explanation": "分步骤讲解",
+ "Worked example": "分步例题",
+ "Common mistake": "常见误区",
+ "Example from this course": "本课程例题",
+ "Change example": "更换例题",
+ "Self-check": "自评",
"Back to Knowledge Map": "返回知识图谱",
"Most flagged topics": "被标记最多的知识点",
'Ask about this explanation': '针对这段解析提问',
diff --git a/services/learning_dna_ui.py b/services/learning_dna_ui.py
index 9409d65..a3fe82c 100644
--- a/services/learning_dna_ui.py
+++ b/services/learning_dna_ui.py
@@ -1,5 +1,5 @@
"""Render evidence dimensions alongside the existing Progress statistics."""
-
+from services.ui_help import help_tip
from services.i18n import tr
import streamlit as st
@@ -93,14 +93,12 @@ def render_learning_dna(course, attempts, sessions, questions, mode, *, example=
"""
title = f"{tr('Example')} · {tr('Learning DNA')}" if example else tr("Learning DNA")
st.subheader(title)
- st.caption(tr("See computation and conceptual understanding separately, with the answers behind each pattern."))
- st.caption(tr("How to read this profile") + " · " + tr("These are question-based observations, not a validated cognitive diagnosis. Multiple-choice answers do not demonstrate that you can explain an idea in your own words."))
+ help_tip(tr("How to read this profile") + " · " + tr("These are question-based observations, not a validated cognitive diagnosis. Multiple-choice answers do not demonstrate that you can explain an idea in your own words.") + " " + tr("Uses your latest answer to each question. Fewer than 3 different questions shows as insufficient evidence."))
try:
profile, _excluded = evidence_profile(attempts, sessions, questions, mode)
except ValueError:
st.warning(tr("Learning DNA couldn't read this practice history."))
return
- st.caption(tr("Uses your latest answer to each question. Fewer than 3 different questions shows as insufficient evidence."))
by_key = {(p.topic_id, p.dimension): p for p in profile}
# One block around the topic cards: the stylesheet sets them side by side on a wide page.
with st.container(key="learning_dna_cards"):
diff --git a/services/paper_progress.py b/services/paper_progress.py
new file mode 100644
index 0000000..8221e31
--- /dev/null
+++ b/services/paper_progress.py
@@ -0,0 +1,35 @@
+"""A winding, dotted paper-plane route; decorative beside the question counter."""
+import hashlib
+import math
+
+from services.ui_style import BRAND_PLANE
+
+
+def progress_route(index, total, previous=None):
+ def point(t):
+ return 20 + 560*t, 48 + 22*math.sin(4*math.pi*t)
+
+ stops = min(max(total, 1), 12)
+ fraction = max(0, min(index / max(1, total-1), 1))
+ before = fraction if previous is None else max(0, min(previous / max(1, total-1), 1))
+ points = [point(i/120) for i in range(121)]
+ path = 'M' + ' L'.join(f'{x:.2f},{y:.2f}' for x,y in points)
+ dots = ''.join(f''
+ for t in ([i/(stops-1) for i in range(stops)] if stops>1 else [0]))
+ plane = BRAND_PLANE.read_text(encoding='utf-8').replace(
+ '