coalescing_panda 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 049b4be87e2a94883db4321af5513b3de1292d95
4
- data.tar.gz: 18cb2a2a9965e4d80e96e8bb5c2d342c4a1e7911
3
+ metadata.gz: 525ed1c66b5491a7b55eaaa5010424ab68c5ad80
4
+ data.tar.gz: f4505d9681606087338a9493592a56f877b82247
5
5
  SHA512:
6
- metadata.gz: a71dcd02c993571e306894b3ba2a19ece4877ef108fb7475811a113d7c1442d38f2dfea109c94fb17dd43f5a63e18300dcfd805fc5411cc302fc3118858ade05
7
- data.tar.gz: 38e4fc6d47585987d5611fa1544ca6792d357de01c9c8b18d169cd9fca210635434c4f161410de7c04ef367454d3642e77f16667927550805e4c383e108c3f06
6
+ metadata.gz: 638088308a6bfb0e6236e1cd421697d3aa7e2edac77f43dc2dc2a04007f9bc47e5f9264a1d757f6f6bffc77ad0af4a578683f5813f30f727ae81d0c5a4440820
7
+ data.tar.gz: 93ab82f7ae7f20991071081fa8d7e2767fbb507557e043d1c30139a8cf42d2b685a3e0036073edb0b04f9fb2e1a6d0be7ba3a88168925dad4f0e895c19d87e8e
@@ -1,6 +1,7 @@
1
1
  module CoalescingPanda
2
2
  class Assignment < ActiveRecord::Base
3
3
  belongs_to :course, foreign_key: :coalescing_panda_course_id, class_name: 'CoalescingPanda::Course'
4
+ belongs_to :assignment_group, foreign_key: :coalescing_panda_assignment_group_id, class_name: 'CoalescingPanda::AssignmentGroup'
4
5
  has_many :submissions, foreign_key: :coalescing_panda_assignment_id, class_name: 'CoalescingPanda::Submission', dependent: :destroy
5
6
 
6
7
  delegate :account, to: :course
@@ -0,0 +1,11 @@
1
+ module CoalescingPanda
2
+ class AssignmentGroup < ActiveRecord::Base
3
+ belongs_to :course, foreign_key: :coalescing_panda_course_id, class_name: 'CoalescingPanda::Course'
4
+ has_many :assignments, foreign_key: :coalescing_panda_assignment_group_id, class_name: 'CoalescingPanda::Assignment', dependent: :destroy
5
+
6
+ delegate :account, to: :course
7
+
8
+ validates :coalescing_panda_course_id, presence: true
9
+ validates :canvas_assignment_group_id, presence: true
10
+ end
11
+ end
@@ -10,6 +10,7 @@ module CoalescingPanda
10
10
  has_many :groups, :as => :context, class_name: 'CoalescingPanda::Group', dependent: :destroy
11
11
  has_many :group_memberships, through: :groups, source: :group_memberships, class_name: 'CoalescingPanda::GroupMembership', dependent: :destroy
12
12
  has_many :canvas_batches, as: :context, dependent: :destroy
13
+ has_many :assignment_groups, foreign_key: :coalescing_panda_course_id, class_name: 'CoalescingPanda::AssignmentGroup', dependent: :destroy
13
14
 
14
15
  validates :coalescing_panda_lti_account_id, presence: true
15
16
  validates :canvas_course_id, presence: true
@@ -1,7 +1,7 @@
1
1
  class CoalescingPanda::Workers::CourseMiner
2
- SUPPORTED_MODELS = [:sections, :users, :enrollments, :assignments, :submissions, :groups, :group_memberships] #ORDER MATTERS!!
2
+ SUPPORTED_MODELS = [:sections, :users, :enrollments, :assignment_groups, :assignments, :submissions, :groups, :group_memberships] #ORDER MATTERS!!
3
3
 
4
- attr_accessor :options, :account, :course, :batch, :course_section_ids, :enrollment_ids, :assignment_ids, :group_ids, :user_ids
4
+ attr_accessor :options, :account, :course, :batch, :course_section_ids, :enrollment_ids, :assignment_ids, :assignment_group_ids, :group_ids, :user_ids
5
5
 
6
6
  def initialize(course, options = [])
7
7
  @course = course
@@ -11,6 +11,7 @@ class CoalescingPanda::Workers::CourseMiner
11
11
  @course_section_ids = []
12
12
  @enrollment_ids = []
13
13
  @assignment_ids = []
14
+ @assignment_group_ids = []
14
15
  @group_ids = []
