diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 2ad7d71c1..7166a7c94 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -1151,6 +1151,7 @@ class CoursesController < ApplicationController
page = params[:page]
# Find the page of the requested reply
@jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+ @jour_count = @jours.count
@limit = 10
if params[:r] && page.nil?
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 587d14c9c..38ec4270b 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -95,6 +95,14 @@ class WordsController < ApplicationController
@jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
@user_activity_id = params[:user_activity_id] if params[:user_activity_id]
@activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id]
+ unless @activity
+ if params[:user_activity_id] == params[:activity_id]
+ redirect_to course_feedback_path(@course)
+ else
+ redirect_to course_path(@course)
+ end
+ return
+ end
elsif @journal_destroyed.jour_type == "Principal"
@user = User.find(@journal_destroyed.jour_id)
@jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
@@ -282,7 +290,7 @@ class WordsController < ApplicationController
# add by nwb
def leave_course_message
user = User.current
- message = params[:new_form][:course_message]
+ message = params[:new_form][:content]
feedback = Course.add_new_jour(user, message, params[:id])
if(feedback.errors.empty?)
if params[:asset_id]
diff --git a/app/views/courses/_course_jours_list.html.erb b/app/views/courses/_course_jours_list.html.erb
new file mode 100644
index 000000000..94e464445
--- /dev/null
+++ b/app/views/courses/_course_jours_list.html.erb
@@ -0,0 +1,17 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
+<% end %>
+
+<%if jours %>
+ <% jours.each do |jour|%>
+
+ <%= render :partial => 'users/course_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id, :is_course => 1} %>
+ <%end%>
+<% end%>
+<% if (jours.count + page * 10) < count %>
+ <%= link_to "点击展开更多",course_feedback_path(@course.id, :page => page),:id => "show_more_jours",:remote => "true",:class => "loadMore mt10 f_grey"%>
+<% end %>
\ No newline at end of file
diff --git a/app/views/courses/feedback.html.erb b/app/views/courses/feedback.html.erb
index 3b2d3030c..1d71ff40f 100644
--- a/app/views/courses/feedback.html.erb
+++ b/app/views/courses/feedback.html.erb
@@ -1,15 +1,28 @@
-<% reply_allow = JournalsForMessage.create_by_user? User.current %>
-
-
+
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb
index 6604f344b..02ae4a80c 100644
--- a/app/views/users/_course_journalsformessage.html.erb
+++ b/app/views/users/_course_journalsformessage.html.erb
@@ -36,6 +36,20 @@
更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+ <% if defined?(is_course) && is_course == 1 && (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher, course))%>
+
+ <% end%>
diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb
index f53a21935..49a8dc966 100644
--- a/app/views/words/destroy.js.erb
+++ b/app/views/words/destroy.js.erb
@@ -28,12 +28,12 @@
<% else %>
$('#course_jour_count').html("<%= @jours_count %>");
<% end %>
- <% elsif @contest && @jours_count%>
- <% if @user_activity_id %>
- $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
- sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity");
- <% end %>
- <% elsif @user && @jours_count%>
+ <% elsif @contest && @jours_count%>
+ <% if @user_activity_id %>
+ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
+ sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity");
+ <% end %>
+ <% elsif @user && @jours_count%>
$('#jour_count').html("<%= @jours_count %>");
<% elsif @homework%>
$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @homework, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
diff --git a/config/routes.rb b/config/routes.rb
index c3a41703f..dd49df318 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1405,7 +1405,7 @@ RedmineApp::Application.routes.draw do
end # end of resources :courses
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'
match '/courses/search', :via => [:get, :post]
- match 'words/:id/leave_course_message', :to => 'words#leave_course_message'
+ match 'words/:id/leave_course_message', :to => 'words#leave_course_message', :as => "leave_course_message"
match 'workflows', :to => 'workflows#index', :via => :get
diff --git a/public/javascripts/contest.js b/public/javascripts/contest.js
index bc1fda130..414af8cc0 100644
--- a/public/javascripts/contest.js
+++ b/public/javascripts/contest.js
@@ -158,6 +158,7 @@ function jourReplyVerify() {
if (jour_content_editor.isEmpty()) {
$("#jour_content_span").text("留言不能为空");
$("#jour_content_span").css('color', '#ff0000');
+ $("#jour_content_span").show();
$("#submit_feedback_user").one('click',function() {
contest_jour_submit();
});
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index aeb92c6c9..e42821cc6 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -1606,3 +1606,35 @@ function submit_course_feedback() {
function show_more_tool(){
$('#navContentCourse').css('display', 'block');
}
+
+//留言
+function course_jour_submit(){
+ if(jourReplyVerify()){
+ jour_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
+ $("#course_feedback_new").submit();
+ }
+}
+
+function jourReplyVerify() {
+ var content = jour_content_editor.html();//$.trim($("#message_content").val());
+ if (jour_content_editor.isEmpty()) {
+ $("#jour_content_span").text("留言不能为空");
+ $("#jour_content_span").show();
+ $("#jour_content_span").css('color', '#ff0000');
+ $("#submit_feedback_user").one('click',function() {
+ course_jour_submit();
+ });
+ return false;
+ }
+ else {
+ $("#jour_content_span").text("填写正确");
+ $("#jour_content_span").css('color', '#008000');
+ return true;
+ }
+}
+
+function cancel_jour_submit(){
+ jour_content_editor.html("");
+ $("#jour_content_span").text("");
+ $("#jour_content_span").hide();
+}
\ No newline at end of file