kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Convert `tallyMixin` to a `useTally` composable

Open rtibbles opened this issue 2 months ago • 4 comments

🙂 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:

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.vue and StatusSummary.vue (barStyleCompleted, barStyleStarted, helpLineStyle, verbosity, showAll, showItem, and the dynamic component computeds). Only the parts that consume the mixin move into setup().
  • The other mixins in the codebase: taskNotificationMixin, commonSyncElements, the media_player video.js mixins, and language-switcher/internal/mixin.js.

Acceptance Criteria

General

  • [ ] useTally exists in kolibri/plugins/coach/frontend/composables/ and returns started, completed, notStarted, helpNeeded and total.
  • [ ] helpNeeded is 0 when the tally object omits it.
  • [ ] The tally prop definition and its validator are exported from the same module and used by both ProgressSummaryBar.vue and StatusSummary.vue; the validator rejects the same inputs it rejects today.
  • [ ] tallyMixin.js is deleted and grep -r tallyMixin returns nothing.
  • [ ] ProgressSummaryBar and StatusSummary render unchanged on Coach class home (/coach/#/<classId>/home), which renders both via ItemProgressDisplay.vue.

Testing

  • [ ] useTally.spec.js covers the four counts, the helpNeeded default, total, and that the returned values update when tally changes.
  • [ ] pnpm test-jest --testPathPattern coach passes.

References

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.

rtibbles avatar Sep 19 '26 21:09 rtibbles

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?

Srijan229 avatar Sep 19 '26 21:09 Srijan229

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.

learning-equality-bot avatar Sep 19 '26 21:09 learning-equality-bot

/assign

Srijan229 avatar Sep 19 '26 21:09 Srijan229

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.

learning-equality-bot avatar Sep 19 '26 21:09 learning-equality-bot