15
16
  @user_ids = []
16
17
  end
@@ -37,6 +38,9 @@ class CoalescingPanda::Workers::CourseMiner
37
38
 
38
39
  def process_api_data(key)
39
40
  case key
41
+ when :assignment_groups
42
+ collection = api_client.list_assignment_groups(course.canvas_course_id).all_pages!
43
+ sync_assignment_groups(collection)
40
44
  when :sections
41
45
  collection = api_client.course_sections(course.canvas_course_id).all_pages!
42
46
  sync_sections(collection)
@@ -73,6 +77,21 @@ class CoalescingPanda::Workers::CourseMiner
73
77
  end
74
78
  end
75
79
 
80
+ def sync_assignment_groups(collection)
81
+ begin
82
+ collection.each do |values|
83
+ values['canvas_assignment_group_id'] = values['id'].to_s
84
+ assignment_group = course.assignment_groups.where(canvas_assignment_group_id: values['canvas_assignment_group_id']).first_or_initialize
85
+ assignment_group.assign_attributes(standard_attributes(assignment_group, values))
86
+ assignment_group.save(validate: false)
87
+ assignment_group_ids << assignment_group.id
88
+ end
89
+ course.assignment_groups.where.not(id: assigment_group_ids).destroy_all
90
+ rescue => e
91
+ Rails.logger.error "Error syncing assignment groups: #{e}"
92
+ end
93
+ end
94
+
76
95
  def sync_sections(collection)
77
96
  begin
78
97
  collection.each do |values|
@@ -141,6 +160,8 @@ class CoalescingPanda::Workers::CourseMiner
141
160
  collection.each do |values|
142
161
  values['canvas_assignment_id'] = values['id'].to_s
143
162
  assignment = course.assignments.where(canvas_assignment_id: values['canvas_assignment_id']).first_or_initialize
163
+ assignment_group = course.assignment_groups.find_by(canvas_assignment_group_id: values['assignment_group_id'])
164
+ assignment.coalescing_panda_assignment_group_id = assignment_group.id if assignment_group
144
165
  assignment.assign_attributes(standard_attributes(assignment, values))
145
166
  assignment.save(validate: false)
146
167
  assignment_ids << assignment.id
@@ -0,0 +1,18 @@
1
+ class CreateCoalescingPandaAssignmentGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :coalescing_panda_assignment_groups do |t|
4
+ t.belongs_to :coalescing_panda_course, null: false
5
+ t.belongs_to :context, polymorphic: true
6
+ t.string :canvas_assignment_group_id
7
+ t.string :name
8
+ t.integer :position
9
+ t.float :group_weight
10
+ t.string :workflow_state
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :coalescing_panda_assignment_groups, [:coalescing_panda_course_id, :canvas_assignment_group_id], name: :index_assignment_group_course, unique: true
16
+ add_index :coalescing_panda_assignment_groups, [:canvas_assignment_group_id, :context_id, :context_type], name: :index_assignment_group_context, unique: true
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ class AddAssignmentGroupIdToAssignments < ActiveRecord::Migration
2
+ def change
3
+ add_column :coalescing_panda_assignments, :coalescing_panda_assignment_group_id, :integer
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module CoalescingPanda
2
- VERSION = '4.1.0'
2
+ VERSION = '4.1.1'
3
3
  end
@@ -11,14 +11,30 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150210180516) do
14
+ ActiveRecord::Schema.define(version: 20150506192717) do
15
15
 
16
- create_table "coalescing_panda_assignments", force: true do |t|
17
- t.integer "coalescing_panda_course_id", null: false
16
+ create_table "coalescing_panda_assignment_groups", force: :cascade do |t|
17
+ t.integer "coalescing_panda_course_id", null: false
18
+ t.integer "context_id"
19
+ t.string "context_type"
20
+ t.string "canvas_assignment_group_id"
18
21
  t.string "name"
19
- t.text "description"
20
- t.string "canvas_assignment_id", null: false
22
+ t.integer "position"
23
+ t.float "group_weight"
21
24
  t.string "workflow_state"
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ add_index "coalescing_panda_assignment_groups", ["canvas_assignment_group_id", "context_id", "context_type"], name: "index_assignment_group_context", unique: true
30
+ add_index "coalescing_panda_assignment_groups", ["coalescing_panda_course_id", "canvas_assignment_group_id"], name: "index_assignment_group_course", unique: true
31
+
32
+ create_table "coalescing_panda_assignments", force: :cascade do |t|
33
+ t.integer "coalescing_panda_course_id", null: false
34
+ t.string "name", limit: 255
35
+ t.text "description"
36
+ t.string "canvas_assignment_id", limit: 255, null: false
37
+ t.string "workflow_state", limit: 255
22
38
  t.float "points_possible"
23
39
  t.datetime "due_at"
24
40
  t.datetime "unlock_at"
@@ -29,38 +45,39 @@ ActiveRecord::Schema.define(version: 20150210180516) do
29
45
  t.integer "group_category_id"
30
46
  t.boolean "grade_group_students_individually"
31
47
  t.boolean "published"
48
+ t.integer "coalescing_panda_assignment_group_id"
32
49
  end
33
50
 
34
51
  add_index "coalescing_panda_assignments", ["coalescing_panda_course_id", "canvas_assignment_id"], name: "index_assignments_course", unique: true
35
52
 
36
- create_table "coalescing_panda_canvas_api_auths", force: true do |t|
37
- t.string "user_id"
38
- t.string "api_domain"
39
- t.string "api_token"
53
+ create_table "coalescing_panda_canvas_api_auths", force: :cascade do |t|
54
+ t.string "user_id", limit: 255
55
+ t.string "api_domain", limit: 255
56
+ t.string "api_token", limit: 255
40
57
  t.datetime "created_at"
41
58
  t.datetime "updated_at"
42
59
  end
43
60
 
44
- create_table "coalescing_panda_canvas_batches", force: true do |t|
45
- t.float "percent_complete", default: 0.0
46
- t.string "status"
61
+ create_table "coalescing_panda_canvas_batches", force: :cascade do |t|
62
+ t.float "percent_complete", default: 0.0
63
+ t.string "status", limit: 255
47
64
  t.text "message"
48
65
  t.datetime "created_at"
49
66
  t.datetime "updated_at"
50
67
  t.integer "context_id"
51
- t.string "context_type"
68
+ t.string "context_type", limit: 255
52
69
  end
53
70
 
54
- create_table "coalescing_panda_courses", force: true do |t|
55
- t.integer "coalescing_panda_lti_account_id", null: false
71
+ create_table "coalescing_panda_courses", force: :cascade do |t|
72
+ t.integer "coalescing_panda_lti_account_id", null: false
56
73
  t.integer "coalescing_panda_term_id"
57
- t.string "name"
58
- t.string "canvas_course_id", null: false
59
- t.string "sis_id"
74
+ t.string "name", limit: 255
75
+ t.string "canvas_course_id", limit: 255, null: false
76
+ t.string "sis_id", limit: 255
60
77
  t.datetime "start_at"
61
78
  t.datetime "conclude_at"
62
- t.string "workflow_state"
63
- t.string "course_code"
79
+ t.string "workflow_state", limit: 255
80
+ t.string "course_code", limit: 255
64
81
  t.datetime "created_at"
65
82
  t.datetime "updated_at"
66
83
  end
@@ -69,13 +86,13 @@ ActiveRecord::Schema.define(version: 20150210180516) do
69
86
  add_index "coalescing_panda_courses", ["coalescing_panda_term_id", "canvas_course_id"], name: "index_courses_term", unique: true
70
87
  add_index "coalescing_panda_courses", ["sis_id"], name: "index_coalescing_panda_courses_on_sis_id"
71
88
 
72
- create_table "coalescing_panda_enrollments", force: true do |t|
73
- t.integer "coalescing_panda_user_id", null: false
74
- t.integer "coalescing_panda_section_id", null: false
75
- t.string "workflow_state"
76
- t.string "sis_id"
77
- t.string "canvas_enrollment_id", null: false
78
- t.string "enrollment_type"
89
+ create_table "coalescing_panda_enrollments", force: :cascade do |t|
90
+ t.integer "coalescing_panda_user_id", null: false
91
+ t.integer "coalescing_panda_section_id", null: false
92
+ t.string "workflow_state", limit: 255
93
+ t.string "sis_id", limit: 255
94
+ t.string "canvas_enrollment_id", limit: 255, null: false
95
+ t.string "enrollment_type", limit: 255
79
96
  t.datetime "start_at"
80
97
  t.datetime "end_at"
81
98
  t.datetime "created_at"
@@ -85,51 +102,51 @@ ActiveRecord::Schema.define(version: 20150210180516) do
85
102
  add_index "coalescing_panda_enrollments", ["coalescing_panda_user_id", "coalescing_panda_section_id", "enrollment_type"], name: "index_enrollments_user_and_section", unique: true
