diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index a1ea891a5..98ebc0705 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -103,13 +103,18 @@ class StudentWorkController < ApplicationController #添加评分的回复 def add_score_reply - respond_to do |format| - format.js + @score = StudentWorksScore.find params[:id] + @jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0) + if @jour.save + respond_to do |format| + format.js + end end end #删除评分的回复 def destroy_score_reply + respond_to do |format| format.js end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 239a15881..b15c9b2d1 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -29,6 +29,7 @@ class JournalsForMessage < ActiveRecord::Base belongs_to :jour, :polymorphic => true belongs_to :user belongs_to :homework_attach + belongs_to :student_works_score belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id' acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)}"}, diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index e44cef6ac..8fa14f8de 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -4,7 +4,7 @@ class StudentWorksScore < ActiveRecord::Base belongs_to :user belongs_to :student_work - has_many :journals_for_messages, :dependent => :destroy + has_many :journals_for_messages, :as => :jour, :dependent => :destroy acts_as_attachable end diff --git a/app/views/student_work/_add_score_reply.html.erb b/app/views/student_work/_add_score_reply.html.erb new file mode 100644 index 000000000..99e9c3793 --- /dev/null +++ b/app/views/student_work/_add_score_reply.html.erb @@ -0,0 +1,4 @@ +<%= form_for('', :remote => true, :method => :post,:url => add_score_reply_student_work_path(score.id)) do |f|%> + <%= f.text_area 'message', :class => 'ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %> + 回复 +<% end%> \ No newline at end of file diff --git a/app/views/student_work/_jour_replay.html.erb b/app/views/student_work/_jour_replay.html.erb new file mode 100644 index 000000000..d673fb8b0 --- /dev/null +++ b/app/views/student_work/_jour_replay.html.erb @@ -0,0 +1,20 @@ +
+ <%= link_to image_tag(url_to_avatar(jour.user), :width => "32", :height => "32"), user_path(jour.user),:class => "st_img fl" %> +
+ + <%= link_to jour.user.show_name, user_path(jour.user), :title => jour.user.show_name, :class => "c_blue fl" %> + + <% if jour.user==User.current || User.current.admin? %> + <%= link_to(l(:label_bid_respond_delete), destroy_score_reply_student_work_index_path(:jour_id => jour.id), + :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr c_purple") %> + <% end %> + + <%=format_time jour.created_on %> + +
+

+ <%= jour.notes%> +

+
+
+
\ 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 50d988403..205b3106f 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -56,32 +56,17 @@ <%= score.comment%>

- <%form_for "", add_score_reply_student_work_path(@work)%> - - 回复 +
+
+ <%= render :partial => 'add_score_reply',:locals => {:score => score}%> +
+
- <% 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" %> -
- - <%= link_to jour.user.show_name, user_path(jour.user), :title => jour.user.show_name, :class => "c_blue fl" %> - - <% if jour.user==User.current || User.current.admin? %> - <%= link_to(l(:label_bid_respond_delete), destroy_score_reply_student_work_index_path(:jour_id => jour.id), - :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr c_purple") %> - <% end %> - - <%=jour score.created_at %> - -
-

- <%= jour.comment%> -

-
-
-
- <% end%> +
+ <% score.journals_for_messages.order("created_on desc").each do |jour|%> + <%= render :partial => 'jour_replay',:locals => {:jour => jour}%> + <% end%> +
diff --git a/app/views/student_work/add_score_reply.js.erb b/app/views/student_work/add_score_reply.js.erb new file mode 100644 index 000000000..7b53b54d8 --- /dev/null +++ b/app/views/student_work/add_score_reply.js.erb @@ -0,0 +1,2 @@ +$("#add_score_reply_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'add_score_reply', :locals => {:score => @score}) %>"); +$("#replay_histroy_<%= @score.id%>").prepend("<%= escape_javascript(render :partial => 'jour_replay', :locals => {:jour => @jour}) %>"); \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index b503fd88d..a4c19e0e4 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -653,7 +653,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;} .ping_box_tit{ float:left; width:575px; margin-left:10px;} .ping_box_ul{} .ping_line{ border-bottom:1px dashed #CCCCCC; padding-bottom:8px; margin-bottom:8px;} -.ping_text{border:1px solid #CCCCCC; margin:5px; padding:5px; width:560px; height:20px; } +.ping_text{border:1px solid #CCCCCC; margin:5px; padding:5px; width:560px; height:50px; } .ping_back_tit{ float:left; width:523px; margin-left:10px; } a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;} a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;}