将未发布的作业恢复成已发布
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
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -142,7 +142,7 @@ ActiveRecord::Schema.define(:version => 20161011012114) do
|
|||
t.integer "downloads", :default => 0
|
||||
t.integer "author_id"
|
||||
t.datetime "created_on"
|
||||
t.string "description"
|
||||
t.text "description"
|
||||
t.string "disk_directory"
|
||||
t.integer "attachtype"
|
||||
t.integer "is_public"
|
||||
|
@ -313,14 +313,16 @@ ActiveRecord::Schema.define(:version => 20161011012114) do
|
|||
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
|
||||
|
||||
create_table "changesets", :force => true do |t|
|
||||
t.integer "repository_id", :null => false
|
||||
t.string "revision", :null => false
|
||||
t.integer "repository_id", :null => false
|
||||
t.string "revision", :null => false
|
||||
t.string "committer"
|
||||
t.datetime "committed_on", :null => false
|
||||
t.datetime "committed_on", :null => false
|
||||
t.text "comments"
|
||||
t.date "commit_date"
|
||||
t.string "scmid"
|
||||
t.integer "user_id"
|
||||
t.integer "project_id"
|
||||
t.integer "type", :default => 0
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
create_table "innodb_monitor", :id => false, :force => true do |t|
|
||||
t.integer "a"
|
||||
end
|
||||
|
||||
create_table "invite_lists", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "user_id"
|
||||
|
|
Loading…
Reference in New Issue