socialforge/app/helpers/student_work_helper.rb

39 lines
1002 B
Ruby

# encoding: utf-8
module StudentWorkHelper
def user_projects_option
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
memberships = User.current.memberships.all(:conditions => cond)
projects = memberships.map(&:project)
not_have_project = []
not_have_project << Setting.please_chose
not_have_project << 0
type = []
type << not_have_project
projects.each do |project|
if project != nil
option = []
option << project.name
option << project.id
type << option
end
end
type
end
#获取指定用户对某一作业的评分结果
def student_work_score work,user
StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first
end
#获取指定评分的角色
def student_work_score_role score
case score.reviewer_role
when 1
role = "教师"
when 2
role = "教辅"
when 3
role = "学生"
end
end
end