本文整理汇总了Python中opaque_keys.edx.locator.BlockUsageLocator._from_string方法的典型用法代码示例。如果您正苦于以下问题:Python BlockUsageLocator._from_string方法的具体用法?Python BlockUsageLocator._from_string怎么用?Python BlockUsageLocator._from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opaque_keys.edx.locator.BlockUsageLocator
的用法示例。
在下文中一共展示了BlockUsageLocator._from_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chart_update
# 需要导入模块: from opaque_keys.edx.locator import BlockUsageLocator [as 别名]
# 或者: from opaque_keys.edx.locator.BlockUsageLocator import _from_string [as 别名]
def chart_update(request):
results = {'success' : False}
chart_info_json = dumps(results)
if request.method == u'GET':
GET = request.GET
user_id = GET[u'user_id']
user_id = request.user if user_id == "" else user_id
chart = int(GET[u'chart'])
course_key = get_course_key(GET[u'course_id'])
if chart == VISUALIZATIONS_ID['LA_chapter_time']:
cs, st = get_DB_course_spent_time(course_key, student_id=user_id)
student_spent_time = chapter_time_to_js(cs, st)
chart_info_json = dumps(student_spent_time)
elif chart == VISUALIZATIONS_ID['LA_course_accesses']:
cs, sa = get_DB_course_section_accesses(course_key, student_id=user_id)
student_course_accesses = course_accesses_to_js(cs, sa)
chart_info_json = dumps(student_course_accesses)
elif chart == VISUALIZATIONS_ID['LA_student_grades']:
students_grades = get_DB_student_grades(course_key, student_id=user_id)
chart_info_json = dumps(students_grades)
elif chart == VISUALIZATIONS_ID['LA_time_schedule']:
student_time_schedule = get_DB_time_schedule(course_key, student_id=user_id)
chart_info_json = dumps(student_time_schedule)
elif chart == VISUALIZATIONS_ID['LA_vid_prob_prog']:
student_prob_vid_progress = get_DB_course_video_problem_progress(course_key, student_id=user_id)
chart_info_json = dumps(student_prob_vid_progress)
elif chart == VISUALIZATIONS_ID['LA_video_progress']:
# Video progress visualization. Video percentage seen total and non-overlapped.
course = get_course_with_access(user_id, action='load', course_key=course_key, depth=None, check_if_enrolled=False)
video_descriptors = videos_problems_in(course)[0]
video_durations = get_info_videos_descriptors(video_descriptors)[2]
video_names, avg_video_time, video_percentages = get_module_consumption(user_id, course_key, 'video', 'video_progress')
if avg_video_time != []:
all_video_time_percent = map(truediv, avg_video_time, video_durations)
all_video_time_percent = [int(round(x*100,0)) for x in all_video_time_percent]
else:
all_video_time_percent = avg_video_time
column_headers = ['Video', 'Different video time', 'Total video time']
chart_info_json = ready_for_arraytodatatable(column_headers, video_names, video_percentages, all_video_time_percent)
elif chart == VISUALIZATIONS_ID['LA_video_time']:
# Time spent on every video resource
video_names, all_video_time = get_module_consumption(user_id, course_key, 'video', 'total_time_vid_prob')[0:2]
column_headers = ['Video', 'Time watched']
chart_info_json = ready_for_arraytodatatable(column_headers, video_names, all_video_time)
elif chart == VISUALIZATIONS_ID['LA_problem_time']:
# Time spent on every problem resource
problem_names, time_x_problem = get_module_consumption(user_id, course_key, 'problem', 'total_time_vid_prob')[0:2]
column_headers = ['Problem', 'Time on problem']
chart_info_json = ready_for_arraytodatatable(column_headers, problem_names, time_x_problem)
elif chart == VISUALIZATIONS_ID['LA_repetition_video_interval']:
# Repetitions per video intervals
video_name = GET[u'video']
video_id = BlockUsageLocator._from_string(video_name)
video_id = Location.from_deprecated_string(video_id._to_deprecated_string())
chart_info_json = get_user_video_intervals(user_id, video_id)
elif chart == VISUALIZATIONS_ID['LA_daily_time']:
# Daily time spent on video and/or problem resources
video_days, video_daily_time = get_daily_consumption(user_id, course_key, 'video')
problem_days, problem_daily_time = get_daily_consumption(user_id, course_key, 'problem')
chart_info_json = join_video_problem_time(video_days, video_daily_time, problem_days, problem_daily_time)
elif chart == VISUALIZATIONS_ID['LA_video_events']:
# Video events dispersion within video length
video_name = GET[u'video']
video_id = BlockUsageLocator._from_string(video_name)
video_id = Location.from_deprecated_string(video_id._to_deprecated_string())
chart_info_json = get_video_events_info(user_id, video_id)
return HttpResponse(chart_info_json, mimetype='application/json')