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


Python milestones_helpers.seed_milestone_relationship_types函数代码示例

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


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

示例1: setUp

    def setUp(self):
        super(ImportEntranceExamTestCase, self).setUp()
        self.url = reverse_course_url('import_handler', self.course.id)
        self.content_dir = path(tempfile.mkdtemp())
        self.addCleanup(shutil.rmtree, self.content_dir)

        # Create tar test file -----------------------------------------------
        # OK course with entrance exam section:
        seed_milestone_relationship_types()
        entrance_exam_dir = tempfile.mkdtemp(dir=self.content_dir)
        # test course being deeper down than top of tar file
        embedded_exam_dir = os.path.join(entrance_exam_dir, "grandparent", "parent")
        os.makedirs(os.path.join(embedded_exam_dir, "course"))
        os.makedirs(os.path.join(embedded_exam_dir, "chapter"))
        with open(os.path.join(embedded_exam_dir, "course.xml"), "w+") as f:
            f.write('<course url_name="2013_Spring" org="EDx" course="0.00x"/>')

        with open(os.path.join(embedded_exam_dir, "course", "2013_Spring.xml"), "w+") as f:
            f.write(
                '<course '
                'entrance_exam_enabled="true" entrance_exam_id="xyz" entrance_exam_minimum_score_pct="0.7">'
                '<chapter url_name="2015_chapter_entrance_exam"/></course>'
            )

        with open(os.path.join(embedded_exam_dir, "chapter", "2015_chapter_entrance_exam.xml"), "w+") as f:
            f.write('<chapter display_name="Entrance Exam" in_entrance_exam="true" is_entrance_exam="true"></chapter>')

        self.entrance_exam_tar = os.path.join(self.content_dir, "entrance_exam.tar.gz")
        with tarfile.open(self.entrance_exam_tar, "w:gz") as gtar:
            gtar.add(entrance_exam_dir)
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:30,代码来源:test_import_export.py

示例2: 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

示例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: _add_entrance_exam

    def _add_entrance_exam(self):
        """ Sets up entrance exam """
        seed_milestone_relationship_types()
        self.course.entrance_exam_enabled = True

        self.entrance_exam = ItemFactory.create(  # pylint: disable=attribute-defined-outside-init
            parent=self.course,
            category="chapter",
            display_name="Entrance Exam Chapter",
            is_entrance_exam=True,
            in_entrance_exam=True
        )
        self.problem_1 = ItemFactory.create(  # pylint: disable=attribute-defined-outside-init
            parent=self.entrance_exam,
            category='problem',
            display_name="The Only Exam Problem",
            graded=True,
            in_entrance_exam=True
        )

        add_entrance_exam_milestone(self.course, self.entrance_exam)

        self.course.entrance_exam_minimum_score_pct = 0.50
        self.course.entrance_exam_id = unicode(self.entrance_exam.location)
        modulestore().update_item(self.course, self.user.id)
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:25,代码来源:test_milestones.py

示例5: test_pre_requisite_course_update_and_fetch

    def test_pre_requisite_course_update_and_fetch(self):
        seed_milestone_relationship_types()
        url = get_url(self.course.id)
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)
        # assert pre_requisite_courses is initialized
        self.assertEqual([], course_detail_json['pre_requisite_courses'])

        # update pre requisite courses with a new course keys
        pre_requisite_course = CourseFactory.create(org='edX', course='900', run='test_run')
        pre_requisite_course2 = CourseFactory.create(org='edX', course='902', run='test_run')
        pre_requisite_course_keys = [unicode(pre_requisite_course.id), unicode(pre_requisite_course2.id)]
        course_detail_json['pre_requisite_courses'] = pre_requisite_course_keys
        self.client.ajax_post(url, course_detail_json)

        # fetch updated course to assert pre_requisite_courses has new values
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)
        self.assertEqual(pre_requisite_course_keys, course_detail_json['pre_requisite_courses'])

        # remove pre requisite course
        course_detail_json['pre_requisite_courses'] = []
        self.client.ajax_post(url, course_detail_json)
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)
        self.assertEqual([], course_detail_json['pre_requisite_courses'])
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:26,代码来源:test_course_settings.py

示例6: 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

示例7: setUp

 def setUp(self):
     """
     Shared scaffolding for individual test runs
     """
     super(EntranceExamHandlerTests, self).setUp()
     self.course_key = self.course.id
     self.usage_key = self.course.location
     self.course_url = '/course/{}'.format(unicode(self.course.id))
     self.exam_url = '/course/{}/entrance_exam/'.format(unicode(self.course.id))
     milestones_helpers.seed_milestone_relationship_types()
     self.milestone_relationship_types = milestones_helpers.get_milestone_relationship_types()
开发者ID:189140879,项目名称:edx-platform,代码行数:11,代码来源:test_entrance_exam.py

示例8: test_invalid_pre_requisite_course

    def test_invalid_pre_requisite_course(self):
        seed_milestone_relationship_types()
        url = get_url(self.course.id)
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)

        # update pre requisite courses one valid and one invalid key
        pre_requisite_course = CourseFactory.create(org='edX', course='900', run='test_run')
        pre_requisite_course_keys = [unicode(pre_requisite_course.id), 'invalid_key']
        course_detail_json['pre_requisite_courses'] = pre_requisite_course_keys
        response = self.client.ajax_post(url, course_detail_json)
        self.assertEqual(400, response.status_code)
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:12,代码来源:test_course_settings.py

示例9: test_pre_requisite_course

 def test_pre_requisite_course(self):
     seed_milestone_relationship_types()
     pre_requisite_course = CourseFactory.create(org='edX', course='900', display_name='pre requisite course')
     course = CourseFactory.create(pre_requisite_courses=[unicode(pre_requisite_course.id)])
     self.setup_user()
     url = reverse('about_course', args=[unicode(course.id)])
     resp = self.client.get(url)
     self.assertEqual(resp.status_code, 200)
     self.assertIn("<span class=\"important-dates-item-text pre-requisite\">{} {}</span>"
                   .format(pre_requisite_course.display_org_with_default,
                           pre_requisite_course.display_number_with_default),
                   resp.content.strip('\n'))
开发者ID:alexmerser,项目名称:lms,代码行数:12,代码来源:test_about.py

示例10: test_pre_requisite_course

 def test_pre_requisite_course(self):
     seed_milestone_relationship_types()
     pre_requisite_course = CourseFactory.create(org='edX', course='900', display_name='pre requisite course')
     course = CourseFactory.create(pre_requisite_courses=[unicode(pre_requisite_course.id)])
     self.setup_user()
     url = reverse('about_course', args=[unicode(course.id)])
     resp = self.client.get(url)
     self.assertEqual(resp.status_code, 200)
     pre_requisite_courses = get_prerequisite_courses_display(course)
     pre_requisite_course_about_url = reverse('about_course', args=[unicode(pre_requisite_courses[0]['key'])])
     self.assertIn("<span class=\"important-dates-item-text pre-requisite\"><a href=\"{}\">{}</a></span>"
                   .format(pre_requisite_course_about_url, pre_requisite_courses[0]['display']),
                   resp.content.strip('\n'))
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:13,代码来源:test_about.py

示例11: test_entrance_exam_store_default_min_score

    def test_entrance_exam_store_default_min_score(self):
        """
        test that creating an entrance exam should store the default value, if key missing in json request
        or entrance_exam_minimum_score_pct is an empty string
        """
        seed_milestone_relationship_types()
        settings_details_url = get_url(self.course.id)
        test_data_1 = {
            'entrance_exam_enabled': 'true',
            'syllabus': 'none',
            'short_description': 'empty',
            'overview': '',
            'effort': '',
            'intro_video': ''
        }
        response = self.client.post(
            settings_details_url,
            data=json.dumps(test_data_1),
            content_type='application/json',
            HTTP_ACCEPT='application/json'
        )
        self.assertEquals(response.status_code, 200)
        course = modulestore().get_course(self.course.id)
        self.assertTrue(course.entrance_exam_enabled)

        # entrance_exam_minimum_score_pct is not present in the request so default value should be saved.
        self.assertEquals(course.entrance_exam_minimum_score_pct, .5)

        #add entrance_exam_minimum_score_pct with empty value in json request.
        test_data_2 = {
            'entrance_exam_enabled': 'true',
            'entrance_exam_minimum_score_pct': '',
            'syllabus': 'none',
            'short_description': 'empty',
            'overview': '',
            'effort': '',
            'intro_video': ''
        }

        response = self.client.post(
            settings_details_url,
            data=json.dumps(test_data_2),
            content_type='application/json',
            HTTP_ACCEPT='application/json'
        )
        self.assertEquals(response.status_code, 200)
        course = modulestore().get_course(self.course.id)
        self.assertTrue(course.entrance_exam_enabled)
        self.assertEquals(course.entrance_exam_minimum_score_pct, .5)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:49,代码来源:test_course_settings.py

示例12: test_entrance_exam_created_updated_and_deleted_successfully

    def test_entrance_exam_created_updated_and_deleted_successfully(self):
        seed_milestone_relationship_types()
        settings_details_url = get_url(self.course.id)
        data = {
            'entrance_exam_enabled': 'true',
            'entrance_exam_minimum_score_pct': '60',
            'syllabus': 'none',
            'short_description': 'empty',
            'overview': '',
            'effort': '',
            'intro_video': ''
        }
        response = self.client.post(settings_details_url, data=json.dumps(data), content_type='application/json',
                                    HTTP_ACCEPT='application/json')
        self.assertEquals(response.status_code, 200)
        course = modulestore().get_course(self.course.id)
        self.assertTrue(course.entrance_exam_enabled)
        self.assertEquals(course.entrance_exam_minimum_score_pct, .60)

        # Update the entrance exam
        data['entrance_exam_enabled'] = "true"
        data['entrance_exam_minimum_score_pct'] = "80"
        response = self.client.post(
            settings_details_url,
            data=json.dumps(data),
            content_type='application/json',
            HTTP_ACCEPT='application/json'
        )
        self.assertEquals(response.status_code, 200)
        course = modulestore().get_course(self.course.id)
        self.assertTrue(course.entrance_exam_enabled)
        self.assertEquals(course.entrance_exam_minimum_score_pct, .80)

        # Delete the entrance exam
        data['entrance_exam_enabled'] = "false"
        response = self.client.post(
            settings_details_url,
            data=json.dumps(data),
            content_type='application/json',
            HTTP_ACCEPT='application/json'
        )
        course = modulestore().get_course(self.course.id)
        self.assertEquals(response.status_code, 200)
        self.assertFalse(course.entrance_exam_enabled)
        self.assertEquals(course.entrance_exam_minimum_score_pct, None)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:45,代码来源:test_course_settings.py

示例13: test_course_milestone_collected

    def test_course_milestone_collected(self):
        seed_milestone_relationship_types()
        student = UserFactory()
        course = CourseFactory.create(org='edx', number='998', display_name='Test Course')
        pre_requisite_course = CourseFactory.create(org='edx', number='999', display_name='Pre requisite Course')
        # set pre-requisite course
        set_prerequisite_courses(course.id, [unicode(pre_requisite_course.id)])
        # get milestones collected by user before completing the pre-requisite course
        completed_milestones = milestones_achieved_by_user(student, unicode(pre_requisite_course.id))
        self.assertEqual(len(completed_milestones), 0)

        GeneratedCertificateFactory.create(
            user=student,
            course_id=pre_requisite_course.id,
            status=CertificateStatuses.generating,
            mode='verified'
        )
        # get milestones collected by user after user has completed the pre-requisite course
        completed_milestones = milestones_achieved_by_user(student, unicode(pre_requisite_course.id))
        self.assertEqual(len(completed_milestones), 1)
        self.assertEqual(completed_milestones[0]['namespace'], unicode(pre_requisite_course.id))
开发者ID:189140879,项目名称:edx-platform,代码行数:21,代码来源:tests.py

示例14: test_about_page_unfulfilled_prereqs

    def test_about_page_unfulfilled_prereqs(self):
        seed_milestone_relationship_types()
        pre_requisite_course = CourseFactory.create(
            org='edX',
            course='900',
            display_name='pre requisite course',
        )

        pre_requisite_courses = [unicode(pre_requisite_course.id)]

        # for this failure to occur, the enrollment window needs to be in the past
        course = CourseFactory.create(
            org='edX',
            course='1000',
            # closed enrollment
            enrollment_start=datetime.datetime(2013, 1, 1),
            enrollment_end=datetime.datetime(2014, 1, 1),
            start=datetime.datetime(2013, 1, 1),
            end=datetime.datetime(2030, 1, 1),
            pre_requisite_courses=pre_requisite_courses,
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        self.setup_user()
        self.enroll(self.course, True)
        self.enroll(pre_requisite_course, True)

        url = reverse('about_course', args=[unicode(course.id)])
        resp = self.client.get(url)
        self.assertEqual(resp.status_code, 200)
        pre_requisite_courses = get_prerequisite_courses_display(course)
        pre_requisite_course_about_url = reverse('about_course', args=[unicode(pre_requisite_courses[0]['key'])])
        self.assertIn("<span class=\"important-dates-item-text pre-requisite\"><a href=\"{}\">{}</a></span>"
                      .format(pre_requisite_course_about_url, pre_requisite_courses[0]['display']),
                      resp.content.strip('\n'))

        url = reverse('about_course', args=[unicode(pre_requisite_course.id)])
        resp = self.client.get(url)
        self.assertEqual(resp.status_code, 200)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:39,代码来源:test_about.py

示例15: _add_prerequisite_course

 def _add_prerequisite_course(self):
     """ Helper method to set up the prerequisite course """
     seed_milestone_relationship_types()
     self.prereq_course = CourseFactory.create()  # pylint: disable=attribute-defined-outside-init
     add_prerequisite_course(self.course.id, self.prereq_course.id)
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:5,代码来源:test_milestones.py


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