将未发布的作业恢复成已发布
This commit is contained in:
parent
ae42e0f0c5
commit
c94f986ba2
|
@ -0,0 +1,20 @@
|
||||||
|
class UpdateHomeworkCommentStatus < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
homeworks = HomeworkCommon.joins(:homework_detail_manual).where("publish_time is not NULL and publish_time <= '#{Date.today}' and homework_detail_manuals.comment_status = 0")
|
||||||
|
homeworks.each do |homework|
|
||||||
|
hw_dm = homework.homework_detail_manual
|
||||||
|
if hw_dm && hw_dm.comment_status == 0
|
||||||
|
if hw_dm.evaluation_end < Date.today && homework.anonymous_comment == 0
|
||||||
|
hw_dm.update_column("comment_status", 3)
|
||||||
|
elsif homework.anonymous_comment == 0 && hw_dm.evaluation_end >= Date.today && hw_dm.evaluation_start <= Date.today
|
||||||
|
hw_dm.update_column("comment_status", 2)
|
||||||
|
else
|
||||||
|
hw_dm.update_column("comment_status", 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20161011012114) do
|
ActiveRecord::Schema.define(:version => 20161015054820) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -142,7 +142,7 @@ ActiveRecord::Schema.define(:version => 20161011012114) do
|
||||||
t.integer "downloads", :default => 0
|
t.integer "downloads", :default => 0
|
||||||
t.integer "author_id"
|
t.integer "author_id"
|
||||||
t.datetime "created_on"
|
t.datetime "created_on"
|
||||||
t.string "description"
|
t.text "description"
|
||||||
t.string "disk_directory"
|
t.string "disk_directory"
|
||||||
t.integer "attachtype"
|
t.integer "attachtype"
|
||||||
t.integer "is_public"
|
t.integer "is_public"
|
||||||
|
@ -321,6 +321,8 @@ ActiveRecord::Schema.define(:version => 20161011012114) do
|
||||||
t.date "commit_date"
|
t.date "commit_date"
|
||||||
t.string "scmid"
|
t.string "scmid"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
t.integer "project_id"
|
||||||
|
t.integer "type", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
|
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
|
||||||
|
@ -971,6 +973,10 @@ ActiveRecord::Schema.define(:version => 20161011012114) do
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "innodb_monitor", :id => false, :force => true do |t|
|
||||||
|
t.integer "a"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "invite_lists", :force => true do |t|
|
create_table "invite_lists", :force => true do |t|
|
||||||
t.integer "project_id"
|
t.integer "project_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
|
Loading…
Reference in New Issue