socialforge/app/helpers/student_work_helper.rb

27 lines
780 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
end