86
103
  add_index "coalescing_panda_enrollments", ["sis_id"], name: "index_coalescing_panda_enrollments_on_sis_id"
87
104
 
88
- create_table "coalescing_panda_group_memberships", force: true do |t|
105
+ create_table "coalescing_panda_group_memberships", force: :cascade do |t|
89
106
  t.integer "coalescing_panda_group_id"
90
107
  t.integer "coalescing_panda_user_id"
91
- t.string "canvas_group_membership_id"
92
- t.string "workflow_state"
108
+ t.string "canvas_group_membership_id", limit: 255
109
+ t.string "workflow_state", limit: 255
93
110
  t.datetime "created_at"
94
111
  t.datetime "updated_at"
95
112
  end
96
113
 
97
- create_table "coalescing_panda_groups", force: true do |t|
114
+ create_table "coalescing_panda_groups", force: :cascade do |t|
98
115
  t.integer "context_id"
99
- t.string "context_type"
100
- t.string "description"
101
- t.string "group_category_id"
102
- t.string "canvas_group_id"
103
- t.string "name"
116
+ t.string "context_type", limit: 255
117
+ t.string "description", limit: 255
118
+ t.string "group_category_id", limit: 255
119
+ t.string "canvas_group_id", limit: 255
120
+ t.string "name", limit: 255
104
121
  t.integer "members_count"
105
122
  t.datetime "created_at"
106
123
  t.datetime "updated_at"
107
124
  end
108
125
 
109
- create_table "coalescing_panda_lti_accounts", force: true do |t|
110
- t.string "name"
111
- t.string "key"
112
- t.string "secret"
113
- t.string "oauth2_client_id"
114
- t.string "oauth2_client_key"
115
- t.string "canvas_account_id"
126
+ create_table "coalescing_panda_lti_accounts", force: :cascade do |t|
127
+ t.string "name", limit: 255
128
+ t.string "key", limit: 255
129
+ t.string "secret", limit: 255
130
+ t.string "oauth2_client_id", limit: 255
131
+ t.string "oauth2_client_key", limit: 255
132
+ t.string "canvas_account_id", limit: 255
116
133
  t.text "settings"
117
134
  t.datetime "created_at"
118
135
  t.datetime "updated_at"
119
136
  end
120
137
 
121
- create_table "coalescing_panda_lti_nonces", force: true do |t|
138
+ create_table "coalescing_panda_lti_nonces", force: :cascade do |t|
122
139
  t.integer "coalescing_panda_lti_account_id"
123
- t.string "nonce"
140
+ t.string "nonce", limit: 255
124
141
  t.datetime "timestamp"
125
142
  end
126
143
 
127
- create_table "coalescing_panda_sections", force: true do |t|
128
- t.integer "coalescing_panda_course_id", null: false
129
- t.string "name"
130
- t.string "canvas_section_id", null: false
131
- t.string "sis_id"
132
- t.string "workflow_state"
144
+ create_table "coalescing_panda_sections", force: :cascade do |t|
145
+ t.integer "coalescing_panda_course_id", null: false
146
+ t.string "name", limit: 255
147
+ t.string "canvas_section_id", limit: 255, null: false
148
+ t.string "sis_id", limit: 255
149
+ t.string "workflow_state", limit: 255
133
150
  t.datetime "start_at"
134
151
  t.datetime "end_at"
135
152
  t.datetime "created_at"
@@ -139,22 +156,22 @@ ActiveRecord::Schema.define(version: 20150210180516) do
139
156
  add_index "coalescing_panda_sections", ["coalescing_panda_course_id", "canvas_section_id"], name: "index_sections_course", unique: true
140
157
  add_index "coalescing_panda_sections", ["sis_id"], name: "index_coalescing_panda_sections_on_sis_id"
141
158
 
142
- create_table "coalescing_panda_sessions", force: true do |t|
143
- t.string "token"
159
+ create_table "coalescing_panda_sessions", force: :cascade do |t|
160
+ t.string "token", limit: 255
144
161
  t.text "data"
145
162
  t.datetime "created_at"
146
163
  t.datetime "updated_at"
147
164
  end
148
165
 
149
- create_table "coalescing_panda_submissions", force: true do |t|
150
- t.integer "coalescing_panda_user_id", null: false
151
- t.integer "coalescing_panda_assignment_id", null: false
152
- t.string "url"
153
- t.string "grade"
154
- t.string "score"
166
+ create_table "coalescing_panda_submissions", force: :cascade do |t|
167
+ t.integer "coalescing_panda_user_id", null: false
168
+ t.integer "coalescing_panda_assignment_id", null: false
169
+ t.string "url", limit: 255
170
+ t.string "grade", limit: 255
171
+ t.string "score", limit: 255
155
172
  t.datetime "submitted_at"
156
- t.string "workflow_state"
157
- t.string "canvas_submission_id", null: false
173
+ t.string "workflow_state", limit: 255
174
+ t.string "canvas_submission_id", limit: 255, null: false
158
175
  t.datetime "created_at"
159
176
  t.datetime "updated_at"
160
177
  end
@@ -162,15 +179,15 @@ ActiveRecord::Schema.define(version: 20150210180516) do
162
179
  add_index "coalescing_panda_submissions", ["canvas_submission_id"], name: "index_coalescing_panda_submissions_on_canvas_submission_id"
163
180
  add_index "coalescing_panda_submissions", ["coalescing_panda_user_id", "coalescing_panda_assignment_id", "canvas_submission_id"], name: "index_submissions_user_and_assignment", unique: true
164
181
 
165
- create_table "coalescing_panda_terms", force: true do |t|
166
- t.integer "coalescing_panda_lti_account_id", null: false
167
- t.string "name"
168
- t.string "code"
169
- t.string "sis_id"
170
- t.string "canvas_term_id", null: false
182
+ create_table "coalescing_panda_terms", force: :cascade do |t|
183
+ t.integer "coalescing_panda_lti_account_id", null: false
184
+ t.string "name", limit: 255
185
+ t.string "code", limit: 255
186
+ t.string "sis_id", limit: 255
187
+ t.string "canvas_term_id", limit: 255, null: false
171
188
  t.datetime "start_at"
172
189
  t.datetime "end_at"
173
- t.string "workflow_state"
190
+ t.string "workflow_state", limit: 255
174
191
  t.datetime "created_at"
175
192
  t.datetime "updated_at"
176
193
  end
@@ -178,14 +195,14 @@ ActiveRecord::Schema.define(version: 20150210180516) do
178
195
  add_index "coalescing_panda_terms", ["canvas_term_id", "coalescing_panda_lti_account_id"], name: "index_terms_account", unique: true
179
196
  add_index "coalescing_panda_terms", ["sis_id"], name: "index_coalescing_panda_terms_on_sis_id"
180
197
 
181
- create_table "coalescing_panda_users", force: true do |t|
182
- t.integer "coalescing_panda_lti_account_id", null: false
183
- t.string "name"
184
- t.string "email"
185
- t.string "roles"
186
- t.string "workflow_state"
187
- t.string "sis_id"
188
- t.string "canvas_user_id", null: false
198
+ create_table "coalescing_panda_users", force: :cascade do |t|
199
+ t.integer "coalescing_panda_lti_account_id", null: false
200
+ t.string "name", limit: 255
201
+ t.string "email", limit: 255
202
+ t.string "roles", limit: 255
203
+ t.string "workflow_state", limit: 255
204
+ t.string "sis_id", limit: 255
205
+ t.string "canvas_user_id", limit: 255, null: false
189
206
  t.datetime "created_at"
190
207
  t.datetime "updated_at"
191
208
  end
@@ -193,16 +210,16 @@ ActiveRecord::Schema.define(version: 20150210180516) do
193
210
  add_index "coalescing_panda_users", ["coalescing_panda_lti_account_id", "canvas_user_id"], name: "index_users_account", unique: true
194
211
  add_index "coalescing_panda_users", ["sis_id"], name: "index_coalescing_panda_users_on_sis_id"
195
212
 
196
- create_table "delayed_jobs", force: true do |t|
197
- t.integer "priority", default: 0, null: false
198
- t.integer "attempts", default: 0, null: false
199
- t.text "handler", null: false
213
+ create_table "delayed_jobs", force: :cascade do |t|
214
+ t.integer "priority", default: 0, null: false
215
+ t.integer "attempts", default: 0, null: false
216
+ t.text "handler", null: false
200
217
  t.text "last_error"
201
218
  t.datetime "run_at"
202
219
  t.datetime "locked_at"
203
220
  t.datetime "failed_at"
204
- t.string "locked_by"
205
- t.string "queue"
221
+ t.string "locked_by", limit: 255
222
+ t.string "queue", limit: 255
206
223
  t.datetime "created_at"
207
224
  t.datetime "updated_at"
208
225
  end
Binary file