Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional xblocks #34275

Conversation

DanielVZ96
Copy link
Contributor

@DanielVZ96 DanielVZ96 commented Feb 22, 2024

Description

This PR implements separating optional progress from normal progress, and also displaying optional chapters and sequences in the outline.

  • Impacts: Learners and authors

Supporting information

Testing instructions

  1. Run the MFE from this branch: feat: optional xblocks frontend-app-learning#1296
  2. Add "done" to the advanced module list
  3. As a non-staff user go to the progress tab and assert only the typical progress donut appears
  4. As a staff user, on the cms open the settings of any sequence or chapter and mark as optional
  5. As a non-staff user, complete some units, and also the optional unit
  6. Navigate to the progress tab again and assert a new optional donut appears with your progress

Screenshots

optional-outline

cms-optional

progress

course-settings

Private-ref: BB-8586

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 22, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Feb 22, 2024

Thanks for the pull request, @DanielVZ96! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@DanielVZ96 DanielVZ96 force-pushed the dvz/optional-lesson branch 2 times, most recently from d9bb981 to b1f6a46 Compare February 25, 2024 04:21
@DanielVZ96 DanielVZ96 marked this pull request as ready for review February 25, 2024 04:39
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

@DanielVZ96, the approach looks nice. However:

  1. The new editor is not displayed in Studio for me. I tried running make lms-static && make lms-restart && make studio-static && make studio-restart, but it's still not there. Am I missing some step?
  2. We're implementing this for Palm first, so this PR should be opened against our fork. I'll close it now.

<h3 class="modal-section-title">
<input type="checkbox" id="optional_content" name="optional_content"
class="input input-checkbox" />
<%- gettext('Mark as optional') %>
Copy link
Member

Choose a reason for hiding this comment

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

We should add an explanation (perhaps with the .field-message class) to this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified in the other PR to look like this
optional-editor-disabled

Comment on lines -769 to +777
~ .tip-warning {
~.tip-warning {
display: block;
}

// CASE: checked
&:checked {
~ .tip-warning {
~.tip-warning {
Copy link
Member

Choose a reason for hiding this comment

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

This does not seem to be right. Why did we change it?

Copy link
Contributor Author

@DanielVZ96 DanielVZ96 Feb 29, 2024

Choose a reason for hiding this comment

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

sorry, autoformatting strikes again, will revert

@@ -238,6 +238,17 @@ class InheritanceMixin(XBlockMixin):
scope=Scope.settings
)

optional_content = Boolean(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe something similar to optional_completion would be better? The current name feels like this is related to grading, not the completion.

Same with the display_name, the name of the new Studio editor, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea. will rename it.

@@ -0,0 +1,5 @@
<h3 class="modal-section-title">
Copy link
Member

Choose a reason for hiding this comment

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

This whole editor is a h3 tag. The heading could simply be Completion instead. See the cms/static/templates/grading-editor.underscore as an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified in the other PR to look like this.
optional-editor

@@ -54,6 +54,7 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring
'resume_block': block.get('resume_block', False),
'type': block_type,
'has_scheduled_content': block.get('has_scheduled_content'),
'optional_content': block.get('optional_content'),
Copy link
Member

Choose a reason for hiding this comment

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

Please read this:

# All Transformers are expected to maintain version-related class
# attributes. While the values for the base class is set to 0,
# the values for each concrete transformer should be 1 or higher.
#
# A transformer's version attributes are used by the block_structure
# framework in order to determine whether any collected data for a
# transformer is outdated because of a data schema change by the
# transformer.
#
# The WRITE_VERSION number is stored along with the transformer's
# data when it is collected and cached (during the collect phase).
# The READ_VERSION number is then verified to be less than or equal
# to the version associated with the collected data when the
# collected data is accessed (during the transform phase).
#
# We distinguish between WRITE_VERSION and READ_VERSION numbers in
# order to:
# 1. support blue-green deployments where new and previous versions
# of the code base are simultaneously executing on different
# workers for a period of time.
#
# A 2-phase deployment is used to stagger read and write changes.
#
# 2. scale for large deployments where it is costly to recompute
# block structures for all courses when a transformer's collected
# data schema changes.
#
# A background management command is run to prime the new data.
#
# See the following document for further information:
# https://openedx.atlassian.net/wiki/display/MA/Block+Structure+Cache+Invalidation+Proposal
#
# The WRITE_VERSION number of a Transformer should be incremented
# when it's collect implementation is additively changed. Backward
# compatibility should be maintained with previous READ_VERSIONs
# until all readers are updated.
#
# The READ_VERSION number of a Transformer should be incremented
# when its transform implementation is updated to make use of the
# newly collected data - and released only after all collected
# block structures are updated with the new WRITE_VERSION.
#

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Agrendalath so based on that I should bump the block_completion transformer write version, and after we're sure all blocks have the new version, we bump the read version?

@@ -1245,10 +1285,10 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
}
];
if (xblockInfo.isChapter()) {
tabs[0].editors = [ReleaseDateEditor];
tabs[0].editors = [ReleaseDateEditor, OptionalContentEditor];
Copy link
Member

Choose a reason for hiding this comment

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

Could we show the editor only when the completion is enabled (ENABLE_COMPLETION_TRACKING_SWITCH.is_enabled())?

Copy link
Contributor Author

@DanielVZ96 DanielVZ96 Feb 29, 2024

Choose a reason for hiding this comment

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

@Agrendalath I'm not sure how to implement that. can we do that in a followup ticket?

tabs[1].editors = [StaffLockEditor];
} else if (xblockInfo.isSequential()) {
tabs[0].editors = [ReleaseDateEditor, GradingEditor, DueDateEditor];
tabs[0].editors = [ReleaseDateEditor, GradingEditor, DueDateEditor, OptionalContentEditor];
Copy link
Member

Choose a reason for hiding this comment

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

We should allow overriding this in Units as well.

Comment on lines +579 to +580
if optional != _is_optional(section_key, subsection_key, unit_key):
continue
Copy link
Member

Choose a reason for hiding this comment

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

What if the section sets the value of the optional_content field to True but the subsection sets it to False? Would it make sense to disallow marking subsection as non-optional when its parent section is marked as optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was handling it as if a parent was optional all children would behave as optional regardless of their actual value, but now that you mention it, in order to reduce confusion it'd be better to disable the checkbox when a parent is optional.

@openedx-webhooks
Copy link

@DanielVZ96 Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants