From e59410be18bda233f2dd5accb551dcfb298a32ce Mon Sep 17 00:00:00 2001 From: Nimisha Asthagiri Date: Thu, 9 Nov 2017 11:53:32 -0500 Subject: [PATCH] Studio Section Highlights: add doc and preview text to modal --- cms/djangoapps/contentstore/views/item.py | 19 +++++++------ .../contentstore/views/tests/test_item.py | 2 +- cms/envs/help_tokens.ini | 1 + cms/static/js/models/xblock_info.js | 6 ++-- .../js/views/modals/course_outline_modals.js | 11 +++----- cms/static/sass/views/_outline.scss | 4 +++ cms/templates/js/highlights-editor.underscore | 28 +++++++++++++++++++ 7 files changed, 52 insertions(+), 19 deletions(-) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index c7bcf93d4c..bff4d8b946 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -46,8 +46,10 @@ from contentstore.views.helpers import ( ) from contentstore.views.preview import get_preview_fragment from edxmako.shortcuts import render_to_string +from help_tokens.core import HelpUrlExpert from models.settings.course_grading import CourseGradingModel -from openedx.core.djangoapps.waffle_utils import WaffleSwitch +from openedx.core.djangoapps.schedules.config import COURSE_UPDATE_WAFFLE_FLAG +from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace, WaffleSwitch from openedx.core.lib.gating import api as gating_api from openedx.core.lib.xblock_utils import request_token, wrap_xblock from static_replace import replace_static_urls @@ -80,6 +82,9 @@ NEVER = lambda x: False ALWAYS = lambda x: True +highlights_setting = WaffleSwitch(u'dynamic_pacing', u'studio_course_update') + + def hash_resource(resource): """ Hash a :class:`xblock.fragment.FragmentResource`. @@ -1185,8 +1190,10 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F }) elif xblock.category == 'chapter': xblock_info.update({ - 'highlights': xblock.highlights, - 'highlights_enabled': highlights_setting().is_enabled(), + 'highlights': getattr(xblock, 'highlights', []), + 'highlights_enabled': highlights_setting.is_enabled(), + 'highlights_preview_only': not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course.id), + 'highlights_doc_url': HelpUrlExpert.the_one().url_for_token('content_highlights'), }) # update xblock_info with special exam information if the feature flag is enabled @@ -1248,12 +1255,6 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F return xblock_info -def highlights_setting(): - namespace = u'dynamic_pacing' - switch = u'studio_course_update' - return WaffleSwitch(namespace, switch) - - def add_container_page_publishing_info(xblock, xblock_info): # pylint: disable=invalid-name """ Adds information about the xblock's publish state to the supplied diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index c36e44ae75..09f7e6f7c0 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -2574,7 +2574,7 @@ class TestXBlockInfo(ItemTest): def test_highlights_enabled(self): chapter = modulestore().get_item(self.chapter.location) - with highlights_setting().override(): + with highlights_setting.override(): xblock_info = create_xblock_info(chapter) self.assertTrue(xblock_info['highlights_enabled']) diff --git a/cms/envs/help_tokens.ini b/cms/envs/help_tokens.ini index b74406f20a..040a65b1c7 100644 --- a/cms/envs/help_tokens.ini +++ b/cms/envs/help_tokens.ini @@ -32,6 +32,7 @@ group_configurations = course_author:course_features/content_experiments/content container = course_author:developing_course/course_components.html#components-that-contain-other-components video = course_author:video/index.html certificates = course_author:set_up_course/studio_add_course_information/studio_creating_certificates.html +content_highlights = course_author:developing_course/course_sections.html#set-section-highlights-for-weekly-course-highlight-messages # below are the language directory names for the different locales [locales] diff --git a/cms/static/js/models/xblock_info.js b/cms/static/js/models/xblock_info.js index 84264750aa..8bd50a4b20 100644 --- a/cms/static/js/models/xblock_info.js +++ b/cms/static/js/models/xblock_info.js @@ -163,8 +163,10 @@ function(Backbone, _, str, ModuleUtils) { /** * This xBlock's Highlights to message to learners. */ - highlights: null, - highlights_enabled: null + highlights: [], + highlights_enabled: false, + highlights_preview_only: true, + highlights_doc_url: '' }, initialize: function() { diff --git a/cms/static/js/views/modals/course_outline_modals.js b/cms/static/js/views/modals/course_outline_modals.js index 0de705a132..bf34283ee9 100644 --- a/cms/static/js/views/modals/course_outline_modals.js +++ b/cms/static/js/views/modals/course_outline_modals.js @@ -236,12 +236,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', }, getIntroductionMessage: function() { - return StringUtils.interpolate( - gettext( - 'Enter 3-5 highlights to include in the email message that learners receive for ' + - 'this section (250 character limit).' - ) - ); + return ''; }, callAnalytics: function(event) { @@ -930,7 +925,9 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', {}, AbstractEditor.prototype.getContext.call(this), { - highlights: this.model.get('highlights') || [] + highlights: this.model.get('highlights'), + highlights_preview_only: this.model.get('highlights_preview_only'), + highlights_doc_url: this.model.get('highlights_doc_url') } ); } diff --git a/cms/static/sass/views/_outline.scss b/cms/static/sass/views/_outline.scss index 3634ef6524..d3674ce852 100644 --- a/cms/static/sass/views/_outline.scss +++ b/cms/static/sass/views/_outline.scss @@ -671,6 +671,10 @@ .highlight-input-label { font-weight: 600; } + + .highlights-info { + font-size: smaller; + } } // outline: edit item settings diff --git a/cms/templates/js/highlights-editor.underscore b/cms/templates/js/highlights-editor.underscore index ca398f614c..2bf31f5ffe 100644 --- a/cms/templates/js/highlights-editor.underscore +++ b/cms/templates/js/highlights-editor.underscore @@ -1,5 +1,33 @@
+
+ +<% if (highlights_preview_only) { %> +

+ <%- gettext('This feature is currently in testing. Course teams can enter highlights, but learners will not receive email messages.') %> +

+<% } %> + +<%- gettext('Enter 3-5 highlights to include in the email message that learners receive for this section (250 character limit).') %> + +

+
+<% // xss-lint: disable=underscore-not-escaped %> +<%= edx.HtmlUtils.interpolateHtml( + gettext( + 'For more information and an example of the email template, ' + + 'read our {linkStart}documentation{linkEnd}.' + ), + { + linkStart: edx.HtmlUtils.HTML(''), + linkEnd: edx.HtmlUtils.HTML('') + } +) %> +

+
+ +
+