Skip to content

Commit 5ea5531

Browse files
committed
temp: support optional completion for individual XBlocks
1 parent 155b9fd commit 5ea5531

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

xmodule/x_module.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,18 @@ def editable_metadata_fields(self):
651651

652652
metadata_fields[field.name] = self._create_metadata_editor_info(field)
653653

654+
# The `optional_completion` field can be either explicitly set or inherited from the parent.
655+
# While we could query the parent's field, there is a special case that cannot be supported with the platform's
656+
# completion calculations that count the completed units instead of individual XBlocks.
657+
# If this field is explicitly set to False, then we want to show it in the metadata editor so that the author
658+
# can reset it to the default inherited value.
659+
if "optional_completion" in self.fields:
660+
has_explicitly_set_optional_completion = self.fields['optional_completion'].is_set_on(self)
661+
if not self.optional_completion or has_explicitly_set_optional_completion:
662+
metadata_fields["optional_completion"] = self._create_metadata_editor_info(
663+
self.fields["optional_completion"]
664+
)
665+
654666
return metadata_fields
655667

656668
def _create_metadata_editor_info(self, field):

0 commit comments

Comments
 (0)