1. 获取当前用户
self.runtime.get_real_user(self.runtime.anonymous_student_id)
例子:获取当前用户的邮箱,用户名和用户角色
student = self.runtime.get_real_user(self.runtime.anonymous_student_id)
studentEmail = student.email
studentUsername = student.username
studentIsStaff = student.is_staff //用户角色
2. 获取用户id
def get_user_id(self):
user_id = self.runtime.anonymous_student_id
assert user_id is not None
return unicode(urllib.quote(user_id))
3. 获取当前用户角色
self.runtime.get_user_role()
可获得用户角色:'instructor', 'staff',"student"
4. 获取当前课程id
self.runtime.course_id
5.获得xblock的唯一id
self.scope_ids.usage_id
6. 获得指定xblock的child
Return the child identified by usage_id.
get_child(usage_id)
children
.
get_children(usage_id_filter=None)
7.获得当前xblock的parent
//Return the parent block of this block, or None if there isn’t one.
get_parent()
8. 清除child 缓存
//Clear out any cached instantiated children.
self.clear_child_cache()
9. 获得xblock的资源url
//Gets the resource directory for this XBlock.
get_resources_dir()
参考链接:
XBLOCK API:http://edx.readthedocs.io/projects/xblock/en/latest/xblock.html
https://searchcode.com/codesearch/view/91455944/
一些属性的调用:https://github.com/edx/edx-platform/blob/master/common/lib/xmodule/xmodule/textannotation_module.py