parent
fd502d2142
commit
0415b424bf
@ -0,0 +1,5 @@
|
|||||||
|
class ShixunWorkComment < ApplicationRecord
|
||||||
|
belongs_to :student_work
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :challenge, optional: true
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
class CreateShixunWorkComments < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :shixun_work_comments do |t|
|
||||||
|
t.references :student_work, index: true, type: :integer
|
||||||
|
t.references :challenge, index: true, type: :integer, default: 0
|
||||||
|
t.references :user, index: true, type: :integer
|
||||||
|
t.text :comment
|
||||||
|
t.text :hidden_comment
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
class MigrateShixunWorkComment < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
StudentWorksScore.where(is_ultimate: 0, score: nil).where("created_at > '2019-09-04 00:00:00'").each do |work_score|
|
||||||
|
if work_score.student_work && work_score.student_work.homework_common&.shixuns
|
||||||
|
if work_score.is_hidden
|
||||||
|
ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, hidden_comment: work_score.comment)
|
||||||
|
else
|
||||||
|
ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, comment: work_score.comment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe ShixunWorkComment, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue