From a8b4bde77c9cad26906169c7a9ab495554983dcc Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 20 Oct 2015 14:38:24 +0800 Subject: [PATCH 01/58] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8div?= =?UTF-8?q?=20=E4=B8=8B=E6=8B=89=E5=88=86=E9=A1=B5=20=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E9=A1=B5=20=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/my/account.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 0531ea9e7..7bc674ea6 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -603,7 +603,7 @@ success: function (data) { schoolsResult = data.schools; count = data.count; - maxPage = count % 100 + 1; //最大页码值 + maxPage = Math.ceil(count/100) //最大页码值 if(schoolsResult.length != undefined && schoolsResult.length != 0) { var i = 0; $("#search_school_result_list").html(''); From cc59b4c8779aad6cbf7216d36c4a5b2c36c3e415 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 20 Oct 2015 15:15:18 +0800 Subject: [PATCH 02/58] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=BC=96=E8=BE=91=E5=B8=96=E5=AD=90=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_message_edit.html.erb | 2 +- app/views/messages/edit.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/boards/_course_message_edit.html.erb b/app/views/boards/_course_message_edit.html.erb index 16807afb0..caa389945 100644 --- a/app/views/boards/_course_message_edit.html.erb +++ b/app/views/boards/_course_message_edit.html.erb @@ -12,5 +12,5 @@ <%= render :partial => 'boards/course_new', - :locals => {:f => f, :edit_mode => edit_mode, :topic => topic} %> + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :course => course} %> \ No newline at end of file diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 0817594ab..624174b14 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -30,7 +30,7 @@ :method => :post} } do |f| %> <%= render :partial => 'boards/course_message_edit', - :locals => {:f => f, :edit_mode => true, :topic => @message} %> + :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> <% end %> <% end %> From 87b4c8324718d3874a1a6708f44405d1f8e398fe Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 20 Oct 2015 16:19:32 +0800 Subject: [PATCH 03/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E5=8C=BF=E8=AF=84=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=88=A0=E9=99=A4=EF=BC=9B=20=E7=9C=8B?= =?UTF-8?q?=E5=AE=8C=E6=B6=88=E6=81=AF=E5=90=8E=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=BA=94=E7=9A=84=E5=AD=97=E6=AE=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 6 +++++- app/controllers/users_controller.rb | 2 +- app/models/student_work.rb | 6 ++++-- app/views/users/_user_message_course.html.erb | 20 +++++++++---------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9393339a8..e5e1bf391 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -63,7 +63,7 @@ class StudentWorkController < ApplicationController journal_for_teacher.update_attributes(:viewed => true) end #不能参与作业匿评消息状态更新 - no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "NoEvaluation", 0) + no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =? and status =?", User.current.id, @homework.course, "StudentWork", 0, 0) no_evaluation.update_all(:viewed => true) # 作品留言 # 消息end @@ -144,6 +144,10 @@ class StudentWorkController < ApplicationController end def new + #更新消息 + noEvaluation = @homework.course_messages.where("user_id =? and viewed =?", User.current.id, 0) + noEvaluation.update_all(:viewed => true) + if @homework.homework_type==2 redirect_to new_user_commit_homework_users_path(homework_id: @homework.id) return diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ef3210719..7adba7cbf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -128,7 +128,7 @@ class UsersController < ApplicationController #课程相关消息 when 'homework' - @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','NoEvaluation') and user_id =?", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?", @user).order("created_at desc") when 'course_message' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") when 'course_news' diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 700613792..010ede635 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -8,6 +8,8 @@ class StudentWork < ActiveRecord::Base has_many :student_works_scores, :dependent => :destroy belongs_to :project has_many :student_work_tests, order: 'id desc' + # course's message + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy before_destroy :delete_praise before_save :set_program_score, :set_src @@ -138,10 +140,10 @@ class StudentWork < ActiveRecord::Base end end + # status == 0 : delay def act_as_message if self.created_at > self.homework_common.end_time + 1 - CourseMessage.create(:user_id => self.user_id, :course_id => self.homework_common.course_id, - :course_message_id => self.id, :course_message_type => 'NoEvaluation',:viewed => false) + self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.homework_common.course_id, :viewed => false, :status => false) end end end diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 6c22976fd..86b44f66d 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -37,7 +37,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil? && !ma.course_message.nil? %> + <% if ma.course_message_type == "HomeworkCommon" %> <% end %> + <% if ma.course_message_type == "JoinCourseRequest" %> + + <% end %> <% end %> \ No newline at end of file From e44d95cca56ba6d5f69a619076b1a66d9982cb31 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 21 Oct 2015 14:52:00 +0800 Subject: [PATCH 06/58] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84=E5=8A=A0=E5=85=A5=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 18 +++-- app/controllers/users_controller.rb | 39 +++++++++++ app/services/courses_service.rb | 26 +++++-- app/views/courses/join.js.erb | 6 +- app/views/users/_user_message_course.html.erb | 67 +++++++++++++++++++ app/views/users/dealwith_apply_request.js.erb | 11 +++ config/routes.rb | 1 + 7 files changed, 151 insertions(+), 17 deletions(-) create mode 100644 app/views/users/dealwith_apply_request.js.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index fe9318006..dcb330b3b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -31,17 +31,21 @@ class CoursesController < ApplicationController def join if User.current.logged? - if params[:role] == 10 + # if params[:role] == 10 cs = CoursesService.new @user = User.current - join = cs.join_course params,user + join = cs.join_course params,@user @state = join[:state] @course = join[:course] - else - @course = Course.find_by_id params[:object_id] - CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') - @state = 6 - end + # else + # if params[:course_password] == course.password + # @course = Course.find_by_id params[:object_id] + # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') + # @state = 6 + # else + # @state = 1 #密码错误 + # end + # end else @state = 5 #未登录 end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7adba7cbf..f09494968 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -239,6 +239,45 @@ class UsersController < ApplicationController end end + #处理加入课程成为教辅教师的请求 + #status 1 同意 2 拒绝 + def dealwith_apply_request + @msg = CourseMessage.find(params[:msg_id]) + case params[:agree] + when 'Y' + apply_user = User.find(@msg.course_message_id) + + if apply_user.member_of_course?(Course.find(@msg.course_id)) + #将角色改为老师或者教辅 + member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0] + member.role_ids = [@msg.content] # msg content保存的是申请的职位角色 + #删除为学生的记录 + joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@msg.course_id) + joined.each do |join| + join.delete + end + + member.course_group_id = 0 + member.save + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) + @msg.update_attributes(:status=>1) + else + members = [] + members << Member.new(:role_ids => [@msg.content.to_i], :user_id => @msg.course_message_id) + Course.find(@msg.course_id).members << members + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) + @msg.update_attributes(:status=>1) + end + + when 'N' + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2) + @msg.update_attributes(:status=>2) + end + respond_to do |format| + format.js + end + end + # added by bai def show_score diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 4639f1c2b..277d5a545 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -308,15 +308,27 @@ class CoursesService if course_endTime_timeout? course @state = 2 else - if current_user.member_of_course?(course) - @state = 3 + if current_user.member_of_course?(course) #如果已经是成员 + #如果加入角色为学生 + if params[:role] == 10 + @state = 3 + else + #如果加入角色为教师或者教辅 + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end else if params[:course_password] == course.password - members = [] - members << Member.new(:role_ids => [10], :user_id => current_user.id) - course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) - @state = 0 + if params[:role] == 10 + members = [] + members << Member.new(:role_ids => [10], :user_id => current_user.id) + course.members << members + StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + @state = 0 + else + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end else @state = 1 end diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb index 64b1ffd4c..b4e6a98ec 100644 --- a/app/views/courses/join.js.erb +++ b/app/views/courses/join.js.erb @@ -5,15 +5,15 @@ $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@c <% if @state == 0 %> alert("加入成功"); hideModal($("#popbox02")); -$("#try_join_course_link").replaceWith(" 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); -window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>" +$("#try_join_course_link").replaceWith(" 'index',:course=>@course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 1 %> alert("密码错误"); <% elsif @state == 2 %> alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)"); <% elsif @state == 3 %> alert("您已经加入了课程"); -window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>" +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 4 %> alert("您加入的课程不存在"); <% elsif @state == 5 %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 86b44f66d..b98e3be53 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -428,4 +428,71 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + <% if ma.course_message_type == "JoinCourseRequest" %> + + <% end %> + <% if ma.course_message_type == "CourseRequestDealResult" %> + + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/dealwith_apply_request.js.erb b/app/views/users/dealwith_apply_request.js.erb new file mode 100644 index 000000000..e31c0be85 --- /dev/null +++ b/app/views/users/dealwith_apply_request.js.erb @@ -0,0 +1,11 @@ +$("#deal_info_<%=@msg.id%>").html( +<% if @msg.status == 0 || @msg.status.nil?%> +<%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>@msg.id),:remote=>'true'%> +'|' +<%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>@msg.id),:remote=>'true'%> +<% elsif @msg.status == 1%> + '您已经同意了该申请' +<% elsif @msg.status == 2%> + '您已经拒绝了该申请' +<%end %> +); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 810c22e7a..cb9e81c01 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -388,6 +388,7 @@ RedmineApp::Application.routes.draw do get 'user_ref_resource_search' post 'import_resources_to_homework' get 'store_selected_resource' + get 'dealwith_apply_request' # end end end From 75ee45b2d19bfb82688b32575c0cd22efb599ea6 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 21 Oct 2015 15:03:46 +0800 Subject: [PATCH 07/58] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=B7=B2=E9=98=85?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f09494968..7425692c0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -243,6 +243,7 @@ class UsersController < ApplicationController #status 1 同意 2 拒绝 def dealwith_apply_request @msg = CourseMessage.find(params[:msg_id]) + case params[:agree] when 'Y' apply_user = User.find(@msg.course_message_id) @@ -260,18 +261,18 @@ class UsersController < ApplicationController member.course_group_id = 0 member.save CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) - @msg.update_attributes(:status=>1) + @msg.update_attributes(:status=>1,:viewed=>1) else members = [] members << Member.new(:role_ids => [@msg.content.to_i], :user_id => @msg.course_message_id) Course.find(@msg.course_id).members << members CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) - @msg.update_attributes(:status=>1) + @msg.update_attributes(:status=>1,:viewed=>1) end when 'N' CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2) - @msg.update_attributes(:status=>2) + @msg.update_attributes(:status=>2,:viewed=>1) end respond_to do |format| format.js From 7f1524ebe1f194e84d1e54f84c92f39df4cf3010 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 22 Oct 2015 09:05:51 +0800 Subject: [PATCH 08/58] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E8=A2=AB=E5=89=94=E9=99=A4=E8=AF=BE=E7=A8=8B=E6=88=90?= =?UTF-8?q?=E5=91=98=E6=97=B6=EF=BC=8C=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84bug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index d59045e07..00bf86ae5 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -350,7 +350,7 @@
  • <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + - "#{ma.course_message.user.members.where("course_id=?", ma.course.id).first.roles.first.name=='Student'?"同学":"老师"}", + "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? "老师":"同学"}", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">回复了作品评论:
  • @@ -435,19 +435,16 @@
  • <%= link_to User.find(ma.course_message_id), user_path(ma.course_message_id), :class => "newsBlue homepageNewsPublisher" %> - ">申请成为您课程的<%= ma.content %> - : + ">申请成为您课程的<%= ma.content %>:
  • - <%= link_to "课程名称:" + ma.course, course_path(ma.course), + <%= link_to "课程名称:" + ma.course.name, course_path(ma.course), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
  • <%= time_tag(ma.created_at).html_safe %>
  • From 7e21c00aed2d82f75be0f53cfe2036c55c4c6996 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 22 Oct 2015 09:20:19 +0800 Subject: [PATCH 09/58] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 38 +++++ app/models/homework_common.rb | 13 ++ app/views/users/_course_homework.html.erb | 72 ++++++++- .../users/_user_homework_detail.html.erb | 150 ++++++++++++++++++ app/views/users/_user_homework_list.html.erb | 114 +++++-------- app/views/words/leave_homework_message.js.erb | 7 + config/routes.rb | 1 + 7 files changed, 316 insertions(+), 79 deletions(-) create mode 100644 app/views/users/_user_homework_detail.html.erb create mode 100644 app/views/words/leave_homework_message.js.erb diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 6304055ed..6ad1a66b4 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -243,7 +243,45 @@ class WordsController < ApplicationController flash[:error] = feedback.errors.full_messages[0] redirect_to course_feedback_url(params[:id]) end + end + + #作业的回复 + def leave_homework_message + if User.current.logged? + @user = User.current + @homework_common = HomeworkCommon.find(params[:id]); + if params[:homework_message].size>0 && User.current.logged? && @user + feedback = HomeworkCommon.add_homework_jour(@user, params[:homework_message], params[:id]) + if (feedback.errors.empty?) + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + end + course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework_common.id}").first + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end + user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework_common.id}").first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end + respond_to do |format| + format.js{ + @user_activity_id = params[:user_activity_id] + @is_in_course = params[:is_in_course] + @homework_common_id = params[:homework_common_id] + } + end + else + flash[:error] = feedback.errors.full_messages[0] + end + end + else + render_403 + end end def add_brief_introdution diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 796080645..03a7644a2 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -12,6 +12,7 @@ class HomeworkCommon < ActiveRecord::Base has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 + has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy @@ -60,6 +61,18 @@ class HomeworkCommon < ActiveRecord::Base self.homework_type == 2 && self.homework_detail_programing end + ###添加回复 + def self.add_homework_jour(user, notes, id , options = {}) + homework = HomeworkCommon.find(id) + if options.count == 0 + jfm = homework.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0) + else + jfm = homework.journals_for_messages.build(options) + end + jfm.save + jfm + end + delegate :language_name, :language, :to => :homework_detail_programing end diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 2d3bc68de..df42f6ee9 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -1,5 +1,5 @@ <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> -
    +
    <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> @@ -71,4 +71,74 @@
    + + <% count=activity.journals_for_messages.count %> +
    +
    +
    +
    + 回复(<%= count %>) +
    +
    + <%if count>3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
      +
      + <%= comment.notes.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb new file mode 100644 index 000000000..40400c71e --- /dev/null +++ b/app/views/users/_user_homework_detail.html.erb @@ -0,0 +1,150 @@ +<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> +
    +
    +
    + <%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%> +
    +
    +
    + <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> + TO + <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> +
    + + + <% if homework_common.homework_detail_manual%> + <% if homework_common.homework_detail_manual.comment_status == 1%> + 未开启匿评 + <% elsif homework_common.homework_detail_manual.comment_status == 2%> + 匿评中 + <% elsif homework_common.homework_detail_manual.comment_status == 3%> + 匿评已结束 + <% end%> + <% end%> + +
    +
    + <%= user_for_homework_common homework_common,is_teacher %> +
    + <% if homework_common.homework_type == 2 && is_teacher%> +
    + <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> +
    + <% end %> + <% if homework_common.homework_type == 2%> +
    + 语言: + <%= homework_common.language_name%> +
    + <% end %> +
    + <%= l(:label_end_time)%>:<%= homework_common.end_time%> +
    +
    +
    + <%= homework_common.description.html_safe %> +
    +
    + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> +
    +
    + <% if is_teacher%> + <%# if false%> +
    +
      +
    • +
        +
      • + <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course), :class => "postOptionLink"%> +
      • +
      • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
      • +
      • + <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true) if homework_common.homework_detail_manual.comment_status == 1%> +
      • +
      • + <%= homework_anonymous_comment homework_common %> +
      • +
      +
    • +
    +
    + <% end%> +
    +
    +
    + + <% count=homework_common.journals_for_messages.count %> +
    +
    +
    +
    + 回复(<%= count %>) +
    +
    + <%if count>3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% homework_common.journals_for_messages.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
      +
      + <%= comment.notes.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => homework_common.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'homework_common_id',params[:homework_common_id],:value =>homework_common.id %> + <%= hidden_field_tag 'is_in_course',params[:is_in_course],:value =>is_in_course %> + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index 44f992bb4..ad39ad14f 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -1,83 +1,41 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> + <% homework_commons.each do |homework_common|%> - <% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> -
    -
    -
    - <%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%> -
    -
    -
    - <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> - TO - <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> -
    - + + <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %> <% end%> <% if homework_commons.count == 10%> <% if is_in_course == 1%> diff --git a/app/views/words/leave_homework_message.js.erb b/app/views/words/leave_homework_message.js.erb new file mode 100644 index 000000000..91525c889 --- /dev/null +++ b/app/views/words/leave_homework_message.js.erb @@ -0,0 +1,7 @@ +<% if @user_activity_id %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% elsif @homework_common_id && @is_in_course %> + $("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework_common,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework_common_id%>,"","87%"); +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 810c22e7a..d140c240a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -855,6 +855,7 @@ RedmineApp::Application.routes.draw do match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share post 'words/:id/leave_user_message', :to => 'words#leave_user_message', :as => "leave_user_message" + post 'words/:id/leave_homework_message', :to => 'words#leave_homework_message', :as => "leave_homework_message" post 'join_in/join', :to => 'courses#join', :as => 'join' delete 'join_in/join', :to => 'courses#unjoin' From 4b8c65d12e84d4ac0fb850e74b6de961614162be Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 22 Oct 2015 14:31:14 +0800 Subject: [PATCH 10/58] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 40 +++++++++++++++++++ app/views/users/dealwith_apply_request.js.erb | 11 +++++ 2 files changed, 51 insertions(+) create mode 100644 app/views/users/dealwith_apply_request.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7adba7cbf..7425692c0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -239,6 +239,46 @@ class UsersController < ApplicationController end end + #处理加入课程成为教辅教师的请求 + #status 1 同意 2 拒绝 + def dealwith_apply_request + @msg = CourseMessage.find(params[:msg_id]) + + case params[:agree] + when 'Y' + apply_user = User.find(@msg.course_message_id) + + if apply_user.member_of_course?(Course.find(@msg.course_id)) + #将角色改为老师或者教辅 + member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0] + member.role_ids = [@msg.content] # msg content保存的是申请的职位角色 + #删除为学生的记录 + joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@msg.course_id) + joined.each do |join| + join.delete + end + + member.course_group_id = 0 + member.save + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) + @msg.update_attributes(:status=>1,:viewed=>1) + else + members = [] + members << Member.new(:role_ids => [@msg.content.to_i], :user_id => @msg.course_message_id) + Course.find(@msg.course_id).members << members + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) + @msg.update_attributes(:status=>1,:viewed=>1) + end + + when 'N' + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2) + @msg.update_attributes(:status=>2,:viewed=>1) + end + respond_to do |format| + format.js + end + end + # added by bai def show_score diff --git a/app/views/users/dealwith_apply_request.js.erb b/app/views/users/dealwith_apply_request.js.erb new file mode 100644 index 000000000..e31c0be85 --- /dev/null +++ b/app/views/users/dealwith_apply_request.js.erb @@ -0,0 +1,11 @@ +$("#deal_info_<%=@msg.id%>").html( +<% if @msg.status == 0 || @msg.status.nil?%> +<%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>@msg.id),:remote=>'true'%> +'|' +<%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>@msg.id),:remote=>'true'%> +<% elsif @msg.status == 1%> + '您已经同意了该申请' +<% elsif @msg.status == 2%> + '您已经拒绝了该申请' +<%end %> +); \ No newline at end of file From 35719f9c28de94dfd6f47d78cf14e36b5162d026 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 22 Oct 2015 15:41:20 +0800 Subject: [PATCH 11/58] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index d140c240a..649cfbb75 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -387,6 +387,7 @@ RedmineApp::Application.routes.draw do get 'user_resource_type' get 'user_ref_resource_search' post 'import_resources_to_homework' + get 'dealwith_apply_request' get 'store_selected_resource' # end end From f7545e623b332c467b850c253e5512254fdd4eca Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 22 Oct 2015 15:41:52 +0800 Subject: [PATCH 12/58] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=88=AA=E6=AD=A2=E6=97=A5=E6=9C=9F=E5=BF=AB?= =?UTF-8?q?=E5=88=B0=E6=97=B6=EF=BC=8C=E5=A4=9A=E5=8F=91=E9=80=81=E4=B8=80?= =?UTF-8?q?=E6=9D=A1=E6=B6=88=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index b98e3be53..720e5f9c5 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -37,7 +37,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "HomeworkCommon" %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil?%>
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> From 4b6f8efc5a1bbf3fdd0673743adf33def8597bbc Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 22 Oct 2015 16:57:36 +0800 Subject: [PATCH 13/58] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=9C=E4=B8=9A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student_work/_student_work_list.html.erb | 1 + app/views/student_work/index.html.erb | 76 +++++++++++++++++++ app/views/users/_user_homework_list.html.erb | 18 ++--- public/stylesheets/courses.css | 10 +++ 4 files changed, 96 insertions(+), 9 deletions(-) diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index 197fecac9..2d0e9220c 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -12,6 +12,7 @@
    <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> <% end%> +
    diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index e28cdb1e2..72ca36ca9 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -28,6 +28,33 @@ $('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); } + $(function(){ + $("#homework_info_hidden").click(function(){ + $("#homeworkInformation").hide(); + $("#homework_info_hidden").hide(); + $("#homework_info_show").show(); + }); + $("#homework_info_show").click(function(){ + $("#homework_info_show").hide(); + $("#homeworkInformation").show(); + $("#homework_info_hidden").show(); + }); + + if($("#homework_description").height() > 54) { + $("#homeworkDetailShow").show(); + } + $("#homeworkDetailShow").click(function(){ + $("#homeworkDetail").toggleClass("max_h54"); + $("#homeworkDetailShow").hide(); + $("#homeworkDetailHide").show(); + }); + $("#homeworkDetailHide").click(function(){ + $("#homeworkDetail").toggleClass("max_h54"); + $("#homeworkDetailHide").hide(); + $("#homeworkDetailShow").show(); + }); + }); +
    @@ -91,6 +118,55 @@
    +
    +
    + + <% if @homework.homework_detail_manual%> + <% if @homework.homework_detail_manual.comment_status == 1%> + 未开启匿评 + <% elsif @homework.homework_detail_manual.comment_status == 2%> + 匿评中 + <% elsif @homework.homework_detail_manual.comment_status == 3%> + 匿评已结束 + <% end%> + <% end%> + [ 隐藏作业信息 ] +
    +
    发布者:<%= @homework.user.show_name %>
    +
    +
    <%= @homework.description.html_safe %>
    +
    + + +
    +
    +
    截止时间:<%= @homework.end_time %>
    + <% if @homework.homework_detail_manual%> + <% if @homework.homework_detail_manual.comment_status == 1%> + <% end_time = @homework.end_time.to_time.to_i + 24*60*60 - 1 %> + <% if end_time >= Time.now.to_i %> +
    提交剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60) %> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    提交已截止
    + <% end %> + <% elsif @homework.homework_detail_manual.comment_status == 2%> + <% end_time = @homework.homework_detail_manual.evaluation_end.to_time.to_i + 24*60*60 - 1 %> + <% if end_time >= Time.now.to_i %> +
    匿评剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60)%> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    匿评已截止
    + <% end %> + <% end%> + <% end%> +
    +
    +
    +
    +
    diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index ad39ad14f..cf511c51f 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -1,15 +1,15 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> <% homework_commons.each do |homework_common|%> <% if activity && activity.course_act%> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index df42f6ee9..4bde4476d 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -43,9 +43,15 @@
    截止时间:<%= activity.end_time.to_s %>
    -
    - <%= activity.description.html_safe %> +
    +
    + <%= activity.description.html_safe %> +
    +
    + + +
    <%# if is_teacher%> <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %>
    +
  •   您迟交了作品!
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 872d8df6d..83fe0456f 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1296,3 +1296,5 @@ a:hover.link_file_a{ background:url(../images/pic_file.png) 0 -25px no-repeat; c .list_style ol li{list-style-type: decimal;margin-left: 20px;} .list_style ul li{list-style-type: disc;margin-left: 20px;} +.list_style_disc {list-style-type:disc;margin-left:5px;} +.system_message_style li{color:#909090} From 4a188dc81d7660b8881df47e68ca7f089e58ddaa Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 23 Oct 2015 14:28:24 +0800 Subject: [PATCH 17/58] =?UTF-8?q?=E5=AF=B9=E6=89=80=E6=9C=89=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=B6=88=E6=81=AF=EF=BC=8C=E7=BB=9F=E4=B8=80=E5=9C=A8?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=89=8D=E5=8A=A0=E5=9C=86=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E8=B0=83=E6=95=B4=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 170 +++++++++--------- public/images/news_dot.png | Bin 0 -> 976 bytes public/images/news_dot2.png | Bin 0 -> 976 bytes public/stylesheets/new_user.css | 4 +- 4 files changed, 86 insertions(+), 88 deletions(-) create mode 100644 public/images/news_dot.png create mode 100644 public/images/news_dot2.png diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 38f895e4c..fb63f4fc0 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -62,27 +62,31 @@ <%= User.current.lastname + User.current.firstname %>老师您好! <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.show_name + "老师")%>刚刚发布了一个作业:

    -

    课程名称:<%= ma.course_message.course.name %> - (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    提交截止:<%= ma.course_message.end_time %>  24点

    -

    匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点

    -

    匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点

    -

    迟交扣分:<%= ma.course_message.late_penalty %>分

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    +
      +
    • 课程名称:<%= ma.course_message.course.name %> + (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 提交截止:<%= ma.course_message.end_time %>  24点
    • +
    • 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点
    • +
    • 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点
    • +
    • 迟交扣分:<%= ma.course_message.late_penalty %>分
    • +
    • 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
    • +

    您可以修改作业内容、评分规则、匿评过程等,谢谢!

    <% else %>

    <%= User.current.lastname + User.current.firstname %>同学您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:

    -

    课程名称:<%= ma.course_message.course.name %> - (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    提交截止:<%= ma.course_message.end_time %>  24点

    -

    匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点

    -

    匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点

    -

    迟交扣分:<%= ma.course_message.late_penalty %>分

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    +
      +
    • 课程名称:<%= ma.course_message.course.name %> + (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 提交截止:<%= ma.course_message.end_time %>  24点
    • +
    • 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点
    • +
    • 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点
    • +
    • 迟交扣分:<%= ma.course_message.late_penalty %>分
    • +
    • 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
    • +

    请抓紧时间提交您的作品,谢谢!

    @@ -109,24 +113,16 @@ <%= User.current.lastname + User.current.firstname %>同学您好! <%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师发布的作业截止日期快到了:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    提交截止:<%= ma.course_message.end_time %>  24点

    -

    匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点

    -

    匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点

    -

    迟交扣分:<%= ma.course_message.late_penalty %>分

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    -

    请抓紧时间提交您的作品,谢谢!

    - <% else %> -

    <%= User.current.lastname + User.current.firstname %>老师您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师发布的作业截止日期快到了:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    提交截止:<%= ma.course_message.end_time %>  24点

    -

    匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点

    -

    匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点

    -

    迟交扣分:<%= ma.course_message.late_penalty %>分

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    -

    您可以修改作业内容、评分规则、匿评过程等,谢谢!

    +
      +
    • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 提交截止:<%= ma.course_message.end_time %>  24点
    • +
    • 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点
    • +
    • 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点
    • +
    • 迟交扣分:<%= ma.course_message.late_penalty %>分
    • +
    • 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
    • +

      请抓紧时间提交您的作品,谢谢!

      +
    <% end %>
  •    截止时间快到了!
  • @@ -154,12 +150,12 @@ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师' : '同学' %>您好! <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>开启了匿评,作业详情如下:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    -

    - 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点 -

    +
      +
    • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
    • +
    • 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点
    • +
    <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%>

    请您尽早完成匿评!如果您在规定时间内未完成匿评,一次将被扣<%= ma.course_message.homework_detail_manual.absence_penalty %>分。

    <% end%> @@ -184,8 +180,10 @@ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好! <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>关闭了匿评,作业详情如下:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    +
      +
    • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -210,14 +208,14 @@

    <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好! <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败! -

    失败原因:提交作品的人数低于2人

    -

    -

    作业详情如下:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年' + ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    - 提交截止:<%= ma.course_message.end_time%>  24点 +

    +
      +
    • 失败原因:提交作品的人数低于2人
    • +
    • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年' + ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 提交截止:<%= ma.course_message.end_time%>  24点
    • +
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -304,16 +302,16 @@ <%= User.current.show_name %>同学您好! <%= ma.course_message.reviewer_role == 3? "匿名用户" : (ma.course_message.user.show_name + "老师")%><%= ma.status == 0? "评阅了您的作品":"重新评阅了您的作品"%>。详情如下:

    -

    课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)

    -

    作业标题:<%=ma.course_message.student_work.homework_common.name %>

    - <% content = ma.content.gsub("作业评分:","").split("    评语:")%> -

    - 作品评分:<%= content[0] %>分 -

    - <% if content.size > 1 %> -
    作品评语:
    -
    <%= content[1] %>
    - <% end %> +
      +
    • 课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)
    • +
    • 作业标题:<%=ma.course_message.student_work.homework_common.name %>
    • + <% content = ma.content.gsub("作业评分:","").split("    评语:")%> +
    • 作品评分:<%= content[0] %>分
    • + <% if content.size > 1 %> +
    • 作品评语:
    • +
      <%= content[1] %>
      + <% end %> +

    本次作业将在<%= ma.course_message.student_work.homework_common.homework_detail_manual.evaluation_end %>  24点结束匿评,到时您将可以看到所有其他同学的作品啦!大家可以进一步互相学习。 期待您取得更大的进步!

    @@ -351,7 +349,7 @@
  • <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + - "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"同学":"老师"}", + "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"}", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">回复了作品评论:
  • @@ -365,12 +363,12 @@ <%= User.current.show_name %>老师您好! <%= ma.course_message.user.show_name%><%= ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"学生"%>回复了您的作品评论。详情如下:

    -
    回复内容:
    -
    <%= ma.course_message.notes %>
    -
    您的评论:
    -
    <%= ma.course_message.jour.comment %>
    -

    课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)

    -

    作业标题:<%=ma.course_message.jour.student_work.homework_common.name %>

    +
      +
    • 回复内容:<%= ma.course_message.notes %>
    • +
    • 您的评论:<%= ma.course_message.jour.comment %>
    • +
    • 课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)
    • +
    • 作业标题:<%=ma.course_message.jour.student_work.homework_common.name %>
    • +
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -395,14 +393,12 @@ <%= User.current.lastname + User.current.firstname %> <%= User.current.allowed_to?(:as_teacher,ma.course_message.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:

    -
      -
    • - 课程名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>) -
    • -
    • 作业标题:<%= ma.course_message.homework_common.name %>
    • -
    • 提交截止:<%= ma.course_message.homework_common.end_time %> 24:00
    • -
    • 提交时间:<%= format_time(ma.course_message.created_at) %>
    • -
    • 迟交扣分:<%= ma.course_message.homework_common.late_penalty %>分
    • +
        +
      • 课程名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>)
      • +
      • 作业标题:<%= ma.course_message.homework_common.name %>
      • +
      • 提交截止:<%= ma.course_message.homework_common.end_time %> 24:00
      • +
      • 提交时间:<%= format_time(ma.course_message.created_at) %>
      • +
      • 迟交扣分:<%= ma.course_message.homework_common.late_penalty %>分

      如需获得最终成绩,请您联系主讲老师对您的作品进行单独评分!

      @@ -444,16 +440,28 @@ 系统提示 ">您有了新的课程成员申请: -
    • +
    • <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id)), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> +
    • + +
    • <% if ma.status == 0 || ma.status.nil?%> <%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%> | - <%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%> + <%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%> <% elsif ma.status == 1%> 您已经同意了该申请 <% elsif ma.status == 2%> @@ -461,16 +469,6 @@ <%end %>
    • -
    • <%= time_tag(ma.created_at).html_safe %>
    <% end %> diff --git a/public/images/news_dot.png b/public/images/news_dot.png new file mode 100644 index 0000000000000000000000000000000000000000..7dea0bbe497f2c0f9b39e489ae60c723fe2b48eb GIT binary patch literal 976 zcmaJ=zi-n(7R|b%XopTzev1*#sc1T1VMQNmFV2ER1605b(*cak< zLLHEpVB#-eMEn6TpbiWm76urQkg84$Na?_e#5qk;27+b#e(1gTefNFup4O`OmKLuq zavZl*E@^c(F2vu(_<#IqSYpFfsyFF2>Ck~0V6I@3HU?$a?BY5$?fr)z@CL_SfKH=H zn?^;ph|8NXhL2pIu{myIGxAMq7gNy2UB^@4@a;PY99w}q86#!*D(*R@g8*+IR2$a8 zu9dUl=3TH6$xOh-)C7^c=Y?{lz>%)Z=JB=w!3aWk6?m3Z)2IQJ1Q=xabka&81SE+^ zYZ*yGcYv5eqL5;*ltgQCMv}!W7(b9j3+#?u*NWp zVhvGDGDI@m_ox{qy>NA+pyAL89G^PG1F@pnCVi?vmg(6MTz@L-h2t`@f(eo73y4p} zN16Z)B|0N!TMk zP`4#;Ysc|yG6-*v@P;9my^xxoh0B@(nF8-Pwyfzzy`W|FY)&j9q-VBLlBkQB^)$++ z)ihEkT#ZZ5ncUb4uFoQCIB*_eyBH7`jE*cjvvW~r>W#Vf>|C^&T!AGc z#Et!{(UUFao_IR7En7^Dk3Hu0fZ6)XD|E!JgjUuHjp$qZ*Xe1?YPEhWoUDM({K@KHxPfQB`G@C_CzDnZ+=Hg4IjObG$-pdF^zI!{ z3}qtVKx}}}IdTIzROp$mOxDpcOM@8%4;1<=sJ31QD)J!^nQX@7cpgX+!{jv{Ok%Fzpet1lS<14#JQiW8-kfVKk0ra5%aUN&sIeCs9UqbD ziI$78C7Z?ILzhguPsaLfCi#+F39YK_wZb2rSDdkOGm%j98(%3ty}>4bHMYRX#X9_{H?<@5g_(pWIJnH($Ts0-vd;-PE<6;LS;N$ExL;_O5hz F{1*rxDeM3M literal 0 HcmV?d00001 diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index ee3d96b4b..599ea5476 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1298,5 +1298,5 @@ a:hover.link_file_a{ background:url(../images/pic_file.png) 0 -25px no-repeat; c .list_style ol li{list-style-type: decimal;margin-left: 20px;} .list_style ul li{list-style-type: disc;margin-left: 20px;} -.list_style_disc {list-style-type:disc;margin-left:5px;} -.system_message_style li{color:#909090} +.ul_grey li {color:#909090; list-style-position:inside; padding-left:1px;list-style-image:url('../images/news_dot2.png')} +.ul_normal_color li {list-style-position:inside; padding-left:1px; list-style-image:url('../images/news_dot.png')} From fde4ce74ba5378eb2d8b8ac5f4210043979a0535 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 23 Oct 2015 14:45:56 +0800 Subject: [PATCH 18/58] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=A2=9E=E5=8A=A0=E8=AF=84=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 9 +++++++-- app/controllers/student_work_controller.rb | 8 +++++++- app/views/homework_common/score_rule_set.js.erb | 6 ++++++ app/views/student_work/_set_score_rule.html.erb | 3 +++ app/views/student_work/index.html.erb | 2 +- app/views/users/_user_homework_detail.html.erb | 3 +++ config/routes.rb | 1 + 7 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 app/views/homework_common/score_rule_set.js.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 9e3a4b836..7793ef097 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController include StudentWorkHelper before_filter :find_course, :only => [:index,:new,:create] - before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr] - before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set] before_filter :member_of_course, :only => [:index] def index @@ -215,6 +215,11 @@ class HomeworkCommonController < ApplicationController end end + #评分设置 + def score_rule_set + + end + private #获取课程 def find_course diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index e5e1bf391..529c5ea72 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -457,7 +457,13 @@ class StudentWorkController < ApplicationController end end respond_to do |format| - format.html{redirect_to student_work_index_url(:homework => @homework.id)} + format.html{ + if params[:student_path] + redirect_to student_work_index_url(:homework => @homework.id) + else + redirect_to user_homeworks_user_path(User.current.id) + end + } end end diff --git a/app/views/homework_common/score_rule_set.js.erb b/app/views/homework_common/score_rule_set.js.erb new file mode 100644 index 000000000..5ff42dff7 --- /dev/null +++ b/app/views/homework_common/score_rule_set.js.erb @@ -0,0 +1,6 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false}) %>'); +showModal('ajax-modal', '350px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule.html.erb b/app/views/student_work/_set_score_rule.html.erb index 7deed7fb8..508b89a1c 100644 --- a/app/views/student_work/_set_score_rule.html.erb +++ b/app/views/student_work/_set_score_rule.html.erb @@ -1,4 +1,7 @@ <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id},:method => "post") do |f|%> + <% if student_path %> + <%=hidden_field_tag 'student_path', params[:student_path], :value => student_path %> + <% end %>
    评分设置
    diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 72ca36ca9..0ea5e7055 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -20,7 +20,7 @@ //设置评分规则 function set_score_rule(){ - $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework}) %>'); + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework,:student_path => true}) %>'); showModal('ajax-modal', '350px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 848417d3e..b4beb7aa3 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -68,6 +68,9 @@
  • <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
  • +
  • + <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true) %> +
  • <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true) if homework_common.homework_detail_manual.comment_status == 1%>
  • diff --git a/config/routes.rb b/config/routes.rb index 649cfbb75..f7edee954 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -102,6 +102,7 @@ RedmineApp::Application.routes.draw do get 'stop_anonymous_comment' get 'alert_anonymous_comment' get 'start_evaluation_set' + get 'score_rule_set' post 'set_evaluation_attr' end collection do From 1ddb21d0a999545eee59420f43a3f9b078c48134 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 23 Oct 2015 14:53:53 +0800 Subject: [PATCH 19/58] =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=B1=95=E5=BC=80=E6=97=B6=E5=8E=BB=E6=8E=89?= =?UTF-8?q?line-height=EF=BC=8C=E6=94=B6=E8=B5=B7=E6=97=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0line-height?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_course_activity.html.erb | 2 ++ app/views/users/_user_activities.html.erb | 2 ++ app/views/users/_user_homework_list.html.erb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index b79964a8d..4a7cb900d 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -76,11 +76,13 @@ } $("#intro_content_show_<%= activity.id %>").click(function(){ $("#activity_description_<%= activity.id %>").toggleClass("maxh360"); + $("#activity_description_<%= activity.id%>").toggleClass("lh18"); $("#intro_content_show_<%= activity.id %>").hide(); $("#intro_content_hide_<%= activity.id %>").show(); }); $("#intro_content_hide_<%= activity.id %>").click(function(){ $("#activity_description_<%= activity.id %>").toggleClass("maxh360"); + $("#activity_description_<%= activity.id%>").toggleClass("lh18"); $("#intro_content_hide_<%= activity.id %>").hide(); $("#intro_content_show_<%= activity.id %>").show(); }); diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index a9584c80e..b7981bdbc 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -44,11 +44,13 @@ } $("#intro_content_show_<%= user_activity.id %>").click(function(){ $("#activity_description_<%= user_activity.id %>").toggleClass("maxh360"); + $("#activity_description_<%= user_activity.id%>").toggleClass("lh18"); $("#intro_content_show_<%= user_activity.id %>").hide(); $("#intro_content_hide_<%= user_activity.id %>").show(); }); $("#intro_content_hide_<%= user_activity.id %>").click(function(){ $("#activity_description_<%= user_activity.id %>").toggleClass("maxh360"); + $("#activity_description_<%= user_activity.id%>").toggleClass("lh18"); $("#intro_content_hide_<%= user_activity.id %>").hide(); $("#intro_content_show_<%= user_activity.id %>").show(); }); diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index ee3e05795..2e530d489 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -21,11 +21,13 @@ } $("#intro_content_show_<%= homework_common.id%>").click(function(){ $("#homework_description_<%= homework_common.id%>").toggleClass("maxh360"); + $("#homework_description_<%= homework_common.id%>").toggleClass("lh18"); $("#intro_content_show_<%= homework_common.id%>").hide(); $("#intro_content_hide_<%= homework_common.id%>").show(); }); $("#intro_content_hide_<%= homework_common.id%>").click(function(){ $("#homework_description_<%= homework_common.id%>").toggleClass("maxh360"); + $("#homework_description_<%= homework_common.id%>").toggleClass("lh18"); $("#intro_content_hide_<%= homework_common.id%>").hide(); $("#intro_content_show_<%= homework_common.id%>").show(); }); From b063be917b7fbb9d6f9d8c8e7e66fd9a998627d0 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 23 Oct 2015 15:45:48 +0800 Subject: [PATCH 20/58] =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9B=E5=BC=B9=E7=AA=97=E6=96=87=E5=AD=97?= =?UTF-8?q?=E4=B8=8Apadding=E5=87=8F=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/courses.css | 2 +- public/stylesheets/new_user.css | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 36a01f5d1..41771eb6e 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -158,7 +158,7 @@ a.postOptionLink:hover {color:#ffffff; background-color:#269ac9;} .homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;} .homepagePostProjectState {width:52px; height:20px; line-height:20px; border-radius:1px; background-color:#28be6c; color:#ffffff; text-align:center; vertical-align:middle; font-size:12px; display:inline-block; margin-left:5px;} .homepagePostAssignTo {float:left; font-size:14px; color:#269ac9;} -.homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -85px -150px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;} +.homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/public_icon.png) -27px -577px no-repeat; padding-left:25px; font-size:14px; margin-right:25px;} .homepagePostImageAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -86px -195px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;} .postAttSize {color:#888888; font-size:12px;} a.postGrey {color:#484848;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index ee3d96b4b..22be12633 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -501,7 +501,7 @@ input.sendSourceText:hover {background-color:#297fb8;} .popbox{/* width:300px; *//* height:100px; */position:fixed !important;/* z-index:100; */left:50%;top:50%;margin:-100px 0 0 -150px; /* background:#fff; */ -moz-border-radius:5px; /* -webkit-border-radius:5px; */ /* border-radius:5px; */ /* box-shadow:0px 0px 8px #194a81; */ /* overflow:auto; */} /*上传资源弹窗*/ .resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} -.uploadText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.uploadText {font-size:16px; color:#269ac9; line-height:16px; padding-top:15px; width:140px; display:inline-block;} .uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;} .uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#269ac9; border-radius:3px; float:left; margin-right:12px;} .uploadBox:hover {background-color:#297fb8;} @@ -684,7 +684,7 @@ a.postOptionLink:hover {color:#ffffff; background-color:#269ac9;} .homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;} .homepagePostProjectState {width:52px; height:20px; line-height:20px; border-radius:1px; background-color:#28be6c; color:#ffffff; text-align:center; vertical-align:middle; font-size:12px; display:inline-block; margin-left:5px;} .homepagePostAssignTo {float:left; font-size:14px; color:#269ac9;} -.homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -85px -150px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;} +.homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/public_icon.png) -27px -577px no-repeat; padding-left:25px; font-size:14px; margin-right:25px;} .homepagePostImageAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -86px -195px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;} .postAttSize {color:#888888; font-size:12px;} a.postGrey {color:#484848;} From 4bedc81524efc9d19ce9a3ef4ce55e53517a1477 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 23 Oct 2015 16:26:58 +0800 Subject: [PATCH 21/58] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8C=89=E9=92=AE=E4=BD=8D=E7=BD=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_student_work_attachment_form.html.erb | 70 +++++++++---------- public/stylesheets/new_user.css | 1 + public/stylesheets/public.css | 1 + 3 files changed, 37 insertions(+), 35 deletions(-) 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 7802f6eb6..265ff9be7 100644 --- a/app/views/student_work/_student_work_attachment_form.html.erb +++ b/app/views/student_work/_student_work_attachment_form.html.erb @@ -1,35 +1,35 @@ -
    - - -
    - - <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> - <%= file_field_tag 'attachments[dummy][file]', - :id => "_file#{work.id}", - :class => 'file_selector', - :multiple => true, - :onchange => "addInputFiles_board(this, '#{work.id}');", - :style => 'display:none', - :data => { - :max_file_size => Setting.attachment_max_size.to_i.kilobytes, - :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), - :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js'), - :description_placeholder => l(:label_optional_description), - :field_is_public => l(:field_is_public), - :are_you_sure => l(:text_are_you_sure), - :file_count => l(:label_file_count), - :delete_all_files => l(:text_are_you_sure_all), - :containerid => "#{work.id}" - } %> - - <%= l(:label_no_file_uploaded) %> - - (<%= l(:label_max_size) %>: - <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) - - <% content_for :header_tags do %> - <%= javascript_include_tag 'attachments' %> - <% end %> -
    - +
    + + +
    + + <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn mb0' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{work.id}", + :class => 'file_selector', + :multiple => true, + :onchange => "addInputFiles_board(this, '#{work.id}');", + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all), + :containerid => "#{work.id}" + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
    + diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index c1ddfa457..a3b7d7e76 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -105,6 +105,7 @@ a.linkGrey6:hover {color:#ffffff !important;} .mt12 { margin-top:12px;} .mt15 {margin-top:15px;} .mt19 {margin-top:19px !important;} +.mb0 {margin-bottom: 0px !important;} .mb4{ margin-bottom:4px;} .mb5{ margin-bottom:5px;} .mb8 {margin-bottom:8px !important;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 630b96bcd..d45b6f94d 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -108,6 +108,7 @@ h4{ font-size:14px; color:#3b3b3b;} .mt15 {margin-top:15px;} .mt19 {margin-top:19px !important;} .ml70{margin-left: 70px;} +.mb0 {margin-bottom: 0px !important;} .mb4{ margin-bottom:4px;} .mb5{ margin-bottom:5px;} .mb8 {margin-bottom:8px;} From bc3fbc270f2ca9de873429f613a3e373ca0bde52 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 23 Oct 2015 16:28:22 +0800 Subject: [PATCH 22/58] =?UTF-8?q?=E5=B0=86=E5=AD=A6=E7=94=9F=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=90=8C=E5=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 2 +- public/stylesheets/new_user.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index fb63f4fc0..91ea32a62 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -361,7 +361,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • From 2a76461cd115bf25f9520a48b06d29eddfec92b5 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 24 Oct 2015 15:34:43 +0800 Subject: [PATCH 33/58] =?UTF-8?q?=E7=AE=80=E5=8D=95=E5=8D=9A=E5=AE=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 + app/controllers/blog_comments_controller.rb | 121 ++++++++++++ app/controllers/blogs_controller.rb | 43 ++++ app/helpers/blog_comments_helper.rb | 2 + app/helpers/blogs_helper.rb | 2 + app/helpers/owner_type_helper.rb | 1 + app/models/blog.rb | 16 ++ app/models/blog_comment.rb | 24 +++ app/models/user.rb | 13 ++ .../blog_comments/_attachments_links.html.erb | 41 ++++ app/views/blog_comments/_blog_attachments.erb | 78 ++++++++ app/views/blog_comments/_edit.html.erb | 53 +++++ app/views/blog_comments/_new.html.erb | 62 ++++++ app/views/blog_comments/_reply_form.html.erb | 35 ++++ .../_simple_ke_reply_form.html.erb | 31 +++ app/views/blog_comments/edit.html.erb | 6 + app/views/blog_comments/quote.js.erb | 10 + app/views/blog_comments/reply.js.erb | 2 + app/views/blog_comments/show.html.erb | 175 ++++++++++++++++ app/views/blogs/_article.html.erb | 145 ++++++++++++++ app/views/blogs/_article_list.html.erb | 101 ++++++++++ app/views/blogs/index.html.erb | 187 ++++++++++++++++++ app/views/blogs/show.html.erb | 0 app/views/courses/join.js.erb | 2 +- app/views/layouts/new_base_user.html.erb | 18 +- db/migrate/20151022071611_create_blogs.rb | 15 ++ .../20151022071804_create_blog_comments.rb | 19 ++ db/schema.rb | 75 +++++-- public/javascripts/blog.js | 82 ++++++++ public/stylesheets/new_user.css | 2 + .../blog_comments_controller_spec.rb | 5 + spec/controllers/blogs_controller_spec.rb | 5 + spec/factories/blog_comments.rb | 6 + spec/factories/blogs.rb | 6 + 34 files changed, 1357 insertions(+), 28 deletions(-) create mode 100644 app/controllers/blog_comments_controller.rb create mode 100644 app/controllers/blogs_controller.rb create mode 100644 app/helpers/blog_comments_helper.rb create mode 100644 app/helpers/blogs_helper.rb create mode 100644 app/models/blog.rb create mode 100644 app/models/blog_comment.rb create mode 100644 app/views/blog_comments/_attachments_links.html.erb create mode 100644 app/views/blog_comments/_blog_attachments.erb create mode 100644 app/views/blog_comments/_edit.html.erb create mode 100644 app/views/blog_comments/_new.html.erb create mode 100644 app/views/blog_comments/_reply_form.html.erb create mode 100644 app/views/blog_comments/_simple_ke_reply_form.html.erb create mode 100644 app/views/blog_comments/edit.html.erb create mode 100644 app/views/blog_comments/quote.js.erb create mode 100644 app/views/blog_comments/reply.js.erb create mode 100644 app/views/blog_comments/show.html.erb create mode 100644 app/views/blogs/_article.html.erb create mode 100644 app/views/blogs/_article_list.html.erb create mode 100644 app/views/blogs/index.html.erb create mode 100644 app/views/blogs/show.html.erb create mode 100644 db/migrate/20151022071611_create_blogs.rb create mode 100644 db/migrate/20151022071804_create_blog_comments.rb create mode 100644 public/javascripts/blog.js create mode 100644 spec/controllers/blog_comments_controller_spec.rb create mode 100644 spec/controllers/blogs_controller_spec.rb create mode 100644 spec/factories/blog_comments.rb create mode 100644 spec/factories/blogs.rb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ee953e913..2c48857a2 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -227,6 +227,8 @@ class AttachmentsController < ApplicationController format.js elsif @attachment.container.is_a?(Message) format.html { redirect_to_referer_or new_board_message_path(@attachment.container) } + elseif @attachment.container.is_a?(BlogComment) + format.html { redirect_to_referer_or user_blog_blog_comment_path(:user_id=>@attachment.container.author.id,:blog_id=>@attachment.container.blog_id,:id=>@attachment.container.id)} elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb new file mode 100644 index 000000000..54def4c1a --- /dev/null +++ b/app/controllers/blog_comments_controller.rb @@ -0,0 +1,121 @@ +class BlogCommentsController < ApplicationController + include ApplicationHelper + before_filter :find_user + def index + + end + def create + if User.current.logged? + @article = BlogComment.new + @article.author = User.current + @article.blog_id = params[:blog_id] + @article.safe_attributes = params[:blog_comment] + if request.post? + @article.save_attachments(params[:attachments]) + if @article.save + # 更新kindeditor上传的图片资源所有者 + # if params[:asset_id] + # ids = params[:asset_id].split(',') + # update_kindeditor_assets_owner ids,@article.id,OwnerTypeHelper::BLOGCOMMENT + # end + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blogs_path(:user_id=>params[:user_id]) + else + respond_to do |format| + format.html { + render :layout => 'new_base_user' + } + end + end + else + redirect_to signin_path + end + end + def new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def show + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def update + @article = BlogComment.find(params[:id]) + @article.safe_attributes = params[:blog_comment] + @article.save_attachments(params[:attachments]) + if @article.save + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id]) + end + def destroy + @article = BlogComment.find(params[:id]) + unless @article.children.empty? #如果是文章被删,那么跳转到用户博客界面 + @article.children.delete + @article.delete + redirect_to user_blogs_path(:user_id=>User.current) + else + root = @article.root + @article.delete + redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) + end + end + + def edit + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + + def quote + @blogComment = BlogComment.find(params[:id]) + @subject = @blogComment.title + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " + @temp = BlogComment.new + @temp.content = "
    #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}
    #{@blogComment.content.html_safe}
    ".html_safe + respond_to do | format| + format.js + end + end + + #回复 + def reply + @article = BlogComment.find(params[:id]).root + @quote = params[:quote][:quote] + @blogComment = BlogComment.new + @blogComment.author = User.current + @blogComment.blog = Blog.find(params[:blog_id]) + params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @blogComment.safe_attributes = params[:blog_comment] + @blogComment.content = @quote + @blogComment.content + @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @article.children << @blogComment + @user_activity_id = params[:user_activity_id] + + attachments = Attachment.attach_files(@blogComment, params[:attachments]) + render_attachment_warning_if_needed(@blogComment) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article)} + format.js + end + rescue Exception => e #如果上面的代码执行发生异常就捕获 + flash[:notice] = e.message + end + + private + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb new file mode 100644 index 000000000..6be17f1d3 --- /dev/null +++ b/app/controllers/blogs_controller.rb @@ -0,0 +1,43 @@ +class BlogsController < ApplicationController + before_filter :find_blog,:except => [:index,:create,:new] + before_filter :find_user + def index + @articls = @user.blog.articles + @article = BlogComment.new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def create + + end + def new + + end + def show + + end + def update + + end + def destory + + end + def edit + + end + private + def find_blog + @blog = Blog.find(params[:blog_id]) + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条 + @blog = Blog.create(:name=>User.find(params[:id]).realname , + :description=>'', + :author_id=>params[:id]) + end + end + + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/helpers/blog_comments_helper.rb b/app/helpers/blog_comments_helper.rb new file mode 100644 index 000000000..2b0c3e5bd --- /dev/null +++ b/app/helpers/blog_comments_helper.rb @@ -0,0 +1,2 @@ +module BlogCommentsHelper +end diff --git a/app/helpers/blogs_helper.rb b/app/helpers/blogs_helper.rb new file mode 100644 index 000000000..cc0dbd200 --- /dev/null +++ b/app/helpers/blogs_helper.rb @@ -0,0 +1,2 @@ +module BlogsHelper +end diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index c03f2d19e..7119d4f60 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -7,4 +7,5 @@ module OwnerTypeHelper BID = 6 JOURNALSFORMESSAGE = 7 HOMEWORKCOMMON = 8 + BLOGCOMMENT=9 end \ No newline at end of file diff --git a/app/models/blog.rb b/app/models/blog.rb new file mode 100644 index 000000000..bd338cdad --- /dev/null +++ b/app/models/blog.rb @@ -0,0 +1,16 @@ +class Blog < ActiveRecord::Base + # attr_accessible :title, :body + include Redmine::SafeAttributes + belongs_to :user + has_many :articles, :class_name => 'BlogComment', :conditions => "#{BlogComment.table_name}.parent_id IS NULL ", :order => "#{BlogComment.table_name}.created_on DESC" + has_many :blog_comments, :dependent => :destroy, :order => "#{BlogComment.table_name}.created_on DESC" + belongs_to :last_comment, :class_name => 'BlogComment', :foreign_key => :last_comment_id + acts_as_tree :dependent => :nullify + #acts_as_list :scope => '(user_id = #{user_id} AND parent_id #{user_id ? = "#{parent_id}" : "IS NULL"})' + acts_as_watchable + + validates :name, presence: true, length: {maximum: 30} + validates :description, length: {maximum: 255} + + safe_attributes 'name', 'description' +end diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb new file mode 100644 index 000000000..92970b663 --- /dev/null +++ b/app/models/blog_comment.rb @@ -0,0 +1,24 @@ +class BlogComment < ActiveRecord::Base + # attr_accessible :title, :body + include Redmine::SafeAttributes + belongs_to :blog + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + + acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC" + acts_as_attachable + belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id' + + acts_as_watchable + + validates_presence_of :title, :content + validates_length_of :title, :maximum => 255 + #validate :cannot_reply_to_locked_comment, :on => :create + safe_attributes 'title', 'content',"sticky", "locked" + + def deleted_attach_able_by? user + (user && user.logged? && (self.author == user) ) || user.admin? + end + + def project + end +end diff --git a/app/models/user.rb b/app/models/user.rb index d66785460..7aaae3492 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,6 +93,7 @@ class User < Principal has_many :changesets, :dependent => :nullify has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" + has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang @@ -255,6 +256,18 @@ class User < Principal # count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count end + def blog + @blog = Blog.where("author_id = #{self.id}").all[0] + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条,并且跳转 + @blog = Blog.create(:name=>(User.find(self.id).realname), + :description=>'', + :author_id=>self.id) + @blog.save + end + @blog + end + # 查询指派给我的缺陷记录 def count_new_issue_assign_to self.issue_assigns diff --git a/app/views/blog_comments/_attachments_links.html.erb b/app/views/blog_comments/_attachments_links.html.erb new file mode 100644 index 000000000..ca0f41d16 --- /dev/null +++ b/app/views/blog_comments/_attachments_links.html.erb @@ -0,0 +1,41 @@ +
    + <% for attachment in attachments %> + + + + <% if options[:length] %> + + <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true,:length => options[:length] -%> + (<%= number_to_human_size attachment.filesize , :precision => 0 %>) + <% if options[:deletable] %> + <%#= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + + <% end %> +
    + <% else %> + + <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true, :length => 45 -%> + (<%= number_to_human_size attachment.filesize , :precision => 0 %>) + <% if options[:deletable] %> + + <% end %> +
    + <% end %> + <% end %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
    + <% images.each do |attachment| %> +
    <%= thumbnail_tag(attachment) %>
    + <% end %> +
    + <% end %> + <% end %> +
    diff --git a/app/views/blog_comments/_blog_attachments.erb b/app/views/blog_comments/_blog_attachments.erb new file mode 100644 index 000000000..48fe91099 --- /dev/null +++ b/app/views/blog_comments/_blog_attachments.erb @@ -0,0 +1,78 @@ + +
    + +<% if defined?(container) && container && container.saved_attachments %> + <% container.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') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
    + <% end %> + <% container.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') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
    + <% end %> +<% end %> +
    +
    + + <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> + + <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + 上传附件 + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '' : 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js', :project => container), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
    + diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb new file mode 100644 index 000000000..d56557ce7 --- /dev/null +++ b/app/views/blog_comments/_edit.html.erb @@ -0,0 +1,53 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +
    +
    +
    +
    + +

    +
    +
    + <%if User.current.id == user.id%> +
    + <%= f.check_box :sticky%> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <%= f.check_box :locked%> + <%= label_tag 'message_locked', l(:label_board_locked) %> +
    +
    + <% end %> +
    +
    + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + <%= f.kindeditor :content,:editor_id => 'message_content_editor', + :owner_id => article.nil? ? 0: article.id, + :owner_type => OwnerTypeHelper::BLOGCOMMENT, + :width => '100%', + :height => 300, + :minHeight=>300, + :class => 'talk_text fl', + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
    +

    +
    +
    +
    +
    + <%= render :partial => 'blog_comments/blog_attachments', :locals => {:container => article} %> +
    +
    +
    +
    + 确定 + + 取消 +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/blog_comments/_new.html.erb b/app/views/blog_comments/_new.html.erb new file mode 100644 index 000000000..2a2281a40 --- /dev/null +++ b/app/views/blog_comments/_new.html.erb @@ -0,0 +1,62 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +
    +
    +
    +
    + +

    +
    + +
    + <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %> + +
    +
    \ No newline at end of file diff --git a/app/views/blog_comments/_reply_form.html.erb b/app/views/blog_comments/_reply_form.html.erb new file mode 100644 index 000000000..cc4c0e952 --- /dev/null +++ b/app/views/blog_comments/_reply_form.html.erb @@ -0,0 +1,35 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +
  • + +
    <%= f.text_field :title, { size: 60, id: "message_subject",:class=>"talk_input w585 fl" }.merge({ hidden: "hidden"}) %>
    + +
    +
  • +
  • +
    +
  • +
  • +
    + + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + + + <%= f.kindeditor :content, :editor_id => 'message_content_editor', + :width => '99%', + :height => 100, + :minHeight=>100, + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
    +

    +
  • +
    +
  • +
    +
  • diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb new file mode 100644 index 000000000..fa7ff0c4a --- /dev/null +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -0,0 +1,31 @@ + + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    +
    +
    + <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb new file mode 100644 index 000000000..a878063db --- /dev/null +++ b/app/views/blog_comments/edit.html.erb @@ -0,0 +1,6 @@ +<% if User.current.logged? && User.current.id == @user.id %> + <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id},:method=>'PUT', + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb new file mode 100644 index 000000000..4d16745ca --- /dev/null +++ b/app/views/blog_comments/quote.js.erb @@ -0,0 +1,10 @@ +if($("#reply_message_<%= @blogComment.id%>").length > 0) { + $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject}) %>"); + $(function(){ + $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); + $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); + init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { + $("#reply_to_message_<%= @blogComment.id%>").replaceWith("

    "); +} \ No newline at end of file diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb new file mode 100644 index 000000000..7ebe4d077 --- /dev/null +++ b/app/views/blog_comments/reply.js.erb @@ -0,0 +1,2 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb new file mode 100644 index 000000000..922fde8ed --- /dev/null +++ b/app/views/blog_comments/show.html.erb @@ -0,0 +1,175 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + + + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> +
    +
    + <% if @article.author.id == User.current.id%> + + <%end%> + +
    + +
    + <% if @article.try(:author).try(:realname) == ' ' %> + <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% else %> + <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% end %> +
    +
    <%= format_time( @article.created_on)%>
    +
    +
    + <%= @article.content.html_safe%> +
    +
    +
    + <%#= link_to_attachments_course @topic, :author => false %> + <% if @article.attachments.any?%> + <% options = {:author => true, :deletable => true} %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %> + <% end %> +
    +
    +
    +
    +
    + <% count=0 %> + <% if @article.parent %> + <% count=@article.parent.children.count%> + <% else %> + <% count=@article.children.count%> + <% end %> +
    + <% unless count == 0 %> +
    +
    回复(<%=count %>)
    +
    + +
    +
    + <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> + +
    +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> +
    +
    + <%= reply.content.html_safe%> +
    +
    + <%= format_time(reply.created_on) %> + +
    +

    +
    +
    +
    + <% end %> +
    + + <% end %> +
    + <% if !@article.locked? && User.current.logged?%> +
    + +
    +
    + <%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'canel_message_replay();', :class => "blue_btn grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %> + <% end %> +
    +
    +
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb new file mode 100644 index 000000000..943d21852 --- /dev/null +++ b/app/views/blogs/_article.html.erb @@ -0,0 +1,145 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
    +
    +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%> +
    + + <% if activity.sticky == 1%> + 置顶 + <% end%> + <% if activity.locked%> +        + <% end%> +
    +
    + 发帖时间:<%= format_time(activity.created_on) %> +
    + +
    + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
    +
    +
    + <% if activity.attachments.any?%> + <% options = {:author => true, :deletable => false } %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %> + <% end %> +
    + +
    +
    +
    + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
    +
    +
    +
    回复( + <%= count %> + )
    +
    <%#=format_date(activity.updated_on)%>
    + <%if count > 3 %> + + <% end %> +
    + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.children.reorder("created_on desc").each do |reply|%> + + <% replies_all_i=replies_all_i+1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
      +
      + <%= reply.content.html_safe %> +
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + + <% if !activity.locked? %> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%> + + + + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    + <% end %> +
    +
    diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb new file mode 100644 index 000000000..e397da2cc --- /dev/null +++ b/app/views/blogs/_article_list.html.erb @@ -0,0 +1,101 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> + + + +
    +
    +
    + <%= @user.name%>的博客 +
    +
    + <% if User.current.logged? && User.current.id == @user.id %> + <%= labelled_form_for @article, :url =>{:controller=>'blog_comments',:action => 'create',:user_id=>user.id , :blog_id => blog.id}, + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/new', :locals => {:f => f, :article => @article, :edit_mode => false, :user => @user} %> + <% end %> + <% end %> + + <% if topics%> + <% topics.each do |topic| %> + + <% if topic %> + <%= render :partial => 'blogs/article', :locals => {:activity => topic, :user_activity_id => topic.id} %> + <% end %> + <% end %> + + <%# if topics.count == 10 %> + + <%# end %> + <% end%> +
    + + diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb new file mode 100644 index 000000000..0e69d1654 --- /dev/null +++ b/app/views/blogs/index.html.erb @@ -0,0 +1,187 @@ + + +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> + + +<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.created_on desc"), :page => 0, :user => @user} %> + + + diff --git a/app/views/blogs/show.html.erb b/app/views/blogs/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb index b4e6a98ec..4965de676 100644 --- a/app/views/courses/join.js.erb +++ b/app/views/courses/join.js.erb @@ -1,4 +1,4 @@ -<% if @object_id && @state != 6%> +<% if @object_id && @state != 6 && @state != 4 %> $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@course, @user)) %>"); <% end %> <% if @state %> diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f3adb0155..01c73addb 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -71,6 +71,14 @@
    +
    +
    + <%= link_to(@user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count, + {:controller => 'blogs', :action => 'index', :user_id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> +
    +
    博客
    +
    +
    <%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %> @@ -84,14 +92,8 @@
    粉丝
    -
    -
    -
    - <%= link_to(format("%.2f" ,get_option_number(@user,1).total_score ).to_i, - {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> -
    -
    积分
    -
    + +
    diff --git a/db/migrate/20151022071611_create_blogs.rb b/db/migrate/20151022071611_create_blogs.rb new file mode 100644 index 000000000..dd782c78f --- /dev/null +++ b/db/migrate/20151022071611_create_blogs.rb @@ -0,0 +1,15 @@ +class CreateBlogs < ActiveRecord::Migration + def change + create_table :blogs do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.integer "position", :default => 1 + t.integer "article_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comments_id" + t.integer "parent_id" + t.integer "author_id" + t.timestamps + end + end +end diff --git a/db/migrate/20151022071804_create_blog_comments.rb b/db/migrate/20151022071804_create_blog_comments.rb new file mode 100644 index 000000000..254dfd692 --- /dev/null +++ b/db/migrate/20151022071804_create_blog_comments.rb @@ -0,0 +1,19 @@ +class CreateBlogComments < ActiveRecord::Migration + def change + create_table :blog_comments do |t| + t.integer "blog_id", :null => false + t.integer "parent_id" + t.string "title", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comment_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4aa12f627..b18ffb544 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 => 20151020021234) do +ActiveRecord::Schema.define(:version => 20151022071804) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -144,6 +144,36 @@ ActiveRecord::Schema.define(:version => 20151020021234) do t.integer "open_anonymous_evaluation", :default => 1 end + create_table "blog_comments", :force => true do |t| + t.integer "blog_id", :null => false + t.integer "parent_id" + t.string "title", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comment_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "blogs", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.integer "position", :default => 1 + t.integer "article_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comments_id" + t.integer "parent_id" + t.integer "author_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "boards", :force => true do |t| t.integer "project_id", :null => false t.string "name", :default => "", :null => false @@ -497,26 +527,23 @@ ActiveRecord::Schema.define(:version => 20151020021234) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 + create_table "dts", :force => true do |t| + t.string "IPLineCode" t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 + t.string "Num" + t.string "Variable" + t.string "TraceInfo" + t.string "Method" + t.string "File" + t.string "IPLine" + t.string "Review" + t.string "Category" + t.string "Defect" + t.string "PreConditions" + t.string "StartLine" t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "enabled_modules", :force => true do |t| @@ -785,6 +812,16 @@ ActiveRecord::Schema.define(:version => 20151020021234) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_details_copy", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" diff --git a/public/javascripts/blog.js b/public/javascripts/blog.js new file mode 100644 index 000000000..62dbaedc5 --- /dev/null +++ b/public/javascripts/blog.js @@ -0,0 +1,82 @@ +function regexTopicSubject() { + var name = $("#message_subject").val(); + if(name.length ==0) + { + $("#subjectmsg").text("标题不能为空"); + $("#subjectmsg").css('color','#ff0000'); + $("#message_subject").focus(); + return false; + } + else if(name.length <= 255) + { + $("#subjectmsg").text("填写正确"); + $("#subjectmsg").css('color','#008000'); + return true; + } + else + { + $("#subjectmsg").text("标题超过255个字符"); + $("#subjectmsg").css('color','#ff0000'); + $("#message_subject").focus(); + return false; + } +} + +function submit_article() +{ + if(regexTopicSubject() && regexTopicDescription()) + { + message_content_editor.sync(); + $("#message-form").submit(); + } +} + +function regexTopicDescription() +{ + var name = message_content_editor.html(); + if(name.length ==0) + { + $("#message_content_span").text("描述不能为空"); + $("#message_content_span").css('color','#ff0000'); + return false; + } + else if(name.length >=6000){ + $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)"); + $("#message_content_span").css('color','#ff0000'); + return false; + } + else + { + $("#message_content_span").text("填写正确"); + $("#message_content_span").css('color','#008000'); + return true; + } +} + +function MessageReplayVevify() { + var content = message_content_editor.html();//$.trim($("#message_content").val()); + 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; + } +} +function submit_message_replay() +{ + if(MessageReplayVevify()) + { + message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值 + $("#message_form").submit(); + } +} + +function canel_message_replay() +{ + $("#reply").hide(200); + $("#message_quote").html(""); +} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 872d8df6d..0a61e0676 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1296,3 +1296,5 @@ a:hover.link_file_a{ background:url(../images/pic_file.png) 0 -25px no-repeat; c .list_style ol li{list-style-type: decimal;margin-left: 20px;} .list_style ul li{list-style-type: disc;margin-left: 20px;} + +.ReplyToMessageInputContainer {width: 582px;float: left;} diff --git a/spec/controllers/blog_comments_controller_spec.rb b/spec/controllers/blog_comments_controller_spec.rb new file mode 100644 index 000000000..585af2555 --- /dev/null +++ b/spec/controllers/blog_comments_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe BlogCommentsController, :type => :controller do + +end diff --git a/spec/controllers/blogs_controller_spec.rb b/spec/controllers/blogs_controller_spec.rb new file mode 100644 index 000000000..5b618caa8 --- /dev/null +++ b/spec/controllers/blogs_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe BlogsController, :type => :controller do + +end diff --git a/spec/factories/blog_comments.rb b/spec/factories/blog_comments.rb new file mode 100644 index 000000000..e168f824a --- /dev/null +++ b/spec/factories/blog_comments.rb @@ -0,0 +1,6 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :blog_comment do + end +end diff --git a/spec/factories/blogs.rb b/spec/factories/blogs.rb new file mode 100644 index 000000000..a1a640f89 --- /dev/null +++ b/spec/factories/blogs.rb @@ -0,0 +1,6 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :blog do + end +end From 5e4e5419f10f45600449354b3789ae4b96b84145 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 24 Oct 2015 15:37:27 +0800 Subject: [PATCH 34/58] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=89=8D=E5=85=81=E8=AE=B8=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/blog_comments/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 922fde8ed..e8f6c3b81 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -81,7 +81,7 @@
    <%#= link_to_attachments_course @topic, :author => false %> <% if @article.attachments.any?%> - <% options = {:author => true, :deletable => true} %> + <% options = {:author => true, :deletable => false} %> <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %> <% end %>
    From a42a58fb42ec457e77d92141a673969b5e3955fa Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Sat, 24 Oct 2015 16:09:44 +0800 Subject: [PATCH 35/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=81=AB=E7=8B=90?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E5=87=BA=E7=8E=B0=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9C=81=E7=95=A5=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/new_user.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 3b79af2bb..5ccf68516 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1269,7 +1269,7 @@ a:hover.tijiao{ background:#0f99a9;} #cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;} #cboxNext{position:absolute; bottom:0px; left:63px; color:#444;} #cboxClose{position:absolute; bottom:0; right:0; display:block; color:#444;} -.system_message_style {line-height: 19.1px; max-width: 681px; work-wrap: break-word; word-break: break-all; text-overflow:clip;} +.system_message_style {line-height: 19.1px; max-width: 681px; work-wrap: break-word; word-break: break-all; text-overflow:clip; z-index:9999} .system_message_style img {max-width: 100%;} /*20150906关联项目LB*/ a.RalationIcon{ background: url(../images/homepage_icon.png) -183px -396px no-repeat; height:20px; display:block; padding-left:20px; color:#888888;} From 479b23a1fd77879841b57c157df84218c3aebc39 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 24 Oct 2015 16:12:03 +0800 Subject: [PATCH 36/58] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E7=BB=99=E5=87=BA=E6=8F=90=E7=A4=BA=20?= =?UTF-8?q?=E5=B9=B6=E4=B8=8D=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=20?= =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E9=87=8D=E5=A4=8D=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E7=9A=84=E7=94=B3=E8=AF=B7=20=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E7=A1=AE=E5=AE=9A=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 12 ++++++++++-- app/views/courses/join.js.erb | 10 +++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 1e0bfbec2..fb01e0398 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -300,6 +300,7 @@ class CoursesService #@state == 4 您加入的课程不存在 #@state == 5 您还未登录 #@state == 6 申请成功,请等待审核完毕 + #@state == 7 您已经发送过申请了,请耐心等待 #@state 其他 未知错误,请稍后再试 def join_course params,current_user course = Course.find_by_id params[:object_id] @@ -313,6 +314,8 @@ class CoursesService #如果加入角色为学生 if params[:role] == "10" @state = 3 + elsif current_user.allowed_to?(:as_teacher,course) + @state = 3 else #如果加入角色为教师或者教辅 CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) @@ -330,8 +333,13 @@ class CoursesService StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) @state = 0 else - CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) - @state = 6 + #如果已经发送过消息了,那么就要给个提示 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 + @state = 7 + else + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end end else @state = 1 diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb index 53cf250d7..e2de705fe 100644 --- a/app/views/courses/join.js.erb +++ b/app/views/courses/join.js.erb @@ -5,21 +5,25 @@ $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@c <% if @state == 0 %> alert("加入成功"); hideModal($("#popbox02")); -$("#try_join_course_link").replaceWith(" 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); -window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>" +$("#try_join_course_link").replaceWith(" 'index',:course=>@course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 1 %> alert("密码错误"); <% elsif @state == 2 %> alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)"); <% elsif @state == 3 %> alert("您已经加入了课程"); -window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>" +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 4 %> alert("您加入的课程不存在"); <% elsif @state == 5 %> alert("您还未登录"); <% elsif @state == 6 %> alert("申请成功,请等待审核") +hideModal($("#popbox02")); +<% elsif @state == 7%> + alert("您已经发送过申请了,请耐心等待") + hideModal($("#popbox02")); <% else %> alert("未知错误,请稍后再试"); <% end %> From 4431f4664f5cce2abc6191708ac6bcf8e0a8ed67 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 24 Oct 2015 16:16:04 +0800 Subject: [PATCH 37/58] =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=A1=AE=E5=AE=9A?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/join.js.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb index e2de705fe..8e6f8ce20 100644 --- a/app/views/courses/join.js.erb +++ b/app/views/courses/join.js.erb @@ -4,7 +4,7 @@ $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@c <% if @state %> <% if @state == 0 %> alert("加入成功"); -hideModal($("#popbox02")); +hidden_join_course_form(); $("#try_join_course_link").replaceWith(" 'index',:course=>@course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 1 %> @@ -19,11 +19,11 @@ alert("您加入的课程不存在"); <% elsif @state == 5 %> alert("您还未登录"); <% elsif @state == 6 %> -alert("申请成功,请等待审核") -hideModal($("#popbox02")); +alert("申请成功,请等待审核"); +hidden_join_course_form(); <% elsif @state == 7%> - alert("您已经发送过申请了,请耐心等待") - hideModal($("#popbox02")); + alert("您已经发送过申请了,请耐心等待"); +hidden_join_course_form(); <% else %> alert("未知错误,请稍后再试"); <% end %> From 586cde6f87c1d89fac58681b2449c7aa07ec73d9 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 09:04:09 +0800 Subject: [PATCH 38/58] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=88=90=E4=B8=BA=E8=AF=BE=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E8=80=81=E5=B8=88=E6=88=96=E6=95=99=E8=BE=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7425692c0..2ffc7338e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -918,6 +918,9 @@ class UsersController < ApplicationController end def show + #更新用户申请成为课程老师或教辅消息的状态 + join_course_messages = CourseMessage.where("course_message_type =? and course_message_id =? and viewed =?", 'JoinCourseRequest', @user.id, false) + join_course_messages.update_all(:viewed => true) @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" From 69bc26033e09f88de292548c7587151f9fd65da6 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 26 Oct 2015 10:54:27 +0800 Subject: [PATCH 39/58] =?UTF-8?q?=E9=98=B2=E6=AD=A2url=E5=88=A0=E5=87=8F?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20url=E5=8D=9A=E5=AE=A2=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6=E6=94=B9=E4=B8=BA20000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blogs_controller.rb | 6 +++++- public/javascripts/blog.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 6be17f1d3..07bf60464 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -28,7 +28,11 @@ class BlogsController < ApplicationController end private def find_blog - @blog = Blog.find(params[:blog_id]) + if params[:blog_id] + @blog = Blog.find(params[:blog_id]) + else + render_404 + end if @blog.nil? #如果某个user的blog不存在,那么就创建一条 @blog = Blog.create(:name=>User.find(params[:id]).realname , diff --git a/public/javascripts/blog.js b/public/javascripts/blog.js index 62dbaedc5..feaab0100 100644 --- a/public/javascripts/blog.js +++ b/public/javascripts/blog.js @@ -40,8 +40,8 @@ function regexTopicDescription() $("#message_content_span").css('color','#ff0000'); return false; } - else if(name.length >=6000){ - $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)"); + else if(name.length >=20000){ + $("#message_content_span").text("描述最多20000个汉字(或40000个英文字符)"); $("#message_content_span").css('color','#ff0000'); return false; } From 2824b564815aab96ec1f8191fc65c280d22a81d2 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 26 Oct 2015 11:54:59 +0800 Subject: [PATCH 40/58] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=95=99=E5=B8=88=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 24 +++++++++++++++++++++++- public/stylesheets/new_user.css | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f3adb0155..7e7a1adf7 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -103,7 +103,21 @@ 课程 <% if is_current_user%> <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> - <%=link_to "", new_course_path(:host=> Setting.host_course), :class => "homepageMenuSetting fr", :title => "新建课程"%> +
    +
      +
    • +
        +
      • + <%= link_to "新建课程", new_course_path(:host=> Setting.host_course), :class => "menuGrey"%> +
      • + +
      • + <%= link_to "加入课程",join_private_courses_courses_path,:remote => true,:class => "menuGrey",:method => "post"%> +
      • +
      +
    • +
    +
    <% else%> <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:remote => true, :title => "加入课程"%> <% end%> @@ -201,5 +215,13 @@
    + diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 3b79af2bb..29d3397c6 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -696,6 +696,11 @@ a:hover.gz_btn{ color:#ff5722;} .lh18 {line-height: 18px;} .maxh360 {max-height: 360px;} +.courseMenu {width:30px; display:block; float:right;height: 50px;} +.courseMenuIcon {display:inline-block; background:url(../images/homepage_icon2.png) -190px -365px no-repeat; width:15px; height:15px; margin-top: 16px; margin-right: 15px; position: relative;line-height:0;} +.topnav_course_menu{display: none; border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-7px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); margin-top: 20px;} +.topnav_course_menu a{color:#269ac9;} + /*课程主页css*/ .homepageCoursesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-65px; font-size:12px; color:#4b4b4b; line-height:2; z-index:9999; display:none;} From d509ef01e83ed4fe03cf53f18556853751ed8007 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 13:26:49 +0800 Subject: [PATCH 41/58] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=8F=8D=E9=A6=88=E7=9A=84=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 5 +++++ app/controllers/courses_controller.rb | 4 ++++ app/controllers/users_controller.rb | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86c220bd2..7632cf591 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -381,6 +381,11 @@ class ApplicationController < ActionController::Base if allowed true else + if params[:action] == 'show' + #更新申请结果反馈消息的状态 + messages = CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?", 'CourseRequestDealResult', @course.id, User.current.id, false) + messages.update_all(:viewed => true) + end if @course && @course.archived? render_403 :message => :notice_not_authorized_archived_project else diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 56252253a..042311961 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -617,6 +617,10 @@ class CoursesController < ApplicationController create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) + #更新申请结果反馈消息的状态 + course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false) + course_request_messages.update_all(:viewed => true) + course_activities = @course.course_activities @canShowRealName = User.current.member_of_course? @course @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2ffc7338e..e2edcb44a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -919,7 +919,8 @@ class UsersController < ApplicationController def show #更新用户申请成为课程老师或教辅消息的状态 - join_course_messages = CourseMessage.where("course_message_type =? and course_message_id =? and viewed =?", 'JoinCourseRequest', @user.id, false) + join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", + params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) join_course_messages.update_all(:viewed => true) @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" From 5fb1291bf8b15c84e7fb5ee6a4c96d6039dc3721 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 26 Oct 2015 14:15:23 +0800 Subject: [PATCH 42/58] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/_user_message_course.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e2edcb44a..2a646f5ce 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -919,7 +919,7 @@ class UsersController < ApplicationController def show #更新用户申请成为课程老师或教辅消息的状态 - join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", + join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and u ser_id =? and course_message_id =? and viewed =?", params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) join_course_messages.update_all(:viewed => true) @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index d7042b6c2..2398fd8c5 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -442,7 +442,7 @@ ">您有了新的课程成员申请:
  • - <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id)), + <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> From 5f5a235e4bc13c61271105104e5fbae007d13e49 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 26 Oct 2015 14:35:42 +0800 Subject: [PATCH 43/58] =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8E=E9=A6=96=E9=A1=B5=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=8F=91=E7=94=9F=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/_join_private_course.html.erb | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 4122a7105..5748d981e 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -4,33 +4,33 @@ 快速进入课程通道