forked from saasbook/flextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make sure db can use environment vars * base seed data created * Models created with correct relations * test resources created for each model * seeded with new external data
- Loading branch information
Showing
8 changed files
with
120 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Assignment < ApplicationRecord | ||
#Relationship with Lms | ||
belongs_to :lms | ||
|
||
#Relationship with Extension | ||
has_many :extensions | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
class CourseToLms < ApplicationRecord | ||
|
||
# Associations | ||
belongs_to :course | ||
belongs_to :lms | ||
|
||
# Validations | ||
validates :course_id, presence: true | ||
validates :lms_id, presence: true | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Extension < ApplicationRecord | ||
#Relationship with Assignment | ||
belongs_to :assignment | ||
|
||
#Relationship with User | ||
has_one :user | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Lms < ApplicationRecord | ||
#Relationship with Course (and CourseToLms) | ||
has_many :course_to_lmss | ||
has_many :courses, :through => :course_to_lmss | ||
|
||
#Relationship with Assignment | ||
has_many :assignments | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class UserToCourse < ApplicationRecord | ||
belongs_to :user | ||
belongs_to :course | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,86 @@ | |
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| | ||
# MovieGenre.find_or_create_by!(name: genre_name) | ||
# end | ||
|
||
LmsCredential.destroy_all | ||
Extension.destroy_all | ||
Assignment.destroy_all | ||
CourseToLms.destroy_all | ||
UserToCourse.destroy_all | ||
Course.destroy_all | ||
Lms.destroy_all | ||
User.destroy_all | ||
|
||
canvas = Lms.create!({ | ||
lms_name: "Canvas", | ||
use_auth_token: true | ||
}) | ||
|
||
|
||
test_assignment = Assignment.create!({ | ||
lms_id: canvas.id, | ||
name: "Test Assignment", | ||
external_assignment_id: "11111" | ||
}) | ||
|
||
|
||
test_course = Course.create!({ | ||
course_name: "Test Course", | ||
}) | ||
|
||
test_course_to_lms = CourseToLms.create!({ | ||
lms_id: canvas.id, | ||
course_id: test_course.id, | ||
external_course_id: "22222" | ||
}) | ||
|
||
test_user = User.create!({ | ||
email: "[email protected]", | ||
}) | ||
|
||
test_user_to_course = UserToCourse.create!({ | ||
user_id: test_user.id, | ||
course_id: test_course.id, | ||
role: "test" | ||
}) | ||
|
||
test_extension = Extension.create!({ | ||
assignment_id: test_assignment.id, | ||
student_email: "[email protected]", | ||
initial_due_date: DateTime.iso8601('2024-04-20'), | ||
new_due_date: DateTime.iso8601('2024-04-30'), | ||
last_processed_by_id: test_user.id, | ||
external_extension_id: "33333" | ||
}) | ||
|
||
test_lms_credential = LmsCredential.create!({ | ||
user_id: test_user.id, | ||
lms_name: "canvas", | ||
token: "test token", | ||
external_user_id: "44444" | ||
}) | ||
|
||
real_course = Course.create!({ | ||
course_name: "CS169L Flextension", | ||
}) | ||
|
||
real_course_to_lms = CourseToLms.create!({ | ||
lms_id: canvas.id, | ||
course_id: real_course.id, | ||
external_course_id: "1534405" | ||
}) | ||
|
||
real_assignment = Assignment.create!({ | ||
lms_id: canvas.id, | ||
name: "Seed Data Testing", | ||
external_assignment_id: "8741483" | ||
}) | ||
|
||
real_extension = Extension.create!({ | ||
assignment_id: real_assignment.id, | ||
student_email: "[email protected]", | ||
initial_due_date: DateTime.iso8601('2024-04-20'), | ||
new_due_date: DateTime.iso8601('2024-04-27'), | ||
last_processed_by_id: test_user.id, | ||
external_extension_id: "270163" | ||
}) |