diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index cba3a98e0..bab5dfb4c 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -94,7 +94,11 @@ class MessagesController < ApplicationController
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message)
if params[:is_board]
- redirect_to project_boards_path(@project)
+ if @project
+ redirect_to project_boards_path(@project)
+ elsif @course
+ redirect_to course_boards_path(@course)
+ end
else
redirect_to board_message_url(@board, @message)
end
@@ -137,7 +141,11 @@ class MessagesController < ApplicationController
#render file: 'messages#show', layout: 'base_courses'
end
if params[:is_board]
- redirect_to project_boards_url(@project)
+ if @project
+ redirect_to project_boards_path(@project)
+ elsif @course
+ redirect_to course_boards_path(@course)
+ end
else
redirect_to board_message_url(@board, @topic, :r => @reply)
end
@@ -179,16 +187,20 @@ class MessagesController < ApplicationController
@message.destroy
# modify by nwb
if @project
- if @message.parent
- redirect_to board_message_url(@board, @message.parent, :r => r)
- else
+ if params[:is_board]
redirect_to project_boards_url(@project)
+ else
+ redirect_to board_message_url(@board, @topic, :r => @reply)
end
elsif @course
- if @message.parent
- redirect_to board_message_url(@board, @message.parent, :r => r)
+ if params[:is_board]
+ redirect_to course_boards_url(@course)
else
- redirect_to course_board_url(@course, @board)
+ if @message.parent
+ redirect_to board_message_url(@board, @message.parent, :r => r)
+ else
+ redirect_to course_board_url(@course, @board)
+ end
end
end
end
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb
new file mode 100644
index 000000000..94ba51529
--- /dev/null
+++ b/app/views/boards/_course_new.html.erb
@@ -0,0 +1,9 @@
+<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
+
+ <%= render :partial => 'form_course', :locals => {:f => f} %>
+
+
+
+ <%= render :partial => 'course_new' %>
+
+
<% if !User.current.logged?%>
@@ -31,38 +29,127 @@
<% end %>
-
-
- <%= l(:label_totle) %>
- <%= @topic_count %>
- <%= l(:label_course_momes_count) %>
-
- <%= link_to l(:label_message_new),
- new_board_message_path(@board),
- :class => 'problem_new_btn fl c_dorange' if User.current.logged? %>
-
-
+
<% if @topics.any? %>
<% @topics.each do |topic| %>
-
- <%= link_to image_tag(url_to_avatar(topic.author), :width=>"32",:height=>"32"), user_path(topic.author),:class => 'problem_pic talk_pic fl' %>
-
- <%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title: topic.subject.to_s,:class => "problem_tit fl fb c_dblue" %>
- <% if topic.sticky? %>
-
置顶
- <% end %>
-
-
由<%= link_to topic.author,user_path(topic.author),:class => "problem_name" %>添加于<%= format_time(topic.created_on) %>
-
- <%=link_to (l(:label_reply) + topic.replies_count.to_s), board_message_path(@board, topic),:class => "talk_btn fr c_white" %>
+
+ <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
+
+ <% author = topic.author.to_s + ":" %>
+ <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %>
+
<%= h(topic.subject) %>
+ <% if topic.sticky? %>
+
<%= l(:label_board_sticky)%>
+ <% end %>
-
-
+
+
+
+
+ <%= topic.content %>
+
+
+
+ <%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
+
+ <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
+
+
+
+
+ <% reply = Message.new(:subject => "RE: #{@message.subject}")%>
+ <% if !topic.locked? && authorize_for('messages', 'reply') %>
+
+
+
+ <%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s} do |f| %>
+
+ <%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
+
<%= l(:label_memo_create)%>
+ <% end %>
+
+
+ <% end %>
+ <% replies_all = topic.children.
+ includes(:author, :attachments, {:board => :project}).
+ reorder("#{Message.table_name}.created_on DESC").offset(2).
+ all %>
+ <% replies_show = topic.children.
+ includes(:author, :attachments, {:board => :project}).
+ reorder("#{Message.table_name}.created_on DESC").limit(2).
+ all %>
+ <% unless replies_show.empty? %>
+ <% reply_count = 0 %>
+
+
+ <% replies_show.each do |message| %>
+
+ -
+ <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
+
+ <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
+
+
<%= textAreailizable message,:content,:attachments => message.attachments %>
+
+
+
<%= format_time(message.created_on) %>
+ <%= link_to(
+
+ l(:button_delete),
+ {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
+ :method => :post,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :title => l(:button_delete),
+ :class => ' c_dblue fr'
+ ) if message.course_destroyable_by?(User.current) %>
+
+
+
+
+ <% end %>
+
+
+
+
+ <% replies_all.each do |message| %>
+
+ -
+ <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
+
+ <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
+
+
<%= textAreailizable message,:content,:attachments => message.attachments %>
+
+
+
<%= format_time(message.created_on) %>
+ <%= link_to(
+
+ l(:button_delete),
+ {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
+ :method => :post,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :title => l(:button_delete),
+ :class => ' c_dblue fr'
+ ) if message.course_destroyable_by?(User.current) %>
+
+
+
+
+ <% end %>
+
+
+
+
+ <% end %>
+
<% end %>
<% else %>
-
- <%= l(:label_no_data) %>
-
+
<%= l(:label_no_data) %>
<% end %>
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
diff --git a/app/views/boards/_form_course.html.erb b/app/views/boards/_form_course.html.erb
new file mode 100644
index 000000000..5cd2d8a2f
--- /dev/null
+++ b/app/views/boards/_form_course.html.erb
@@ -0,0 +1,60 @@
+<%= error_messages_for 'message' %>
+<% replying ||= false %>
+<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %>
+<% if replying %>
+ -
+
+
+ <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %>
+
+
+
+
+<% else %>
+ -
+
+
+
+ <%= f.text_field :subject, { size: 60, id: "message_subject", onkeyup: "regexSubject();",:class=>"talk_input w585" }.merge(extra_option) %>
+
+
+
+<% end %>
+-
+ <% unless replying %>
+ <% if @message.safe_attribute? 'sticky' %>
+ <%= f.check_box :sticky %>
+ <%= label_tag 'message_sticky', l(:label_board_sticky) %>
+ <% end %>
+ <% if @message.safe_attribute? 'locked' %>
+ <%= f.check_box :locked %>
+ <%= label_tag 'message_locked', l(:label_board_locked) %>
+ <% end %>
+ <% end %>
+
+
+-
+
+ <% unless replying %>
+
+ <% end %>
+ <%= text_area :quote,:quote,:style => 'display:none' %>
+ <% if replying%>
+ <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %>
+ <% else %>
+ <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %>
+ <% end %>
+
+
+
+
+-
+ <% unless replying %>
+
+ <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %>
+
+ <% end %>
+
+-
+
+
\ No newline at end of file
diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb
new file mode 100644
index 000000000..b42cabbeb
--- /dev/null
+++ b/app/views/boards/_form_project.html.erb
@@ -0,0 +1,60 @@
+<%= error_messages_for 'message' %>
+<% replying ||= false %>
+<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %>
+<% if replying %>
+-
+
+
+ <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %>
+
+
+
+
+<% else %>
+ -
+
+
+
+ <%= f.text_field :subject, { size: 60, id: "message_subject", onkeyup: "regexSubject();",:class=>"talk_input w585" }.merge(extra_option) %>
+
+
+
+<% end %>
+-
+ <% unless replying %>
+ <% if @message.safe_attribute? 'sticky' %>
+ <%= f.check_box :sticky %>
+ <%= label_tag 'message_sticky', l(:label_board_sticky) %>
+ <% end %>
+ <% if @message.safe_attribute? 'locked' %>
+ <%= f.check_box :locked %>
+ <%= label_tag 'message_locked', l(:label_board_locked) %>
+ <% end %>
+ <% end %>
+
+
+-
+
+ <% unless replying %>
+
+ <% end %>
+ <%= text_area :quote,:quote,:style => 'display:none' %>
+ <% if replying%>
+ <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %>
+ <% else %>
+ <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %>
+ <% end %>
+
+
+
+
+-
+<% unless replying %>
+
+ <%= render :partial => 'attachments/form_project', :locals => {:container => @message,:isReply => @isReply} %>
+
+ <% end %>
+
+-
+
+
\ No newline at end of file
diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb
index b5526e5de..371007a72 100644
--- a/app/views/boards/_project_new_topic.html.erb
+++ b/app/views/boards/_project_new_topic.html.erb
@@ -1,6 +1,6 @@
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
- <%= l(:project_module_boards_post) %>
- <%= render :partial => 'messages/form_project', :locals => {:f => f} %>
+
+ <%= render :partial => 'form_project', :locals => {:f => f} %>
-
<%= link_to l(:button_cancel), project_boards_path(@project), :class => 'grey_btn fr ml10' %>
<%= l(:button_submit)%>
diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb
index 5ee353c68..490c1a584 100644
--- a/app/views/boards/_project_show.html.erb
+++ b/app/views/boards/_project_show.html.erb
@@ -27,7 +27,7 @@
<%= render :partial => 'project_new_topic' %>
-
、
+
@@ -46,72 +46,108 @@
+ <% reply = Message.new(:subject => "RE: #{@message.subject}")%>
+ <% if !topic.locked? && authorize_for('messages', 'reply') %>
+
+
+
+ <%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s} do |f| %>
+
+ <%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
+
<%= l(:label_memo_create)%>
+ <% end %>
+
+
+ <% end %>
+ <% replies_all = topic.children.
includes(:author, :attachments, {:board => :project}).
- reorder("#{Message.table_name}.created_on DESC").
- limit(2).
+ reorder("#{Message.table_name}.created_on DESC").offset(2).
all %>
- <% unless replies.empty? %>
+ <% replies_show = topic.children.
+ includes(:author, :attachments, {:board => :project}).
+ reorder("#{Message.table_name}.created_on DESC").limit(2).
+ all %>
+ <% unless replies_show.empty? %>
<% reply_count = 0 %>
- <% replies.each do |message| %>
-
">
-
<%= link_to image_tag(url_to_avatar(message.author), :width => '46',:height => '46'), user_path(message.author) %>
-
-
- <%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %>
-
<%= format_time(message.created_on) %>
-
-
<%= textAreailizable message,:content,:attachments => message.attachments %>
-
-
+
+
<% end %>
+
+
+
+
<% end %>
- <% reply = Message.new(:subject => "RE: #{@message.subject}")%>
- <% if !topic.locked? && authorize_for('messages', 'reply') %>
-
- <%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
-
<%= l(:label_message_reply) %>
- <%= render :partial => 'messages/form_project', :locals => {:f => f, :replying => true} %>
-
<%= l(:button_submit)%>
- <% end %>
-
-
- <% end %>
+
<% end %>
<% else %>
<%= l(:label_no_data) %>
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
index f293fd350..50d33be39 100644
--- a/app/views/boards/show.html.erb
+++ b/app/views/boards/show.html.erb
@@ -46,7 +46,76 @@ function show_newtalk()
{
$("#about_newtalk").toggle();
}
-
+function show_newreply()
+{
+ $("#replyContent").toggle();
+}
+function show_more() {
+ $("#contentmessage").toggleClass("course_description_none");
+ var information = $("#expend_more_information2");
+ var arrow = $("#arrow2");
+ var val = information.attr("value");
+ if (val == "show_more") {
+ $("#expend_more_information2").text("收起");
+ information.attr("value", "hide_more");
+ arrow.attr("src", "/images/jiantouup.jpg")
+ }
+ else {
+ $("#expend_more_information2").text("展开");
+ information.attr("value", "show_more");
+ arrow.attr("src", "/images/jiantou.jpg")
+ }
+}
+function regexContent()
+{
+ var content = $.trim($("#message_content").val());
+ if(content.length ==0)
+ {
+ $("#message_content_span").text("<%= l(:label_reply_empty) %>");
+ $("#message_content_span").css('color','#ff0000');
+ flag = false;
+ }
+ else
+ {
+ $("#message_content_span").text("<%= l(:label_field_correct) %>");
+ $("#message_content_span").css('color','#008000');
+ flag = true;
+ }
+}
+function regexSubject()
+{
+ var content = $.trim($("#message_subject").val());
+ if(content.length ==0)
+ {
+ $("#subject_span").text("主题不能为空");
+ $("#subject_span").css('color','#ff0000');
+ return false;
+ }
+ else
+ {
+ $("#subject_span").text("填写正确");
+ $("#subject_span").css('color','#008000');
+ return true;
+ }
+ return false;
+}
+function regexContent()
+{
+ var content = message_content_editor.html();
+ if(content.length ==0)
+ {
+ $("#message_content_span").text("描述不能为空");
+ $("#message_content_span").css('color','#ff0000');
+ return false;
+ }
+ else
+ {
+ $("#message_content_span").text("填写正确");
+ $("#message_content_span").css('color','#008000');
+ return true;
+ }
+ return false;
+}
<% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %>
diff --git a/db/schema.rb b/db/schema.rb
index dcbe017fb..fa82de59a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20150428021035) do
+ActiveRecord::Schema.define(:version => 20150505025537) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -438,13 +438,6 @@ ActiveRecord::Schema.define(:version => 20150428021035) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
- create_table "discuss_demos", :force => true do |t|
- t.string "title"
- t.text "body"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
create_table "documents", :force => true do |t|
t.integer "project_id", :default => 0, :null => false
t.integer "category_id", :default => 0, :null => false
@@ -541,6 +534,8 @@ ActiveRecord::Schema.define(:version => 20150428021035) do
t.integer "is_teacher_score", :default => 0
end
+ add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id"
+
create_table "homework_evaluations", :force => true do |t|
t.string "user_id"
t.string "homework_attach_id"
@@ -553,6 +548,9 @@ ActiveRecord::Schema.define(:version => 20150428021035) do
t.integer "bid_id"
end
+ add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id"
+ add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id"
+
create_table "homework_users", :force => true do |t|
t.string "homework_attach_id"
t.string "user_id"
@@ -1159,6 +1157,9 @@ ActiveRecord::Schema.define(:version => 20150428021035) do
t.datetime "updated_at", :null => false
end
+ add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id"
+ add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id"
+
create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.integer "taggable_id"
diff --git a/public/javascripts/project.js b/public/javascripts/project.js
index 6dbb0ff6b..6dbc90271 100644
--- a/public/javascripts/project.js
+++ b/public/javascripts/project.js
@@ -58,7 +58,22 @@ function show_more_msg() {
arrow.attr("src", "/images/jiantou.jpg")
}
}
-
+function show_more_reply(contentid, id2, id3) {
+ $(contentid).toggleClass("course_description_none");
+ var information = $(id2);
+ var arrow = $(id3);
+ var val = information.attr("value");
+ if (val == "show_more") {
+ $(id2).text("收起");
+ information.attr("value", "hide_more");
+ arrow.attr("src", "/images/jiantouup.jpg")
+ }
+ else {
+ $(id2).text("展开更多信息");
+ information.attr("value", "show_more");
+ arrow.attr("src", "/images/jiantou.jpg")
+ }
+}
//项目版本库git帮助文档显示
function showhelpAndScrollTo(id) {
@@ -84,7 +99,29 @@ function showhelpAndScrollTo(id) {
information.attr("value", "show_help");
}
}
-
+function showhelpAndScrollToMessage(id, id1) {
+ $('#' + id).toggle();
+ if(cookieget("repositories_visiable") == "true")
+ {
+ cookiesave("repositories_visiable", false,'','','');
+ }
+ else
+ {
+ cookiesave("repositories_visiable", true,'','','');
+ }
+ var information = $(id1);
+ var val = information.attr("value");
+ if(val=="show_help")
+ {
+ $(id1).text("收起回复");
+ information.attr("value", "hide_help");
+ }
+ else
+ {
+ $(id1).text("展开回复");
+ information.attr("value", "show_help");
+ }
+}
$(function(){