Allow previewing cohorted content when masquerading
This commit is contained in:
committed by
Clinton Blackburn
parent
849ad8df94
commit
9e00e2b397
@@ -33,6 +33,19 @@ class StaffPage(CoursewarePage):
|
||||
self.q(css=self.VIEW_MODE_OPTIONS_CSS).filter(lambda el: el.text == view_mode).first.click()
|
||||
self.wait_for_ajax()
|
||||
|
||||
def set_staff_view_mode_specific_student(self, username_or_email):
|
||||
"""
|
||||
Set the current preview mode to "Specific Student" with the given username or email
|
||||
"""
|
||||
required_mode = "Specific student"
|
||||
if self.staff_view_mode != required_mode:
|
||||
self.q(css=self.VIEW_MODE_OPTIONS_CSS).filter(lambda el: el.text == required_mode).first.click()
|
||||
# Use a script here because .clear() + .send_keys() triggers unwanted behavior if a username is already set
|
||||
self.browser.execute_script(
|
||||
'$(".action-preview-username").val("{}").blur().change();'.format(username_or_email)
|
||||
)
|
||||
self.wait_for_ajax()
|
||||
|
||||
def open_staff_debug_info(self):
|
||||
"""
|
||||
Open the staff debug window
|
||||
|
||||
@@ -6,8 +6,10 @@ Tests the "preview" selector in the LMS that allows changing between Staff, Stud
|
||||
from ..helpers import UniqueCourseTest, create_user_partition_json
|
||||
from ...pages.studio.auto_auth import AutoAuthPage
|
||||
from ...pages.lms.courseware import CoursewarePage
|
||||
from ...pages.lms.instructor_dashboard import InstructorDashboardPage
|
||||
from ...pages.lms.staff_view import StaffPage
|
||||
from ...fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||
from bok_choy.promise import EmptyPromise
|
||||
from xmodule.partitions.partitions import Group
|
||||
from textwrap import dedent
|
||||
|
||||
@@ -335,6 +337,44 @@ class CourseWithContentGroupsTest(StaffViewTest):
|
||||
course_page.set_staff_view_mode('Student in beta')
|
||||
verify_expected_problem_visibility(self, course_page, [self.beta_text, self.everyone_text])
|
||||
|
||||
def create_cohorts_and_assign_students(self, student_a_username, student_b_username):
|
||||
"""
|
||||
Adds 2 manual cohorts, linked to content groups, to the course.
|
||||
Each cohort is assigned one student.
|
||||
"""
|
||||
instructor_dashboard_page = InstructorDashboardPage(self.browser, self.course_id)
|
||||
instructor_dashboard_page.visit()
|
||||
cohort_management_page = instructor_dashboard_page.select_cohort_management()
|
||||
cohort_management_page.is_cohorted = True
|
||||
|
||||
def add_cohort_with_student(cohort_name, content_group, student):
|
||||
""" Create cohort and assign student to it. """
|
||||
cohort_management_page.add_cohort(cohort_name, content_group=content_group)
|
||||
# After adding the cohort, it should automatically be selected
|
||||
EmptyPromise(
|
||||
lambda: cohort_name == cohort_management_page.get_selected_cohort(), "Waiting for new cohort"
|
||||
).fulfill()
|
||||
cohort_management_page.add_students_to_selected_cohort([student])
|
||||
add_cohort_with_student("Cohort Alpha", "alpha", student_a_username)
|
||||
add_cohort_with_student("Cohort Beta", "beta", student_b_username)
|
||||
cohort_management_page.wait_for_ajax()
|
||||
|
||||
def test_as_specific_student(self):
|
||||
student_a_username = 'tass_student_a'
|
||||
student_b_username = 'tass_student_b'
|
||||
AutoAuthPage(self.browser, username=student_a_username, course_id=self.course_id, no_login=True).visit()
|
||||
AutoAuthPage(self.browser, username=student_b_username, course_id=self.course_id, no_login=True).visit()
|
||||
self.create_cohorts_and_assign_students(student_a_username, student_b_username)
|
||||
|
||||
# Masquerade as student in alpha cohort:
|
||||
course_page = self._goto_staff_page()
|
||||
course_page.set_staff_view_mode_specific_student(student_a_username)
|
||||
verify_expected_problem_visibility(self, course_page, [self.alpha_text, self.everyone_text])
|
||||
|
||||
# Masquerade as student in beta cohort:
|
||||
course_page.set_staff_view_mode_specific_student(student_b_username)
|
||||
verify_expected_problem_visibility(self, course_page, [self.beta_text, self.everyone_text])
|
||||
|
||||
|
||||
def verify_expected_problem_visibility(test, courseware_page, expected_problems):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user