From 46e0ecfb895ae086aabaa0a13ed42000c7da1eba Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 24 Feb 2020 08:58:46 -0500 Subject: [PATCH 1/2] Remove a bok-choy test that shouldn't have been a bok-choy test --- .../tests/lms/test_lms_course_home.py | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/common/test/acceptance/tests/lms/test_lms_course_home.py b/common/test/acceptance/tests/lms/test_lms_course_home.py index cef78f8ba3..bee5448968 100644 --- a/common/test/acceptance/tests/lms/test_lms_course_home.py +++ b/common/test/acceptance/tests/lms/test_lms_course_home.py @@ -167,73 +167,3 @@ class CourseHomeA11yTest(CourseHomeBaseTest): ] }) course_search_results_page.a11y_audit.check_for_accessibility_errors() - - -class CourseOutlineTest(UniqueCourseTest): - """ - Test Suite to verify the course outline page on the LMS. - """ - USERNAME = "STUDENT_TESTER" - EMAIL = "student101@example.com" - - def setUp(self): - """ - Initialize pages and install a course fixture. - """ - super(CourseOutlineTest, self).setUp() - - self.course_home_page = CourseHomePage(self.browser, self.course_id) - # Install a course with sections and problems - self.course_fix = CourseFixture( - self.course_info['org'], - self.course_info['number'], - self.course_info['run'], - self.course_info['display_name'], - start_date=datetime.now() + timedelta(days=-10), - end_date=datetime.now() + timedelta(days=10) - ) - - self.course_fix.add_children( - XBlockFixtureDesc('chapter', 'Test Section').add_children( - XBlockFixtureDesc('sequential', 'Test Subsection', metadata={ - 'due': (datetime.now()).isoformat(), - 'format': 'Homework' - }).add_children( - XBlockFixtureDesc('problem', 'Test Problem', data=load_data_str('multiple_choice.xml')), - ) - ), - ).install() - # Auto-auth register for the course. - auto_auth(self.browser, self.USERNAME, self.EMAIL, False, self.course_id) - - def change_course_pacing_to_self_paced(self): - """ - Change the course pacing from Instructor Paced to Self-paced course - for a live course. - """ - self.course_fix.add_course_details({'start_date': (datetime.now() + timedelta(days=5))}) - self.course_fix.configure_course() - self.course_fix.add_course_details({'self_paced': True}) - self.course_fix.configure_course() - self.course_fix.add_course_details({'start_date': (datetime.now() + timedelta(days=-10))}) - self.course_fix.configure_course() - - def test_outline_when_pacing_changed_to_self_paced(self): - """ - Scenario: Ensure that due dates are not displayed on the course outline page - when switched to self-paced mode from instructor-paced. - - Given an instructor paced course with a due graded content - Visit the course outline page - Verify the due date visibility - Change the course pacing to self-paced - Visit the course outline page again - Verify that due date is not visible - """ - self.course_home_page.visit() - due_date = self.course_home_page.outline.get_subsection_due_date() - self.assertIn(str(datetime.now().year), due_date) - self.change_course_pacing_to_self_paced() - self.course_home_page.visit() - due_date = self.course_home_page.outline.get_subsection_due_date() - self.assertNotIn(str(datetime.now().year), due_date) From f3bce46757607d5d7d708f6581333bb0c73c5e44 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 21 Feb 2020 11:58:17 -0500 Subject: [PATCH 2/2] Allow due-dates for self-paced courses in the course outline --- .../templates/course_experience/course-outline-fragment.html | 2 +- .../course_experience/tests/views/test_course_home.py | 2 +- openedx/features/course_experience/views/course_outline.py | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openedx/features/course_experience/templates/course_experience/course-outline-fragment.html b/openedx/features/course_experience/templates/course_experience/course-outline-fragment.html index 2d913abf96..3ccdd7641b 100644 --- a/openedx/features/course_experience/templates/course_experience/course-outline-fragment.html +++ b/openedx/features/course_experience/templates/course_experience/course-outline-fragment.html @@ -91,7 +91,7 @@ self_paced = context.get('self_paced', False) ## ## Exam subsections expose exam status message field as well as a status icon <% - if subsection.get('due') is None or self_paced: + if subsection.get('due') is None or (self_paced and not in_edx_when): # examples: Homework, Lab, etc. data_string = subsection.get('format') data_datetime = "" diff --git a/openedx/features/course_experience/tests/views/test_course_home.py b/openedx/features/course_experience/tests/views/test_course_home.py index 82169369dd..8b88c99381 100644 --- a/openedx/features/course_experience/tests/views/test_course_home.py +++ b/openedx/features/course_experience/tests/views/test_course_home.py @@ -218,7 +218,7 @@ class TestCourseHomePage(CourseHomePageTestCase): # Fetch the view and verify the query counts # TODO: decrease query count as part of REVO-28 - with self.assertNumQueries(73, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST): + with self.assertNumQueries(74, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST): with check_mongo_calls(4): url = course_home_url(self.course) self.client.get(url) diff --git a/openedx/features/course_experience/views/course_outline.py b/openedx/features/course_experience/views/course_outline.py index 111000cf5e..bab2cdc485 100644 --- a/openedx/features/course_experience/views/course_outline.py +++ b/openedx/features/course_experience/views/course_outline.py @@ -10,6 +10,7 @@ from completion import waffle as completion_waffle from django.contrib.auth.models import User from django.template.context_processors import csrf from django.template.loader import render_to_string +import edx_when.api as edx_when_api from opaque_keys.edx.keys import CourseKey from pytz import UTC from waffle.models import Switch @@ -71,6 +72,10 @@ class CourseOutlineFragmentView(EdxFragmentView): if page_context: context['self_paced'] = page_context.get('pacing_type', 'instructor_paced') == 'self_paced' + # We're using this flag to prevent old self-paced dates from leaking out on courses not + # managed by edx-when. + context['in_edx_when'] = edx_when_api.is_enabled_for_course(course_key) + html = render_to_string('course_experience/course-outline-fragment.html', context) return Fragment(html)