数据库增加是否开启匿评字段

新建作业是增加是否开启匿评功能以及相关页面效果显示
修改相关js判断
This commit is contained in:
sw 2014-11-19 10:34:36 +08:00
parent 861dbc854e
commit 91cb6e29d5
9 changed files with 110 additions and 37 deletions

View File

@ -807,6 +807,7 @@ class BidsController < ApplicationController
@bid.is_evaluation = params[:bid][:is_evaluation]
@bid.proportion = params[:bid][:proportion]
@bid.evaluation_num = params[:bid][:evaluation_num]
@bid.open_anonymous_evaluation = params[:bid][:open_anonymous_evaluation]
@bid.reward_type = 3
# @bid.budget = params[:bid][:budget]
@bid.deadline = params[:bid][:deadline]
@ -863,6 +864,7 @@ class BidsController < ApplicationController
@bid.is_evaluation = params[:bid][:is_evaluation]
@bid.proportion = params[:bid][:proportion]
@bid.evaluation_num = params[:bid][:evaluation_num]
@bid.open_anonymous_evaluation = params[:bid][:open_anonymous_evaluation]
@bid.reward_type = 3
@bid.deadline = params[:bid][:deadline]
@bid.budget = 0

View File

@ -511,6 +511,7 @@ class CoursesController < ApplicationController
def new_homework
@homework = Bid.new
@homework.safe_attributes = params[:bid]
@homework.open_anonymous_evaluation = 1
if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] ))
render :layout => 'base_courses'
else

View File

@ -44,6 +44,10 @@
<%= f.select :proportion, proportion_option %>
</p>
<p>
<%= f.check_box :open_anonymous_evaluation, :style => "margin-left:10px;" %>
<span>未开启匿评作业将直接进入众评点赞阶段</span>
</p>
<p id="evaluation_num_p">
<%= f.text_field :evaluation_num, :required => true, :size => 60, :style => "width:150px;", :onblur => "regexEvaluationNum();" , :maxlength => 4%>
<span id="bid_evaluation_num_span">匿评分配数量不宜太大,否则会影响开启匿评速度</span>
</p>

View File

@ -43,6 +43,8 @@
{
var evaluation_num = $.trim($("#bid_evaluation_num").val());
var regex = /^\d+$/;
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
if(evaluation_num=="")
{
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
@ -71,6 +73,35 @@
return false;
}
}
else
{
return true;
}
}
$(function(){
$("#bid_open_anonymous_evaluation").click(function(){
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
$("#evaluation_num_p").slideDown();
}
else
{
$("#evaluation_num_p").slideUp();
}
});
});
$(function(){
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
$("#evaluation_num_p").show();
}
else
{
$("#evaluation_num_p").hide();
}
});
function submitHomework(id)
{

View File

@ -49,6 +49,10 @@
<%= f.select :proportion, proportion_option %>
</p>
<p>
<%= f.check_box :open_anonymous_evaluation, :style => "margin-left:10px;" %>
<span>未开启匿评作业将直接进入众评点赞阶段</span>
</p>
<p id="evaluation_num_p">
<%= f.text_field :evaluation_num, :required => true, :size => 60, :style => "width:150px;", :onblur => "regexEvaluationNum();" , :maxlength => 4%>
<span id="bid_evaluation_num_span">匿评分配数量不宜太大,否则会影响开启匿评速度</span>
</p>

View File

@ -43,6 +43,8 @@
{
var evaluation_num = $.trim($("#bid_evaluation_num").val());
var regex = /^\d+$/;
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
if(evaluation_num=="")
{
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
@ -71,6 +73,24 @@
return false;
}
}
else
{
return true;
}
}
$(function(){
$("#bid_open_anonymous_evaluation").click(function(){
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
$("#evaluation_num_p").slideDown();
}
else
{
$("#evaluation_num_p").slideUp();
}
});
});
function submitHomework()
{

View File

@ -2198,3 +2198,4 @@ zh:
label_submit_comments: 提交评论
field_evaluation_num: 匿评分配数量
label_my_score: 我的评分
field_open_anonymous_evaluation: 是否开启匿评

View File

@ -0,0 +1,9 @@
class AddOpenAnonymousEvaluation < ActiveRecord::Migration
def up
add_column :bids, :open_anonymous_evaluation, :integer, default: 1
end
def down
remove_column :bids, :open_anonymous_evaluation
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 => 20141105012624) do
ActiveRecord::Schema.define(:version => 20141119011439) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -110,6 +110,7 @@ ActiveRecord::Schema.define(:version => 20141105012624) do
t.integer "proportion", :default => 60
t.integer "comment_status", :default => 0
t.integer "evaluation_num", :default => 3
t.integer "open_anonymous_evaluation", :default => 1
end
create_table "boards", :force => true do |t|