本文整理汇总了Python中oppia.models.Tracker.section_title方法的典型用法代码示例。如果您正苦于以下问题:Python Tracker.section_title方法的具体用法?Python Tracker.section_title怎么用?Python Tracker.section_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oppia.models.Tracker
的用法示例。
在下文中一共展示了Tracker.section_title方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: course_activity_view
# 需要导入模块: from oppia.models import Tracker [as 别名]
# 或者: from oppia.models.Tracker import section_title [as 别名]
def course_activity_view(request, course_id, activity_id):
course = can_view_course(request, course_id)
activity = Activity.objects.get(pk=activity_id)
# log the activity in the tracker
tracker = Tracker()
tracker.user = request.user
tracker.course = course
tracker.type = activity.type
tracker.data = ""
tracker.ip = request.META.get('REMOTE_ADDR','0.0.0.0')
tracker.agent = request.META.get('HTTP_USER_AGENT','unknown')
tracker.activity_title = activity.title
tracker.section_title = activity.section.title
tracker.save()
if activity.type == "page":
activity_content_file = activity.get_content()
with codecs.open(settings.MEDIA_ROOT + "courses/" + course.shortname + "/" + activity_content_file, "r", "utf-8") as f:
s = f.read()
template = re.compile('\<body(?P<body>.*?)>(?P<content>.*)\<\/body\>', re.DOTALL)
activity_content = template.search(s).group('content')
activity_content = activity_content.replace("images/",settings.MEDIA_URL + "courses/" + course.shortname + "/images/")
return render_to_response('oppia/preview/course_activity_page.html',
{'course': course, 'activity': activity , 'content' : activity_content },
context_instance=RequestContext(request))
else:
activity_content= None
return render_to_response('oppia/preview/course_activity_not_supported.html',
{'course': course, 'activity': activity , 'content' : activity_content },
context_instance=RequestContext(request))