Merge branch 'Homework' of http://repository.trustie.net/xianbo/trustie2 into Homework

This commit is contained in:
z9hang 2014-11-05 10:41:50 +08:00
commit b462d4e00a
11 changed files with 98 additions and 32 deletions

View File

@ -511,7 +511,7 @@ class BidsController < ApplicationController
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score,
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
@ -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
@ -1006,10 +1008,10 @@ class BidsController < ApplicationController
@bid = Bid.find(params[:id])
if(@bid.comment_status == 0)
homeworks = @bid.homeworks
if(homeworks && homeworks.size > 2)
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

@ -103,7 +103,7 @@ class HomeworkAttachController < ApplicationController
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score,
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1

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,42 @@
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))
{
if(evaluation_num > 0)
{
$("#bid_evaluation_num_span").text("填写正确");
$("#bid_evaluation_num_span").css('color','#008000');
return true;
}
else
{
$("#bid_evaluation_num_span").text("匿评分配数量必须为大于0");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
}
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

@ -3,7 +3,7 @@
$("#<%= @bid.id %>_start_anonymous_comment").remove();
$("#<%= @bid.id %>_anonymous_comment").append('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true %>');
<% elsif @statue == 2 %>
alert('启动失败\n作业总数大于4份时才能启动匿评');
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
<% elsif @statue == 3%>
alert("已开启匿评,请务重复开启");
<% end %>

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

@ -7,7 +7,7 @@
<% linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) %>
<% desc = course_endTime_timeout?(course) ? '重启' : '关闭' %>
<%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %>
<%= link_to "#{desc}", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %>
<% else %>
<!-- 关闭课程block -->
<% end %>

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,42 @@
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))
{
if(evaluation_num > 0)
{
$("#bid_evaluation_num_span").text("填写正确");
$("#bid_evaluation_num_span").css('color','#008000');
return true;
}
else
{
$("#bid_evaluation_num_span").text("匿评分配数量必须为大于0");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
}
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

@ -463,7 +463,7 @@ zh:
permission_view_courses: 查看课程
permission_new_course: 新建课程
permission_configure_course: 配置课程
permission_close_course: 关闭/重开课程
permission_close_course: 关闭/重开
permission_new_assignment: 新建任务
permission_edit_assignment: 编辑任务
permission_delete_assignment: 删除任务
@ -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"