The ejercicios (exercises) module delivers ComuniTEA’s structured PECS learning path. Children are grouped into one of three tiers based on their vocabulary level, and each group follows its own multi-level exercise road map. Progress is stored locally inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElthonJohan/comunitea/llms.txt
Use this file to discover all available pages before exploring further.
AsyncStorage via two Zustand persist stores — useG2ProgressStore and useG3ProgressStore — which are surfaced to components through the useEjerciciosG2 and useEjerciciosG3 selector hooks. The useUserGroup hook maps the authenticated user’s VocabLevel to a group tier and provides board layout constants used throughout the tablero and exercise screens.
useUserGroup
useUserGroup reads profile.level from the auth context and returns a normalized group designation along with UI layout constants. It is used by both the tablero (to limit visible subcategories for basic users) and exercise screens (to decide which exercise road map to show).
VocabLevel → UserGroupLevel mapping
profile.level (DB value) | UserGroupLevel | Exercise group |
|---|---|---|
"BASICO" | 'basic' | G3 (severe) |
"INTERMEDIO" | 'intermediate' | G2 (moderate) |
"AVANZADO" | 'advanced' | G2 (moderate/advanced) |
Return shape
Normalized group string. Drive exercise routing with this value.
Recommended pictogram tile width in dp.
62 for basic, 54 for intermediate/advanced.Recommended pictogram tile height in dp.
58 for basic, 50 for intermediate/advanced.Minimum touch target size (always
48 dp) — fulfills accessibility guidelines.4 for basic users (fewer choices = less cognitive load), 999 (unlimited) for intermediate/advanced.Usage example
useEjerciciosG2
useEjerciciosG2 is a Zustand selector hook that exposes the full G2 progress state and all mutation actions from useG2ProgressStore. It uses useShallow for stability — only re-renders when a selected field actually changes.
State shape
Array of completed exercise keys in the form
"nivel-ejercicioIndex" (e.g. "2-1", "3-E2"). An exercise key is generated by g2ExerciseKey(nivel, ejercicioIndex).Maps exercise key → number of wrong answers. Used to compute the star rating when the exercise is completed.
Stars earned per level (1–5). Set when the last exercise in a level is completed.
Rolling log of emotion IDs recorded during Level 2 exercises (max 30 entries).
Fine-grained fail counter for sub-exercise slots (Levels 2–3 only). Key format:
"nivel-E1", "nivel-E2", "nivel-E3".Stars per sub-exercise slot. Key matches
g2SubExerciseKey(nivel, sub).Rolling log of “ask for help” registrations from Level 3 exercises (max 40 entries). Each entry is
{ situacion: string, persona: string }.true after the Zustand persist middleware has finished reading from AsyncStorage. Gate all progress rendering behind this flag.Query methods
Returns
true if the exercise at the given level and index is in completados.Returns
true when all G2_EJERCICIOS_POR_NIVEL (6) exercise slots for the level are completed.Level 1 is always unlocked. Level N is unlocked when level N−1 is complete.
Convenience method for rendering the level badge/thumbnail state on the road-map screen.
Returns the 0-based index of the first incomplete exercise in the level. Used to resume from where the child left off.
Returns 0 if the level is not yet complete, otherwise the stored star count (1–3).
Returns the star count for a specific sub-exercise, or
null if it hasn’t been completed yet.Mutation actions
Increments the fail counter for the exercise and fires the gamification bridge (
wrong_attempt event).Increments the sub-exercise fail counter for levels 2 and 3.
Marks a sub-exercise as complete, computes its stars from accumulated fails, and — for the third sub-exercise (E3) — computes the level stars as the minimum of E1/E2/E3 stars.
Marks a regular exercise complete. When the last exercise in the level is completed, computes and stores the level star count.
Appends an emotion ID to
emocionesRegistradas (Level 2 activities).Appends a
{ situacion, persona } record to ayudasRegistradas (Level 3 activities).Resets all G2 state to defaults. Useful for testing or when starting over.
Level structure
| Level | Name | Emoji | Exercises |
|---|---|---|---|
| 1 | Reconocer y Pedir | 👋 | 6 slots (E1–E6) |
| 2 | Mis emociones | 💜 | 6 slots (E1–E3 as sub-exercises) |
| 3 | Pedir ayuda | 🙋 | 6 slots (E1–E3 as sub-exercises) |
| 4 | Las Categorías | 🗂️ | 6 slots |
| 5 | Turno y Respuesta | 💬 | 6 slots |
Usage example
useEjerciciosG3
useEjerciciosG3 mirrors useEjerciciosG2 but targets Group 3 (severe TEA / basic level). The G3 path has 5 levels with exactly 3 exercises each (no sub-exercise tabs). It also exposes a caminoCompleto flag and a segmentBetweenCompleted helper for rendering the connecting path segments on the road-map UI.
State shape
Completed exercise keys in the form
"nivel-ejercicioIndex" (e.g. "1-1", "3-2"). Generated by g3ExerciseKey(nivel, ejercicioIndex).Maps exercise key → number of wrong answers.
Stars earned per level. Computed when the 3rd exercise (index 2) in a level is completed.
true when all 5 levels are fully completed. Persisted separately in AsyncStorage under STORAGE_KEYS.EJERCICIOS_G3_COMPLETADOS.true after AsyncStorage rehydration is complete.Query methods
Returns
true if the exercise is in completados.Returns
true when all 3 exercises (indices 0, 1, 2) for the level are completed.Level 1 is always unlocked. Level N requires level N−1 to be complete.
Road-map badge state.
Returns the 0-based index of the first incomplete exercise in the level (0, 1, or 2). Returns
0 when all exercises are done. Used to resume from where the child left off.Returns
true when fromNivel is complete AND fromNivel < toNivel. Used to render the connecting path segment between two level nodes as “completed” (colored vs. grey).Returns 0 for incomplete levels, otherwise 1–3.
Mutation actions
Increments
fallosPorEjercicio[key] and fires the wrong_attempt gamification event.Marks the exercise done. If it is the final exercise in the level (index 2), computes and stores the level star count from total fails across all 3 exercises.
Marks the entire G3 path as complete and persists the flag to
AsyncStorage.Clears
EJERCICIOS_G3_COMPLETADOS from AsyncStorage and resets all store state to defaults.Level structure
| Level | Name | Emoji | Exercises |
|---|---|---|---|
| 1 | El Despertar | ☀️ | 3 |
| 2 | La Elección | 🔀 | 3 |
| 3 | Mis Necesidades | 💭 | 3 |
| 4 | Pedir Ayuda | 🤝 | 3 |
| 5 | Mi Primera Frase | ✨ | 3 |
Usage example
Progress stores (Zustand + AsyncStorage)
Both G2 and G3 exercise stores use Zustand’spersist middleware with a custom AsyncStorage adapter. Progress is local only — it is not synced to Supabase in the current version.
G2 store key
G3 store key
Reading progress outside React (async helpers)
For non-component contexts (e.g. report generation, background jobs), two async helpers read G2 data directly fromAsyncStorage without mounting the store:
Resetting all progress
Star system
Both G2 and G3 use the same star-awarding formula based on the total number of wrong answers accumulated during the exercise (or level, for G2).| Errors | Stars | Description |
|---|---|---|
| 0 | ★★★ | Perfect — no mistakes |
| 1–2 | ★★☆ | Good — a few mistakes |
| 3+ | ★☆☆ | Completed — many mistakes |
min(stars_E1, stars_E2, stars_E3). This ensures the level rating reflects the weakest sub-exercise, not the average.
Exercise progress is stored locally in
AsyncStorage and is not synchronized to Supabase in the current version of ComuniTEA. Progress is per-device. Clearing app data or uninstalling the app will erase all exercise progress. A cloud sync feature is planned for a future release.Exercise data reference
G2 exercise data (features/ejercicios/data/grupo2.ts)
The G2 exercise data module exports typed constants for each level and exercise:
G3 exercise data (features/ejercicios/data/grupo3.ts)
Group 2 (Moderate TEA)
5 levels × 6 exercises = 30 total exercise slots. Features emotion tracking (Level 2) and help-request logging (Level 3). Stars calculated per sub-exercise and aggregated by level minimum.
Group 3 (Severe TEA)
5 levels × 3 exercises = 15 total exercise slots. Simpler one-or-two-choice interactions. Stars calculated from total level fails. Includes a
caminoCompleto milestone when all levels are finished.