【发布时间】:2015-10-23 17:11:15
【问题描述】:
我目前正在使用以下内容来确定教室用户是教师还是学生,并使用了必要的教室用户配置文件和教室课程实现。
有没有更直接的方法来询问 API 的这个问题?或者是否可以使用区分教师和学生角色的标识符来扩充用户配置文件。
最好的,
肖恩
def is_teacher? client
profile = classroom_user_profile(client)
has_courses = classroom_courses(client, only_me:true).size != 0
can_create_courses = profile.has_key?('permissions') and profile['permissions'].find{ |h| h.has_value?('CREATE_COURSE') } != nil
is_teacher = can_create_courses || has_courses
end
【问题讨论】:
-
我觉得将请求发送到带有用户 ID 的 Userprofiles(developers.google.com/classroom/reference/rest/v1/userProfiles),如果您获得“create_course”作为许可,则在响应中,然后是它的老师。但是,这里提到了一些其他解决方案stackoverflow.com/questions/32830670/… 可能会对您有所帮助。
标签: google-classroom