From 5cf6b7e76afc83018bd71e5e5905418db210d73d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 09:38:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=97=B6=E9=97=B4--->=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 7159c3c83..6eb722981 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -24,7 +24,7 @@ <%= course_activity_desc activity%>
- <%= l :label_activity_time %> : <%= format_time(activity.created_at) %> + <%= activity.course_act_type == "Course" ? l(:label_create_time) : l(:label_activity_time) %> : <%= format_time(activity.created_at) %>

<%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %> From 35d6c76a8e99ba2a9d5487e29ba1726501f6a935 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 13:55:46 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50811083234_update_course_activity_time.rb | 22 ------------------- .../20150814024425_change_attachment_time.rb | 13 +++++++++++ ...50814031258_update_course_activity_time.rb | 22 +++++++++++++++++++ db/schema.rb | 2 +- 4 files changed, 36 insertions(+), 23 deletions(-) delete mode 100644 db/migrate/20150811083234_update_course_activity_time.rb create mode 100644 db/migrate/20150814024425_change_attachment_time.rb create mode 100644 db/migrate/20150814031258_update_course_activity_time.rb diff --git a/db/migrate/20150811083234_update_course_activity_time.rb b/db/migrate/20150811083234_update_course_activity_time.rb deleted file mode 100644 index 9ba8140d8..000000000 --- a/db/migrate/20150811083234_update_course_activity_time.rb +++ /dev/null @@ -1,22 +0,0 @@ -class UpdateCourseActivityTime < ActiveRecord::Migration - def up - count = CourseActivity.all.count / 10 + 1 - transaction do - for i in 1 ... count do i - CourseActivity.page(i).per(10).each do |activity| - if activity.course_act - if activity.course_act.respond_to?("created_at") - activity.created_at = activity.course_act.created_at - elsif activity.course_act.respond_to?("created_on") - activity.created_at = activity.course_act.created_on - end - activity.save - end - end - end - end - end - - def down - end -end diff --git a/db/migrate/20150814024425_change_attachment_time.rb b/db/migrate/20150814024425_change_attachment_time.rb new file mode 100644 index 000000000..fd1ffb7a7 --- /dev/null +++ b/db/migrate/20150814024425_change_attachment_time.rb @@ -0,0 +1,13 @@ +class ChangeAttachmentTime < ActiveRecord::Migration + def up + Attachment.where("container_type = 'Course'").each do |attachment| + if attachment.container && attachment.container.created_at.to_i > attachment.created_on.to_i + attachment.created_on = attachment.container.created_at + 3600 * 24 + attachment.save + end + end + end + + def down + end +end diff --git a/db/migrate/20150814031258_update_course_activity_time.rb b/db/migrate/20150814031258_update_course_activity_time.rb new file mode 100644 index 000000000..155e212a3 --- /dev/null +++ b/db/migrate/20150814031258_update_course_activity_time.rb @@ -0,0 +1,22 @@ +class UpdateCourseActivityTime < ActiveRecord::Migration + def up + count = CourseActivity.all.count / 10 + 1 + transaction do + for i in 1 ... count do i + CourseActivity.page(i).per(10).each do |activity| + if activity.course_act + if activity.course_act.respond_to?("created_at") + activity.created_at = activity.course_act.created_at + elsif activity.course_act.respond_to?("created_on") + activity.created_at = activity.course_act.created_on + end + activity.save + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 1488ca365..2014bf1ef 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 => 20150811083234) do +ActiveRecord::Schema.define(:version => 20150814031258) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 50fa03d00cd0a2bdfd6184a68945ee5fb6d94a6b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:44:31 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=AF=A5=E9=97=AE=E5=8D=B7=E6=89=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=9C=A8=E5=8A=A8=E6=80=81=EF=BC=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=90=8E=E5=8F=96=E6=B6=88=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=AF=A5=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 34a381246..3adbbb791 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -10,7 +10,7 @@ class Poll < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy - after_create :act_as_activity, :act_as_course_activity + before_save :act_as_activity, :act_as_course_activity acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -32,7 +32,11 @@ class Poll < ActiveRecord::Base #课程动态公共表记录 def act_as_course_activity if self.polls_type == "Course" - self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + if self.polls_status == 2 #问卷是发布状态 + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + elsif self.polls_status == 1 #问卷是新建状态 + self.course_acts.destroy_all + end end end end From a8283a28617d18113b45e511ad22c43bd7b0174c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:46:14 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index ac142f5a1..f9fb31969 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -704,7 +704,7 @@ module CoursesHelper url = course_feedback_path(activity.course) when "Poll" title = "问卷 " + activity.course_act.polls_name - url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id) + url = poll_path(activity.course_act_id) end end link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb" From 16aea5ef4291b6c7371315f33730e2a5a4b7755c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 15:44:54 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=BF=9F=E4=BA=A4=E6=89=A3=E5=88=860-50?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_manual_form.html.erb | 3 ++- .../_homework_detail_programing_form.html.erb | 3 ++- public/javascripts/course.js | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/views/homework_common/_homework_detail_manual_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb index ffec93e73..3af12973a 100644 --- a/app/views/homework_common/_homework_detail_manual_form.html.erb +++ b/app/views/homework_common/_homework_detail_manual_form.html.erb @@ -48,7 +48,8 @@