From d80ade96c847e12a39f4df408b1a81f5bad14533 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 27 May 2015 16:01:00 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E8=AF=84=E5=88=86?= =?UTF-8?q?=E5=90=8E=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=202=E3=80=81?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=8F=AA=E5=A1=AB=E5=86=99=E4=BA=86=E8=AF=84?= =?UTF-8?q?=E5=88=86=E5=B0=B1=E5=8F=AA=E6=9B=B4=E6=96=B0=E8=AF=84=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=AF=B9=E8=AF=84=E8=AE=BA=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=203=E3=80=81=E5=A6=82=E6=9E=9C=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E8=AF=84=E5=88=86=E8=BF=87=EF=BC=8C=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E8=AF=84=E5=88=86=E4=B8=BA=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9C=AA=E8=BF=9B=E8=A1=8C=E8=BF=87=E8=AF=84=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E5=B0=B1=E6=98=AF=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 32 +++++++-------- app/views/student_work/_show.html.erb | 40 +++---------------- .../student_work/_student_work_score.html.erb | 31 ++++++++++++++ app/views/student_work/add_score.js.erb | 9 ++++- 4 files changed, 58 insertions(+), 54 deletions(-) create mode 100644 app/views/student_work/_student_work_score.html.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 63ab4d0f0..d5bbd6586 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -74,27 +74,25 @@ class StudentWorkController < ApplicationController #添加评分,已评分则为修改评分 def add_score - score = student_work_score @work,User.current - if score - if params[:new_form] && params[:new_form][:user_message] - score.score = params[:score] - score.comment = params[:new_form][:user_message] - end + @score = student_work_score @work,User.current + if @score + @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + @score.score = params[:score] if params[:score] + @is_new = false else - if params[:new_form] && params[:new_form][:user_message] - score = StudentWorksScore.new - score.score = params[:score] - score.comment = params[:new_form][:user_message] - score.user_id = User.current.id - score.student_work_id = @work.id - score.reviewer_role = 1 - end + @score = StudentWorksScore.new + @score.score = params[:score] if params[:score] + @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + @score.user_id = User.current.id + @score.student_work_id = @work.id + @score.reviewer_role = 1 + @is_new = true end - score.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(score) + @score.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@score) - if score.save + if @score.save respond_to do |format| format.js end diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index f7a01f309..fae1c1e89 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -32,48 +32,18 @@
-- <%= score.comment%> -
- - <%= render :partial => 'work_attachments', :locals => {:attachments => score.attachments} %> - -+ <%= score.comment%> +
+ + <%= render :partial => 'work_attachments', :locals => {:attachments => score.attachments} %> + +