From 81a97f6a5e98c39053f074a97aa020b2b47bd7c7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 5 Jun 2014 14:00:18 +0800 Subject: [PATCH] =?UTF-8?q?=201.=E8=80=81=E5=B8=88=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=90=AF=E7=94=A8=E4=BA=92=E8=AF=84=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E8=AF=A5=E5=8A=9F=E8=83=BD=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=82=E5=AF=B9=E4=B8=8D=E5=90=AF=E7=94=A8=E4=BA=92?= =?UTF-8?q?=E8=AF=84=E7=9A=84=E4=BD=9C=E4=B8=9A=EF=BC=8C=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E4=B8=8B=E8=BD=BD=E4=BD=9C=E4=B8=9A=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E4=BA=92=E7=9B=B8=E6=89=93=E5=88=86=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E5=8F=AF=E4=BB=A5=E7=95=99=E8=A8=80=EF=BC=9B=E8=80=81?= =?UTF-8?q?=E5=B8=88=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C=E8=AF=84=E5=88=86?= =?UTF-8?q?=E3=80=81=E4=B8=8B=E8=BD=BD=E4=BD=9C=E4=B8=9A=E7=AD=89=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E3=80=82=E5=90=AF=E7=94=A8=E4=BA=92=E8=AF=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=8A=9F=E8=83=BD=E5=92=8C=E7=8E=B0=E5=9C=A8=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=20=202.=E5=AF=B9=E5=90=AF=E7=94=A8=E4=BA=92=E8=AF=84?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A=EF=BC=8C=E6=AF=8F=E4=B8=AA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=AA=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=89=93=E5=88=86=EF=BC=8C=E6=89=93=E5=88=86=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 5 +++- app/controllers/homework_attach_controller.rb | 4 +++ app/helpers/courses_helper.rb | 6 +++++ app/helpers/projects_helper.rb | 13 ++++++++++ app/views/bids/_fork_form.html.erb | 1 + app/views/bids/_homework_form.html.erb | 1 + app/views/bids/_homework_list.html.erb | 16 ++++++++++-- .../_comprehensive_evaluation.html.erb | 11 +------- .../homework_attach/_evaluation.html.erb | 4 +++ app/views/homework_attach/show.html.erb | 26 ++++++++++++++----- app/views/projects/_homework_form.html.erb | 4 +-- config/locales/zh.yml | 6 +++++ .../20140605025247_add_evaluation_to_bid.rb | 5 ++++ db/schema.rb | 3 ++- 14 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 app/views/homework_attach/_evaluation.html.erb create mode 100644 db/migrate/20140605025247_add_evaluation_to_bid.rb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 5fb5d1853..97ebb4d49 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -176,7 +176,8 @@ class BidsController < ApplicationController @homework.budget = 0 @homework.author_id = User.current.id @homework.commit = 0 - @homework.homework_type = params[:bid][:homework_type] + @homework.homework_type = 1 + @homework.is_evaluation = params[:bid][:is_evaluation] @homework.parent_id = @bid.id @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) # @bid. @@ -408,6 +409,7 @@ class BidsController < ApplicationController if @bid.homework_type == 1 @homework = HomeworkAttach.new #@homework_list = @bid.homeworks + #增加作业按评分排序, @homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id) AS score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC") @@ -692,6 +694,7 @@ class BidsController < ApplicationController @bid = Bid.new @bid.name = params[:bid][:name] @bid.description = params[:bid][:description] + @bid.is_evaluation = params[:bid][:is_evaluation] @bid.reward_type = 3 # @bid.budget = params[:bid][:budget] @bid.deadline = params[:bid][:deadline] diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 64b34dfc1..1c3e8cabe 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -128,6 +128,10 @@ class HomeworkAttachController < ApplicationController @stars_status_map["star#{star_status.stars.to_i}".to_sym] = percent_m.to_s + "%" end + #是否已经进行过评价 + @has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0 + #是否开启互评功能 + @is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil @limit = 10 @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") @feedback_count = @jours.count diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 054b3b5a3..fb0a269e6 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -162,4 +162,10 @@ module CoursesHelper cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id) cur_user_homework end + + #判断当前用户对指定作业是否已经评价过 + def has_evaluation? homework + seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count + seem_count > 0 + end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index a42a626dc..085035a2c 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -227,6 +227,19 @@ module ProjectsHelper type << option2 end + #是否启动互评下拉框 + def is_evaluation_option + type = [] + option1 = [] + option2 = [] + option1 << l(:lable_start_mutual_evaluation) + option1 << 1 + option2 << l(:lable_close_mutual_evaluation) + option2 << 2 + type << option1 + type << option2 + end + # 用来判断用户是否是项目的管理员 # added by william def is_manager?(user_id,project_id) diff --git a/app/views/bids/_fork_form.html.erb b/app/views/bids/_fork_form.html.erb index 1bfb4550b..3fcf0f02e 100644 --- a/app/views/bids/_fork_form.html.erb +++ b/app/views/bids/_fork_form.html.erb @@ -19,6 +19,7 @@
<%= f.select :homework_type, homework_type_option %>
--> +<%= f.select :is_evaluation, is_evaluation_option %>
\ No newline at end of file diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb index f726c038f..92b162035 100644 --- a/app/views/bids/_homework_form.html.erb +++ b/app/views/bids/_homework_form.html.erb @@ -36,6 +36,7 @@<%= f.select :homework_type, homework_type_option %>
--> +<%= f.select :is_evaluation, is_evaluation_option %>
<%= hidden_field_tag 'course_id', @project_id %>