在线评审启动失败发消息
This commit is contained in:
parent
355d5b59fe
commit
1fce3e7778
|
@ -107,6 +107,8 @@
|
|||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 发布的竞赛题:<%= ma.contest_message.name%>的截止日期快到了"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>发布的竞赛题:<%= ma.contest_message.name%>的截止时间快到啦</a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 2 %>
|
||||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 启动了在线评审:<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>启动了在线评审:<%= ma.contest_message.name%></a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 4 %>
|
||||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 在线评审启动失败(评委数为0或作品数为0):<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>在线评审启动失败(评委数为0或作品数为0):<%= ma.contest_message.name%></a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 5 %>
|
||||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 启动的在线评审:<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>启动的在线评审:<%= ma.contest_message.name%>的截止时间快到啦</a></li>
|
||||
<% elsif ma.contest_message_type == "Message" %>
|
||||
|
|
|
@ -163,6 +163,24 @@
|
|||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
|
||||
<!--在线评审启动失败-->
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 4 && ma.contest_message %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<div class="longMessageWidth">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<%= link_to image_tag(url_to_avatar(ma.contest_message.user), :width => "30", :height => "30"), user_path(ma.contest_message.user), :target => '_blank' %>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%= link_to ma.contest_message.user.show_name, user_path(ma.contest_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
|
||||
<span class="homepageNewsType fl">在线评审启动失败<font class="fr c_red">(评委数为0或作品数为0):</font></span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}"%>
|
||||
</li>
|
||||
</div>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
|
||||
<!--在线评审时间快到了-->
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 5 && ma.contest_message %>
|
||||
<ul class="homepageNewsList fl">
|
||||
|
|
|
@ -12,20 +12,32 @@ namespace :contest_work_evaluation do
|
|||
def contest_judges contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
|
||||
end
|
||||
# 获取竞赛的管理人员
|
||||
def contest_managers contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")}
|
||||
end
|
||||
#自动开启匿评的任务
|
||||
task :start_evaluation => :environment do
|
||||
Rails.logger.info("log--------------------------------contest_work_start_evaluation start")
|
||||
puts "--------------------------------contest_work_start_evaluation start"
|
||||
works = Work.where(:online_evaluation => true, :work_status => [1, 2])
|
||||
work_ids = works.blank? ? "(-1)" : "(" + works.map{|work| work.id}.join(",") + ")"
|
||||
puts "1111 #{work_ids}"
|
||||
homework_detail_manuals = WorkDetailManual.where("evaluation_start <= '#{Date.today}' and work_id in #{work_ids}")
|
||||
homework_detail_manuals.each do |homework_detail_manual|
|
||||
puts "222 #{homework_detail_manual.evaluation_start}"
|
||||
work = homework_detail_manual.work
|
||||
contestant_works = work.contestant_works.has_committed
|
||||
if homework_detail_manual.evaluation_num != -1
|
||||
judges = contest_judges work.contest
|
||||
|
||||
# 作品数为0||评委数为0 启动失败给管理员发消息
|
||||
if contestant_works.count == 0 || judges.count == 0
|
||||
contest = work.contest
|
||||
contest_managers(contest).each do |m|
|
||||
work.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 4)
|
||||
end
|
||||
else
|
||||
#限定评审人数
|
||||
if homework_detail_manual.evaluation_num != -1
|
||||
# 分配作品 启动成功给评委发消息
|
||||
n = homework_detail_manual.evaluation_num
|
||||
n = (n < judges.size && n != -1) ? n : judges.size
|
||||
contestant_works.each_with_index do |work, index|
|
||||
|
@ -44,8 +56,15 @@ namespace :contest_work_evaluation do
|
|||
contest.contest_members.each do |m|
|
||||
work.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 2)
|
||||
end
|
||||
else
|
||||
|
||||
#未限定评审人数
|
||||
else
|
||||
work.update_column('work_status', 3)
|
||||
contest = work.contest
|
||||
contest.contest_members.each do |m|
|
||||
work.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue