Skip to content

feat: display optional completion information on the cards#48

Merged
Agrendalath merged 3 commits intomainfrom
agrendalath/bb-9331-optional-completion
Mar 17, 2026
Merged

feat: display optional completion information on the cards#48
Agrendalath merged 3 commits intomainfrom
agrendalath/bb-9331-optional-completion

Conversation

@Agrendalath
Copy link
Copy Markdown
Member

@Agrendalath Agrendalath commented Mar 10, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates learning path and course cards to surface “optional completion” information, based on additional completion data returned from the completion-aggregator API.

Changes:

  • Extend course completion fetching/mapping to include optionalCompletion data.
  • Compute and attach optional-completion flags (hasOptionalCompletion, hasUnearnedOptionalCompletion) to learning path and course view models.
  • Update LearningPathCard and CourseCard UI copy to distinguish required vs optional completion.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/learningpath/data/queries.js Computes learning path optional-completion flags from the completions map; removes unused per-course completion query usage.
src/learningpath/data/dataUtils.js Expands the completions map structure and propagates optional-completion flags onto course objects.
src/learningpath/data/api.js Requests optional completion data from completion-aggregator and camelCases it into the client model.
src/learningpath/LearningPathCard.jsx Displays required-vs-optional completion messaging on learning path cards.
src/learningpath/CourseCard.jsx Displays required-vs-optional completion messaging on course cards.
package.json Bumps package version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +72 to +84
let hasOptionalCompletion = false;
let hasUnearnedOptionalCompletion = false;
const totalCompletion = lp.steps.reduce((sum, step) => {
const completion = completionsMap[step.courseKey];
return sum + (completion?.percent ?? 0);
const completionData = completionsMap[step.courseKey];
const optionalPossible = completionData?.optionalCompletion?.possible ?? 0;
const optionalEarned = completionData?.optionalCompletion?.earned ?? 0;
if (optionalPossible > 0) {
hasOptionalCompletion = true;
if (optionalPossible > optionalEarned) {
hasUnearnedOptionalCompletion = true;
}
}
return sum + (completionData?.completion?.percent ?? 0);
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useLearningPaths uses reduce to compute totalCompletion but also mutates hasOptionalCompletion/hasUnearnedOptionalCompletion as side effects inside the reducer. This makes the reducer non-pure and harder to reason about (and easier to break if the logic changes). Consider replacing this with a single for...of loop (or a reduce that returns an object containing { totalCompletion, hasOptionalCompletion, hasUnearnedOptionalCompletion }) so the aggregation is explicit and side-effect free.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@tecoholic tecoholic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Agrendalath 👍

  • I tested this: Verified that the changes are reflected in the UI.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Before

image

After

image

@Agrendalath Agrendalath force-pushed the agrendalath/bb-9331-optional-completion branch from 698663d to c342389 Compare March 17, 2026 19:09
@Agrendalath Agrendalath enabled auto-merge March 17, 2026 19:09
@Agrendalath Agrendalath merged commit 6fde50c into main Mar 17, 2026
3 checks passed
@Agrendalath Agrendalath deleted the agrendalath/bb-9331-optional-completion branch March 17, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants