本文整理汇总了Python中models.settings.course_metadata.CourseMetadata.fetch_all方法的典型用法代码示例。如果您正苦于以下问题:Python CourseMetadata.fetch_all方法的具体用法?Python CourseMetadata.fetch_all怎么用?Python CourseMetadata.fetch_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.settings.course_metadata.CourseMetadata
的用法示例。
在下文中一共展示了CourseMetadata.fetch_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_delete_pre_exiting_entrance_exam
# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch_all [as 别名]
def test_import_delete_pre_exiting_entrance_exam(self):
"""
Check that pre existed entrance exam content should be overwrite with the imported course.
"""
exam_url = '/course/{}/entrance_exam/'.format(unicode(self.course.id))
resp = self.client.post(exam_url, {'entrance_exam_minimum_score_pct': 0.5}, http_accept='application/json')
self.assertEqual(resp.status_code, 201)
# Reload the test course now that the exam module has been added
self.course = modulestore().get_course(self.course.id)
metadata = CourseMetadata.fetch_all(self.course)
self.assertTrue(metadata['entrance_exam_enabled'])
self.assertIsNotNone(metadata['entrance_exam_minimum_score_pct'])
self.assertEqual(metadata['entrance_exam_minimum_score_pct']['value'], 0.5)
self.assertTrue(len(milestones_helpers.get_course_milestones(unicode(self.course.id))))
content_milestones = milestones_helpers.get_course_content_milestones(
unicode(self.course.id),
metadata['entrance_exam_id']['value'],
milestones_helpers.get_milestone_relationship_types()['FULFILLS']
)
self.assertTrue(len(content_milestones))
# Now import entrance exam course
with open(self.entrance_exam_tar) as gtar:
args = {"name": self.entrance_exam_tar, "course-data": [gtar]}
resp = self.client.post(self.url, args)
self.assertEquals(resp.status_code, 200)
course = self.store.get_course(self.course.id)
self.assertIsNotNone(course)
self.assertEquals(course.entrance_exam_enabled, True)
self.assertEquals(course.entrance_exam_minimum_score_pct, 0.7)
示例2: test_contentstore_views_entrance_exam_post
# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch_all [as 别名]
def test_contentstore_views_entrance_exam_post(self):
"""
Unit Test: test_contentstore_views_entrance_exam_post
"""
resp = self.client.post(self.exam_url, {}, http_accept='application/json')
self.assertEqual(resp.status_code, 201)
resp = self.client.get(self.exam_url)
self.assertEqual(resp.status_code, 200)
# Reload the test course now that the exam module has been added
self.course = modulestore().get_course(self.course.id)
metadata = CourseMetadata.fetch_all(self.course)
self.assertTrue(metadata['entrance_exam_enabled'])
self.assertIsNotNone(metadata['entrance_exam_minimum_score_pct'])
self.assertIsNotNone(metadata['entrance_exam_id']['value'])
self.assertTrue(len(milestones_helpers.get_course_milestones(unicode(self.course.id))))
content_milestones = milestones_helpers.get_course_content_milestones(
unicode(self.course.id),
metadata['entrance_exam_id']['value'],
self.milestone_relationship_types['FULFILLS']
)
self.assertTrue(len(content_milestones))