• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python roles.CourseInstructorRole类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: delete_course_and_groups

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,代码行数:30,代码来源:utils.py


示例2: generate_certificate

def generate_certificate(request, course_id):
    user = request.user
    course_key = locator.CourseLocator.from_string(course_id)
    course = modulestore().get_course(course_key)

    course_name = course.display_name
    course_end_date = ''
    if course.end:
        course_end_date = str(course.end.date())
    course_short_desc = get_course_about_section(course, 'short_description')

    instructor_name = ''
    role = CourseInstructorRole(course_key)
    if role.users_with_role():
        instructor_user = role.users_with_role()[0]
        instructor_name = UserProfile.objects.get(user=instructor_user).name

    cert = EdraakCertificate(course_name=course_name,
                             course_id=course_id,
                             user_profile_name=user.profile.name,
                             course_org=course.org,
                             course_end_date=course_end_date,
                             course_desc=course_short_desc,
                             instructor=instructor_name)

    cert.generate_and_save()

    return cert.temp_file
开发者ID:cylau1987,项目名称:edx-platform,代码行数:28,代码来源:utils.py


示例3: delete_course_and_groups

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,代码行数:27,代码来源:utils.py


示例4: remove_all_instructors

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,代码行数:8,代码来源:utils.py


示例5: remove_all_instructors

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,代码行数:9,代码来源:utils.py


示例6: make_instructor

    def make_instructor(self):
        """
        create staff instructor
        """
        instructor = AdminFactory.create(password="test")
        role = CourseInstructorRole(self.course.id)
        role.add_users(instructor)

        return instructor
开发者ID:PomegranitesUnite,项目名称:edx-platform,代码行数:9,代码来源:test_views.py


示例7: try_remove_instructor

def try_remove_instructor(request, locator, user):
    # remove all roles in this course from this user: but fail if the user
    # is the last instructor in the course team
    instructors = CourseInstructorRole(locator)
    if instructors.has_user(user):
        if instructors.users_with_role().count() == 1:
            msg = {"error":_("You may not remove the last instructor from a course")}
            raise CannotOrphanCourse(msg)
        else:
            auth.remove_users(request.user, instructors, user)
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:10,代码来源:user.py


示例8: delete_course_and_groups

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,代码行数:19,代码来源:utils.py


示例9: delete_course_and_groups

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,代码行数:22,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python roles.CourseStaffRole类代码示例发布时间:2022-05-27
下一篇:
Python roles.CourseCcxCoachRole类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap