竞赛作品的相关设置

This commit is contained in:
cxt 2016-12-30 10:30:21 +08:00
parent 034a4c1b72
commit 73350e34f1
42 changed files with 906 additions and 49 deletions

View File

@ -93,11 +93,11 @@ class ContestantWorksController < ApplicationController
def show
#@score = student_work_score @work,User.current
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
# if @homework.homework_detail_manual.comment_status == 2 && !@is_teacher && @work.user != User.current
# @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc")
# else
# @student_work_scores = student_work_score_record(@work)
# end
if @contestwork.work_status == 3 && User.current.judge_of_contest?(@contest) && @contestwork.online_evaluation
@student_work_scores = @work.contestant_work_scores.where("user_id = #{User.current.id} and reviewer_role = 2").order("updated_at desc")
else
@student_work_scores = contestant_work_score_record(@work)
end
respond_to do |format|
format.js
end
@ -362,6 +362,54 @@ class ContestantWorksController < ApplicationController
end
end
def add_score
@is_last = params[:is_last] == "true"
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
render_403 and return unless User.current.judge_of_contest?(@contest) && @contestwork.work_status == 3
@is_last_a = @work.contestant_work_scores.empty?
@new_score = ContestantWorkScore.new
@new_score.score = params[:score].to_i
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@new_score.user_id = User.current.id
@new_score.contestant_work_id = @work.id
@new_score.reviewer_role = 2
# if User.current.admin?
# @new_score.reviewer_role = 1
# else
# role = User.current.members.where("course_id = ?",@course.id).first.roles.where("is_current = 1").first.name
# @new_score.reviewer_role = get_role_by_name(role)
# end
# if @score
# if @is_teacher
# @is_new = true
# @is_last_a = false
# else
# @is_new = false
# end
# else
# @is_new = true
# end
@new_score.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@new_score)
if @new_score.save
@contestwork.update_column('updated_at', Time.now)
update_contest_activity(@contestwork.class,@contestwork.id)
update_user_activity(@contestwork.class,@contestwork.id)
if @work.save
@work = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:id => @work.id).first
@count = @contestwork.contestant_works.has_committed.count
@student_work_scores = contestant_work_score_record @work
respond_to do |format|
format.js
end
end
end
end
private
def hsd_committed_work?(user, homework)
sw = ContestantWork.where("user_id =? and work_id =?", user, homework).first

View File

@ -2,8 +2,9 @@ class WorksController < ApplicationController
layout "base_contests"
before_filter :find_contest, :only => [:index,:new,:create]
before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal]
before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:alert_open_student_works,:open_student_works]
before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:open_contestant_works,:set_score_open,:alert_score_open_modal,
:set_score_rule]
before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:open_contestant_works]
before_filter :member_of_contest, :only => [:index]
def index
@ -71,6 +72,13 @@ class WorksController < ApplicationController
homework.work_status = homework.publish_time > Date.today ? 0 : 1
work_detail_manual = WorkDetailManual.new
work_detail_manual.evaluation_start = homework.end_time + 7
work_detail_manual.evaluation_end = work_detail_manual.evaluation_start + 7
work_detail_manual.evaluation_num = 3
homework.work_detail_manual = work_detail_manual
#分组作业
if homework.work_type == 3
homework_detail_group = WorkDetailGroup.new
@ -81,6 +89,7 @@ class WorksController < ApplicationController
end
if homework.save
work_detail_manual.save if work_detail_manual
homework_detail_group.save if homework_detail_group
redirect_to works_path(:contest => @contest.id)
end
@ -101,7 +110,14 @@ class WorksController < ApplicationController
end
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
homework_end_time = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d")
work_detail_manual = @contestwork.work_detail_manual
if homework_end_time != param_end_time
eval_start = work_detail_manual.evaluation_start
if eval_start.nil? || (eval_start <= param_end_time && @contestwork.work_status <= 2)
work_detail_manual.evaluation_start = @contestwork.end_time + 7
work_detail_manual.evaluation_end = work_detail_manual.evaluation_start + 7
end
if homework_end_time > param_end_time
@contestwork.contestant_works.each do |st|
if param_end_time < Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
@ -129,6 +145,8 @@ class WorksController < ApplicationController
#status = false
if @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
@contestwork.work_status = 1
elsif @contestwork.end_time < Date.today && @contestwork.work_status == 1
@contestwork.work_status = 2
#status = true
end
@ -146,6 +164,7 @@ class WorksController < ApplicationController
if @contestwork.save
@homework_detail_group.save if @homework_detail_group
work_detail_manual.save if work_detail_manual
@hw_status = params[:hw_status].to_i
if @hw_status == 1
@ -180,20 +199,80 @@ class WorksController < ApplicationController
def destroy
if @contestwork.destroy
respond_to do |format|
format.html {
format.js {
@hw_status = params[:hw_status].to_i
if @hw_status == 1
redirect_to user_contest_community_path(User.current.id)
elsif @hw_status == 2
redirect_to contest_path(@contest.id)
else
redirect_to works_path(:contest => @contest.id)
end
}
end
end
end
def alert_score_open_modal
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
else
@user_activity_id = -1
end
@hw_status = params[:hw_status].to_i
end
def set_score_open
@contestwork.update_attribute('score_open', params[:score_open].to_i)
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.admin_of_contest?(@contest)
end
def open_contestant_works
@contestwork.update_attributes(:is_open => !@contestwork.is_open)
@user_activity_id = params[:user_activity_id]
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.admin_of_contest?(@contest)
end
def score_rule_set
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
else
@user_activity_id = -1
end
@hw_status = params[:hw_status].to_i
end
def set_score_rule
# 未启动在线评审时才能更改评审参数
if @contestwork.work_status < 3
@contestwork.online_evaluation = params[:online_evaluation] ? 1 : 0
# 如果开启在线评审
if params[:online_evaluation]
work_detail_manual = @contestwork.work_detail_manual
work_detail_manual.evaluation_start = params[:evaluation_start]
work_detail_manual.evaluation_end = params[:evaluation_end]
work_detail_manual.evaluation_num = params[:evaluation_limit].to_i == 1 ? params[:evaluation_num] : -1
work_detail_manual.save
end
end
score_valid = params[:score_valid].to_i == 1 ? true : false
if score_valid != @contestwork.score_valid
@contestwork.score_valid = score_valid
@contestwork.contestant_works.has_committed.each do |c_work|
c_work.save
end
end
@contestwork.save
if params[:student_path] && params[:student_path] == "true"
redirect_to contestant_works_path(:work => @contestwork.id)
else
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
respond_to do |format|
format.js
end
end
end
private
#获取竞赛

View File

@ -3948,6 +3948,8 @@ def get_cw_status contest_work
else
str += '<span class="red_homework_btn_cir ml5">作品补交中</span>'
end
elsif contest_work.work_status == 2
str += '<span class="red_homework_btn_cir ml5">提交已截止</span>'
end
str
end

View File

@ -13,4 +13,44 @@ module ContestantWorksHelper
end
str
end
#成绩计算
def set_final_score contestwork, contestant_work
if contestwork.online_evaluation
if contestwork.score_valid
if ContestantWorkScore.find_by_sql("SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id").count < 2
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
else
judge_score = ContestantWorkScore.find_by_sql("SELECT (SUM(score)-MIN(score)-MAX(score))/(COUNT(score)-2) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
end
@work.work_score = judge_score.first.score.try(:round, 2).to_f
else
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.work_score = judge_score.first.score.try(:round, 2).to_f
end
else
contestant_work.work_score = nil
end
end
#获取学生作品的评分记录:同一个评委只显示最后一次评分
def contestant_work_score_record work
sql = "SELECT MAX(id) id FROM contestant_work_scores WHERE reviewer_role = 2 AND score IS NOT NULL AND contestant_work_id = #{work.id} GROUP BY user_id"
tea_ts_ids = ContestantWorkScore.find_by_sql sql
tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
scores = work.contestant_work_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
return scores
end
#获取指定评分的角色
def student_work_score_role score
case score.reviewer_role
when 1
role = "管理员"
when 2
role = "评委"
when 3
role = "参赛者"
end
end
end

View File

@ -1,4 +1,5 @@
class ContestantWork < ActiveRecord::Base
include ContestantWorksHelper
belongs_to :work
belongs_to :user
belongs_to :project
@ -8,6 +9,9 @@ class ContestantWork < ActiveRecord::Base
has_many :contestant_work_scores, :dependent => :destroy
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
has_many :attachments, :dependent => :destroy
has_many :contestant_work_evaluation_distributions
before_save :set_work_score
scope :has_committed, lambda{where("work_status != 0 and work_status != 3")}
scope :no_copy, lambda{where("work_status != 3")}
@ -20,4 +24,8 @@ class ContestantWork < ActiveRecord::Base
self.contest_messages << ContestMessage.new(:user_id => self.user_id, :contest_id => self.work.contest_id, :viewed => false, :status => false)
end
end
def set_work_score
set_final_score self.work,self
end
end

View File

@ -0,0 +1,5 @@
class ContestantWorkEvaluationDistribution < ActiveRecord::Base
belongs_to :user
belongs_to :contestant_work
attr_accessible :user_id, :contestant_work_id
end

View File

@ -2,4 +2,6 @@ class ContestantWorkScore < ActiveRecord::Base
belongs_to :contestant_work
belongs_to :user
attr_accessible :comment, :reviewer_role, :score, :contestant_work_id, :user_id
has_many :journals_for_messages
end

View File

@ -1,10 +1,12 @@
class Work < ActiveRecord::Base
# work_status 0未发布/挂起 1提交中 2提交截止 3启动在线评审 4评审结束
belongs_to :user
belongs_to :contest
attr_accessible :description, :end_time, :is_delete, :is_open, :name, :publish_time, :score_open, :work_status, :work_type, :contest_id, :user_id
include ApplicationHelper
has_one :work_detail_group, :dependent => :destroy
has_one :work_detail_manual, :dependent => :destroy
has_many :contestant_work_projects, :dependent => :destroy
has_many :contestant_works, :dependent => :destroy, :conditions => "is_delete != 1"
has_many :journals_for_messages, :as => :jour, :dependent => :destroy

View File

@ -0,0 +1,4 @@
class WorkDetailManual < ActiveRecord::Base
belongs_to :work
attr_accessible :evaluation_end, :evaluation_num, :evaluation_start, :work_id
end

View File

@ -0,0 +1,50 @@
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_contestant_works_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
<li >
<span class="tit_fb"> 评价:</span>
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>500),:maxlength => 500 %>
<div class="cl"></div>
</li>
<p id="hint_message_<%=work.id %>" style="margin-left: 65px;"></p>
<li >
<span class="tit_fb mt2"> 评分:</span>
<input type="number" name="score" id="score_<%= work.id%>" value="<%= (score.nil? || score.score.nil?) ? -1 : score.score%>" min="-1" max="100" size="4" data-units="dollars" />
<span class="ml5">分</span>
<span id="score_notice_span_<%= work.id%>" class="ml5 c_red" style="display: none;">未评分</span>
<div class="cl"></div></li>
<li >
<span class="tit_fb"> 批阅结果:</span>
<div>
<%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %>
</div>
<div class="cl"></div>
<span class="c_red ml5" style="display: none;" id="none_notice_<%= work.id%>">评语、评分、批阅结果至少有一个不为空。</span>
<a href="javascript:void(0);" id="work_submit_<%= work.id %>" class="blue_n_btn fr evaluation_submit" onclick="score_submit('<%=work.id %>');">提交</a>
<div class="cl"></div>
</li>
<% end%>
<script type="text/javascript">
var first_click_score = true;
function score_submit(id){
if ($.trim($('#score_comment_'+id).val()) == "") {
$('#hint_message_'+id).html("为了对参赛者的作品负责,请您务必填写评语");
$("#hint_message_"+id).css('color','#ff0000');
$("#score_comment_"+id).focus();
} else if (parseFloat($("#score_"+id).val()) == -1) {
$('#score_notice_span_'+id).html("请先评分");
$('#score_notice_span_'+id).show();
$("#score_"+id).focus();
}
else if(first_click_score) {
first_click_score = false;
$("#work_submit_"+id).parent().parent().submit();
$('#about_hwork_'+id).html('');
}
}
function submit_teacher_score(id){
if (first_click_score) {
first_click_score = false;
$("#work_submit_"+id).parent().parent().submit();
hideModal();
}
}
</script>

View File

@ -16,9 +16,9 @@
<% unless @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
<%=link_to "提交作品", new_contestant_work_path(:work => @contestwork.id),:class => 'blueCir ml5 f12' %>
<% end %>
<% elsif !@is_teacher && !@is_judge && my_work &&Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<% elsif !@is_teacher && !@is_judge && my_work && @contestwork.work_status > 1 && !@stundet_works.empty?%>
<span class="f12 c_red">截止日期已过,已提交且不可修改</span>
<% elsif !@is_teacher && !@is_judge && my_work &&Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<% elsif !@is_teacher && !@is_judge && my_work && @contestwork.work_status == 1 && !@stundet_works.empty?%>
<% if @contestwork.work_type == 3 %>
<span class="f12 c_red">组长已提交,组长还可修改</span>
<% else %>

View File

@ -0,0 +1,44 @@
<ul class="ping_box_ul <%= is_last ? '' : 'ping_line'%> fl">
<% show_real_name = @is_teacher || score.user == User.current || score.reviewer_role != 3 %>
<%= link_to image_tag(url_to_avatar(show_real_name ? score.user : ""), :width => "34", :height => "34"), show_real_name ? user_path(score.user) : "javascript:void(0)",:class => "ping_pic fl" %>
<% show_real_score = @contestwork.score_open || @is_teacher || score.contestant_work.user == User.current || score.user == User.current %>
<div class="pingBoxTit">
<%= link_to show_real_name ? score.user.show_name : "匿名", show_real_name ? user_path(score.user) : "javascript:void(0)", :title => show_real_name ? score.user.show_name : "匿评用户", :class => "linkBlue fl" %>
<span class="ml5 fl">
<%= student_work_score_role score%>
</span>
<% unless score.score.nil? %>
<span class="ml20 fl">评分:</span>
<a href="javascript:void(0);" class="c_orange fl" >
<%= show_real_score ? score.score : "**" %>分
</a>
<% end %>
<!--<a href="javascript:void(0);" class="fr linkBlue mr5" onclick="$('#add_score_reply_<%#= score.id%>').slideToggle();">回复</a>-->
<span class="fr c_grey mr20">
<%=format_time score.updated_at %>
</span>
<div class="cl mb5"></div>
<p class="break_word">
<%= score.comment%>
</p>
<div class="cl"></div>
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => score.attachments} %>
<div class="cl"></div>
<!--<div id="add_score_reply_<%#= score.id%>" class="undis">-->
<!--<%#= render :partial => 'add_score_reply',:locals => {:score => score,:is_last => is_last}%>-->
<!--</div>-->
<div class="cl"></div>
<!--<div id="replay_histroy_<%#= score.id%>">-->
<!--<%# score.journals_for_messages.order("created_on desc").each do |jour|%>-->
<!--<%# show_real_name = @is_teacher || score.reviewer_role != 3 || @contestwork.work_status != 3 %>-->
<!--<%#= render :partial => 'jour_replay',:locals => {:jour => jour, :show_real_name => show_real_name || jour.user == User.current}%>-->
<!--<%# end%>-->
<!--</div>-->
<div class="cl"></div>
</div>
</ul>

View File

@ -0,0 +1,8 @@
<%student_work_scores.each do |student_score|%>
<div id="work_score_<%= student_score.id%>">
<%= render :partial => 'contestant_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
</div>
<% end%>
<% if is_member_work && student_work_scores.empty? && !@is_teacher %>
<p class="c_red" style="text-align: center">暂无评分</p>
<% end %>

View File

@ -15,7 +15,7 @@
<%=format_time work.commit_time %>
</li>
<% if work.user == User.current && Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %>
<% if work.user == User.current && @contestwork.work_status == 1 %>
<!-- 我的作业 && 匿评作业 && 未开启匿评,显示编辑和删除按钮 -->
<li class="fr" >
<%= link_to("", contestant_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %>
@ -76,7 +76,7 @@
<div class="cl"></div>
</li>
<!--<li >-->
<!--<%# if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%>-->
<!--<%# if @contestwork.online_evaluation && User.current.judge_of_contest?(@contestwork.contest) && @contestwork.work_status == 3 %>-->
<!--&lt;!&ndash; 老师 || 开启匿评状态 && 不是当前用户自己的作品 &ndash;&gt;-->
<!--<div id="add_student_score_<%#= work.id%>" class="mt10 evaluation">-->
<!--<%#= render :partial => 'add_score',:locals => {:work => work,:score => score,:is_member_work => is_member_work}%>-->
@ -94,7 +94,7 @@
<!--<ul>-->
<!--<li >-->
<!--<%# if @is_teacher %>-->
<!--&lt;!&ndash; 老师 &ndash;&gt;-->
<!--<!-- 老师 -->-->
<!--<div id="add_student_score_<%#= work.id%>" class="mt10 evaluation">-->
<!--<%#= render :partial => 'add_score',:locals => {:work => work,:score => score,:is_member_work => is_member_work}%>-->
<!--</div>-->
@ -104,8 +104,8 @@
<!--</ul>-->
<% end %>
<!--<div class="ping_box fl" id="score_list_<%#= work.id%>" style="<%#= student_work_scores.empty? ? 'padding:0px;' : ''%>">-->
<!--<%#= render :partial => 'student_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>-->
<!--<div class="ping_box fl" id="score_list_<%#= work.id%>" style="<%#= student_work_scores.empty? ? 'padding:0px;' : ''%>">-->
<!--<%#= render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>-->
<!--</div>-->
<div class="cl"></div>
<!---ping_box end--->

View File

@ -0,0 +1,18 @@
<% is_member_work = @contestwork.work_type == 3 && @work.contestant_work_projects.empty? %>
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @new_score,:is_member_work => is_member_work}) %>");
$('#score_<%= @work.id%>').peSlider({range: 'min'});
<% score_open = @is_teacher || @contestwork.score_open == 1 || @work.user == User.current %>
$("#score_list_<%= @work.id%>").html("<%=escape_javascript(render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => @student_work_scores, :is_member_work => is_member_work}) %>");
var num = $("#work_num_<%= @work.id%>").html();
$("#score_list_<%= @work.id%>").removeAttr("style");
<% if @contestwork.work_type == 3 %>
$("#student_work_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => @work}) %>");
<% else %>
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'contest_evaluation_un_work',:locals => {:student_work => @work, :index => 1, :score_open => score_open}) %>");
$("#work_num_<%= @work.id%>").html(num);
<% end %>
$("#student_work_count").html("<%=@count %>");

View File

@ -10,7 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify','contest'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>

View File

@ -12,7 +12,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify' %>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify','contest' %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>

View File

@ -49,7 +49,22 @@
<%= link_to "编 辑",edit_work_path(activity, :hw_status => hw_status), :class => "wpostOptionLink"%>
</li>
<li>
<%= link_to "删 除",work_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "wpostOptionLink" %>
<a href="javascript:void(0)" onclick="delete_confirm_box_2('<%=work_path(activity, :hw_status => hw_status) %>', '提交的作品将被全部清空<br/>是否确定删除?')" class="wpostOptionLink">删除</a>
</li>
<li>
<%= link_to("评分设置", score_rule_set_work_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %>
</li>
<% if (!activity.online_evaluation && !activity.is_open && activity.work_status == 2) || (activity.online_evaluation && activity.work_status == 4 && !activity.is_open) %>
<li>
<a href="javascript:void(0)" onclick="alert_open_contestant_works('<%= open_contestant_works_work_path(activity, :user_activity_id => user_activity_id,:hw_status=>hw_status)%>', false)" class="wpostOptionLink">公开作品</a>
</li>
<% elsif activity.is_open %>
<li>
<a href="javascript:void(0)" onclick="alert_open_contestant_works('<%= open_contestant_works_work_path(activity, :user_activity_id => user_activity_id,:hw_status=>hw_status)%>', true)" class="wpostOptionLink">取消公开</a>
</li>
<% end %>
<li>
<%= link_to("成绩公开范围", alert_score_open_modal_work_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %>
</li>
</ul>
</li>

View File

@ -103,7 +103,7 @@
</li>
<li class="messageInformationContents">
<% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? %>
<%= link_to ma.contest_message.name, new_work_path(:work => ma.contest_message.id),
<%= link_to ma.contest_message.name, new_contestant_work_path(:work => ma.contest_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"

View File

@ -0,0 +1,42 @@
<div id="muban_popup_box" style="width:400px;">
<div class="muban_popup_top">
<h3 class="fl">成绩公开范围</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<%= form_for('new_form',:url =>{:controller => 'works',:action => 'set_score_open',:id => @contestwork.id,:user_activity_id => @user_activity_id, :hw_status => @hw_status},
:method => "post", :remote => true) do |f|%>
<div class="muban_popup_con clear">
<div class="clear mt15 ml20">
<ul class="pro_newsetting_con fl">
<li class="mb10 clear">
<ul class="fl">
<li class="clear">
<label class="fl ml5">请选择作品成绩的公开范围</label>
</li>
<li class="clear ml20">
<input type="radio" class="fl" id="open_to_all" <%= @contestwork.score_open ? "checked" : "" %> value="1" name="score_open"/>
<label for="open_to_all" class="fl ml5 fontGrey2">成绩对所有参赛者可见</label>
</li>
<li class="clear ml20">
<input type="radio" class="fl" id="open_to_me" <%= !@contestwork.score_open ? "checked" : "" %> value="0" name="score_open"/>
<label for="open_to_me" class="fl ml5 fontGrey2">成绩仅对自己可见</label>
</li>
</ul>
</li>
</ul>
<ul class="fl ml20">
<div class="popup_tip_box fontGrey2">
<em></em>
<span></span>
<p>管理员始终能看到所有成绩</p>
</div>
</ul>
<div class="cl"></div>
<a href="javascript:void(0);" class="fr sy_btn_blue mr20" onclick="$(this).parent().parent().parent().submit();">确定</a>
<a href="javascript:void(0);" class="fr sy_btn_grey mr5" onclick="hideModal();">取消</a>
</div>
</div>
<% end%>
</div>

View File

@ -0,0 +1,136 @@
<div id="muban_popup_box" style="width:600px;">
<div class="muban_popup_top">
<h3 class="fl">评分设置</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<%= form_for('new_form',:url =>{:controller => 'works',:action => 'set_score_rule',:work => homework.id,:student_path => student_path,:user_activity_id=>user_activity_id,:hw_status=>hw_status},:method => "post", :remote => !student_path) do |f|%>
<div class="muban_popup_con clear">
<div class="clear mt15 ml20">
<ul class="pro_newsetting_con fl">
<li class="clear">
<input type="checkbox" class="fl ml30" id="online_evaluation" name="online_evaluation" <%=homework.online_evaluation ? 'checked' : '' %> value="1"/>
<label class="pop_box_label_l fl text_l ml10">启用在线评审&nbsp;&nbsp;:&nbsp;</label>
<div class="cl"></div>
<ul class="clear">
<li class="clear mt10">
<label class="fl pop_box_label ml42">开启在线评审&nbsp;&nbsp;:&nbsp;&nbsp;</label>
<div class="calendar_div fl">
<input type="text" name="evaluation_start" id="evaluation_start_time" placeholder="开启评审日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.work_detail_manual.evaluation_start%>"/>
</div>
<div class="cl"></div>
<p id="homework_evaluation_start_time" class="ml53 c_red"></p>
</li>
<li class="clear mt10">
<label class="fl pop_box_label ml42">关闭在线评审&nbsp;&nbsp;:&nbsp;&nbsp;</label>
<div class="calendar_div fl">
<input type="text" name="evaluation_end" id="evaluation_end_time" placeholder="关闭评审日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.work_detail_manual.evaluation_end%>"/>
</div>
<div class="cl"></div>
<p id="homework_evaluation_end_time" class="ml53 c_red"></p>
</li>
<li class="clear">
<label class="pop_box_label fl clear ml39">作品评审人数&nbsp;&nbsp;:&nbsp;</label>
<div class="cl"></div>
<ul class="clear ml90">
<li>
<input type="radio" class="fl" value="1" name="evaluation_limit" id="limit"/>
<label for="limit" class="fl ml5">限定</label>
<input type="text" name="evaluation_num" id="evaluation_num" maxlength="2" class="radio-width90 fl ml10" value="<%= homework.work_detail_manual.evaluation_num == -1 ? 3 : homework.work_detail_manual.evaluation_num%>"/>
<div class="cl"></div>
<p id="evaluation_num_notice" class="c_red"></p>
</li>
<li class="clear mt20">
<input type="radio" class="fl" value="0" name="evaluation_limit" id="no_limit"/>
<label for="no_limit" class="fl ml5">不限定</label>
</li>
</ul>
</li>
</ul>
</li>
<li class="mb10 clear">
<label class="pop_box_label_l fl ml30">最终得分&nbsp;&nbsp;:&nbsp;</label>
<div class="cl"></div>
<ul class="fl ml90">
<li class="clear mb10">
<input type="radio" class="fl" id="all_score_valid" value="1" name="score_valid"/>
<label for="score_valid" class="fl ml5">全部评分有效</label>
<div class="cl"></div>
</li>
<li class="clear">
<input type="radio" class="fl" id="score_valid" value="0" name="score_valid"/>
<label for="all_score_valid" class="fl ml5">最高分和最低分无效</label>
<div class="cl"></div>
</li>
</ul>
</li>
</ul>
<ul class="fl ml20">
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p >允许评委对作品进行在线评审</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p >系统自动开启在线评审的时间</p>
</div>
<div class="popup_tip_box fontGrey2 mb25">
<em></em>
<span></span>
<p>系统自动关闭在线评审的时间</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em style="top: 10px;"></em>
<span style="top: 10px;"></span>
<p>参赛作品供指定数量的评委评审<br/>由系统随机分配<br/></p>
</div>
<div class="popup_tip_box fontGrey2 mb30">
<em></em>
<span></span>
<p>参赛作品供全部的评委评审</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p>全部评委给的评分取平均值</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p >全部评委给的评分去除一个最高分<br/>和一个最低分,再取平均值</p>
</div>
</ul>
<div class="cl"></div>
<a href="javascript:void(0);" class="fr sy_btn_blue mr80" onclick="submit_set_score_rule('<%= homework.end_time%>');">确定</a>
<a href="javascript:void(0);" class="fr sy_btn_grey mr5" onclick="hideModal();">取消</a>
</div>
</div>
<% end %>
</div>
<script>
$(function(){
<% if homework.score_valid %>
$("#all_score_valid").attr("checked", "checked");
<% else %>
$("#score_valid").attr("checked", "checked");
<% end %>
<% if homework.online_evaluation %>
$("#online_evaluation").attr("checked", "checked");
<% end %>
<% if homework.work_detail_manual.evaluation_num != -1 %>
$("#limit").attr("checked", "checked");
<% else %>
$("#no_limit").attr("checked", "checked");
<% end %>
// $("#online_evaluation").on('click', function(){
// if($("#online_evaluation").is(":checked")){
// $('#evaluation_start_time').datepicker(datepickerOptions);
// $('#evaluation_end_time').datepicker(datepickerOptions);
// }
// });
});
</script>

View File

@ -0,0 +1,2 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'works/alert_score_open_modal') %>";
pop_box_new(htmlvalue, 400, 200);

View File

@ -0,0 +1,8 @@
hideModal();
<% if @hw_status == 1 %>
window.location.href = "<%=user_contest_community_path(User.current.id) %>"
<% elsif @hw_status == 2 %>
window.location.href = "<%=contest_path(@contest.id) %>"
<% else %>
window.location.href = "<%=works_path(:contest => @contest.id) %>"
<% end %>

View File

@ -0,0 +1,11 @@
hideModal();
<% if @hw_status == 5 %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'contestant_works/work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher}) %>");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% end %>
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @contestwork.id%>,"","100%", "<%=@contestwork.class.to_s%>");
<% end %>

View File

@ -0,0 +1,27 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'works/set_score_rule',:locals => {:homework => @contestwork, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>";
pop_box_new(htmlvalue, 600, 450);
var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
$(function() {
<% if @contestwork.work_status < 3 %>
$('#evaluation_start_time').datepicker(datepickerOptions);
$('#evaluation_end_time').datepicker(datepickerOptions);
<% else %>
$("#online_evaluation").attr('disabled', 'disabled');
$("#limit").attr('disabled', 'disabled');
$("#no_limit").attr('disabled', 'disabled');
$("#evaluation_num").attr('disabled', 'disabled');
<% end %>
});
function set_score_rule_submit() {
if($("#late_penalty_num").val().trim() == ""){
$("#late_penalty_num").val("0");
}
if($("#absence_penalty_num").val().trim() == ""){
$("#absence_penalty_num").val("0");
}
if($("#appeal_penalty").val().trim() == ""){
$("#appeal_penalty").val("0");
}
$('#muban_popup_box').find('form').submit();
hideModal();
}

View File

@ -0,0 +1,11 @@
hideModal();
<% if @hw_status != 5 %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @contestwork.id%>,"","100%", "<%=@contestwork.class.to_s%>");
<% end %>
<% else %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'contestant_works/work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher}) %>");
<% end %>

View File

@ -0,0 +1,10 @@
<% if @hw_status != 5 %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @contestwork.id%>,"","100%", "<%=@contestwork.class.to_s%>");
<% end %>
<% else %>
window.location.href = '<%=contestant_works_path(:work => @contestwork.id) %>';
<% end %>

View File

@ -596,6 +596,7 @@ RedmineApp::Application.routes.draw do
member do
get 'retry_work'
post 'add_score'
end
end
@ -606,7 +607,11 @@ RedmineApp::Application.routes.draw do
end
member do
get 'alert_score_open_modal'
post 'set_score_open'
get 'open_contestant_works'
get 'score_rule_set'
post 'set_score_rule'
end
end

View File

@ -0,0 +1,12 @@
class ChangeWorkColumn < ActiveRecord::Migration
def up
change_column :works, :score_open, :boolean, :default => false
add_column :works, :online_evaluation, :boolean, :default => false
add_column :works, :score_valid, :boolean, :default => true
Work.update_all(:score_open => 0)
end
def down
end
end

View File

@ -0,0 +1,17 @@
class CreateWorkDetailManuals < ActiveRecord::Migration
def change
create_table :work_detail_manuals do |t|
t.date :evaluation_start
t.date :evaluation_end
t.integer :evaluation_num
t.references :work
t.timestamps
end
add_index :work_detail_manuals, :work_id
Work.all.each do |work|
WorkDetailManual.create(:work_id => work.id, :evaluation_start => work.end_time + 7, :evaluation_end => work.end_time + 14, :evaluation_num => 3)
end
end
end

View File

@ -0,0 +1,12 @@
class CreateContestantWorkEvaluationDistributions < ActiveRecord::Migration
def change
create_table :contestant_work_evaluation_distributions do |t|
t.references :user
t.references :contestant_work
t.timestamps
end
add_index :contestant_work_evaluation_distributions, :user_id
add_index :contestant_work_evaluation_distributions, :contestant_work_id
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20161227085308) do
ActiveRecord::Schema.define(:version => 20161228091749) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -2501,6 +2501,17 @@ ActiveRecord::Schema.define(:version => 20161227085308) do
add_index "work_detail_groups", ["work_id"], :name => "index_work_detail_groups_on_work_id"
create_table "work_detail_manuals", :force => true do |t|
t.date "evaluation_start"
t.date "evaluation_end"
t.integer "evaluation_num"
t.integer "work_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "work_detail_manuals", ["work_id"], :name => "index_work_detail_manuals_on_work_id"
create_table "workflows", :force => true do |t|
t.integer "tracker_id", :default => 0, :null => false
t.integer "old_status_id", :default => 0, :null => false
@ -2526,12 +2537,14 @@ ActiveRecord::Schema.define(:version => 20161227085308) do
t.date "end_time"
t.integer "work_type"
t.integer "contest_id"
t.boolean "is_delete", :default => false
t.boolean "score_open", :default => true
t.boolean "is_open", :default => false
t.boolean "is_delete", :default => false
t.boolean "score_open", :default => false
t.boolean "is_open", :default => false
t.integer "work_status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "online_evaluation", :default => false
t.boolean "score_valid", :default => true
end
add_index "works", ["contest_id"], :name => "index_works_on_contest_id"

View File

@ -0,0 +1,69 @@
#coding=utf-8
namespace :contest_work_evaluation do
desc "start and end evaluation"
def get_assigned_contestant_works(contestant_works, n, index, num)
contestant_works[(index % num) .. ((index + n - 1) % num)]
end
# 获取竞赛的评委人员
def contest_judges contest
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
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(",") + ")"
homework_detail_manuals = WorkDetailManual.where("evaluation_start <= #{Date.today} and work_id in #{work_ids}")
homework_detail_manuals.each do |homework_detail_manual|
work = homework_detail_manual.work
contestant_works = work.contestant_works.has_committed
if homework_detail_manual.evaluation_num != -1
judges = contest_judges work.contest
n = homework_detail_manual.evaluation_num
n = (n < judges.size && n != -1) ? n : judges.size
contestant_works.each_with_index do |work, index|
user = work.user
assigned_judges = get_assigned_contestant_works(judges, n, index, judges.size)
assigned_judges.each do |h|
contestant_works_evaluation_distributions = ContestantWorkEvaluationDistribution.new(user_id: h.user_id, contestant_work_id: work.id)
contestant_works_evaluation_distributions.save
end
end
work.update_column('work_status', 3)
# 匿评开启消息邮件通知,# 所有人
#send_message_anonymous_comment(homework_common, 2)
contest = work.contest
contest.contest_members.each do |m|
work.contest_messages << CoontestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 2)
end
else
end
end
Rails.logger.info("log--------------------------------contest_work_start_evaluation end")
puts "--------------------------------contest_work_start_evaluation end"
end
#自动关闭匿评的任务
task :end_evaluation => :environment do
works = Work.where(:online_evaluation => true, :work_status => 3)
homework_detail_manuals = WorkDetailManual.where(:evaluation_end => Date.today, :work_id => works.map{|work| work.id})
homework_detail_manuals.each do |homework_detail_manual|
work = homework_detail_manual.work
work.contestant_works.has_committed.each do |student_work|
student_work.save
end
work.update_column('work_status', 4)
# 匿评关闭消息通知 给所有人发
contest = work.contest
contest.contest_members.each do |m|
work.contest_messages << CoontestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 3)
end
end
end
end

View File

@ -5,23 +5,32 @@ namespace :contest_work_publishtime do
task :publish => :environment do
puts "--------------------------------contest_work_publish start"
Rails.logger.info("log--------------------------------contest_work_publish start")
homework_commons = Work.where("publish_time = '#{Date.today}'")
homework_commons = Work.where("work_status = 0 and publish_time <= '#{Date.today}'")
homework_commons.each do |homework|
if homework.work_status == 0
homework.update_column('work_status', 1)
homework.update_attribute('work_status', 1)
contest = homework.contest
contest.contestants.each do |m|
homework.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => contest.id, :viewed => false, :status => nil)
end
if homework.contest_acts.size == 0
homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id)
end
# 邮件通知
# Mailer.run.homework_added(homework)
contest = homework.contest
contest.contestants.each do |m|
homework.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => contest.id, :viewed => false, :status => nil)
end
if homework.contest_acts.size == 0
homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id)
end
# 邮件通知
# Mailer.run.homework_added(homework)
end
Rails.logger.info("log--------------------------------contest_work_publish end")
puts "--------------------------------contest_work_publish end"
end
task :end => :environment do
puts "--------------------------------contest_work_publish_end start"
Rails.logger.info("log--------------------------------contest_work_publish_end start")
homework_commons = Work.where("work_status = 1 and end_time <= '#{Date.today}'")
homework_commons.each do |homework|
homework.update_attribute('work_status', 2)
end
Rails.logger.info("log--------------------------------contest_work_publish_end end")
puts "--------------------------------contest_work_publish_end end"
end
end

View File

