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

Python milestones_helpers.fulfill_course_milestone函数代码示例

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

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



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

示例1: test_courseware_page_unfulfilled_prereqs

    def test_courseware_page_unfulfilled_prereqs(self):
        """
        Test courseware access when a course has pre-requisite course yet to be completed
        """
        seed_milestone_relationship_types()
        pre_requisite_course = CourseFactory.create(org="edX", course="900", run="test_run")

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org="edX", course="1000", run="test_run", pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        test_password = "t3stp4ss.!"
        user = UserFactory.create()
        user.set_password(test_password)
        user.save()
        self.login(user.email, test_password)
        CourseEnrollmentFactory(user=user, course_id=course.id)

        url = reverse("courseware", args=[unicode(course.id)])
        response = self.client.get(url)
        self.assertRedirects(response, reverse("dashboard"))
        self.assertEqual(response.status_code, 302)

        fulfill_course_milestone(pre_requisite_course.id, user)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
开发者ID:johnny-nan,项目名称:edx-platform,代码行数:28,代码来源:test_access.py


示例2: setUp

    def setUp(self):
        super(CourseOverviewAccessTestCase, self).setUp()

        today = datetime.datetime.now(pytz.UTC)
        last_week = today - datetime.timedelta(days=7)
        next_week = today + datetime.timedelta(days=7)

        self.course_default = CourseFactory.create()
        self.course_started = CourseFactory.create(start=last_week)
        self.course_not_started = CourseFactory.create(start=next_week, days_early_for_beta=10)
        self.course_staff_only = CourseFactory.create(visible_to_staff_only=True)
        self.course_mobile_available = CourseFactory.create(mobile_available=True)
        self.course_with_pre_requisite = CourseFactory.create(
            pre_requisite_courses=[str(self.course_started.id)]
        )
        self.course_with_pre_requisites = CourseFactory.create(
            pre_requisite_courses=[str(self.course_started.id), str(self.course_not_started.id)]
        )

        self.user_normal = UserFactory.create()
        self.user_beta_tester = BetaTesterFactory.create(course_key=self.course_not_started.id)
        self.user_completed_pre_requisite = UserFactory.create()
        fulfill_course_milestone(self.user_completed_pre_requisite, self.course_started.id)
        self.user_staff = UserFactory.create(is_staff=True)
        self.user_anonymous = AnonymousUserFactory.create()
开发者ID:PomegranitesUnite,项目名称:edx-platform,代码行数:25,代码来源:test_access.py


示例3: test_access_on_course_with_pre_requisites

    def test_access_on_course_with_pre_requisites(self):
        """
        Test course access when a course has pre-requisite course yet to be completed
        """
        seed_milestone_relationship_types()
        user = UserFactory.create()

        pre_requisite_course = CourseFactory.create(org="test_org", number="788", run="test_run")

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org="test_org", number="786", run="test_run", pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        # user should not be able to load course even if enrolled
        CourseEnrollmentFactory(user=user, course_id=course.id)
        response = access._has_access_course_desc(user, "view_courseware_with_prerequisites", course)
        self.assertFalse(response)
        self.assertIsInstance(response, access_response.MilestoneError)
        # Staff can always access course
        staff = StaffFactory.create(course_key=course.id)
        self.assertTrue(access._has_access_course_desc(staff, "view_courseware_with_prerequisites", course))

        # User should be able access after completing required course
        fulfill_course_milestone(pre_requisite_course.id, user)
        self.assertTrue(access._has_access_course_desc(user, "view_courseware_with_prerequisites", course))
开发者ID:johnny-nan,项目名称:edx-platform,代码行数:27,代码来源:test_access.py


示例4: test_access_on_course_with_pre_requisites

    def test_access_on_course_with_pre_requisites(self):
        """
        Test course access when a course has pre-requisite course yet to be completed
        """
        user = UserFactory.create()

        pre_requisite_course = CourseFactory.create(
            org='test_org', number='788', run='test_run'
        )

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org='test_org', number='786', run='test_run', pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        # user should not be able to load course even if enrolled
        CourseEnrollmentFactory(user=user, course_id=course.id)
        response = access._has_access_course(user, 'load', course)
        self.assertFalse(response)
        self.assertIsInstance(response, access_response.MilestoneAccessError)
        # Staff can always access course
        staff = StaffFactory.create(course_key=course.id)
        self.assertTrue(access._has_access_course(staff, 'load', course))

        # User should be able access after completing required course
        fulfill_course_milestone(pre_requisite_course.id, user)
        self.assertTrue(access._has_access_course(user, 'load', course))
开发者ID:luisvasq,项目名称:edx-platform,代码行数:28,代码来源:test_access.py


示例5: handle_post_cert_generated

def handle_post_cert_generated(sender, instance, **kwargs):  # pylint: disable=no-self-argument, unused-argument
    """
    Handles post_save signal of GeneratedCertificate, and mark user collected
    course milestone entry if user has passed the course
    or certificate status is 'generating'.
    """
    if settings.FEATURES.get('ENABLE_PREREQUISITE_COURSES') and instance.status == CertificateStatuses.generating:
        fulfill_course_milestone(instance.course_id, instance.user)
开发者ID:HowestX,项目名称:edx-platform,代码行数:8,代码来源:models.py


示例6: test_fulfilled_prerequisite_course

 def test_fulfilled_prerequisite_course(self):
     """
     Tests the case when a user fulfills existing pre-requisite course
     """
     self._add_prerequisite_course()
     add_prerequisite_course(self.course.id, self.prereq_course.id)
     fulfill_course_milestone(self.prereq_course.id, self.user)
     self.init_course_access()
     self.api_response()
开发者ID:10clouds,项目名称:edx-platform,代码行数:9,代码来源:test_milestones.py


示例7: handle_post_cert_generated

def handle_post_cert_generated(sender, instance, **kwargs):  # pylint: disable=unused-argument
    """
    Handles post_save signal of GeneratedCertificate, and mark user collected
    course milestone entry if user has passed the course.
    User is assumed to have passed the course if certificate status is either 'generating' or 'downloadable'.
    """
    allowed_cert_states = [CertificateStatuses.generating, CertificateStatuses.downloadable]
    if is_prerequisite_courses_enabled() and instance.status in allowed_cert_states:
        fulfill_course_milestone(instance.course_id, instance.user)
开发者ID:msaqib52,项目名称:edx-platform,代码行数:9,代码来源:models.py


示例8: handle_post_cert_generated

def handle_post_cert_generated(sender, instance, **kwargs):  # pylint: disable=no-self-argument, unused-argument
    """
    Handles post_save signal of GeneratedCertificate, and mark user collected
    course milestone entry if user has passed the course.
    User is assumed to have passed the course if certificate status is either 'generating' or 'downloadable'.
    """
    allowed_cert_states = [CertificateStatuses.generating, CertificateStatuses.downloadable]
    if settings.FEATURES.get('ENABLE_PREREQUISITE_COURSES') and instance.status in allowed_cert_states:
        fulfill_course_milestone(instance.course_id, instance.user)
开发者ID:189140879,项目名称:edx-platform,代码行数:9,代码来源:models.py


示例9: test_courseware_page_unfulfilled_prereqs

    def test_courseware_page_unfulfilled_prereqs(self):
        """
        Test courseware access when a course has pre-requisite course yet to be completed
        """
        pre_requisite_course = CourseFactory.create(
            org='edX',
            course='900',
            run='test_run',
        )

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org='edX',
            course='1000',
            run='test_run',
            pre_requisite_courses=pre_requisite_courses,
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        test_password = 't3stp4ss.!'
        user = UserFactory.create()
        user.set_password(test_password)
        user.save()
        self.login(user.email, test_password)
        CourseEnrollmentFactory(user=user, course_id=course.id)

        url = reverse('courseware', args=[unicode(course.id)])
        response = self.client.get(url)
        self.assertRedirects(
            response,
            reverse(
                'dashboard'
            )
        )
        self.assertEqual(response.status_code, 302)

        fulfill_course_milestone(pre_requisite_course.id, user)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
开发者ID:PomegranitesUnite,项目名称:edx-platform,代码行数:39,代码来源:test_access.py


示例10: handle_course_cert_awarded

def handle_course_cert_awarded(sender, user, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Mark a milestone entry if user has passed the course.
    """
    if is_prerequisite_courses_enabled():
        fulfill_course_milestone(course_key, user)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:6,代码来源:models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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