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 %>

<%= l(:label_attachment_plural) %>

<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>

\ 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 %>

<%= l(:label_attachment_plural) %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index fd4b0a93e..5e041065d 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,6 +1,8 @@ <% is_student = is_cur_course_student? @bid.courses.first %> <% is_teacher = is_course_teacher User.current,@bid.courses.first %> + +<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> <%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
@@ -53,11 +55,21 @@ <% else %> <% homework_filename = homework.name %> <% end %> - <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%> + + <% if is_evaluation || is_teacher%> + <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%> + <% else %> + <%= homework_filename %> + <% end %> + <% if is_student %> - <%= link_to "互评>>" , homework_attach_path(homework)%> + <% if is_evaluation %> + <%= link_to "互评>>" , homework_attach_path(homework)%> + <% else %> + <%= link_to "查看详细" , homework_attach_path(homework)%> + <% end %> <% else %> <% if is_teacher %> <%= link_to "综评>>" , homework_attach_path(homework)%> diff --git a/app/views/homework_attach/_comprehensive_evaluation.html.erb b/app/views/homework_attach/_comprehensive_evaluation.html.erb index e6ebacffe..08db30542 100644 --- a/app/views/homework_attach/_comprehensive_evaluation.html.erb +++ b/app/views/homework_attach/_comprehensive_evaluation.html.erb @@ -22,12 +22,6 @@
<%= comprehensive_evaluation.first.notes%>
- <% if is_teacher %> -
评分: - <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
- <% end %>
<% else %> <% if is_teacher %> @@ -35,10 +29,7 @@
作业综评:
-
评分: - <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
+ <%= render :partial => 'evaluation', :locals => {:homework => homework} %>
<%= render :partial => 'addjour', :locals => {:homework_attach => homework, :sta => 0,:is_comprehensive_evaluation => 1} %>
diff --git a/app/views/homework_attach/_evaluation.html.erb b/app/views/homework_attach/_evaluation.html.erb new file mode 100644 index 000000000..bd8677fb1 --- /dev/null +++ b/app/views/homework_attach/_evaluation.html.erb @@ -0,0 +1,4 @@ +
评分: + <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> + (每个用户对每份作业只能进行一次评价!) +
\ No newline at end of file diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 2b2ec5cce..cdbbe9fda 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -8,7 +8,6 @@ <% is_student = is_cur_course_student? @homework.bid.courses.first %> <% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %> -

<%= notice %>

@@ -29,8 +28,12 @@ 作业下载: - <% options = {:author => true } %> - <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <% if @is_evaluation || is_teacher%> + <% options = {:author => true } %> + <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <% else %> + <%= l(:label_cant_download) %> + <% end %> 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%> @@ -133,10 +136,19 @@
作业评论:
<% if is_student %> -
评分: - <%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
+ <% if @is_evaluation %> + <% if @has_evaluation %> +
+ <%= l(:lable_has_evaluation)%> +
+ <% else %> + <%= render :partial => 'evaluation', :locals => {:homework => @homework} %> + <% end %> + <% else %> +
+ <%= l(:lable_close_evaluation)%> +
+ <% end %> <% end %>
diff --git a/app/views/projects/_homework_form.html.erb b/app/views/projects/_homework_form.html.erb index 13255120f..596d83071 100644 --- a/app/views/projects/_homework_form.html.erb +++ b/app/views/projects/_homework_form.html.erb @@ -32,10 +32,8 @@

-->

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>

-

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

<%= l(:label_attachment_plural) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index de390a8f8..aecf2f19a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1546,6 +1546,7 @@ zh: label_bids_credit_number: 分 field_budget: 奖励 field_deadline: 截止日期 + field_is_evaluation: 是否启动互评 label_tags_selected: 已选标签 label_tags_related: 相关标签 button_project_tags_add: 增加 @@ -1600,6 +1601,9 @@ zh: label_have_feedback: 有了 label_of_feedback: 的 label_welcome_participate: 参与了 + label_cant_download: 未开启互评功能作业不允许下载 + lable_close_evaluation: 该作业未开启互评功能 + lable_has_evaluation: 您已进行过评价 #modify by men label_x_welcome_participate: zero: 参与了 @@ -1789,6 +1793,8 @@ zh: label_new_join_order: 请输入课程密码 label_task_submit_form_accessory: 作业最终以附件形式提交 label_task_submit_form_project: 作业最终以项目形式提交 + lable_start_mutual_evaluation: 启动互评 + lable_close_mutual_evaluation: 关闭互评 label_has_been: 已经被 label_course_userd_by: 个课程引用 diff --git a/db/migrate/20140605025247_add_evaluation_to_bid.rb b/db/migrate/20140605025247_add_evaluation_to_bid.rb new file mode 100644 index 000000000..f940974b4 --- /dev/null +++ b/db/migrate/20140605025247_add_evaluation_to_bid.rb @@ -0,0 +1,5 @@ +class AddEvaluationToBid < ActiveRecord::Migration + def change + add_column :bids, :is_evaluation, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 721945ed4..185f5e134 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140527060344) do +ActiveRecord::Schema.define(:version => 20140605025247) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -105,6 +105,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do t.integer "homework_type" t.integer "parent_id" t.string "password" + t.integer "is_evaluation" end create_table "boards", :force => true do |t|