diff --git a/common/lib/xmodule/xmodule/js/src/sequence/display.js b/common/lib/xmodule/xmodule/js/src/sequence/display.js index d49d3361a0..eb7b3b9cab 100644 --- a/common/lib/xmodule/xmodule/js/src/sequence/display.js +++ b/common/lib/xmodule/xmodule/js/src/sequence/display.js @@ -57,6 +57,8 @@ this.ajaxUrl = this.el.data('ajax-url'); this.nextUrl = this.el.data('next-url'); this.prevUrl = this.el.data('prev-url'); + this.savePosition = this.el.data('save-position'); + this.showCompletion = this.el.data('show-completion'); this.keydownHandler($(element).find('#sequence-list .tab')); this.base_page_title = ($('title').data('base-title') || '').trim(); this.bind(); @@ -230,11 +232,15 @@ if (this.position !== newPosition) { if (this.position) { this.mark_visited(this.position); - this.update_completion(this.position); - modxFullUrl = '' + this.ajaxUrl + '/goto_position'; - $.postWithPrefix(modxFullUrl, { - position: newPosition - }); + if (this.showCompletion) { + this.update_completion(this.position); + } + if (this.savePosition) { + modxFullUrl = '' + this.ajaxUrl + '/goto_position'; + $.postWithPrefix(modxFullUrl, { + position: newPosition + }); + } } // On Sequence change, fire custom event 'sequence:change' on element. diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py index 0700897aa2..2cd8d29114 100644 --- a/common/lib/xmodule/xmodule/seq_module.py +++ b/common/lib/xmodule/xmodule/seq_module.py @@ -330,7 +330,8 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule): 'next_url': context.get('next_url'), 'prev_url': context.get('prev_url'), 'banner_text': banner_text, - 'disable_navigation': not self.is_user_authenticated(context), + 'save_position': self.is_user_authenticated(context), + 'show_completion': self.is_user_authenticated(context), 'gated_content': self._get_gated_content_info(prereq_met, prereq_meta_info) } fragment.add_content(self.system.render_template("seq_module.html", params)) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 7a2c18d62c..cc7c922106 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -2334,6 +2334,7 @@ class TestIndexView(ModuleStoreTestCase): with self.store.bulk_operations(course.id): chapter = ItemFactory(parent=course, category='chapter') section = ItemFactory(parent=chapter, category='sequential') + ItemFactory.create(parent=section, category='vertical', display_name="Vertical") url = reverse( 'courseware_section', @@ -2350,6 +2351,16 @@ class TestIndexView(ModuleStoreTestCase): with override_waffle_flag(waffle_flag, active=True): response = self.client.get(url, follow=False) assert response.status_code == 200 + self.assertIn('data-save-position="false"', response.content) + self.assertIn('data-show-completion="false"', response.content) + + user = UserFactory() + CourseEnrollmentFactory(user=user, course_id=course.id) + self.assertTrue(self.client.login(username=user.username, password='test')) + response = self.client.get(url, follow=False) + assert response.status_code == 200 + self.assertIn('data-save-position="true"', response.content) + self.assertIn('data-show-completion="true"', response.content) @attr(shard=5) diff --git a/lms/templates/seq_module.html b/lms/templates/seq_module.html index 1bff2b9dac..de1df5628a 100644 --- a/lms/templates/seq_module.html +++ b/lms/templates/seq_module.html @@ -1,7 +1,12 @@ <%page expression_filter="h"/> <%! from django.utils.translation import ugettext as _ %> -
+
% if banner_text:
@@ -46,8 +51,7 @@ data-page-title="${item['page_title']}" data-path="${item['path']}" data-graded="${item['graded']}" - id="tab_${idx}" - ${"disabled=disabled" if disable_navigation else ""}> + id="tab_${idx}"> % if 'complete' in item: