Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pages/0_Dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,21 @@ def load_demo_package(filename: str, expected_course_id: str) -> StudyPackage:
st.rerun()

with st.container(key="dashboard_learning_dna"):
dna_course = selected_course
if dna_course is None and st.session_state["courses"]:
courses_by_id = {course.course_id: course for course in st.session_state["courses"]}
dna_course_id = st.selectbox(
tr("Course"), list(courses_by_id),
format_func=lambda course_id: courses_by_id[course_id].course_name,
key="learning_dna_course",
)
dna_course = courses_by_id[dna_course_id]
if st.button(
tr("View Learning DNA"), icon=":material/insights:",
key="learning_dna_open", disabled=selected_course is None,
key="learning_dna_open", disabled=dna_course is None,
):
st.session_state[f"progress_tab_{selected_course.course_id}"] = "Learning DNA"
select_course(st.session_state, dna_course.course_id)
st.session_state[f"progress_tab_{dna_course.course_id}"] = "Learning DNA"
st.switch_page("pages/3_Performance.py")

# Study totals: one always-visible row of small tiles (assets/paper_panels.css).
Expand Down
17 changes: 16 additions & 1 deletion tests/test_learning_dna.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def test_dashboard_entry_navigates_to_learning_dna_in_registered_app():
from tests.auth_helpers import signed_in_app
app=signed_in_app(ROOT/'app.py').run()
assert not app.exception
assert app.button(key='learning_dna_open').disabled
assert not app.button(key='learning_dna_open').disabled
course,history=course_and_history()
app.session_state['courses'] = [course]
app.session_state['current_course']=course
app.session_state['practice_history_test-dna']=history
app.session_state['performance_mode_test-dna']='Topic Practice'
Expand All @@ -235,3 +236,17 @@ def test_dashboard_entry_navigates_to_learning_dna_in_registered_app():
assert 'progress_tab_test-dna' not in app.session_state
app.switch_page('pages/3_Performance.py').run()
assert [s.value for s in app.subheader if s.value!=course.course_name][0]=='Mastery by topic'


def test_dashboard_dna_opens_chosen_demo_without_previously_opening_course():
from tests.auth_helpers import signed_in_app
app = signed_in_app(ROOT/'app.py').run()
assert app.session_state['current_course'] is None
app.selectbox(key='learning_dna_course').select('calculus-i-demo').run()
app.button(key='learning_dna_open').click().run()
assert not app.exception
assert app.title[0].value == 'Progress'
assert app.session_state['current_course'].course_id == 'calculus-i-demo'
assert app.session_state['progress_tab_calculus-i-demo'] == 'Learning DNA'
sections = [s.value for s in app.subheader if s.value != 'Calculus I Demo']
assert sections[0] == 'Example · Learning DNA'
Loading