def test_add_users_doesnt_add_duplicate_entry(self):
     """
     Tests that calling add_users multiple times before a single call
     to remove_users does not result in the user remaining in the group.
     """
     role = CourseStaffRole(self.course_key)
     role.add_users(self.student)
     self.assertTrue(role.has_user(self.student))
     # Call add_users a second time, then remove just once.
     role.add_users(self.student)
     role.remove_users(self.student)
     self.assertFalse(role.has_user(self.student))
Exemple #2
0
 def test_add_users_doesnt_add_duplicate_entry(self):
     """
     Tests that calling add_users multiple times before a single call
     to remove_users does not result in the user remaining in the group.
     """
     role = CourseStaffRole(self.course_key)
     role.add_users(self.student)
     self.assertTrue(role.has_user(self.student))
     # Call add_users a second time, then remove just once.
     role.add_users(self.student)
     role.remove_users(self.student)
     self.assertFalse(role.has_user(self.student))
Exemple #3
0
def assign_staff_role_to_ccx(ccx_locator, user, master_course_id):
    """
    Check if user has ccx_coach role on master course then assign him staff role on ccx only
    if role is not already assigned. Because of this coach can open dashboard from master course
    as well as ccx.
    :param ccx_locator: CCX key
    :param user: User to whom we want to assign role.
    :param master_course_id: Master course key
    """
    coach_role_on_master_course = CourseCcxCoachRole(master_course_id)
    # check if user has coach role on master course
    if coach_role_on_master_course.has_user(user):
        # Check if user has staff role on ccx.
        role = CourseStaffRole(ccx_locator)
        if not role.has_user(user):
            # assign user the staff role on ccx
            with ccx_course(ccx_locator) as course:
                allow_access(course, user, "staff", send_email=False)
Exemple #4
0
def assign_staff_role_to_ccx(ccx_locator, user, master_course_id):
    """
    Check if user has ccx_coach role on master course then assign him staff role on ccx only
    if role is not already assigned. Because of this coach can open dashboard from master course
    as well as ccx.
    :param ccx_locator: CCX key
    :param user: User to whom we want to assign role.
    :param master_course_id: Master course key
    """
    coach_role_on_master_course = CourseCcxCoachRole(master_course_id)
    # check if user has coach role on master course
    if coach_role_on_master_course.has_user(user):
        # Check if user has staff role on ccx.
        role = CourseStaffRole(ccx_locator)
        if not role.has_user(user):
            # assign user the staff role on ccx
            with ccx_course(ccx_locator) as course:
                allow_access(course, user, "staff", send_email=False)