小程序的学生列表和教师列表增加用户课堂角色的参数

online_time
cxt 5 years ago
parent f91fcc9751
commit a9dec59642

@ -1,15 +1,16 @@
module Weapps::CoursesHelper
require 'chinese_pinyin'
def teacher_list teachers
def teacher_list teachers, user_course_identity
data = []
teachers.each do |teacher|
if teacher.user.present?
teacher_user = teacher.user
name = teacher_user.real_name
role = teacher.role == "CREATOR" ? "管理员" : teacher.role == "PROFESSOR" ? "教师" : "助教"
member_roles = user_course_identity < Course::ASSISTANT_PROFESSOR ? teacher_user.course_role(teacher.course) : []
item = {name: name, course_member_id: teacher.id, login: teacher_user.login, user_id: teacher.user_id, role: role,
school: teacher_user.school_name, image_url: url_to_avatar(teacher_user)}
school: teacher_user.school_name, image_url: url_to_avatar(teacher_user), member_roles: member_roles}
pinyin = Pinyin.t(name.strip, splitter: '')
first_char = pinyin[0]
letter = first_letter first_char
@ -28,15 +29,16 @@ module Weapps::CoursesHelper
end
def student_list students, excellent
def student_list students, excellent, user_course_identity
data = []
students.each do |student|
if student.user.present?
student_user = student.user
name = student_user.real_name
phone = excellent ? "" : student_user.hidden_phone
member_roles = user_course_identity < Course::ASSISTANT_PROFESSOR ? student_user.course_role(student.course) : []
item = {name: name, course_member_id: student.id, login: student_user.login, user_id: student.user_id,
student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone}
student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone, member_roles: member_roles}
pinyin = Pinyin.t(name.strip, splitter: '')
first_char = pinyin[0]
letter = first_letter first_char

@ -1,4 +1,4 @@
json.students student_list @students, @course.excellent
json.students student_list @students, @course.excellent, @user_course_identity
json.students_count @students_count
if @course_group
json.course_group do

@ -1,3 +1,3 @@
json.teacher_list teacher_list(@teacher_list)
json.teacher_list teacher_list(@teacher_list, @user_course_identity)
json.teacher_list_size @teacher_list_size
json.apply_size @applications_size
Loading…
Cancel
Save