Skip to content

feat(redwood): implement optional completion#823

Merged
Agrendalath merged 3 commits intoopencraft-release/redwood.1-echofrom
agrendalath/bb-9331-optional-completion-redwood
Mar 17, 2026
Merged

feat(redwood): implement optional completion#823
Agrendalath merged 3 commits intoopencraft-release/redwood.1-echofrom
agrendalath/bb-9331-optional-completion-redwood

Conversation

@Agrendalath
Copy link
Member

@Agrendalath Agrendalath commented Jan 27, 2026

This adds a new XBlock field that allows marking sections, subsections, and units as optional, so their completion is counted separately.

Note: I would suggest reviewing each commit individually here.

Testing instructions

  1. Run pip install -e . in the edx-platform directory to rebuild Open_edX.egg-info.
  2. Run tutor dev exec cms npm run build-dev.
  3. Use feat(redwood): implement optional completion frontend-app-learning#88 for the Learning MFE.
  4. Set the "Optional" completion for a section, subsection, and unit in the legacy Studio experience.
  5. Check that each of these optional blocks has an "OPTIONAL" badge on the Course Outline page and in the Course Sidebar (in the courseware) within the Learning MFE.
  6. Check that an optional unit has an alert (explaining that the completion is optional) above its rendered content.
  7. Check that the optional completion is displayed on the Progress page.
  8. Go to http://local.openedx.io:8000/admin/lms_xblock/xblockasidesconfig/add/ and press "Save".
  9. Mark an individual XBlock as optional. Publish it. See the "OPTIONAL" badge above the XBlock's display name.
  10. Check this individual XBlock in the Learning MFE.

Author's notes

Individual XBlock banners will be updated - we will leave only one, with an appropriate message. We probably won't use asides - this part is just a proof of concept.

Private-ref: BB-9331

This adds a new XBlock field that allows marking sections, subsections,
and units as optional, which means that their completion is counted separately.
@Agrendalath Agrendalath force-pushed the agrendalath/bb-9331-optional-completion-redwood branch from ea74837 to 994e741 Compare February 20, 2026 14:43
@Agrendalath Agrendalath marked this pull request as ready for review March 4, 2026 18:13
@Agrendalath Agrendalath force-pushed the agrendalath/bb-9331-optional-completion-redwood branch from 27d21bc to d4faeaa Compare March 4, 2026 18:18
@Agrendalath
Copy link
Member Author

@tecoholic, I reverted the PoC for displaying individual XBlock completion. I will look into adding the final version next week. Please feel free to review the rest.

Copy link
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 optional completion features work as mentioned in the PR testing instructions
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

'incomplete_count': incomplete_count,
'locked_count': locked_count
}
return counts
Copy link
Member

Choose a reason for hiding this comment

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

@Agrendalath This is a smart refactor :)

has_children = getattr(block, "children", False)
is_explicitly_optional = block.get_explicitly_set_fields_by_scope(Scope.settings).get('optional_completion', False)
if view != STUDIO_VIEW and not has_children and is_explicitly_optional:
data['is-optional'] = getattr(block, 'optional_completion', False)
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't getattr(block, 'optional_completion', False) here return the same as is_explicitly_optional? Why not use the same value?

Copy link
Member Author

Choose a reason for hiding this comment

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

@tecoholic, the optional_completion field comes from the InheritanceMixin, so it is true when any of the XBlock's parents had set it to true. By checking the explicitly set field, we ensure that the optional_completion has been set for this specific (individual) XBlock. We already display the optional banner when the unit is optional, so this information would be duplicated for each XBlock within this unit. Therefore, we want to show it only for optional XBlocks within a non-optional unit.

@tecoholic
Copy link
Member

@Agrendalath I just realized the "Optional 4" banner is not actually there.

Check this individual XBlock in the Learning MFE. It should have an additional "Optional 4" banner.

The 3 in Studio
image

And the same 3 appear in the Learning MFE as well

image

@Agrendalath
Copy link
Member Author

@tecoholic, as mentioned in #823 (comment), I reverted these banners. Yesterday, I pushed a commit that reimplements the "Optional 1" banner as an "OPTIONAL" badge above the XBlock's name, but I forgot to update this part in the testing instructions. I'll update it now.

@Agrendalath
Copy link
Member Author

Agrendalath commented Mar 17, 2026

Note for future reference (because I will squash the commits): a59c421 and 27f938e demonstrate the use of asides to display optional completion.

@Agrendalath Agrendalath force-pushed the agrendalath/bb-9331-optional-completion-redwood branch from 92ae027 to 07503ca Compare March 17, 2026 19:19
@Agrendalath Agrendalath force-pushed the agrendalath/bb-9331-optional-completion-redwood branch from 07503ca to 35304d3 Compare March 17, 2026 19:20
@Agrendalath Agrendalath enabled auto-merge March 17, 2026 19:20
@Agrendalath Agrendalath merged commit 553d3bd into opencraft-release/redwood.1-echo Mar 17, 2026
22 checks passed
@Agrendalath Agrendalath deleted the agrendalath/bb-9331-optional-completion-redwood branch March 17, 2026 19:22
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