@ -1718,7 +1718,7 @@ function expand_course_list(id, target, btnid, count) {
//点击删除时的确认弹框: 不走destroy方法
function delete_confirm_box(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f16">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-remote="true">确定</a>'+
'<div class="clear mt15"><p class="text_c f16 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
@ -1726,7 +1726,7 @@ function delete_confirm_box(url, str){
//点击删除时的确认弹框: 走destroy方法
function delete_confirm_box_2(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f16">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-method="delete" data-remote="true">确定</a>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-method="delete" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}

View File

@ -26,3 +26,121 @@ function regex_contest_name(str)
return true;
}
}
// 公开作品弹框
function alert_open_contestant_works(url, is_open){
if(is_open){
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">取消公开作品</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">本次题目的全部作品将不对未加入本竞赛的用户开放<br/>是否确定取消公开作品</p><div class="cl"></div>'+
'<a href="'+ url + '" class="fr sy_btn_blue mt10" style="margin-right: 142px;" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
}else{
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">公开作品</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">本次题目的全部作品将对Trustie平台所有注册用户开放<br/>是否确定公开作品</p><div class="cl"></div>'+
'<a href="'+ url + '" class="fr sy_btn_blue mt10" style="margin-right: 142px;" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
}
pop_box_new(htmlvalue, 400, 160);
}
//提交匿评参数设置
function submit_set_score_rule(end_time){
if($("#online_evaluation").is(":checked")){
if(!regex_evaluation_start(end_time)){
$("#evaluation_start_time").focus();
}
else if(!regex_evaluation_end()){
$("#evaluation_end_time").focus();
}
else if($("#limit").is(":checked")){
if(!regex_evaluation_num()){
$("#evaluation_num").focus();
}
else{
$('#muban_popup_box form').submit();
hideModal();
}
}
else{
$('#muban_popup_box form').submit();
hideModal();
}
}
else{
$('#muban_popup_box form').submit();
hideModal();
}
}
//验证匿评开启时间:大于截止时间,或者为空
function regex_evaluation_start(end_time){
var evaluation_start = $.trim($("#evaluation_start_time").val());
if(evaluation_start == ""){
$("#homework_evaluation_start_time").text("开启匿评日期不能为空");
return false;
}
var end_time = new Date(end_time);
var evaluation_start_time = new Date(evaluation_start);
if(evaluation_start_time > end_time){
$("#homework_evaluation_start_time").text("");
return true;
}else{
$("#homework_evaluation_start_time").text("开启匿评日期必须大于截止日期");
return false;
}
}
//验证匿评结束时间:大于匿评开启时间,或者为空。当匿评开启时间为空时,匿评结束时间必须为空
function regex_evaluation_end(){
var evaluation_start = $.trim($("#evaluation_start_time").val());
var evaluation_end = $.trim($("#evaluation_end_time").val());
if(evaluation_end == ""){
$("#homework_evaluation_end_time").text("关闭匿评日期不能为空");
return true;
}
var evaluation_start_time = new Date(evaluation_start);
var evaluation_end_time = new Date(evaluation_end);
if(evaluation_end_time >= evaluation_start_time){
$("#homework_evaluation_end_time").text("");
return true;
}else{
$("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期");
return false;
}
}
//验证匿评数量
function regex_evaluation_num(){
var evaluation_num = $.trim($("#evaluation_num").val());
var regex = /^\d+$/;
if(evaluation_num==""){
$("#evaluation_num_notice").text("匿评人数不能为空");
return false;
}
else if(regex.test(evaluation_num)){
if($("#score_valid").is(":checked")){
if(evaluation_num <= 2){
$("#evaluation_num_notice").html("最高分和最低分无效时作品评审人数必须大于2");
return true;
}else{
$("#evaluation_num_notice").html("");
return true;
}
}else{
if(evaluation_num > 0){
$("#evaluation_num_notice").html("");
return true;
}
else{
$("#evaluation_num_notice").text("匿评人数必须为大于0");
return false;
}
}
}
else{
$("#evaluation_num_notice").text("匿评人数只能为正整数");
return false;
}
}

View File

@ -78,6 +78,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.font999{ color:#999;}
.fontRed{color:#770000;}
.text_c{ text-align:center;}
.text_l{ text-align:left;}
/* Float & Clear */
.clear{ zoom:1;}
@ -121,8 +122,10 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.ml35{margin-left: 35px;}
.ml36{ margin-left:36px; }
.ml38{ margin-left:38px;}
.ml39{ margin-left:39px;}
.ml40{ margin-left:40px;}
.ml41{ margin-left:41px;}
.ml42{ margin-left:42px;}
.ml45{ margin-left:45px;}
.ml48{ margin-left:48px;}
.ml50{ margin-left: 50px;}
@ -224,6 +227,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.mb12 {margin-bottom:12px !important;}
.mb15{margin-bottom: 15px;}
.mb20{ margin-bottom:20px;}
.mb25{ margin-bottom:25px;}
.mb30 {margin-bottom:30px;}
.mb40 {margin-bottom:40px;}
.pl5{ padding-left:5px;}
@ -872,4 +876,4 @@ input.btn{display: inline-block;border:none; padding:0 10px;color: #333;backgrou
input.btn-blue{background: #3b94d6; color: #fff; cursor:pointer;}
input:hover.btn-blue{background: #2788d0; color: #fff;}
input.btn-grey{background: #d9d9d9; color: #656565; cursor:default;}
input.btn-grey:hover{background: #717171; color: #fff; cursor:default;}
input.btn-grey:hover{background: #717171; color: #fff; cursor:default;}

View File

@ -8,7 +8,7 @@ a:hover.muban_icons_close{background: url(/images/sy/sy_icons_close.png) -40px 0
#muban_popup_box label.pop_box_label{width: 100px; text-align: right; display: inline-block;}
input.radio-width90{ width: 90px; }
#muban_popup_box input,#muban_popup_box select{ border:1px solid #c8c8c8; height: 28px; color: #888;}
#muban_popup_box label.pop_box_label {width: 100px; text-align: right; display: inline-block;}
#muban_popup_box label.pop_box_label_l {width: 100px; text-align: left; display: inline-block;}
/*模板表格 20161013byLB*/
.muban_table{ width:100%; background:#fff; border:1px solid #e5e5e5; border-bottom: none; }
.muban_table thead tr{ height:40px; line-height:40px;}

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :contestant_work_evaluation_distribution do
user nil
contestant_work nil
end
end

View File

@ -0,0 +1,9 @@
FactoryGirl.define do
factory :work_detail_manual do
evaluation_start "2016-12-28 17:17:49"
evaluation_end "2016-12-28 17:17:49"
evaluation_num 1
work nil
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ContestantWorkEvaluationDistribution, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe WorkDetailManual, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end