diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 5146282ac..5fd42a97e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -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| diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 12aa5860f..4b7fdb15e 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -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 diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb index de4c16960..448e4144a 100644 --- a/app/views/bids/_homework_form.html.erb +++ b/app/views/bids/_homework_form.html.erb @@ -32,7 +32,7 @@ <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %>

- <%= 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')%> @@ -43,6 +43,10 @@

<%= f.select :proportion, proportion_option %>

+

+ <%= f.text_field :evaluation_num, :required => true, :size => 60, :style => "width:150px;", :onblur => "regexEvaluationNum();" , :maxlength => 4%> + 匿评分配数量不宜太大,否则会影响开启匿评速度 +

<%= hidden_field_tag 'course_id', @course.id %>

diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index fd21872b0..322b8cdc3 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -1,7 +1,7 @@