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