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


Python milestones_helpers.add_course_content_milestone函数代码示例

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


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

示例1: add_entrance_exam_milestone

def add_entrance_exam_milestone(course_id, x_block):
    # Add an entrance exam milestone if one does not already exist for given xBlock
    # As this is a standalone method for entrance exam, We should check that given xBlock should be an entrance exam.
    if x_block.is_entrance_exam:
        namespace_choices = milestones_helpers.get_namespace_choices()
        milestone_namespace = milestones_helpers.generate_milestone_namespace(
            namespace_choices.get('ENTRANCE_EXAM'),
            course_id
        )
        milestones = milestones_helpers.get_milestones(milestone_namespace)
        if len(milestones):
            milestone = milestones[0]
        else:
            description = 'Autogenerated during {} entrance exam creation.'.format(unicode(course_id))
            milestone = milestones_helpers.add_milestone({
                'name': _('Completed Course Entrance Exam'),
                'namespace': milestone_namespace,
                'description': description
            })
        relationship_types = milestones_helpers.get_milestone_relationship_types()
        milestones_helpers.add_course_milestone(
            unicode(course_id),
            relationship_types['REQUIRES'],
            milestone
        )
        milestones_helpers.add_course_content_milestone(
            unicode(course_id),
            unicode(x_block.location),
            relationship_types['FULFILLS'],
            milestone
        )
开发者ID:28554010,项目名称:edx-platform,代码行数:31,代码来源:entrance_exam.py

示例2: add_entrance_exam_milestone

def add_entrance_exam_milestone(course, entrance_exam):
    """
    Adds the milestone for given `entrance_exam` in `course`

    Args:
        course (Course): Course object in which the extrance_exam is located
        entrance_exam (xblock): the entrance exam to be added as a milestone
    """
    namespace_choices = get_namespace_choices()
    milestone_relationship_types = get_milestone_relationship_types()

    milestone_namespace = generate_milestone_namespace(
        namespace_choices.get('ENTRANCE_EXAM'),
        course.id
    )
    milestone = add_milestone(
        {
            'name': 'Test Milestone',
            'namespace': milestone_namespace,
            'description': 'Testing Courseware Entrance Exam Chapter',
        }
    )
    add_course_milestone(
        unicode(course.id),
        milestone_relationship_types['REQUIRES'],
        milestone
    )
    add_course_content_milestone(
        unicode(course.id),
        unicode(entrance_exam.location),
        milestone_relationship_types['FULFILLS'],
        milestone
    )
开发者ID:10clouds,项目名称:edx-platform,代码行数:33,代码来源:test_entrance_exam.py

示例3: test_get_course_tabs_list_entrance_exam_enabled

 def test_get_course_tabs_list_entrance_exam_enabled(self):
     """
     Unit Test: test_get_course_tabs_list_entrance_exam_enabled
     """
     entrance_exam = ItemFactory.create(
         category="chapter",
         parent_location=self.course.location,
         data="Exam Data",
         display_name="Entrance Exam",
         is_entrance_exam=True
     )
     milestone = {
         'name': 'Test Milestone',
         'namespace': '{}.entrance_exams'.format(unicode(self.course.id)),
         'description': 'Testing Courseware Tabs'
     }
     self.user.is_staff = False
     self.course.entrance_exam_enabled = True
     self.course.entrance_exam_id = unicode(entrance_exam.location)
     milestone = milestones_helpers.add_milestone(milestone)
     milestones_helpers.add_course_milestone(
         unicode(self.course.id),
         self.relationship_types['REQUIRES'],
         milestone
     )
     milestones_helpers.add_course_content_milestone(
         unicode(self.course.id),
         unicode(entrance_exam.location),
         self.relationship_types['FULFILLS'],
         milestone
     )
     course_tab_list = get_course_tab_list(self.course, self.user)
     self.assertEqual(len(course_tab_list), 1)
     self.assertEqual(course_tab_list[0]['tab_id'], 'courseware')
     self.assertEqual(course_tab_list[0]['name'], 'Entrance Exam')
开发者ID:HowestX,项目名称:edx-platform,代码行数:35,代码来源:test_tabs.py

示例4: test_add_course_content_milestone_returns_none_when_app_disabled

 def test_add_course_content_milestone_returns_none_when_app_disabled(self):
     response = milestones_helpers.add_course_content_milestone(
         unicode(self.course.id),
         'i4x://any/content/id',
         'requires',
         self.milestone
     )
     self.assertIsNone(response)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:8,代码来源:test_milestones_helpers.py

示例5: _create_entrance_exam

def _create_entrance_exam(request, course_key, entrance_exam_minimum_score_pct=None):
    """
    Internal workflow operation to create an entrance exam
    """
    # Provide a default value for the minimum score percent if nothing specified
    if entrance_exam_minimum_score_pct is None:
        entrance_exam_minimum_score_pct = _get_default_entrance_exam_minimum_pct()

    # Confirm the course exists
    course = modulestore().get_course(course_key)
    if course is None:
        return HttpResponse(status=400)

    # Create the entrance exam item (currently it's just a chapter)
    payload = {
        'category': "chapter",
        'display_name': _("Entrance Exam"),
        'parent_locator': unicode(course.location),
        'is_entrance_exam': True,
        'in_entrance_exam': True,
    }
    parent_locator = unicode(course.location)
    created_block = create_xblock(
        parent_locator=parent_locator,
        user=request.user,
        category='chapter',
        display_name=_('Entrance Exam'),
        is_entrance_exam=True
    )

    # Set the entrance exam metadata flags for this course
    # Reload the course so we don't overwrite the new child reference
    course = modulestore().get_course(course_key)
    metadata = {
        'entrance_exam_enabled': True,
        'entrance_exam_minimum_score_pct': unicode(entrance_exam_minimum_score_pct),
        'entrance_exam_id': unicode(created_block.location),
    }
    CourseMetadata.update_from_dict(metadata, course, request.user)

    # Create the entrance exam section item.
    create_xblock(
        parent_locator=unicode(created_block.location),
        user=request.user,
        category='sequential',
        display_name=_('Entrance Exam - Subsection')
    )

    # Add an entrance exam milestone if one does not already exist
    namespace_choices = milestones_helpers.get_namespace_choices()
    milestone_namespace = milestones_helpers.generate_milestone_namespace(
        namespace_choices.get('ENTRANCE_EXAM'),
        course_key
    )
    milestones = milestones_helpers.get_milestones(milestone_namespace)
    if len(milestones):
        milestone = milestones[0]
    else:
        description = 'Autogenerated during {} entrance exam creation.'.format(unicode(course.id))
        milestone = milestones_helpers.add_milestone({
            'name': _('Completed Course Entrance Exam'),
            'namespace': milestone_namespace,
            'description': description
        })
    relationship_types = milestones_helpers.get_milestone_relationship_types()
    milestones_helpers.add_course_milestone(
        unicode(course.id),
        relationship_types['REQUIRES'],
        milestone
    )
    milestones_helpers.add_course_content_milestone(
        unicode(course.id),
        unicode(created_block.location),
        relationship_types['FULFILLS'],
        milestone
    )

    return HttpResponse(status=201)
开发者ID:DefyVentures,项目名称:edx-platform,代码行数:78,代码来源:entrance_exam.py

示例6: setUp


#.........这里部分代码省略.........
            parent=subsection,
            category="problem",
            display_name="Exam Problem - Problem 1"
        )
        self.problem_2 = ItemFactory.create(
            parent=subsection,
            category="problem",
            display_name="Exam Problem - Problem 2"
        )
        self.problem_3 = ItemFactory.create(
            parent=subsection,
            category="problem",
            display_name="Exam Problem - Problem 3"
        )
        if settings.FEATURES.get('ENTRANCE_EXAMS', False):
            namespace_choices = milestones_helpers.get_namespace_choices()
            milestone_namespace = milestones_helpers.generate_milestone_namespace(
                namespace_choices.get('ENTRANCE_EXAM'),
                self.course.id
            )
            self.milestone = {
                'name': 'Test Milestone',
                'namespace': milestone_namespace,
                'description': 'Testing Courseware Entrance Exam Chapter',
            }
            milestones_helpers.seed_milestone_relationship_types()
            self.milestone_relationship_types = milestones_helpers.get_milestone_relationship_types()
            self.milestone = milestones_helpers.add_milestone(self.milestone)
            milestones_helpers.add_course_milestone(
                unicode(self.course.id),
                self.milestone_relationship_types['REQUIRES'],
                self.milestone
            )
            milestones_helpers.add_course_content_milestone(
                unicode(self.course.id),
                unicode(self.entrance_exam.location),
                self.milestone_relationship_types['FULFILLS'],
                self.milestone
            )
        user = UserFactory()
        self.request = RequestFactory()
        self.request.user = user
        self.request.COOKIES = {}
        self.request.META = {}
        self.request.is_secure = lambda: True
        self.request.get_host = lambda: "edx.org"
        self.request.method = 'GET'
        self.field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
            self.course.id,
            user,
            self.entrance_exam
        )
        self.course.entrance_exam_enabled = True
        self.course.entrance_exam_minimum_score_pct = 0.50
        self.course.entrance_exam_id = unicode(self.entrance_exam.scope_ids.usage_id)
        modulestore().update_item(self.course, user.id)  # pylint: disable=no-member

        self.client.login(username=self.request.user.username, password="test")
        CourseEnrollment.enroll(self.request.user, self.course.id)

        self.expected_locked_toc = (
            [
                {
                    'active': True,
                    'sections': [
                        {
开发者ID:saitonttks,项目名称:edx-platform,代码行数:67,代码来源:test_entrance_exam.py


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