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


Python milestones_helpers.get_pre_requisite_courses_not_completed函数代码示例

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


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

示例1: test_course_listing_has_pre_requisite_courses

    def test_course_listing_has_pre_requisite_courses(self):
        """
        Creates four courses. Enroll test user in all courses
        Sets two of them as pre-requisites of another course.
        Checks course where pre-requisite course is set has appropriate info.
        """
        seed_milestone_relationship_types()
        course_location2 = self.store.make_course_key('Org1', 'Course2', 'Run2')
        self._create_course_with_access_groups(course_location2)
        pre_requisite_course_location = self.store.make_course_key('Org1', 'Course3', 'Run3')
        self._create_course_with_access_groups(pre_requisite_course_location)
        pre_requisite_course_location2 = self.store.make_course_key('Org1', 'Course4', 'Run4')
        self._create_course_with_access_groups(pre_requisite_course_location2)
        # create a course with pre_requisite_courses
        pre_requisite_courses = [
            unicode(pre_requisite_course_location),
            unicode(pre_requisite_course_location2),
        ]
        course_location = self.store.make_course_key('Org1', 'Course1', 'Run1')
        self._create_course_with_access_groups(course_location, {
            'pre_requisite_courses': pre_requisite_courses
        })

        set_prerequisite_courses(course_location, pre_requisite_courses)
        # get dashboard
        course_enrollment_pairs = list(get_course_enrollment_pairs(self.student, None, []))
        courses_having_prerequisites = frozenset(course.id for course, _enrollment in course_enrollment_pairs
                                                 if course.pre_requisite_courses)
        courses_requirements_not_met = get_pre_requisite_courses_not_completed(
            self.student,
            courses_having_prerequisites
        )
        self.assertEqual(len(courses_requirements_not_met[course_location]['courses']), len(pre_requisite_courses))
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:33,代码来源:test_course_listing.py

示例2: _has_fulfilled_prerequisites

def _has_fulfilled_prerequisites(user, course_id):
    """
    Returns whether the given user has fulfilled all prerequisites for the
    given course.

    Arguments:
        user: user to check
        course_id: ID of the course to check
    """
    return MilestoneAccessError() if get_pre_requisite_courses_not_completed(user, course_id) else ACCESS_GRANTED
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:10,代码来源:access.py

示例3: can_view_courseware_with_prerequisites

 def can_view_courseware_with_prerequisites():  # pylint: disable=invalid-name
     """
     Checks if prerequisite courses feature is enabled and course has prerequisites
     and user is neither staff nor anonymous then it returns False if user has not
     passed prerequisite courses otherwise return True.
     """
     if settings.FEATURES['ENABLE_PREREQUISITE_COURSES'] \
             and not _has_staff_access_to_descriptor(user, course, course.id) \
             and course.pre_requisite_courses \
             and not user.is_anonymous() \
             and get_pre_requisite_courses_not_completed(user, [course.id]):
         return False
     else:
         return True
开发者ID:mitsei,项目名称:edx-platform,代码行数:14,代码来源:access.py

示例4: _can_view_courseware_with_prerequisites

def _can_view_courseware_with_prerequisites(user, course):  # pylint: disable=invalid-name
    """
    Checks if a user has access to a course based on its prerequisites.

    If the user is staff or anonymous, immediately grant access.
    Else, return whether or not the prerequisite courses have been passed.

    Arguments:
        user (User): the user whose course access we are checking.
        course (AType): the course for which we are checking access.
    where AType is CourseDescriptor, CourseOverview, or any other class that
        represents a course and has the attributes .location and .id.
    """
    return (
        not settings.FEATURES["ENABLE_PREREQUISITE_COURSES"]
        or _has_staff_access_to_descriptor(user, course, course.id)
        or not course.pre_requisite_courses
        or user.is_anonymous()
        or not get_pre_requisite_courses_not_completed(user, [course.id])
    )
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:20,代码来源:access.py

示例5: student_dashboard


#.........这里部分代码省略.........
    block_courses = frozenset(
        enrollment.course_id for enrollment in course_enrollments
        if is_course_blocked(
            request,
            CourseRegistrationCode.objects.filter(
                course_id=enrollment.course_id,
                registrationcoderedemption__redeemed_by=request.user
            ),
            enrollment.course_id
        )
    )

    enrolled_courses_either_paid = frozenset(
        enrollment.course_id for enrollment in course_enrollments
        if enrollment.is_paid_course()
    )

    # If there are *any* denied reverifications that have not been toggled off,
    # we'll display the banner
    denied_banner = any(item.display for item in reverifications["denied"])

    # Populate the Order History for the side-bar.
    order_history_list = order_history(
        user,
        course_org_filter=site_org_whitelist,
        org_filter_out_set=site_org_blacklist
    )

    # get list of courses having pre-requisites yet to be completed
    courses_having_prerequisites = frozenset(
        enrollment.course_id for enrollment in course_enrollments
        if enrollment.course_overview.pre_requisite_courses
    )
    courses_requirements_not_met = get_pre_requisite_courses_not_completed(user, courses_having_prerequisites)

    if 'notlive' in request.GET:
        redirect_message = _("The course you are looking for does not start until {date}.").format(
            date=request.GET['notlive']
        )
    elif 'course_closed' in request.GET:
        redirect_message = _("The course you are looking for is closed for enrollment as of {date}.").format(
            date=request.GET['course_closed']
        )
    else:
        redirect_message = ''

    valid_verification_statuses = ['approved', 'must_reverify', 'pending', 'expired']
    display_sidebar_on_dashboard = (len(order_history_list) or
                                    (verification_status['status'] in valid_verification_statuses and
                                    verification_status['should_display']))

    # Filter out any course enrollment course cards that are associated with fulfilled entitlements
    for entitlement in [e for e in course_entitlements if e.enrollment_course_run is not None]:
        course_enrollments = [
            enr for enr in course_enrollments if entitlement.enrollment_course_run.course_id != enr.course_id
        ]

    context = {
        'urls': urls,
        'programs_data': programs_data,
        'enterprise_message': enterprise_message,
        'consent_required_courses': consent_required_courses,
        'enterprise_customer_name': enterprise_customer_name,
        'enrollment_message': enrollment_message,
        'redirect_message': redirect_message,
        'account_activation_messages': account_activation_messages,
开发者ID:luisvasq,项目名称:edx-platform,代码行数:67,代码来源:dashboard.py


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