qalam_oauth_engine 3.0.6 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/canvas_oauth/canvas_controller.rb +0 -1
- data/lib/canvas_oauth/canvas_api.rb +83 -56
- data/lib/canvas_oauth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce5f3ea19a895f5964a450249d587a9a9e847064071bb260f42f078d3a5ed58
|
4
|
+
data.tar.gz: d2621e2449cb88ec7dfcaea89219c4e825a981e4ed82eaaf2dd9af40beb554a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a55695a6a6b196a6cb7cc3402d314b987473ed58a1b78dd538b35f80903b0035beff1dd00acb714c1a2f521348f9baf978f941584098c742e182f2be003a0b
|
7
|
+
data.tar.gz: df1b190fb6e62609f9867ca96c6365786137681c2c5bc3f0b14fef895308912fce6d1956d40385e1a06d233c7e2437fd0bf5ebf3f2c98372d2ec0ea9cc62743c
|
@@ -6,7 +6,6 @@ module CanvasOauth
|
|
6
6
|
if verify_oauth2_state(params[:state]) && params[:code]
|
7
7
|
if token = canvas.get_access_token(params[:code])
|
8
8
|
set_root_account
|
9
|
-
puts @root_account_id.inspect.green
|
10
9
|
refresh_token = canvas.refresh_token
|
11
10
|
if CanvasOauth::Authorization.cache_token(token, refresh_token, user_id, @root_account_id, tool_consumer_instance_guid)
|
12
11
|
redirect_to main_app.root_path
|
@@ -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
|
-
|
114
|
-
|
113
|
+
if params[:all_pages]
|
114
|
+
while url && current_page = authenticated_get(url, params) do
|
115
|
+
all_pages.concat(current_page) if valid_page?(current_page)
|
115
116
|
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
links = LinkHeader.parse(current_page.headers['link'])
|
118
|
+
url = links.find_link(["rel", "next"]).try(:href)
|
119
|
+
params[:query] = nil if params[:query]
|
120
|
+
end
|
121
|
+
else
|
122
|
+
current_page = authenticated_get(url, params)
|
123
|
+
all_pages.concat(current_page) if valid_page?(current_page)
|
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,66 @@ 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
|
-
#
|
339
|
+
# get_school_grades
|
340
|
+
# get_school_class_rooms
|
341
|
+
# get_school_subjects
|
342
|
+
# get_students_by_grade
|
343
|
+
# get_students_by_class_room
|
337
344
|
|
338
|
-
def get_canvas_user_profile
|
345
|
+
def get_canvas_user_profile(params={})
|
339
346
|
authenticated_get "/api/v1/users/#{canvas_user_id}/profile"
|
340
347
|
end
|
341
348
|
|
342
|
-
def get_course_active_pages(course_id, publish=nil)
|
349
|
+
def get_course_active_pages(course_id, publish=nil, params={})
|
343
350
|
unless publish.nil?
|
344
|
-
paginated_get "/api/v1/courses/#{course_id}/pages?published=#{publish}&sort=created_at&order=desc"
|
351
|
+
paginated_get "/api/v1/courses/#{course_id}/pages?published=#{publish}&sort=created_at&order=desc", params
|
345
352
|
else
|
346
|
-
paginated_get "/api/v1/courses/#{course_id}/pages?sort=created_at&order=desc"
|
353
|
+
paginated_get "/api/v1/courses/#{course_id}/pages?sort=created_at&order=desc", params
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
def update_external_tool_nav(external_tool_url, tool_id, publish, type, account_id=@canvas_root_account_id, params={})
|
358
|
+
account_id ||= @canvas_root_account_id
|
359
|
+
if type == 'account'
|
360
|
+
body = {"account_navigation"=>{"enabled"=>"#{publish}"},
|
361
|
+
"tool_id"=>tool_id, "external_tool_url"=>external_tool_url}
|
362
|
+
elsif type == 'course'
|
363
|
+
body = {"course_navigation"=>{"enabled"=>"#{publish}"},
|
364
|
+
"tool_id"=>tool_id, "external_tool_url"=>external_tool_url}
|
347
365
|
end
|
366
|
+
authenticated_put "/api/v1/accounts/#{account_id}/external_tools_url", { body: body } if body
|
367
|
+
end
|
368
|
+
|
369
|
+
def get_school_details(account_id=@canvas_root_account_id, params={})
|
370
|
+
account_id ||= @canvas_root_account_id
|
371
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_details"
|
348
372
|
end
|
349
373
|
|
350
|
-
def
|
351
|
-
|
352
|
-
|
374
|
+
def get_school_grades(account_id=@canvas_root_account_id, params={})
|
375
|
+
account_id ||= @canvas_root_account_id
|
376
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_grades", params
|
353
377
|
end
|
354
378
|
|
355
|
-
def
|
356
|
-
|
357
|
-
|
379
|
+
def get_school_subjects(account_id=@canvas_root_account_id, params={})
|
380
|
+
account_id ||= @canvas_root_account_id
|
381
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_subjects", params
|
358
382
|
end
|
359
383
|
|
360
|
-
def
|
361
|
-
|
384
|
+
def get_school_class_rooms(account_id=@canvas_root_account_id, params={})
|
385
|
+
account_id ||= @canvas_root_account_id
|
386
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_class_rooms", params
|
362
387
|
end
|
363
388
|
|
364
|
-
def
|
365
|
-
|
389
|
+
def get_students_by_grade(grade_id, account_id=@canvas_root_account_id, params={})
|
390
|
+
account_id ||= @canvas_root_account_id
|
391
|
+
paginated_get "/api/v1/accounts/#{account_id}/grade_students/#{grade_id}", params
|
366
392
|
end
|
367
393
|
|
368
|
-
def
|
369
|
-
|
394
|
+
def get_students_by_class_room(class_room_id, account_id=@canvas_root_account_id, params={})
|
395
|
+
account_id ||= @canvas_root_account_id
|
396
|
+
paginated_get "/api/v1/accounts/#{account_id}/class_room_students/#{class_room_id}", params
|
370
397
|
end
|
371
398
|
### END QALAM API ###
|
372
399
|
end
|
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.7
|
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-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|