qalam_oauth_engine 3.0.4 → 3.0.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a94aa9f960fad372ccd1ce843c502f7f1f8011f010e29dd095224a0d9a5c701f
|
4
|
+
data.tar.gz: a1f11ff92ae13c52c42271180623616cbf47cd42780e34e3f029a30c6143fe44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8540835b1a123aae6f271195d80443a7627649dc2156c1ec2a6f0e6be6295d99f0669815b5e11250b7b0c7f70c7811d901158107ed1e2424934a0de3ba2c3d7b
|
7
|
+
data.tar.gz: f01b816cc088416ffa80ddfd5908ae40bded8ac8e11f8c784ead5317fd82a3d4039b424aa29cfff82aad4756c5776bbcdc291ec8116ebec48776dd2cb0a3b5a1
|
@@ -23,13 +23,13 @@ module CanvasOauth
|
|
23
23
|
def verify_oauth2_state(callback_state)
|
24
24
|
callback_state.present? && callback_state == session.delete(:oauth2_state)
|
25
25
|
end
|
26
|
-
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
def set_root_account
|
28
|
+
if session[:account_id]
|
29
|
+
@root_account_id = canvas.root_account_id(session[:account_id])
|
30
|
+
elsif session[:course_id]
|
31
|
+
@root_account_id = canvas.course_root_account_id(session[:course_id])
|
32
|
+
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -4,7 +4,7 @@ module CanvasOauth
|
|
4
4
|
PER_PAGE = 50
|
5
5
|
|
6
6
|
attr_accessor :token, :refresh_token, :key, :secret
|
7
|
-
attr_reader :canvas_url, :canvas_user_id
|
7
|
+
attr_reader :canvas_url, :canvas_user_id, :canvas_root_account_id
|
8
8
|
|
9
9
|
def initialize(canvas_url, canvas_user_id, canvas_root_account_id, token, refresh_token, key, secret)
|
10
10
|
unless [key, secret].all?(&:present?)
|
@@ -104,18 +104,23 @@ module CanvasOauth
|
|
104
104
|
authenticated_request(:put, *params)
|
105
105
|
end
|
106
106
|
|
107
|
-
def paginated_get(url, params
|
107
|
+
def paginated_get(url, params={})
|
108
108
|
params[:query] ||= {}
|
109
|
-
params[:query][:per_page]
|
110
|
-
|
109
|
+
params[:query][:per_page] ||= PER_PAGE
|
110
|
+
params[:query][:page] ||= 1
|
111
111
|
all_pages = []
|
112
112
|
|
113
|
-
|
113
|
+
if params[:current_page]
|
114
|
+
current_page = authenticated_get(url, params)
|
114
115
|
all_pages.concat(current_page) if valid_page?(current_page)
|
116
|
+
else
|
117
|
+
while url && current_page = authenticated_get(url, params) do
|
118
|
+
all_pages.concat(current_page) if valid_page?(current_page)
|
115
119
|
|
116
|
-
|
117
|
-
|
118
|
-
|
120
|
+
links = LinkHeader.parse(current_page.headers['link'])
|
121
|
+
url = links.find_link(["rel", "next"]).try(:href)
|
122
|
+
params[:query] = nil if params[:query]
|
123
|
+
end
|
119
124
|
end
|
120
125
|
|
121
126
|
all_pages
|
@@ -195,7 +200,7 @@ module CanvasOauth
|
|
195
200
|
# root_account_id
|
196
201
|
# course_root_account_id
|
197
202
|
|
198
|
-
def get_report(account_id, report_type, params)
|
203
|
+
def get_report(account_id, report_type, params={})
|
199
204
|
report = authenticated_post("/api/v1/accounts/#{account_id}/reports/#{report_type}", { body: params })
|
200
205
|
report = authenticated_get "/api/v1/accounts/#{account_id}/reports/#{report_type}/#{report['id']}"
|
201
206
|
while (report['status'] == 'created' || report['status'] == 'running')
|
@@ -212,108 +217,108 @@ module CanvasOauth
|
|
212
217
|
end
|
213
218
|
end
|
214
219
|
|
215
|
-
def get_file(file_id)
|
220
|
+
def get_file(file_id, params={})
|
216
221
|
authenticated_get "/api/v1/files/#{file_id}"
|
217
222
|
end
|
218
223
|
|
219
|
-
def get_accounts_provisioning_report(account_id)
|
224
|
+
def get_accounts_provisioning_report(account_id, params={})
|
220
225
|
get_report(account_id, :provisioning_csv, 'parameters[accounts]' => true)
|
221
226
|
end
|
222
227
|
|
223
|
-
def get_courses
|
228
|
+
def get_courses(params={})
|
224
229
|
paginated_get "/api/v1/courses"
|
225
230
|
end
|
226
231
|
|
227
|
-
def get_account(account_id)
|
232
|
+
def get_account(account_id, params={})
|
228
233
|
authenticated_get "/api/v1/accounts/#{account_id}"
|
229
234
|
end
|
230
235
|
|
231
|
-
def get_account_sub_accounts(account_id)
|
236
|
+
def get_account_sub_accounts(account_id, params={})
|
232
237
|
paginated_get "/api/v1/accounts/#{account_id}/sub_accounts", { query: { :recursive => true } }
|
233
238
|
end
|
234
239
|
|
235
|
-
def get_account_courses(account_id)
|
240
|
+
def get_account_courses(account_id, params={})
|
236
241
|
paginated_get "/api/v1/accounts/#{account_id}/courses"
|
237
242
|
end
|
238
243
|
|
239
|
-
def get_account_users(account_id)
|
244
|
+
def get_account_users(account_id, params={})
|
240
245
|
paginated_get "/api/v1/accounts/#{account_id}/users"
|
241
246
|
end
|
242
247
|
|
243
|
-
def get_course(course_id)
|
248
|
+
def get_course(course_id, params={})
|
244
249
|
authenticated_get "/api/v1/courses/#{course_id}"
|
245
250
|
end
|
246
251
|
|
247
|
-
def get_section_enrollments(section_id)
|
252
|
+
def get_section_enrollments(section_id, params={})
|
248
253
|
paginated_get "/api/v1/sections/#{section_id}/enrollments"
|
249
254
|
end
|
250
255
|
|
251
|
-
def get_user_enrollments(user_id)
|
256
|
+
def get_user_enrollments(user_id, params={})
|
252
257
|
paginated_get "/api/v1/users/#{user_id}/enrollments"
|
253
258
|
end
|
254
259
|
|
255
|
-
def get_course_users(course_id)
|
260
|
+
def get_course_users(course_id, params={})
|
256
261
|
paginated_get "/api/v1/courses/#{course_id}/users"
|
257
262
|
end
|
258
263
|
|
259
|
-
def get_all_course_users(course_id)
|
264
|
+
def get_all_course_users(course_id, params={})
|
260
265
|
paginated_get "/api/v1/courses/#{course_id}/users", { query: {enrollment_state: ["active","invited","rejected","completed","inactive"] } }
|
261
266
|
end
|
262
267
|
|
263
|
-
def get_course_teachers_and_tas(course_id)
|
268
|
+
def get_course_teachers_and_tas(course_id, params={})
|
264
269
|
paginated_get "/api/v1/courses/#{course_id}/users", { query: { enrollment_type: ['teacher', 'ta'] } }
|
265
270
|
end
|
266
271
|
|
267
|
-
def get_course_students(course_id)
|
272
|
+
def get_course_students(course_id, params={})
|
268
273
|
paginated_get "/api/v1/courses/#{course_id}/students"
|
269
274
|
end
|
270
275
|
|
271
|
-
def get_course_active_students(course_id)
|
276
|
+
def get_course_active_students(course_id, params={})
|
272
277
|
paginated_get "/api/v1/courses/#{course_id}/active_users"
|
273
278
|
end
|
274
279
|
|
275
|
-
def get_section(section_id)
|
280
|
+
def get_section(section_id, params={})
|
276
281
|
authenticated_get "/api/v1/sections/#{section_id}"
|
277
282
|
end
|
278
283
|
|
279
|
-
def get_sections(course_id)
|
284
|
+
def get_sections(course_id, params={})
|
280
285
|
paginated_get "/api/v1/courses/#{course_id}/sections", { query: { :include => ['students', 'avatar_url', 'enrollments'] } }
|
281
286
|
end
|
282
287
|
|
283
|
-
def get_assignments(course_id)
|
288
|
+
def get_assignments(course_id, params={})
|
284
289
|
paginated_get "/api/v1/courses/#{course_id}/assignments"
|
285
290
|
end
|
286
291
|
|
287
|
-
def get_assignment(course_id, assignment_id)
|
292
|
+
def get_assignment(course_id, assignment_id, params={})
|
288
293
|
authenticated_get "/api/v1/courses/#{course_id}/assignments/#{assignment_id}"
|
289
294
|
end
|
290
295
|
|
291
|
-
def get_user_profile(user_id)
|
296
|
+
def get_user_profile(user_id, params={})
|
292
297
|
authenticated_get "/api/v1/users/#{user_id}/profile"
|
293
298
|
end
|
294
299
|
|
295
|
-
def create_assignment(course_id, params)
|
300
|
+
def create_assignment(course_id, params={})
|
296
301
|
authenticated_post "/api/v1/courses/#{course_id}/assignments", { body: { assignment: params } }
|
297
302
|
end
|
298
303
|
|
299
|
-
def update_assignment(course_id, assignment_id, params)
|
304
|
+
def update_assignment(course_id, assignment_id, params={})
|
300
305
|
authenticated_put "/api/v1/courses/#{course_id}/assignments/#{assignment_id}", { body: { assignment: params } }
|
301
306
|
end
|
302
307
|
|
303
|
-
def grade_assignment(course_id, assignment_id, user_id, params)
|
308
|
+
def grade_assignment(course_id, assignment_id, user_id, params={})
|
304
309
|
authenticated_put "/api/v1/courses/#{course_id}/assignments/#{assignment_id}/submissions/#{user_id}", { body: params }
|
305
310
|
end
|
306
311
|
|
307
|
-
def get_submission(course_id, assignment_id, user_id)
|
312
|
+
def get_submission(course_id, assignment_id, user_id, params={})
|
308
313
|
authenticated_get "/api/v1/courses/#{course_id}/assignments/#{assignment_id}/submissions/#{user_id}"
|
309
314
|
end
|
310
315
|
|
311
|
-
def course_account_id(course_id)
|
316
|
+
def course_account_id(course_id, params={})
|
312
317
|
course = get_course(course_id)
|
313
318
|
course['account_id'] if course
|
314
319
|
end
|
315
320
|
|
316
|
-
def root_account_id(account_id)
|
321
|
+
def root_account_id(account_id, params={})
|
317
322
|
if account_id && account = get_account(account_id)
|
318
323
|
root_id = account['root_account_id']
|
319
324
|
end
|
@@ -321,7 +326,7 @@ module CanvasOauth
|
|
321
326
|
root_id || account_id
|
322
327
|
end
|
323
328
|
|
324
|
-
def course_root_account_id(course_id)
|
329
|
+
def course_root_account_id(course_id, params={})
|
325
330
|
root_account_id(course_account_id(course_id))
|
326
331
|
end
|
327
332
|
### END CANVAS API ###
|
@@ -329,44 +334,84 @@ module CanvasOauth
|
|
329
334
|
### QALAM API ENDPOINTS ###
|
330
335
|
# get_canvas_user_profile
|
331
336
|
# get_course_active_pages
|
332
|
-
#
|
333
|
-
# account_external_tool_update
|
337
|
+
# update_external_tool_nav
|
334
338
|
# get_school_details
|
335
|
-
#
|
336
|
-
#
|
337
|
-
|
338
|
-
|
339
|
+
# get_school_grades
|
340
|
+
# get_school_grade
|
341
|
+
# get_school_class_rooms
|
342
|
+
# get_school_class_room
|
343
|
+
# get_school_subjects
|
344
|
+
# get_school_subject
|
345
|
+
# get_students_by_grade
|
346
|
+
# get_students_by_class_room
|
347
|
+
|
348
|
+
def get_canvas_user_profile(params={})
|
339
349
|
authenticated_get "/api/v1/users/#{canvas_user_id}/profile"
|
340
350
|
end
|
341
351
|
|
342
|
-
def get_course_active_pages(course_id, publish=nil)
|
352
|
+
def get_course_active_pages(course_id, publish=nil, params={})
|
343
353
|
unless publish.nil?
|
344
|
-
paginated_get "/api/v1/courses/#{course_id}/pages?published=#{publish}&sort=created_at&order=desc"
|
354
|
+
paginated_get "/api/v1/courses/#{course_id}/pages?published=#{publish}&sort=created_at&order=desc", params
|
345
355
|
else
|
346
|
-
paginated_get "/api/v1/courses/#{course_id}/pages?sort=created_at&order=desc"
|
356
|
+
paginated_get "/api/v1/courses/#{course_id}/pages?sort=created_at&order=desc", params
|
347
357
|
end
|
348
358
|
end
|
349
359
|
|
350
|
-
def
|
351
|
-
|
352
|
-
|
360
|
+
def update_external_tool_nav(external_tool_url, tool_id, publish, type, account_id=@canvas_root_account_id, params={})
|
361
|
+
account_id ||= @canvas_root_account_id
|
362
|
+
if type == 'account'
|
363
|
+
body = {"account_navigation"=>{"enabled"=>"#{publish}"},
|
364
|
+
"tool_id"=>tool_id, "external_tool_url"=>external_tool_url}
|
365
|
+
elsif type == 'course'
|
366
|
+
body = {"course_navigation"=>{"enabled"=>"#{publish}"},
|
367
|
+
"tool_id"=>tool_id, "external_tool_url"=>external_tool_url}
|
368
|
+
end
|
369
|
+
authenticated_put "/api/v1/accounts/#{account_id}/external_tools_url", { body: body } if body
|
353
370
|
end
|
354
371
|
|
355
|
-
def
|
356
|
-
|
357
|
-
|
372
|
+
def get_school_details(account_id=@canvas_root_account_id, params={})
|
373
|
+
account_id ||= @canvas_root_account_id
|
374
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_details"
|
358
375
|
end
|
359
376
|
|
360
|
-
def
|
361
|
-
|
377
|
+
def get_school_grades(account_id=@canvas_root_account_id, params={})
|
378
|
+
account_id ||= @canvas_root_account_id
|
379
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_grades", params
|
380
|
+
end
|
381
|
+
|
382
|
+
def get_school_grade(grade_id, account_id=@canvas_root_account_id, params={})
|
383
|
+
account_id ||= @canvas_root_account_id
|
384
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_grades/#{grade_id}", params
|
385
|
+
end
|
386
|
+
|
387
|
+
def get_school_subjects(account_id=@canvas_root_account_id, params={})
|
388
|
+
account_id ||= @canvas_root_account_id
|
389
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_subjects", params
|
390
|
+
end
|
391
|
+
|
392
|
+
def get_school_subject(subject_id, account_id=@canvas_root_account_id, params={})
|
393
|
+
account_id ||= @canvas_root_account_id
|
394
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_subjects/#{subject_id}", params
|
395
|
+
end
|
396
|
+
|
397
|
+
def get_school_class_rooms(account_id=@canvas_root_account_id, params={})
|
398
|
+
account_id ||= @canvas_root_account_id
|
399
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_class_rooms", params
|
400
|
+
end
|
401
|
+
|
402
|
+
def get_school_class_room(class_room_id, account_id=@canvas_root_account_id, params={})
|
403
|
+
account_id ||= @canvas_root_account_id
|
404
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_class_rooms/#{class_room_id}", params
|
362
405
|
end
|
363
406
|
|
364
|
-
def
|
365
|
-
|
407
|
+
def get_students_by_grade(grade_id, account_id=@canvas_root_account_id, params={})
|
408
|
+
account_id ||= @canvas_root_account_id
|
409
|
+
paginated_get "/api/v1/accounts/#{account_id}/grade_students/#{grade_id}", params
|
366
410
|
end
|
367
411
|
|
368
|
-
def
|
369
|
-
|
412
|
+
def get_students_by_class_room(class_room_id, account_id=@canvas_root_account_id, params={})
|
413
|
+
account_id ||= @canvas_root_account_id
|
414
|
+
paginated_get "/api/v1/accounts/#{account_id}/class_room_students/#{class_room_id}", params
|
370
415
|
end
|
371
416
|
### END QALAM API ###
|
372
417
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CanvasOauth
|
2
2
|
class CanvasApiExtensions
|
3
3
|
def self.build(canvas_url, user_id, tool_consumer_instance_guid)
|
4
|
-
account_id = CanvasOauth::Authorization.
|
4
|
+
account_id = CanvasOauth::Authorization.fetch_account(user_id, tool_consumer_instance_guid)
|
5
5
|
token = CanvasOauth::Authorization.fetch_token(user_id, tool_consumer_instance_guid)
|
6
6
|
refresh_token = CanvasOauth::Authorization.fetch_refresh_token(user_id, tool_consumer_instance_guid)
|
7
7
|
canvas_key = ((CanvasLtiKey.table_exists? && CanvasLtiKey.find_by(canvas_url: canvas_url)&.key) or CanvasConfig.key)
|
data/lib/canvas_oauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qalam_oauth_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Donahue
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-08-
|
14
|
+
date: 2021-08-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|