-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #445 from satikaj/8.0.x
Feat: Numbas updated with polymorphic association
- Loading branch information
Showing
9 changed files
with
27 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
class AssessmentComment < TaskComment | ||
belongs_to :overseer_assessment, optional: false | ||
|
||
before_create do | ||
self.content_type = :assessment | ||
end | ||
|
||
def serialize(user) | ||
json = super(user) | ||
json[:overseer_assessment_id] = self.overseer_assessment_id | ||
json[:overseer_assessment_id] = self.commentable_id | ||
json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
db/migrate/20240601103707_add_polymorphic_association_to_comment.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class AddPolymorphicAssociationToComment < ActiveRecord::Migration[7.1] | ||
def change | ||
remove_index :task_comments, :overseer_assessment_id | ||
|
||
add_column :task_comments, :commentable_type, :string | ||
rename_column :task_comments, :overseer_assessment_id, :commentable_id | ||
|
||
TaskComment.where('NOT commentable_id IS NULL').in_batches.update_all(commentable_type: 'OverseerAssessment') | ||
|
||
add_index :task_comments, [:commentable_type, :commentable_id] | ||
end | ||
end |
7 changes: 0 additions & 7 deletions
7
db/migrate/20240601103707_add_test_attempt_link_to_comment.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters