Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cms/djangoapps/contentstore/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from django.http import Http404, HttpResponse, HttpResponseBadRequest
from django.utils.translation import gettext as _
from django.views.decorators.http import require_http_methods
from edx_django_utils.plugins import pluggable_override
from edx_proctoring.api import (
does_backend_support_onboarding,
get_exam_by_content_id,
Expand Down Expand Up @@ -1116,6 +1117,7 @@ def _get_gating_info(course, xblock):
return info


@pluggable_override('OVERRIDE_CREATE_XBLOCK_INFO')
def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=False, include_child_info=False, # lint-amnesty, pylint: disable=too-many-statements
course_outline=False, include_children_predicate=NEVER, parent_xblock=None, graders=None,
user=None, course=None, is_concise=False):
Expand All @@ -1134,6 +1136,13 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F

In addition, an optional include_children_predicate argument can be provided to define whether or
not a particular xblock should have its children included.

You can customize the behavior of this function using the `OVERRIDE_CREATE_XBLOCK_INFO` pluggable override point.
For example:
>>> def create_xblock_info(default_fn, xblock, *args, **kwargs):
... xblock_info = default_fn(xblock, *args, **kwargs)
... xblock_info['icon'] = xblock.icon_override
... return xblock_info
"""
is_library_block = isinstance(xblock.location, LibraryUsageLocator)
is_xblock_unit = is_unit(xblock, parent_xblock)
Expand Down
1 change: 1 addition & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@
EditInfoMixin,
AuthoringMixin,
)
XBLOCK_EXTRA_MIXINS = ()

XBLOCK_SELECT_FUNCTION = prefer_xmodules

Expand Down
3 changes: 3 additions & 0 deletions cms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ def get_env_setting(setting):

LOGO_IMAGE_EXTRA_TEXT = ENV_TOKENS.get('LOGO_IMAGE_EXTRA_TEXT', '')

############## XBlock extra mixins ############################
XBLOCK_MIXINS += tuple(XBLOCK_EXTRA_MIXINS)

############## Settings for course import olx validation ############################
COURSE_OLX_VALIDATION_STAGE = ENV_TOKENS.get('COURSE_OLX_VALIDATION_STAGE', COURSE_OLX_VALIDATION_STAGE)
COURSE_OLX_VALIDATION_IGNORE_LIST = ENV_TOKENS.get(
Expand Down
13 changes: 13 additions & 0 deletions cms/static/js/views/modals/course_outline_modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,19 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
}, options));
},

/**
* This function allows comprehensive themes to create custom editors without adding boilerplate code.
*
* A simple example theme for this can be found at https://github.com/open-craft/custom-unit-icons-theme
**/
getCustomEditModal: function(tabs, editors, xblockInfo, options) {
Comment thread
Agrendalath marked this conversation as resolved.
Outdated
return new SettingsXBlockModal($.extend({
tabs: tabs,
editors: editors,
model: xblockInfo
}, options));
},

getPublishModal: function(xblockInfo, options) {
return new PublishXBlockModal($.extend({
editors: [PublishEditor],
Expand Down
5 changes: 4 additions & 1 deletion cms/static/js/views/pages/course_outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ define([
collapsedClass: 'is-collapsed'
},

// Extracting this to a variable allows comprehensive themes to replace or extend `CourseOutlineView`.
outlineViewClass: CourseOutlineView,

initialize: function() {
var self = this;
this.initialState = this.options.initialState;
Expand Down Expand Up @@ -90,7 +93,7 @@ define([
this.highlightsEnableView.render();
}

this.outlineView = new CourseOutlineView({
this.outlineView = new this.outlineViewClass({
el: this.$('.outline'),
model: this.model,
isRoot: true,
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/lib/xblock_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,6 @@ def get_icon(block):
"""
A function that returns the CSS class representing an icon to use for this particular
XBlock (in the courseware navigation bar). Mostly used for Vertical/Unit XBlocks.
It can be overridden by setting `GET_UNIT_ICON_IMPL` to an alternative implementation.
It can be overridden by setting `OVERRIDE_GET_UNIT_ICON` to an alternative implementation.
"""
return block.get_icon_class()