File tree Expand file tree Collapse file tree
openedx/core/lib/xblock_utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11## xss-lint: disable=mako-missing-default
22< %!
33from openedx.core.djangolib.js_utils import dump_js_escaped_json
4+ from django.utils.translation import gettext as _
45%>
6+ % if 'data-is-optional="True"' in data_attributes:
7+ < span class ="optional-completion-badge text-uppercase border badge badge-light mb-3 "> ${_("Optional")}</ span >
8+ % endif
59< div class ="${' '.join(classes) | n, decode.utf8} " ${data_attributes} >
610% if js_init_parameters:
711 < script type ="json/xblock-args " class ="xblock-json-init-args ">
Original file line number Diff line number Diff line change 2323from web_fragments .fragment import Fragment
2424from xblock .core import XBlock
2525from xblock .exceptions import InvalidScopeError
26+ from xblock .fields import Scope
2627from xblock .scorable import ScorableXBlockMixin
2728
2829from common .djangoapps import static_replace
@@ -141,6 +142,13 @@ def wrap_xblock(
141142 if block .name :
142143 data ['name' ] = block .name
143144
145+ # We check whether the block is explicitly set as optional because this information is already displayed for units
146+ # in the Learning MFE.
147+ has_children = getattr (block , "children" , False )
148+ is_explicitly_optional = block .get_explicitly_set_fields_by_scope (Scope .settings ).get ('optional_completion' , False )
149+ if view != STUDIO_VIEW and not has_children and is_explicitly_optional :
150+ data ['is-optional' ] = getattr (block , 'optional_completion' , False )
151+
144152 template_context = {
145153 'content' : block .display_name if display_name_only else frag .content ,
146154 'classes' : css_classes ,
You can’t perform that action at this time.
0 commit comments