Support adding cohorts from the instructor dashboard

TNL-162
This commit is contained in:
Andy Armstrong
2014-09-26 15:43:15 -04:00
committed by cahrens
parent b58f7ad7b4
commit 6219ecacfe
23 changed files with 570 additions and 159 deletions

View File

@@ -37,7 +37,7 @@ class MembershipPage(PageObject):
def _get_cohort_options(self):
"""
Returns the available options in the cohort dropdown, including the initial "Select a cohort".
Returns the available options in the cohort dropdown, including the initial "Select a cohort group".
"""
return self.q(css=".cohort-management #cohort-select option")
@@ -55,7 +55,7 @@ class MembershipPage(PageObject):
def get_cohorts(self):
"""
Returns, as a list, the names of the available cohorts in the drop-down, filtering out "Select a cohort".
Returns, as a list, the names of the available cohorts in the drop-down, filtering out "Select a cohort group".
"""
return [
self._cohort_name(opt.text)
@@ -86,6 +86,15 @@ class MembershipPage(PageObject):
lambda el: self._cohort_name(el.text) == cohort_name
).first.click()
def add_cohort(self, cohort_name):
"""
Adds a new manual cohort with the specified name.
"""
self.q(css="div.cohort-management-nav .action-create").first.click()
textinput = self.q(css="#cohort-create-name").results[0]
textinput.send_keys(cohort_name)
self.q(css="div.form-actions .action-save").first.click()
def get_cohort_group_setup(self):
"""
Returns the description of the current cohort

View File

@@ -11,6 +11,8 @@ from ...pages.lms.auto_auth import AutoAuthPage
from ...pages.lms.instructor_dashboard import InstructorDashboardPage
from ...pages.studio.settings_advanced import AdvancedSettingsPage
import uuid
class CohortConfigurationTest(UniqueCourseTest, CohortTestMixin):
"""
@@ -149,6 +151,30 @@ class CohortConfigurationTest(UniqueCourseTest, CohortTestMixin):
self.assertEqual("There was an error when trying to add students:", error_messages[0])
self.assertEqual("Unknown user: unknown_user", error_messages[1])
self.assertEqual(
self.student_name+",unknown_user,",
self.student_name + ",unknown_user,",
self.membership_page.get_cohort_student_input_field_value()
)
def test_add_new_cohort(self):
"""
Scenario: A new manual cohort can be created, and a student assigned to it.
Given I have a course with a user in the course
When I add a new manual cohort to the course via the LMS instructor dashboard
Then the new cohort is displayed and has no users in it
And when I add the user to the new cohort
Then the cohort has 1 user
"""
new_cohort = str(uuid.uuid4().get_hex()[0:20])
self.assertFalse(new_cohort in self.membership_page.get_cohorts())
self.membership_page.add_cohort(new_cohort)
# After adding the cohort, it should automatically be selected
EmptyPromise(
lambda: new_cohort == self.membership_page.get_selected_cohort(), "Waiting for new cohort to appear"
).fulfill()
self.assertEqual(0, self.membership_page.get_selected_cohort_count())
self.membership_page.add_students_to_selected_cohort([self.instructor_name])
# Wait for the number of users in the cohort to change, indicating that the add operation is complete.
EmptyPromise(
lambda: 1 == self.membership_page.get_selected_cohort_count(), 'Waiting for student to be added'
).fulfill()