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 @@
-
+
<%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%>
-<% unless @work.student_works_scores.empty?%> -
+
<%@work.student_works_scores.each do |score|%> -
    - <%= link_to image_tag(url_to_avatar(score.user), :width => "34", :height => "34"), user_path(score.user),:class => "ping_pic fl" %> -
    - <%= link_to score.user.show_name, user_path(score.user), :title => score.user.show_name, :class => "c_blue fl" %> - (<%= student_work_score_role score%>) - 评分: - <%= score.score%>分 - 回复 - - <%=format_time score.created_at %> - -
    -

    - <%= score.comment%> -

    -
    - <%= render :partial => 'work_attachments', :locals => {:attachments => score.attachments} %> -
    -
    - <%= render :partial => 'add_score_reply',:locals => {:score => score}%> -
    -
    - -
    - <% score.journals_for_messages.order("created_on desc").each do |jour|%> - <%= render :partial => 'jour_replay',:locals => {:jour => jour}%> - <% end%> -
    -
    -
    -
+
+ <%= render :partial => 'student_work_score',:locals => {:score => score}%> +
<% end%>
-<%end%> 收起
\ No newline at end of file diff --git a/app/views/student_work/_student_work_score.html.erb b/app/views/student_work/_student_work_score.html.erb new file mode 100644 index 000000000..c1536df98 --- /dev/null +++ b/app/views/student_work/_student_work_score.html.erb @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index fa58c3739..22f31a6c3 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -1,3 +1,8 @@ -$("#add_student_score").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work}) %>"); +$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @score}) %>"); $('#score_<%= @work.id%>').peSlider({range: 'min'}); -alert("评分成功"); \ No newline at end of file + +<% if @is_new%> + $("#score_list_<%= @work.id%>").prepend("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); +<% else %> + $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); +<% end%>