3

Open edX course数据探索

 2 years ago
source link: http://wwj718.github.io/post/edx/open-edx-course-data-explore/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

采用jupyter来探究,基于dogwood做的探索

获取course的各种方法

需要注意的是各种方法获取的course,关联的数据不尽相同

get_courses

from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
courses = CourseOverview.get_all_courses(org=filtered_by_org)
#course = CourseOverview.get_from_id(course_key)
  • 使用方法:
from django.contrib.auth.models import AnonymousUser
user=AnonymousUser() 
courses = get_courses(user)
course = all_courses[0]  # CourseOverview object 
  • 捕获对象:CourseOverview
  • 一些实用属性和方法:
	course.course_image_url #>>>u'/asset-v1:edX+DemoX+Demo_Course+type@asset+block@images_course_image.jpg'
	course.created 
	course.get_all_course_keys()
	get_all_courses()
	a.get_next_by_created()
	a.max_student_enrollments_allowed

get_course

  • 方法路径: from courseware.courses import get_course
  • 源码:get_course
  • 使用方法:
    from opaque_keys.edx.locations import SlashSeparatedCourseKey
	course_id_string = u"course-v1:a+b+c"
	course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id_string)
	from courseware.courses import get_course  
	course = get_course(course_id) # CourseDescriptorWithMixins
  • 捕获对象:CourseDescriptorWithMixins
	from xmodule.modulestore.django import modulestore
	course = modulestore().get_course(course_key)
  • 一些实用属性和方法:
	course.advanced_modules #高级模块
	course.children # >>>BlockUsageLocator  已有的章节
	course.category # u'course'  自省功能 ,course.children[0].category -> u'chapter'
	course.display_name # 课程名 ,可以在高级设置里修改
	course.display_name_with_defaulte
	course.display_number_with_default #course name,在course_id_string中间的那个值(唯一性),可以在高级设置里修改
	course.fields # 列出所有属性
	course.get_children() # 获得子节点
	course.get_content_titles() # 获得所有内容的标题
	course.get_context().keys() #显示出所有的context,使用keys来观察层次,其中数据很完备
	course.html_textbooks 
	course.id #>>>CourseLocator
	course.number  # course name/number 有唯一性
	course.pdf_textbooks
	course.raw_grader
	course.tabs[0].name #>>>u'Courseware'
	course.top_level_discussion_topic_ids 
	course.xml_attributes
	course.xml_element_name()

get_course_about_section

  • 方法路径: from courseware.courses import get_course_about_section

  • 源码: get_course_about_section

  • Valid keys:

    • overview
    • short_description
    • description
    • key_dates (includes start, end, exams, etc)
    • video
    • course_staff_short
    • course_staff_extended
    • requirements
    • syllabus
    • textbook
    • effort
    • more_info
    • ocw_links
  • 案例:course_about.html

    • 疑惑,这个放在course_about页面正常,直接使用有误,跟踪course //course缺乏static_asset_path属性,所以报错
    • views course_about

CourseDetails

  • 方法路径: from openedx.core.djangoapps.models.course_details import CourseDetails
  • 源码: CourseDetails
  • 使用方法:
    from openedx.core.djangoapps.models.course_details import CourseDetails
	course_id_string = u"course-v1:a+b+c"
	course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id_string)
	course_details = CourseDetails.fetch(course_key)
	#course_details.overview
  • CourseKey.from_string:
	from opaque_keys.edx.keys import CourseKey
	course = modulestore().get_course(CourseKey.from_string(kwargs.get('course_id')))

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK