edx 属性的获取

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)


//Return instantiated XBlocks for each of this blocks 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

edx-platform-API

http://edx.readthedocs.io/projects/edx-platform-api/en/latest/courses/overview.html#courses-api-overview


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值