当前位置: 首页>>代码示例>>Python>>正文


Python CourseStaffRole.users_with_role方法代码示例

本文整理汇总了Python中student.roles.CourseStaffRole.users_with_role方法的典型用法代码示例。如果您正苦于以下问题:Python CourseStaffRole.users_with_role方法的具体用法?Python CourseStaffRole.users_with_role怎么用?Python CourseStaffRole.users_with_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在student.roles.CourseStaffRole的用法示例。


在下文中一共展示了CourseStaffRole.users_with_role方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_user_for_role

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
 def test_get_user_for_role(self):
     """
     test users_for_role
     """
     role = CourseStaffRole(self.course_key)
     role.add_users(self.student)
     self.assertGreater(len(role.users_with_role()), 0)
开发者ID:AdityaKashyap,项目名称:edx-platform,代码行数:9,代码来源:test_roles.py

示例2: delete_course_and_groups

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
def delete_course_and_groups(course_id, commit=False):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore('direct')
    content_store = contentstore()

    org, course_num, _ = course_id.split("/")
    module_store.ignore_write_events_on_courses.append('{0}/{1}'.format(
        org, course_num))

    loc = CourseDescriptor.id_to_location(course_id)
    if delete_course(module_store, content_store, loc, commit):
        print 'removing forums permissions and roles...'
        unseed_permissions_roles(course_id)

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        if commit:
            try:
                staff_role = CourseStaffRole(loc)
                staff_role.remove_users(*staff_role.users_with_role())
                instructor_role = CourseInstructorRole(loc)
                instructor_role.remove_users(
                    *instructor_role.users_with_role())
            except Exception as err:
                log.error(
                    "Error in deleting course groups for {0}: {1}".format(
                        loc, err))
开发者ID:norsecode,项目名称:edx-platform,代码行数:32,代码来源:utils.py

示例3: delete_course_and_groups

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
def delete_course_and_groups(course_id, commit=False):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore('direct')
    content_store = contentstore()

    course_id_dict = Location.parse_course_id(course_id)
    module_store.ignore_write_events_on_courses.append('{org}/{course}'.format(**course_id_dict))

    loc = CourseDescriptor.id_to_location(course_id)
    if delete_course(module_store, content_store, loc, commit):

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        if commit:
            try:
                staff_role = CourseStaffRole(loc)
                staff_role.remove_users(*staff_role.users_with_role())
                instructor_role = CourseInstructorRole(loc)
                instructor_role.remove_users(*instructor_role.users_with_role())
            except Exception as err:
                log.error("Error in deleting course groups for {0}: {1}".format(loc, err))

            # remove location of this course from loc_mapper and cache
            loc_mapper().delete_course_mapping(loc)
开发者ID:DazzaGreenwood,项目名称:edx-platform,代码行数:29,代码来源:utils.py

示例4: remove_all_instructors

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
def remove_all_instructors(course_key):
    """
    Removes all instructor and staff users from the given course.
    """
    staff_role = CourseStaffRole(course_key)
    staff_role.remove_users(*staff_role.users_with_role())
    instructor_role = CourseInstructorRole(course_key)
    instructor_role.remove_users(*instructor_role.users_with_role())
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:10,代码来源:utils.py

示例5: remove_all_instructors

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
def remove_all_instructors(course_key):
    """
    Removes given user as instructor and staff to the given course,
    after verifying that the requesting_user has permission to do so.
    """
    staff_role = CourseStaffRole(course_key)
    staff_role.remove_users(*staff_role.users_with_role())
    instructor_role = CourseInstructorRole(course_key)
    instructor_role.remove_users(*instructor_role.users_with_role())
开发者ID:HoraceS,项目名称:edx-platform,代码行数:11,代码来源:utils.py

示例6: delete_course_and_groups

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
def delete_course_and_groups(course_id, user_id):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore()

    with module_store.bulk_write_operations(course_id):
        module_store.delete_course(course_id, user_id)

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        try:
            staff_role = CourseStaffRole(course_id)
            staff_role.remove_users(*staff_role.users_with_role())
            instructor_role = CourseInstructorRole(course_id)
            instructor_role.remove_users(*instructor_role.users_with_role())
        except Exception as err:
            log.error("Error in deleting course groups for {0}: {1}".format(course_id, err))
开发者ID:AlexanderFuentes,项目名称:edx-platform,代码行数:21,代码来源:utils.py

示例7: delete_course_and_groups

# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import users_with_role [as 别名]
def delete_course_and_groups(course_id, commit=False):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore('direct')
    content_store = contentstore()

    module_store.ignore_write_events_on_courses.add(course_id)

    if delete_course(module_store, content_store, course_id, commit):

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        if commit:
            try:
                staff_role = CourseStaffRole(course_id)
                staff_role.remove_users(*staff_role.users_with_role())
                instructor_role = CourseInstructorRole(course_id)
                instructor_role.remove_users(*instructor_role.users_with_role())
            except Exception as err:
                log.error("Error in deleting course groups for {0}: {1}".format(course_id, err))
开发者ID:LoveCoding,项目名称:Projects,代码行数:24,代码来源:utils.py


注:本文中的student.roles.CourseStaffRole.users_with_role方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。