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 @@
-
- <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
+ <%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
+
分
diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb
index 8c589c040..829905327 100644
--- a/app/views/homework_common/_homework_detail_programing_form.html.erb
+++ b/app/views/homework_common/_homework_detail_programing_form.html.erb
@@ -43,7 +43,8 @@
-
- <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
+ <%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
+
分
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 6ba202b28..be29fdc30 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -412,6 +412,24 @@ function regex_homework_name()
}
}
+//处理迟交扣分
+function check_late_penalty()
+{
+ var obj = $("input[name='late_penalty']");
+ var regex = /^\d+$/;
+ if(regex.test(obj.val()))
+ {
+ if(obj.val() > 50)
+ {
+ obj.val("50");
+ }
+ }
+ else
+ {
+ obj.val("0");
+ }
+}
+
//验证匿评数量
function regex_evaluation_num()
{
From 6051d0797d4018af815c3d45b31a681641451a89 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 14 Aug 2015 16:24:43 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=90=9C=E7=B4=A2?=
=?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=8D=E6=AD=A3=E7=A1=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 67 ++-------------------------
app/views/courses/search.html.erb | 12 ++---
2 files changed, 11 insertions(+), 68 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 71715035e..29f2e00f4 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -106,74 +106,17 @@ class CoursesController < ApplicationController
# 课程搜索
# add by nwb
def search
- courses_all = Course.all_course
- name = params[:name]
- if name.blank?
- @courses = []
- @courses_all = []
- @course_count = 0
- @course_pages = Paginator.new @course_count, per_page_option, params['page']
+ if params[:name].empty?
+ courses = Course.visible
+ @courses = paginateHelper courses,10
else
- @courses = courses_all.visible
- if params[:name].present?
- @courses_all = @courses.like(params[:name])
- else
- @courses_all = @courses;
- end
- @course_count = @courses_all.count
- @course_pages = Paginator.new @course_count, per_page_option, params['page']
-
- # 课程的动态数
- # @course_activity_count=Hash.new
- # @courses_all.each do |course|
- # @course_activity_count[course.id]=0
- # end
- #
- # case params[:course_sort_type]
- # when '0'
- # @courses = @courses_all.order("created_at desc")
- # @s_type = 0
- # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
- #
- # @course_activity_count=get_course_activity @courses,@course_activity_count
- #
- # when '1'
- # @courses = @courses_all.order("course_ac_para desc")
- # @s_type = 1
- # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
- #
- # @course_activity_count=get_course_activity @courses,@course_activity_count
- #
- # when '2'
- # @courses = @courses_all.order("watchers_count desc")
- # @s_type = 2
- # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
- #
- # @course_activity_count=get_course_activity @courses,@course_activity_count
- #
- # when '3'
- # @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
- # @courses=handle_course @courses_all,@course_activity_count
- # @s_type = 3
- # @courses = @courses[@course_pages.offset, @course_pages.per_page]
- #
- # else
- # @s_type = 0
- # @courses = @courses_all.order("created_at desc")
- # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
- #
- # @course_activity_count=get_course_activity @courses,@course_activity_count
- #
- # end
+ courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'")
+ @courses = paginateHelper courses,10
end
respond_to do |format|
format.html {
render :layout => 'course_base'
- scope = Course
- unless params[:closed]
- scope = scope.active
- end
}
format.atom {
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
diff --git a/app/views/courses/search.html.erb b/app/views/courses/search.html.erb
index 98b056487..c19f9821a 100644
--- a/app/views/courses/search.html.erb
+++ b/app/views/courses/search.html.erb
@@ -39,17 +39,17 @@
<% end %>
-<% if @courses.size == 0 %>
-<%= render :partial => 'layouts/no_content'%>
+<% if @courses && !@courses.empty? %>
+
+ <%= render_course_hierarchy(@courses)%>
+
<% else %>
-
- <%= render_course_hierarchy(@courses)%>
-
+ <%= render :partial => 'layouts/no_content'%>
<% end %>