From a0324f5e396ec2d0865b870f82eeee660f24a5a3 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 27 May 2015 11:25:32 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=84=E5=88=86=E5=9B=9E?=
=?UTF-8?q?=E5=A4=8D=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=20=E8=AF=84=E5=88=86=E5=9B=9E=E5=A4=8D=E7=9C=9F?=
=?UTF-8?q?=E5=AE=9E=E4=BF=A1=E6=81=AF=E6=98=BE=E7=A4=BA=20=E8=AF=84?=
=?UTF-8?q?=E5=88=86=E5=9B=9E=E5=A4=8D=E4=BB=A5=E5=8F=8A=E5=9B=9E=E5=A4=8D?=
=?UTF-8?q?=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 11 ++-
app/helpers/student_work_helper.rb | 12 +++
app/models/student_works_score.rb | 2 +
app/views/student_work/_add_score.html.erb | 2 +-
app/views/student_work/_show.html.erb | 92 +++++++++++--------
.../_student_work_attachment_form.html.erb | 22 -----
app/views/student_work/show.js.erb | 2 +-
config/routes.rb | 3 +-
8 files changed, 82 insertions(+), 64 deletions(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 7e3bab1d6..a1ea891a5 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -72,7 +72,7 @@ class StudentWorkController < ApplicationController
end
- #评分
+ #添加评分,已评分则为修改评分
def add_score
score = student_work_score @work,User.current
if score
@@ -101,13 +101,20 @@ class StudentWorkController < ApplicationController
end
end
- #评分的回复
+ #添加评分的回复
def add_score_reply
respond_to do |format|
format.js
end
end
+ #删除评分的回复
+ def destroy_score_reply
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
#获取作业
def find_homework
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index e4a9bceba..20a85f19e 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -24,4 +24,16 @@ module StudentWorkHelper
def student_work_score work,user
StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first
end
+
+ #获取指定评分的角色
+ def student_work_score_role score
+ case score.reviewer_role
+ when 1
+ role = "教师"
+ when 2
+ role = "教辅"
+ when 3
+ role = "学生"
+ end
+ end
end
\ No newline at end of file
diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb
index a4592dd3e..e44cef6ac 100644
--- a/app/models/student_works_score.rb
+++ b/app/models/student_works_score.rb
@@ -1,8 +1,10 @@
class StudentWorksScore < ActiveRecord::Base
+ #reviewer_role: 1:教师评分;2:教辅评分;3:学生匿评
attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role
belongs_to :user
belongs_to :student_work
+ has_many :journals_for_messages, :dependent => :destroy
acts_as_attachable
end
diff --git a/app/views/student_work/_add_score.html.erb b/app/views/student_work/_add_score.html.erb
index 68f4185b4..a1406902f 100644
--- a/app/views/student_work/_add_score.html.erb
+++ b/app/views/student_work/_add_score.html.erb
@@ -6,7 +6,7 @@
评分:
-
+
分
diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb
index 5506a9951..50d988403 100644
--- a/app/views/student_work/_show.html.erb
+++ b/app/views/student_work/_show.html.erb
@@ -3,73 +3,91 @@
上交时间:
- <%=format_time work.created_at %>
+ <%=format_time @work.created_at %>
- <% if work.project%>
+ <% if @work.project%>
关联项目:
- <%= link_to( work.project.name, project_path(work.project.id), :class => "c_blue02" )%>
+ <%= link_to( @work.project.name, project_path(@work.project.id), :class => "c_blue02" )%>
<% end%>
内容:
- <%= work.description%>
+ <%= @work.description%>
附件:
- <% if work.attachments.empty?%>
+ <% if @work.attachments.empty?%>
尚未提交附件
<% else%>
- <%= render :partial => 'work_attachments', :locals => {:attachments => work.attachments} %>
+ <%= render :partial => 'work_attachments', :locals => {:attachments => @work.attachments} %>
<% end%>
- <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%>
+ <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%>
+<% unless @work.student_works_scores.empty?%>
-
-
-
-
-
-
jacknudt
-
(教辅)
-
评分:
-
85分
-
删除
-
回复
-
一小时前
-
-
作品非常好,格式不正确,继续努力!
-
-
回复
-
-
-
-
-
程梦雯
-
删除
-
一小时前
+ <%@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%>
+
+
+ <%form_for "", add_score_reply_student_work_path(@work)%>
+
+ 回复
+
+ <% score.journals_for_messages.each do |jour|%>
+
+ <%= link_to image_tag(url_to_avatar(jour.user), :width => "32", :height => "32"), user_path(jour.user),:class => "st_img fl" %>
+
+
+
+ <% end%>
+
-
-
-
-
+
+ <% end%>
-收起
+<%end%>
+收起
\ No newline at end of file
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 dd1793034..7802f6eb6 100644
--- a/app/views/student_work/_student_work_attachment_form.html.erb
+++ b/app/views/student_work/_student_work_attachment_form.html.erb
@@ -1,27 +1,5 @@
- <% if defined?(score) && score && score.saved_attachments %>
- <% score.attachments.each_with_index do |attachment, i| %>
-
- <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%>
- <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
- <%= l(:field_is_public)%>:
- <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
- <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
- <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
-
- <% end %>
- <% score.saved_attachments.each_with_index do |attachment, i| %>
-
- <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
- <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
- <%= l(:field_is_public)%>:
- <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
- <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
- <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
-
- <% end %>
- <% end %>
diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb
index f208aa52e..fa12e097d 100644
--- a/app/views/student_work/show.js.erb
+++ b/app/views/student_work/show.js.erb
@@ -2,6 +2,6 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0)
{$("#about_hwork_<%= @work.id%>").html("");}
else
{
- $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => @work,:score => @score}) %>");
+ $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>");
$('#score_<%= @work.id%>').peSlider({range: 'min'});
}
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index dba1e8340..0bb3f6bed 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -94,9 +94,10 @@ RedmineApp::Application.routes.draw do
resources :student_work do
member do
post 'add_score'
+ post 'add_score_reply'
end
collection do
-
+ delete 'destroy_score_reply'
end
end