diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 4e43966fa02e..486019071bd4 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -1191,6 +1191,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F 'group_access': xblock.group_access, 'user_partitions': user_partitions, 'show_correctness': xblock.show_correctness, + 'icon': xblock.icon, }) if xblock.category == 'sequential': diff --git a/cms/static/js/models/xblock_info.js b/cms/static/js/models/xblock_info.js index 78eaaddea234..108dfcb283a1 100644 --- a/cms/static/js/models/xblock_info.js +++ b/cms/static/js/models/xblock_info.js @@ -53,6 +53,10 @@ function(Backbone, _, str, ModuleUtils) { * True if the xblock is a parentable xblock. */ has_children: null, + /** + * Meta icon of the unit. + */ + icons: null, /** * True if the xblock has changes. * Note: this is not always provided as a performance optimization. It is only provided for diff --git a/cms/static/js/spec/views/pages/course_outline_spec.js b/cms/static/js/spec/views/pages/course_outline_spec.js index dc5fec49dbb0..b79ebf31c15d 100644 --- a/cms/static/js/spec/views/pages/course_outline_spec.js +++ b/cms/static/js/spec/views/pages/course_outline_spec.js @@ -270,7 +270,7 @@ describe('CourseOutlinePage', function() { 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'settings-modal-tabs', 'timed-examination-preference-editor', 'access-editor', 'show-correctness-editor', 'highlights-editor', 'highlights-enable-editor', - 'course-highlights-enable' + 'course-highlights-enable', 'icon-editor' ]); appendSetFixtures(mockOutlinePage); mockCourseJSON = createMockCourseJSON({}, [ diff --git a/cms/static/js/views/modals/course_outline_modals.js b/cms/static/js/views/modals/course_outline_modals.js index 6bff80e9772b..d4a0ba791326 100644 --- a/cms/static/js/views/modals/course_outline_modals.js +++ b/cms/static/js/views/modals/course_outline_modals.js @@ -17,7 +17,8 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', AbstractEditor, BaseDateEditor, ReleaseDateEditor, DueDateEditor, GradingEditor, PublishEditor, AbstractVisibilityEditor, StaffLockEditor, UnitAccessEditor, ContentVisibilityEditor, TimedExaminationPreferenceEditor, - AccessEditor, ShowCorrectnessEditor, HighlightsEditor, HighlightsEnableXBlockModal, HighlightsEnableEditor; + AccessEditor, ShowCorrectnessEditor, HighlightsEditor, HighlightsEnableXBlockModal, HighlightsEnableEditor, + IconEditor; CourseOutlineXBlockModal = BaseModal.extend({ events: _.extend({}, BaseModal.prototype.events, { @@ -1026,6 +1027,28 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', } }); + IconEditor = BaseDateEditor.extend({ + fieldName: 'icon', + templateName: 'icon-editor', + + hasChanges: function() { + return this.model.get("icon") !== parseInt(this.$('#icon').val()); + }, + + getValue: function () { + return (parseInt(this.$('#icon').val())); + }, + + getRequestData: function () { + return this.hasChanges() ? { + publish: 'republish', + metadata: { + 'icon': this.getValue() + } + } : {}; + } + }); + return { getModal: function(type, xblockInfo, options) { if (type === 'edit') { @@ -1050,7 +1073,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', editors: [] }; if (xblockInfo.isVertical()) { - editors = [StaffLockEditor, UnitAccessEditor]; + editors = [StaffLockEditor, UnitAccessEditor, IconEditor]; } else { tabs = [ { diff --git a/cms/templates/course_outline.html b/cms/templates/course_outline.html index 5507ed75fab5..38d138a99be7 100644 --- a/cms/templates/course_outline.html +++ b/cms/templates/course_outline.html @@ -26,7 +26,7 @@ <%block name="header_extras"> -% for template_name in ['course-outline', 'xblock-string-field-editor', 'basic-modal', 'modal-button', 'course-outline-modal', 'due-date-editor', 'release-date-editor', 'grading-editor', 'publish-editor', 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'verification-access-editor', 'timed-examination-preference-editor', 'access-editor', 'settings-modal-tabs', 'show-correctness-editor', 'highlights-editor', 'highlights-enable-editor', 'course-highlights-enable']: +% for template_name in ['course-outline', 'xblock-string-field-editor', 'basic-modal', 'modal-button', 'course-outline-modal', 'due-date-editor', 'release-date-editor', 'grading-editor', 'publish-editor', 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'verification-access-editor', 'timed-examination-preference-editor', 'access-editor', 'settings-modal-tabs', 'show-correctness-editor', 'highlights-editor', 'highlights-enable-editor', 'course-highlights-enable', 'icon-editor']: @@ -164,7 +164,7 @@

${_("Page Actions")}

% endif <%static:studiofrontend entry="courseOutlineHealthCheck"> - <% + <% course_key = context_course.id %> { @@ -188,7 +188,7 @@

${_("Page Actions")}

"settings": ${reverse('settings_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json} } } - +
diff --git a/cms/templates/js/icon-editor.underscore b/cms/templates/js/icon-editor.underscore new file mode 100644 index 000000000000..9d8fe51b7309 --- /dev/null +++ b/cms/templates/js/icon-editor.underscore @@ -0,0 +1,8 @@ + + diff --git a/common/lib/xmodule/xmodule/modulestore/inheritance.py b/common/lib/xmodule/xmodule/modulestore/inheritance.py index aa462d3a640a..b686fd45534f 100644 --- a/common/lib/xmodule/xmodule/modulestore/inheritance.py +++ b/common/lib/xmodule/xmodule/modulestore/inheritance.py @@ -51,6 +51,12 @@ class InheritanceMixin(XBlockMixin): default=False, scope=Scope.settings, ) + icon = Integer( + display_name=_("Icon"), + default=0, + help=_("XBlock Icon ID"), + scope=Scope.settings, + ) course_edit_method = String( display_name=_("Course Editor"), help=_("Enter the method by which this course is edited (\"XML\" or \"Studio\")."), diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py index cf0fa057ef41..7dce2cc1f5d6 100644 --- a/common/lib/xmodule/xmodule/seq_module.py +++ b/common/lib/xmodule/xmodule/seq_module.py @@ -492,7 +492,8 @@ def _render_student_view_for_items(self, context, display_items, fragment, view= 'id': text_type(usage_id), 'bookmarked': is_bookmarked, 'path': " > ".join(display_names + [item.display_name_with_default]), - 'graded': item.graded + 'graded': item.graded, + 'icon': item.icon, } if is_user_authenticated: diff --git a/lms/templates/seq_module.html b/lms/templates/seq_module.html index de1df5628aab..23e4843700df 100644 --- a/lms/templates/seq_module.html +++ b/lms/templates/seq_module.html @@ -38,8 +38,30 @@ % else: % for idx, item in enumerate(items): + + <% + icon = item.get('icon', 0) + iconClass = 'null' + %> + + % if icon == 0: + <% iconClass = item['type'] %> + % endif + % if icon == 1: + <% iconClass = 'other' %> + % endif + % if icon == 2: + <% iconClass = 'problem' %> + % endif + % if icon == 3: + <% iconClass = 'vertical' %> + % endif + % if icon == 4: + <% iconClass = 'video' %> + % endif +
  • -