當前位置: 首頁>>代碼示例>>Python>>正文


Python roles.CourseInstructorRole類代碼示例

本文整理匯總了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;未經允許,請勿轉載。