Convert `tallyMixin` to a `useTally` composable
🙂 Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:
- Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
- Confirm that you’ve read the guidelines in your comment.
Overview
tallyMixin supplies a tally prop and five derived counts (started, completed, helpNeeded, notStarted, total) to two coach status components. Kolibri's frontend convention is composition over inheritance: composables, not mixins. Replace it with a useTally composable.
Complexity: Low Target branch: develop
Context
tallyMixin declares a tally object prop whose validator requires started, notStarted and completed to be integers and helpNeeded to be an integer or absent, and exposes started, completed, notStarted, helpNeeded (defaulting to 0) and total as computed properties.
Both consumers are Options API components:
ProgressSummaryBar.vuedivides bytotalinbarStyleCompleted,barStyleStartedandhelpLineStyle.StatusSummary.vuepasses the counts toLearnerProgressCountandLearnerProgressRatio.
Neither component has a spec file.
The Change
tallyMixin should be replaced by a useTally composable, placed with the coach plugin's other composables rather than beside the components.
The tally prop definition and its validator should be exported from the composable's module, so the two consumers share one definition instead of each declaring their own — see kolibri/plugins/qti_viewer/frontend/utils/props.js for the same pattern applied to QTI props.
ProgressSummaryBar.vue and StatusSummary.vue should gain a setup() that consumes the composable.
Out of Scope
- The remaining Options API computeds and methods in
ProgressSummaryBar.vueandStatusSummary.vue(barStyleCompleted,barStyleStarted,helpLineStyle,verbosity,showAll,showItem, and the dynamic component computeds). Only the parts that consume the mixin move intosetup(). - The other mixins in the codebase:
taskNotificationMixin,commonSyncElements, themedia_playervideo.js mixins, andlanguage-switcher/internal/mixin.js.
Acceptance Criteria
General
- [ ]
useTallyexists inkolibri/plugins/coach/frontend/composables/and returnsstarted,completed,notStarted,helpNeededandtotal. - [ ]
helpNeededis0when thetallyobject omits it. - [ ] The
tallyprop definition and its validator are exported from the same module and used by bothProgressSummaryBar.vueandStatusSummary.vue; the validator rejects the same inputs it rejects today. - [ ]
tallyMixin.jsis deleted andgrep -r tallyMixinreturns nothing. - [ ]
ProgressSummaryBarandStatusSummaryrender unchanged on Coach class home (/coach/#/<classId>/home), which renders both viaItemProgressDisplay.vue.
Testing
- [ ]
useTally.spec.jscovers the four counts, thehelpNeededdefault,total, and that the returned values update whentallychanges. - [ ]
pnpm test-jest --testPathPattern coachpasses.
References
- Composables — composable conventions and the return-a-named-object interface.
kolibri/plugins/coach/frontend/composables/useClassSummary.js— an existing coach composable to model the file shape on.
AI usage
I used Claude Code to re-measure our tech debt audit against develop and to draft this issue. I made the scoping calls myself — where the tally prop definition lives, keeping the rest of both components on the Options API, putting the composable in composables/, and limiting new tests to the composable.
Hi @rtibbles , I’d like to work on this issue. I’ve read the contribution guidelines, including the guidance on generative AI. The scope and acceptance criteria are clear to me, and I plan to implement the useTally composable, update both consumers, and add the specified tests. May I take this up?
Hi! 👋
Thanks for your interest! This issue supports self-assignment. Comment /assign to assign yourself.
Visit Contributing guidelines to learn about the contributing process. 😊
Are you preparing for Google Summer of Code? See our GSoC guidelines.
/assign
Hi! 👋
You've been assigned to this issue. Here's what to do next:
- Read the issue description carefully and make sure you understand the requirements
- Link your pull request to this issue when you submit it
- If you can no longer work on this, unassign yourself so others can pick it up
Good luck! 😊
Are you preparing for Google Summer of Code? See our GSoC guidelines.