Explore the learn-p5 Expo app codebase (thorough). I need the full picture of the "locked module" messaging on the learn route and how to refer to the actual prior module.
Previously found:
src/components/ExerciseCard.tsx line 64 has the hardcoded string "Complete the current module to unlock this one."
The full content of src/app/learn/index.tsx - especially how orderedCourses is built (lines 75-79 mentioned reordering), how currentSlug/isCurrent is determined (lines 68-73), and how isCourseCompleted works. Report the order/sequencing logic.
The full content of src/components/ExerciseCard.tsx including the prop interface (does it accept a priorModuleTitle or similar?). Report all props.
The Course type and whether there's any explicit "prerequisite" / "order" / "previousModule" field. If sequencing is purely positional (order in the courses array), report how the array is ordered.
The data source: src/data/courses/index.ts (or similar) - how courses are listed/ordered. Is there a fixed canonical order? Report it.
Identify the cleanest way to compute, for a locked course, the title of the prior course the user must complete first. (Likely: find the highest-indexed incomplete course before this one in canonical order; or the immediately-preceding incomplete course.)
Report file paths, line numbers, the exact current string location, the ordering mechanism, and the recommended approach to surface the prior module's title. Be thorough.
Assistant
I'll explore the codebase thoroughly. Let me start by reading the key files mentioned and exploring the data structure in parallel.
Assistant
Now let me explore the data types, course loader, and the data source in parallel.
Assistant
Now let me verify the canonical order matches the YAML files and check for any prerequisite/order fields anywhere in the codebase. Let me also confirm the slugs and titles.
Assistant
The broad grep was too noisy. Let me narrow the prerequisite search to just the YAML/course data files and verify the order field doesn't exist.
Assistant
The YAML files have no prerequisite/order field. Let me confirm the .ts generated course files match the same structure and check the dynamic [slug] route for any locked handling, plus re-run the prerequisite search narrowly.
Assistant
Let me confirm there's no other locked messaging in the course detail routes and check for a barrel index file in the courses data folder.
Assistant
I now have the full picture. Here is the thorough report.
Report: "Locked module" messaging on the learn route
its slug is in the completedCourses AsyncStorage list (key completedCourses), OR
every one of its exercises is in the completedLessons AsyncStorage list (key completedLessons).
currentSlug (lines 68-73) — the "current module"
ts
const currentSlug = useMemo(() => {
for (const c of courses) {
if (!isCourseCompleted(c)) return c.slug;
}
return null;
}, [courses, completedLessons, completedCourses]);
Iterates coursesin their loaded (canonical) order and returns the slug of the first non-completed course. This is the single "current" module. If everything is complete, returns null. Note: this uses the raw courses array order, NOT orderedCourses.
orderedCourses (lines 75-79) — display reordering only
This is purely a display reordering: all incomplete courses first (in canonical order), then all completed courses (in canonical order). It does NOT change sequencing semantics — currentSlug is computed from the raw courses order above. So the current course stays at the top of the visible list, other locked (future) courses follow, and completed ones sink to the bottom.
A course is locked iff it is not completed AND not the current one. Because currentSlug is the first incomplete course, this implies: every course before currentSlug is completed, currentSlug is the only unlocked-incomplete course, and every course after currentSlug is locked. So there is exactly one blocker for all locked courses: the current course.
Props passed to <ExerciseCard> (lines 102-110): title, moduleName, description, locked, completed, isCurrent, onContinue. No prior-module info is passed.
There is NO priorModuleTitle, lockHint, prerequisite, or any similar prop. The component has no way to receive the prior module's title today.
Hardcoded locked string (line 64)
tsx
<Text style={[styles.description, { color: colors.textSecondary }]}>
{locked ? "Complete the current module to unlock this one." : description}
</Text>
This is the only occurrence of that string in the repo (confirmed via grep — single match at src/components/ExerciseCard.tsx:64). It is generic and never names which module.
The locked card also: disables the press (line 35), dims to 0.5 opacity (line 39), shows a lock icon (line 46), greys the title (line 57), and sets accessibilityLabel={${title} (locked)} (line 42).
Note: there is separate, unrelated per-exercise locking inside a course at src/app/learn/[course]/index.tsx (lines 289-333, using isLessonLocked) and achievement "unlocked" toasts in [course]/[id].tsx (line 732-737). Those are not the course-level "locked module" messaging on the learn route.
3. Course type — no prerequisite / order / previousModule field
No prerequisite, order, previousModule, nextModule, dependsOn, or similar field exists. Confirmed by:
Reading the Course type (above).
Grepping all *.yaml in src/data/courses for prerequisite|previousModule|priorModule|requires|dependsOn|^order:|nextModule|prevModule → No files found.
Grepping all *.ts in src/data/courses for the same → No files found.
Grepping all *.{ts,tsx} in src for priorModule|previousModule|prerequisite|prevModule|nextModule|dependsOn → no meaningful matches (only the unrelated per-exercise lock util).
Sequencing is purely positional — determined by the order of the COURSE_FILES array in the loader (see §4). moduleName is a grouping label (e.g., "Fundamentals", "Drawing"), NOT a sequence field.
There is no barrel index.ts in src/data/courses/ (glob confirmed: no src/data/courses/index.ts). The canonical course list and order are defined only by the hardcoded COURSE_FILES array in courseLoader.ts (lines 19-36):
loadAllCourses() (lines 40-46) returns this array as-is (cached in cachedCourses). This is the single source of truth for canonical order.
Canonical order with titles and moduleNames (from each *.yaml lines 1-3)
#
slug
title
moduleName
1
shapes
Shapes
Fundamentals
2
color
Color
Fundamentals
3
transform
Transform
Fundamentals
4
custom-shapes
Custom Shapes
Drawing
5
curves
Curves
Drawing
6
typography
Typography
Drawing
7
image
Image
Visual Media
8
math
Math
Math & Logic
9
vectors
Vectors
Math & Logic
10
random-noise
Random & Noise
Math & Logic
11
dom
DOM Elements
Interaction
12
events
Events
Interaction
13
time
Time & Date
Utility
14
io
Loading Data
Utility
15
data
Data Storage
Utility
16
webgl
WebGL Basics
3D
The .ts files in src/data/courses/ are gitignored build artifacts generated from the .yaml (per AGENTS.md). The .yaml files are the source of truth for content, but order comes from courseLoader.ts's COURSE_FILES array, not from the YAML.
5. Recommended approach: surface the prior module's title for a locked course
Key insight from the current data model
Because completion is strictly sequential by construction:
currentSlug = first incomplete course in canonical order (learn/index.tsx:68-73)
…every course before currentSlug is completed, currentSlug is the only unlocked-incomplete course, and every locked course is blocked by exactly the same single course: the current one (currentSlug). So the existing string "Complete the current module to unlock this one" is semantically correct about which module — it just never names it.
Your two candidate hypotheses, evaluated
"Immediately-preceding course in canonical order" — WRONG/confusing. For a locked course at index i, courses[i-1] may itself be locked (incomplete) if it sits after currentSlug. Example: if currentSlug = color (index 1), then transform (2), custom-shapes (3), curves (4) are all locked; the "immediately preceding" course to curves is custom-shapes, which is itself locked — pointing the user there is unhelpful.
"Highest-indexed incomplete course before this one" — CORRECT, and in the sequential model it always equals currentSlug. This is the robust general formulation: walk backward from i to the first incomplete course.
Both collapse to the same answer under the current model: the blocker is the course with slug === currentSlug.
Recommended (cleanest) implementation
Surface currentSlug's course title. It matches the existing "current module" semantics with a minimal change:
src/components/ExerciseCard.tsx — add an optional prop and use it in the locked string:
If you later allow non-sequential completion (e.g., a course marked complete via completedCourses while earlier ones remain incomplete), the per-locked-course blocker may diverge from currentSlug. In that case use the general formulation — for a locked course at canonical index i, find the nearest preceding incomplete course:
Under today's sequential model this returns currentSlug for every locked course, so it's a safe, forward-compatible choice. But for the current code, simply passing currentCourse.title is the cleanest minimal change and exactly matches the existing "current module" wording.