Disable setting course pacing during course run.
Also adds improved styling for course pacing settings, and unit tests around query counts for self-paced courses. ECOM-2650
This commit is contained in:
@@ -131,15 +131,20 @@ class SettingsPage(CoursePage):
|
||||
raise Exception("Invalid license name: {name}".format(name=license_name))
|
||||
button.click()
|
||||
|
||||
pacing_css = 'section.pacing input[type=radio]:checked'
|
||||
pacing_css = 'section.pacing input[type=radio]'
|
||||
|
||||
@property
|
||||
def checked_pacing_css(self):
|
||||
"""CSS for the course pacing button which is currently checked."""
|
||||
return self.pacing_css + ':checked'
|
||||
|
||||
@property
|
||||
def course_pacing(self):
|
||||
"""
|
||||
Returns the label text corresponding to the checked pacing radio button.
|
||||
"""
|
||||
self.wait_for_element_presence(self.pacing_css, 'course pacing controls present and rendered')
|
||||
checked = self.q(css=self.pacing_css).results[0]
|
||||
self.wait_for_element_presence(self.checked_pacing_css, 'course pacing controls present and rendered')
|
||||
checked = self.q(css=self.checked_pacing_css).results[0]
|
||||
checked_id = checked.get_attribute('id')
|
||||
return self.q(css='label[for={checked_id}]'.format(checked_id=checked_id)).results[0].text
|
||||
|
||||
@@ -149,9 +154,24 @@ class SettingsPage(CoursePage):
|
||||
Sets the course to either self-paced or instructor-led by checking
|
||||
the appropriate radio button.
|
||||
"""
|
||||
self.wait_for_element_presence(self.pacing_css, 'course pacing controls present')
|
||||
self.wait_for_element_presence(self.checked_pacing_css, 'course pacing controls present')
|
||||
self.q(xpath="//label[contains(text(), '{pacing}')]".format(pacing=pacing)).click()
|
||||
|
||||
@property
|
||||
def course_pacing_disabled_text(self):
|
||||
"""
|
||||
Return the message indicating that course pacing cannot be toggled.
|
||||
"""
|
||||
return self.q(css='#course-pace-toggle-tip').results[0].text
|
||||
|
||||
def course_pacing_disabled(self):
|
||||
"""
|
||||
Return True if the course pacing controls are disabled; False otherwise.
|
||||
"""
|
||||
self.wait_for_element_presence(self.checked_pacing_css, 'course pacing controls present')
|
||||
statuses = self.q(css=self.pacing_css).map(lambda e: e.get_attribute('disabled')).results
|
||||
return all((s == 'true' for s in statuses))
|
||||
|
||||
################
|
||||
# Waits
|
||||
################
|
||||
|
||||
@@ -1766,7 +1766,10 @@ class SelfPacedOutlineTest(CourseOutlineTest):
|
||||
)
|
||||
),
|
||||
)
|
||||
self.course_fixture.add_course_details({'self_paced': True})
|
||||
self.course_fixture.add_course_details({
|
||||
'self_paced': True,
|
||||
'start_date': datetime.now() + timedelta(days=1)
|
||||
})
|
||||
ConfigModelFixture('/config/self_paced', {'enabled': True}).install()
|
||||
|
||||
def test_release_dates_not_shown(self):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Acceptance tests for Studio's Settings Details pages
|
||||
"""
|
||||
from datetime import datetime, timedelta
|
||||
from unittest import skip
|
||||
|
||||
from .base_studio_test import StudioCourseTest
|
||||
@@ -205,19 +206,23 @@ class CoursePacingTest(StudioSettingsDetailsTest):
|
||||
|
||||
def populate_course_fixture(self, __):
|
||||
ConfigModelFixture('/config/self_paced', {'enabled': True}).install()
|
||||
# Set the course start date to tomorrow in order to allow setting pacing
|
||||
self.course_fixture.add_course_details({'start_date': datetime.now() + timedelta(days=1)})
|
||||
|
||||
def test_default_instructor_led(self):
|
||||
"""
|
||||
Test that the 'instructor led' button is checked by default.
|
||||
"""
|
||||
self.assertEqual(self.settings_detail.course_pacing, 'Instructor Led')
|
||||
self.assertEqual(self.settings_detail.course_pacing, 'Instructor-Led')
|
||||
|
||||
def test_self_paced(self):
|
||||
"""
|
||||
Test that the 'self-paced' button is checked for a self-paced
|
||||
course.
|
||||
"""
|
||||
self.course_fixture.add_course_details({'self_paced': True})
|
||||
self.course_fixture.add_course_details({
|
||||
'self_paced': True
|
||||
})
|
||||
self.course_fixture.configure_course()
|
||||
self.settings_detail.refresh_page()
|
||||
self.assertEqual(self.settings_detail.course_pacing, 'Self-Paced')
|
||||
@@ -230,3 +235,14 @@ class CoursePacingTest(StudioSettingsDetailsTest):
|
||||
self.settings_detail.save_changes()
|
||||
self.settings_detail.refresh_page()
|
||||
self.assertEqual(self.settings_detail.course_pacing, 'Self-Paced')
|
||||
|
||||
def test_toggle_pacing_after_course_start(self):
|
||||
"""
|
||||
Test that course authors cannot toggle the pacing of their course
|
||||
while the course is running.
|
||||
"""
|
||||
self.course_fixture.add_course_details({'start_date': datetime.now()})
|
||||
self.course_fixture.configure_course()
|
||||
self.settings_detail.refresh_page()
|
||||
self.assertTrue(self.settings_detail.course_pacing_disabled())
|
||||
self.assertIn('Course pacing cannot be changed', self.settings_detail.course_pacing_disabled_text)
|
||||
|
||||
Reference in New Issue
Block a user