parent
3afb70bf84
commit
0480405afb
|
@ -287,6 +287,7 @@ class BidsController < ApplicationController
|
|||
end
|
||||
#end
|
||||
|
||||
# 显示课程
|
||||
def show_course
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@courses = []
|
||||
|
|
|
@ -105,7 +105,7 @@ class CoursesController < ApplicationController
|
|||
@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
|
||||
|
|
|
@ -91,8 +91,8 @@ module CoursesHelper
|
|||
end
|
||||
|
||||
alias studentCountOrigin studentCount
|
||||
def studentCount project
|
||||
count = studentCountOrigin project
|
||||
def studentCount course
|
||||
count = studentCountOrigin course
|
||||
garble count
|
||||
end
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@ module WatchersHelper
|
|||
end
|
||||
end
|
||||
|
||||
# 用户是否允许加入课程判断
|
||||
# add by nwb
|
||||
def join_in_course_for_list(course, user, options=[])
|
||||
return '' unless user && user.logged?
|
||||
# modify by nwb
|
||||
|
|
|
@ -2,17 +2,18 @@ class AddBoardsTypeToBoards < ActiveRecord::Migration
|
|||
def change
|
||||
add_column :boards, :course_id, :int
|
||||
|
||||
Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
# course_id不能直接设置为 project_id
|
||||
#Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
#Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
|
||||
#Board.all.each do |board|
|
||||
# project = Project.find_by_id(board.project_id)
|
||||
# if project && project.project_type == 1
|
||||
# board.course_id = board.project_id
|
||||
# board.project_id = -1
|
||||
# board.save
|
||||
# end
|
||||
# end
|
||||
Board.all.each do |board|
|
||||
project = Project.find_by_id(board.project_id)
|
||||
if project && project.project_type == 1
|
||||
board.course_id = project.course_extra.id
|
||||
board.project_id = -1
|
||||
board.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,16 +2,17 @@ class AddCourseidToEnabledModules < ActiveRecord::Migration
|
|||
def change
|
||||
add_column :enabled_modules, :course_id, :int
|
||||
|
||||
EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
#couese_id不能直接设置为project_id
|
||||
#EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
#EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
|
||||
#EnabledModule.all.each do |enablemodule|
|
||||
# project = Project.find_by_id(enablemodule.project_id)
|
||||
# if project && project.project_type == 1
|
||||
# enablemodule.course_id = enablemodule.project_id
|
||||
# enablemodule.project_id = -1
|
||||
# enablemodule.save
|
||||
# end
|
||||
#end
|
||||
EnabledModule.all.each do |enablemodule|
|
||||
project = Project.find_by_id(enablemodule.project_id)
|
||||
if project && project.project_type == 1
|
||||
enablemodule.course_id = project.course_extra.id
|
||||
enablemodule.project_id = -1
|
||||
enablemodule.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,17 +5,18 @@ class AddCourseidToToMembers < ActiveRecord::Migration
|
|||
remove_index :members, name: 'index_members_on_user_id_and_project_id'
|
||||
add_index "members", ["user_id", "project_id","course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
|
||||
|
||||
Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
#couese_id不能直接设置为project_id
|
||||
#Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
#Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
|
||||
# 课程成员数据迁移
|
||||
#Member.all.each do |member|
|
||||
# project = Project.find_by_id(member.project_id)
|
||||
# if project && project.project_type == 1
|
||||
# member.course_id = member.project_id
|
||||
# member.project_id = -1
|
||||
# member.save
|
||||
# end
|
||||
#end
|
||||
Member.all.each do |member|
|
||||
project = Project.find_by_id(member.project_id)
|
||||
if project && project.project_type == 1
|
||||
member.course_id = project.course_extra.id
|
||||
member.project_id = -1
|
||||
member.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column(:homework_for_courses, :project_id, :course_id)
|
||||
|
||||
# 作业数据迁移
|
||||
HomeworkForCourse.all.each do |work|
|
||||
project = Project.find_by_id(work.project_id)
|
||||
if project && project.project_type == 1
|
||||
work.course_id = project.course_extra.id
|
||||
work.project_id = -1
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class MigrateCourseAttachments < ActiveRecord::Migration
|
|||
project = Project.find_by_id(attach.container_id)
|
||||
if project && project.project_type == 1
|
||||
attach.container_type= 'Course'
|
||||
attach.container_id = project.course_extra.id
|
||||
attach.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class MigrateCourseTags < ActiveRecord::Migration
|
|||
project = Project.find_by_id(tagging.taggable_id)
|
||||
if project && project.project_type == 1
|
||||
tagging.taggable_type= 'Course'
|
||||
tagging.taggable_id = project.course_extra.id
|
||||
tagging.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ class MigrateCourseJournals < ActiveRecord::Migration
|
|||
project = Project.find_by_id(journal.jour_id)
|
||||
if project && project.project_type == 1
|
||||
journal.jour_type = 'Course'
|
||||
journal.jour_id = project.course_extra.id
|
||||
journal.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
class AddCourseidToNews < ActiveRecord::Migration
|
||||
#迁移原课程新闻数据
|
||||
#迁移原课程通知数据
|
||||
def change
|
||||
add_column :news, :course_id, :int
|
||||
|
||||
News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
# course_id不能直接设置为 project_id
|
||||
#News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
|
||||
#News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
|
||||
|
||||
News.all.each do |news|
|
||||
project = Project.find_by_id(news.project_id)
|
||||
if project && project.project_type == 1
|
||||
news.course_id = project.course_extra.id
|
||||
news.project_id = -1
|
||||
news.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class MigrateCourseStudents < ActiveRecord::Migration
|
||||
def change
|
||||
# 原课程的学生数据迁移成新模式
|
||||
StudentsForCourse.all.each do |student|
|
||||
project = Project.find_by_id(student.course_id)
|
||||
if project
|
||||
student.course_id = project.course_extra.id
|
||||
student.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
34
db/schema.rb
34
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140611161801) do
|
||||
ActiveRecord::Schema.define(:version => 20140618105213) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -742,18 +742,18 @@ ActiveRecord::Schema.define(:version => 20140611161801) do
|
|||
create_table "relative_memos", :force => true do |t|
|
||||
t.integer "osp_id"
|
||||
t.integer "parent_id"
|
||||
t.string "subject", :null => false
|
||||
t.text "content", :null => false
|
||||
t.string "subject", :null => false
|
||||
t.text "content", :limit => 16777215, :null => false
|
||||
t.integer "author_id"
|
||||
t.integer "replies_count", :default => 0
|
||||
t.integer "replies_count", :default => 0
|
||||
t.integer "last_reply_id"
|
||||
t.boolean "lock", :default => false
|
||||
t.boolean "sticky", :default => false
|
||||
t.boolean "is_quote", :default => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "viewed_count_crawl", :default => 0
|
||||
t.integer "viewed_count_local", :default => 0
|
||||
t.boolean "lock", :default => false
|
||||
t.boolean "sticky", :default => false
|
||||
t.boolean "is_quote", :default => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "viewed_count_crawl", :default => 0
|
||||
t.integer "viewed_count_local", :default => 0
|
||||
t.string "url"
|
||||
t.string "username"
|
||||
t.string "userhomeurl"
|
||||
|
@ -972,11 +972,13 @@ ActiveRecord::Schema.define(:version => 20140611161801) do
|
|||
add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id"
|
||||
|
||||
create_table "user_scores", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "collaboration"
|
||||
t.integer "influence"
|
||||
t.integer "skill"
|
||||
t.integer "activity"
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "collaboration"
|
||||
t.integer "influence"
|
||||
t.integer "skill"
|
||||
t.integer "active"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "user_statuses", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue