修改匿评个数可配置、以及增加其相关js验证

This commit is contained in:
sw 2014-11-05 10:06:20 +08:00
parent eb551788ac
commit 54a9044679
8 changed files with 74 additions and 26 deletions

View File

@ -806,6 +806,7 @@ class BidsController < ApplicationController
@bid.description = params[:bid][:description]
@bid.is_evaluation = params[:bid][:is_evaluation]
@bid.proportion = params[:bid][:proportion]
@bid.evaluation_num = params[:bid][:evaluation_num]
@bid.reward_type = 3
# @bid.budget = params[:bid][:budget]
@bid.deadline = params[:bid][:deadline]
@ -861,6 +862,7 @@ class BidsController < ApplicationController
@bid.description = params[:bid][:description]
@bid.is_evaluation = params[:bid][:is_evaluation]
@bid.proportion = params[:bid][:proportion]
@bid.evaluation_num = params[:bid][:evaluation_num]
@bid.reward_type = 3
@bid.deadline = params[:bid][:deadline]
@bid.budget = 0
@ -1009,7 +1011,7 @@ class BidsController < ApplicationController
if(homeworks && homeworks.size >= 2)
homeworks.each_with_index do |homework, index|
user = homework.user
n = 3 # TODO: this value should get from params, (老师设置)
n = @bid.evaluation_num
n = n < homeworks.size ? n : homeworks.size - 1
assigned_homeworks = get_assigned_homeworks(homeworks, n, index)
assigned_homeworks.each do |h|

View File

@ -32,7 +32,7 @@
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %>
</p>
<p>
<%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:150px;", :readonly => true, :onchange => "regexDeadLine();") %>
<%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:100px;", :readonly => true, :onchange => "regexDeadLine();") %>
<%= calendar_for('bid_deadline')%>
<span id="bid_deadline_span">
</span>
@ -43,6 +43,10 @@
<p>
<%= f.select :proportion, proportion_option %>
</p>
<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>
<p>
<%= hidden_field_tag 'course_id', @course.id %>
</p>

View File

@ -1,7 +1,7 @@
<script type="text/javascript">
function regexName()
{
var name = $("#bid_name").val();
var name = $.trim($("#bid_name").val());
if(name=="")
{
@ -18,7 +18,7 @@
}
function regexDeadLine()
{
var deadline = $("#bid_deadline").val();
var deadline = $.trim($("#bid_deadline").val());
var regex = /^\d{4}-\d{2}-\d{2}$/;
if(deadline=="")
{
@ -39,10 +39,33 @@
return false;
}
}
function regexEvaluationNum()
{
var evaluation_num = $.trim($("#bid_evaluation_num").val());
var regex = /^\d+$/;
if(evaluation_num=="")
{
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
else if(regex.test(evaluation_num))
{
$("#bid_evaluation_num_span").text("填写正确");
$("#bid_evaluation_num_span").css('color','#008000');
return true;
}
else
{
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
}
function submitHomework(id)
{
if(regexDeadLine()&&regexName())
if(regexDeadLine()&&regexName()&&regexEvaluationNum())
{
$("#edit_bid_" + id).submit();
}

View File

@ -37,7 +37,7 @@
</p>
<% time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') %>
<p>
<%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:150px;",:value => "#{time}", :onchange => "regexDeadLine();", :readonly => true) %>
<%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:100px;",:value => "#{time}", :onchange => "regexDeadLine();", :readonly => true) %>
<%= calendar_for('bid_deadline')%>
<span id="bid_deadline_span">
</span>
@ -48,6 +48,10 @@
<p>
<%= f.select :proportion, proportion_option %>
</p>
<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>
<p>
<%= hidden_field_tag 'course_id', @course.id %>
</p>

View File

@ -1,7 +1,7 @@
<script type="text/javascript">
function regexName()
{
var name = $("#bid_name").val();
var name = $.trim($("#bid_name").val());
if(name=="")
{
@ -18,7 +18,7 @@
}
function regexDeadLine()
{
var deadline = $("#bid_deadline").val();
var deadline = $.trim($("#bid_deadline").val());
var regex = /^\d{4}-\d{2}-\d{2}$/;
if(deadline=="")
{
@ -39,10 +39,33 @@
return false;
}
}
function regexEvaluationNum()
{
var evaluation_num = $.trim($("#bid_evaluation_num").val());
var regex = /^\d+$/;
if(evaluation_num=="")
{
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
else if(regex.test(evaluation_num))
{
$("#bid_evaluation_num_span").text("填写正确");
$("#bid_evaluation_num_span").css('color','#008000');
return true;
}
else
{
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
}
function submitHomework()
{
if(regexDeadLine()&&regexName())
if(regexDeadLine()&&regexName()&&regexEvaluationNum())
{
$("#new_bid").submit();
}

View File

@ -2183,4 +2183,5 @@ zh:
label_teacher_comments: 教师评论
label_anonymous_comments: 匿评
label_anonymous: 匿名
label_submit_comments: 提交评论
label_submit_comments: 提交评论
field_evaluation_num: 匿评分配数量

View File

@ -0,0 +1,5 @@
class AddEvaluationNumToBid < ActiveRecord::Migration
def change
add_column :bids, :evaluation_num, :integer, default: 3
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 => 20141102054414) do
ActiveRecord::Schema.define(:version => 20141105012624) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -109,6 +109,7 @@ ActiveRecord::Schema.define(:version => 20141102054414) do
t.integer "is_evaluation"
t.integer "proportion", :default => 60
t.integer "comment_status", :default => 0
t.integer "evaluation_num", :default => 3
end
create_table "boards", :force => true do |t|
@ -178,13 +179,6 @@ ActiveRecord::Schema.define(:version => 20141102054414) do
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
create_table "class_members", :force => true do |t|
t.integer "member_id"
t.integer "course_class_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "code_review_assignments", :force => true do |t|
t.integer "issue_id"
t.integer "change_id"
@ -317,14 +311,6 @@ ActiveRecord::Schema.define(:version => 20141102054414) do
t.integer "container_id", :default => 0
end
create_table "course_classes", :force => true do |t|
t.string "name"
t.text "explain"
t.integer "course_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "course_infos", :force => true do |t|
t.integer "course_id"
t.integer "user_id"