# encoding: utf-8 module SubjectsHelper def subject_co_users subject shixuns = Shixun.where(:id => subject.stage_shixuns.map(&:shixun_id)) co_users = User.where(:id => shixuns.map(&:user_id)).where("id != #{subject.user_id}") end # 实训路径详情列表,右侧状态显示栏 def shixun_show_in_subject subject_status, shixun_status content = "" content = if subject_status < 2 case shixun_status when 0, 1 '暂未公开' when 2 '已发布' when 3 '已关闭' end else if shixun_status != 2 case shixun_status when 0, 1 '暂未公开' when 3 '已关闭' end else "" end end return content.html_safe end # 实训路径详情列表,右侧鼠标移入时,html样式 def start_shixun_in_subject subject, shixun, myshixun is_modify = ShixunModify.where(:myshixun_id => myshixun.try(:id), :shixun_id => shixun.try(:id), :status => 1).first content_before = '' content = if shixun.status == 2 || User.current.manager_of_shixun?(shixun) content_before = "查看详情" if User.current.try(:mail).blank? %Q{开始实战} elsif shixun.challenges_count > 0 if is_modify.blank? %Q{#{link_to '开始实战', shixun_exec_shixun_path(shixun, :is_subject => subject.id), :class => "btn_auto user_bluebg_btn fl none", :id => "shixun_operation", :target => "_blank"}} else %Q{开始实战} end end end return "#{content_before}#{content}".html_safe end end