新建问卷发布多条班级动态
This commit is contained in:
parent
bf6bdc8c9e
commit
1566111d11
|
@ -44,7 +44,9 @@ class Poll < ActiveRecord::Base
|
|||
def act_as_course_activity
|
||||
if self.polls_type == "Course"
|
||||
if self.polls_status == 2 #问卷是发布状态
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
|
||||
if CourseActivity.where(:course_id => self.polls_group_id, :user_id => self.user_id, :course_act_id => self.id, :course_act_type => 'Poll').count == 0
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
|
||||
end
|
||||
elsif self.polls_status == 1 #问卷是新建状态
|
||||
self.course_acts.destroy_all
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class DeleteCourseActivities < ActiveRecord::Migration
|
||||
def up
|
||||
course_acts = CourseActivity.where(:course_id => 844, :user_id => 10096, :course_act_id => 436, :course_act_type => 'Poll')
|
||||
|
||||
if course_acts.count > 1
|
||||
course_acts.limit(course_acts.count - 1).each do |act|
|
||||
act.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue