diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index c3033f1b401c..4159b1928c58 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -1712,104 +1712,6 @@ def test_json_init_data(self, json_data, json_output): self.assertEqual(html.count(""), 1) -class ViewInStudioTest(ModuleStoreTestCase): - """Tests for the 'View in Studio' link visiblity.""" - - def setUp(self): - """ Set up the user and request that will be used. """ - super(ViewInStudioTest, self).setUp() - self.staff_user = GlobalStaffFactory.create() - self.request = RequestFactoryNoCsrf().get('/') - self.request.user = self.staff_user - self.request.session = {} - self.module = None - self.default_context = {'bookmarked': False, 'username': self.user.username} - - def _get_module(self, course_id, descriptor, location): - """ - Get the module from the course from which to pattern match (or not) the 'View in Studio' buttons - """ - field_data_cache = FieldDataCache.cache_for_descriptor_descendents( - course_id, - self.staff_user, - descriptor - ) - - return render.get_module( - self.staff_user, - self.request, - location, - field_data_cache, - ) - - def setup_mongo_course(self, course_edit_method='Studio'): - """ Create a mongo backed course. """ - course = CourseFactory.create( - course_edit_method=course_edit_method - ) - - descriptor = ItemFactory.create( - category='vertical', - parent_location=course.location, - ) - - child_descriptor = ItemFactory.create( - category='vertical', - parent_location=descriptor.location - ) - - self.module = self._get_module(course.id, descriptor, descriptor.location) - - # pylint: disable=attribute-defined-outside-init - self.child_module = self._get_module(course.id, child_descriptor, child_descriptor.location) - - -class MongoViewInStudioTest(ViewInStudioTest): - """Test the 'View in Studio' link visibility in a mongo backed course.""" - - def test_view_in_studio_link_studio_course(self): - """Regular Studio courses should see 'View in Studio' links.""" - self.setup_mongo_course() - result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context) - self.assertIn('View Unit in Studio', result_fragment.content) - - def test_view_in_studio_link_only_in_top_level_vertical(self): - """Regular Studio courses should not see 'View in Studio' for child verticals of verticals.""" - self.setup_mongo_course() - # Render the parent vertical, then check that there is only a single "View Unit in Studio" link. - result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context) - # The single "View Unit in Studio" link should appear before the first xmodule vertical definition. - parts = result_fragment.content.split('data-block-type="vertical"') - self.assertEqual(3, len(parts), "Did not find two vertical blocks") - self.assertIn('View Unit in Studio', parts[0]) - self.assertNotIn('View Unit in Studio', parts[1]) - self.assertNotIn('View Unit in Studio', parts[2]) - - def test_view_in_studio_link_xml_authored(self): - """Courses that change 'course_edit_method' setting can hide 'View in Studio' links.""" - self.setup_mongo_course(course_edit_method='XML') - result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context) - self.assertNotIn('View Unit in Studio', result_fragment.content) - - -class MixedViewInStudioTest(ViewInStudioTest): - """Test the 'View in Studio' link visibility in a mixed mongo backed course.""" - - MODULESTORE = TEST_DATA_MIXED_MODULESTORE - - def test_view_in_studio_link_mongo_backed(self): - """Mixed mongo courses that are mongo backed should see 'View in Studio' links.""" - self.setup_mongo_course() - result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context) - self.assertIn('View Unit in Studio', result_fragment.content) - - def test_view_in_studio_link_xml_authored(self): - """Courses that change 'course_edit_method' setting can hide 'View in Studio' links.""" - self.setup_mongo_course(course_edit_method='XML') - result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context) - self.assertNotIn('View Unit in Studio', result_fragment.content) - - @XBlock.tag("detached") class DetachedXBlock(XBlock): """ diff --git a/lms/static/sass/course/layout/_courseware_preview.scss b/lms/static/sass/course/layout/_courseware_preview.scss index 9a75cb1612cf..2c2626a8b61f 100644 --- a/lms/static/sass/course/layout/_courseware_preview.scss +++ b/lms/static/sass/course/layout/_courseware_preview.scss @@ -16,6 +16,10 @@ $proctoring-banner-text-size: 14px; @extend %inner-wrapper; width: auto; + + a.btn { + margin: 5px 0 5px 5px; + } } .preview-actions { diff --git a/lms/templates/edit_unit_link.html b/lms/templates/edit_unit_link.html deleted file mode 100644 index 6b507c1945cf..000000000000 --- a/lms/templates/edit_unit_link.html +++ /dev/null @@ -1,7 +0,0 @@ -<%page expression_filter="h"/> -<%! from django.utils.translation import ugettext as _ %> - -
- ${_("View Unit in Studio")} -
-${frag_content | n, decode.utf8} diff --git a/lms/templates/preview_menu.html b/lms/templates/preview_menu.html index cd7da9f50310..6afc80fc4e33 100644 --- a/lms/templates/preview_menu.html +++ b/lms/templates/preview_menu.html @@ -26,10 +26,32 @@ staff_selected = selected(not masquerade or masquerade.role != "student") specific_student_selected = selected(not staff_selected and masquerade.user_name) student_selected = selected(not staff_selected and not specific_student_selected and not masquerade_group_id) + + if settings.HTTPS == 'on': + protocol = 'https' + else: + protocol = 'http' + insights_base_url = settings.ANALYTICS_DASHBOARD_URL + studio_base_url = '' + if settings.CMS_BASE: + studio_base_url = protocol + '://' + settings.CMS_BASE + insights_url = insights_base_url + studio_url = studio_base_url + if course and course.id: + if insights_base_url: + insights_url = "{base_url}/{course_id}".format( + base_url=insights_base_url, + course_id=course.id, + ) + if studio_base_url: + studio_url = "{base_url}/course/{course_id}".format( + base_url=studio_base_url, + course_id=course.id, + ) %> diff --git a/openedx/core/lib/xblock_utils/__init__.py b/openedx/core/lib/xblock_utils/__init__.py index 00423da4bc9c..c8c205f2e2f4 100644 --- a/openedx/core/lib/xblock_utils/__init__.py +++ b/openedx/core/lib/xblock_utils/__init__.py @@ -323,23 +323,7 @@ def add_staff_markup(user, disable_staff_debug_info, block, view, frag, context) return frag # TODO: make this more general, eg use an XModule attribute instead if isinstance(block, VerticalBlock) and (not context or not context.get('child_of_vertical', False)): - # check that the course is a mongo backed Studio course before doing work - is_studio_course = block.course_edit_method == "Studio" - - if is_studio_course: - # build edit link to unit in CMS. Can't use reverse here as lms doesn't load cms's urls.py - edit_link = "//" + settings.CMS_BASE + '/container/' + text_type(block.location) - - # return edit link in rendered HTML for display - return wrap_fragment( - frag, - render_to_string( - "edit_unit_link.html", - {'frag_content': frag.content, 'edit_link': edit_link} - ) - ) - else: - return frag + return frag if isinstance(block, SequenceModule) or getattr(block, 'HIDDEN', False): return frag