From a006e2e46256d6aaf53074dc0dc9c7c0f20d65f1 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 26 May 2015 18:14:53 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AE=9E=E7=8E=B0=E6=89=93=E5=88=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=202=E3=80=81=E6=89=93=E5=88=86=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=203=E3=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9A=E7=94=A8=E6=88=B7=E5=AF=B9?= =?UTF-8?q?=E6=9F=90=E4=B8=80=E4=BD=9C=E4=B8=9A=E7=9A=84=E8=AF=84=E5=88=86?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 26 +++++++++++++++++-- app/helpers/student_work_helper.rb | 6 +++++ app/views/student_work/_add_score.html.erb | 20 ++++++++++++++ app/views/student_work/_show.html.erb | 23 +++------------- .../_student_work_attachment_form.html.erb | 12 ++++----- app/views/student_work/add_score.js.erb | 2 ++ 6 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 app/views/student_work/_add_score.html.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d3a4be17d..5e09c5460 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1,5 +1,6 @@ class StudentWorkController < ApplicationController layout "base_courses" + include StudentWorkHelper before_filter :find_homework, :only => [:new, :index, :create] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score] @@ -72,9 +73,30 @@ 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 + 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 + end - respond_to do |format| - format.js + score.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(score) + + if score.save + respond_to do |format| + format.js + end end end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index 467cbcdce..e4a9bceba 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module StudentWorkHelper def user_projects_option cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" @@ -18,4 +19,9 @@ module StudentWorkHelper end type end + + #获取指定用户对某一作业的评分结果 + def student_work_score work,user + StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first + end end \ No newline at end of file diff --git a/app/views/student_work/_add_score.html.erb b/app/views/student_work/_add_score.html.erb new file mode 100644 index 000000000..66aeee68c --- /dev/null +++ b/app/views/student_work/_add_score.html.erb @@ -0,0 +1,20 @@ +<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id)) do |f|%> +
  • + 评价: + <%= f.text_area 'user_message', :class => 'hwork_ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %> +
    +
  • +
  • + 评分: + + +
  • +
  • + 批阅结果: +
    + <%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work} %> +
    + 提交 +
    +
  • +<% end%> \ No newline at end of file diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index b2eabc536..ea9f9a420 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -32,26 +32,9 @@
    - <%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id)) do |f|%> -
  • - 评价: - <%= f.text_area 'user_message', :class => 'hwork_ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %> -
    -
  • -
  • - 评分: - - -
  • -
  • - 批阅结果: -
    - <%= render :partial => 'student_work/student_work_attachment_form', :locals => {:id => work.id} %> -
    - 提交 -
    -
  • - <% end%> +
    + <%= render :partial => 'add_score',:locals => {:work => work}%> +
    diff --git a/app/views/student_work/_student_work_attachment_form.html.erb b/app/views/student_work/_student_work_attachment_form.html.erb index f56d70f36..00028f481 100644 --- a/app/views/student_work/_student_work_attachment_form.html.erb +++ b/app/views/student_work/_student_work_attachment_form.html.erb @@ -1,13 +1,13 @@
    - +
    - <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> <%= file_field_tag 'attachments[dummy][file]', - :id => "_file#{id}", + :id => "_file#{work.id}", :class => 'file_selector', :multiple => true, - :onchange => "addInputFiles_board(this, '#{id}');", + :onchange => "addInputFiles_board(this, '#{work.id}');", :style => 'display:none', :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, @@ -19,9 +19,9 @@ :are_you_sure => l(:text_are_you_sure), :file_count => l(:label_file_count), :delete_all_files => l(:text_are_you_sure_all), - :containerid => "#{id}" + :containerid => "#{work.id}" } %> - + <%= l(:label_no_file_uploaded) %> (<%= l(:label_max_size) %>: diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index 6f0d25876..fa58c3739 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -1 +1,3 @@ +$("#add_student_score").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work}) %>"); +$('#score_<%= @work.id%>').peSlider({range: 'min'}); alert("评分成功"); \ No newline at end of file