panda_pal 5.4.0.beta1 → 5.4.0.beta6
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 +4 -4
- data/app/assets/config/panda_pal_manifest.js +3 -0
- data/app/models/panda_pal/organization.rb +3 -0
- data/app/models/panda_pal/organization_concerns/task_scheduling.rb +14 -1
- data/lib/panda_pal/ability_mixin.rb +85 -0
- data/lib/panda_pal/engine.rb +4 -0
- data/lib/panda_pal/helpers/session_replacement.rb +8 -4
- data/lib/panda_pal/jobs/grade_passback_job.rb +50 -0
- data/lib/panda_pal/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ad739feb20cd4db69778441ccc21256211d3a8715b1ea82921a9786ed1d6f44
|
4
|
+
data.tar.gz: 6d0e6927cd23b2a56336a0a9e3dbfda787cb59415c13d1fc4eb316e1c87c400c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9389b4e09c6fb0c270c7cb1c641bbe4cdc010b9084b51519100dfdf9cd4c103e36a8f0d86819d6619e2dc27f42afa52d214c7936c75c120ce6c994ca30ce1e21
|
7
|
+
data.tar.gz: 4fe4207ca646e48c6d13dfe7b259d306066b812b3a1502fb866f0501cffcb43dc4e935c8cd3ad198980d16582125441e5eb11c94601d6a3f3cad12e60c900c5e
|
@@ -1,4 +1,17 @@
|
|
1
|
-
|
1
|
+
unless defined?(Sidekiq.schedule)
|
2
|
+
module PandaPal
|
3
|
+
module OrganizationConcerns
|
4
|
+
module TaskScheduling
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
raise "The PandaPal TaskScheduling requires Sidekiq-scheduler to be installed"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
return
|
14
|
+
end
|
2
15
|
|
3
16
|
require_relative 'settings_validation'
|
4
17
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module PandaPal
|
2
|
+
module AbilityMixin
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
class_methods do
|
6
|
+
def self.role_permissions(labels)
|
7
|
+
roles = find_roles_by_label(labels)
|
8
|
+
|
9
|
+
if Rails.env.test? && roles.count == 0 && (labels || []).include?('Administrator')
|
10
|
+
return Hash.new(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
final = {}
|
14
|
+
roles.find_each do |role|
|
15
|
+
role.permissions.each do |perm_name, perm|
|
16
|
+
final[perm_name] = false if final[perm_name].nil?
|
17
|
+
final[perm_name] = true if perm['enabled'] == true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
final
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.find_roles_by_label(labels)
|
24
|
+
raise "PandaPal AbilityMixin's support for Roles and Permissions requires that Roles be synced by CanvasSync" unless defined?(Role)
|
25
|
+
|
26
|
+
built_ins = []
|
27
|
+
labels = labels.split(',') if labels.is_a?(String)
|
28
|
+
custom_labels = Array(labels).reject do |l|
|
29
|
+
if role_is_default?(l)
|
30
|
+
built_ins << l
|
31
|
+
elsif l == 'Account Admin'
|
32
|
+
built_ins << 'AccountMembership'
|
33
|
+
else
|
34
|
+
next
|
35
|
+
end
|
36
|
+
true
|
37
|
+
end
|
38
|
+
Role.where(workflow_state: 'built_in', base_role_type: built_ins)
|
39
|
+
.or(Role.where.not(workflow_state: 'built_in').where(label: custom_labels))
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.role_is_default?(role)
|
43
|
+
%w[TeacherEnrollment TaEnrollment StudentEnrollment DesignerEnrollment ObserverEnrollment].include? role
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def is_lti_launch?
|
48
|
+
@controller.current_session.present?
|
49
|
+
end
|
50
|
+
|
51
|
+
def panda_pal_session
|
52
|
+
@panda_pal_session ||= @controller.current_session&.data || {}
|
53
|
+
end
|
54
|
+
|
55
|
+
def rails_session
|
56
|
+
@rails_session ||= @controller.session
|
57
|
+
end
|
58
|
+
|
59
|
+
def launch_params
|
60
|
+
@launch_params ||= panda_pal_session[:launch_params] || {}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Roles and Permissions
|
64
|
+
def lti_roles
|
65
|
+
@lti_roles ||= LTIRoles::RoleManager.new(launch_params['ext_roles'] || '')
|
66
|
+
end
|
67
|
+
|
68
|
+
def canvas_permissions
|
69
|
+
panda_pal_session[:canvas_permissions] ||= self.class.role_permissions(launch_params['custom_canvas_role'])
|
70
|
+
end
|
71
|
+
|
72
|
+
def canvas_role_labels
|
73
|
+
labels = launch_params['custom_canvas_role']
|
74
|
+
labels.is_a?(String) ? labels.split(',') : []
|
75
|
+
end
|
76
|
+
|
77
|
+
def canvas_roles
|
78
|
+
self.class.find_roles_by_label(canvas_role_labels)
|
79
|
+
end
|
80
|
+
|
81
|
+
def launch_role_ids
|
82
|
+
panda_pal_session[:launch_role_ids] ||= canvas_roles.map(&:canvas_id)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/panda_pal/engine.rb
CHANGED
@@ -65,6 +65,10 @@ module PandaPal
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
initializer "panda_pal.assets.precompile" do |app|
|
69
|
+
app.config.assets.precompile << "panda_pal_manifest.js"
|
70
|
+
end
|
71
|
+
|
68
72
|
initializer :secure_headers do |app|
|
69
73
|
begin
|
70
74
|
::SecureHeaders::Configuration.default do |config|
|
@@ -13,11 +13,15 @@ module PandaPal::Helpers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class_methods do
|
16
|
-
def link_nonce_type(value = :not_given)
|
17
|
-
if
|
18
|
-
|
16
|
+
def link_nonce_type(value = :not_given, use_non_app: false)
|
17
|
+
if use_non_app || !defined?(::ApplicationController) || self <= ::ApplicationController
|
18
|
+
if value == :not_given
|
19
|
+
@link_nonce_type || superclass.try(:link_nonce_type) || :nonce
|
20
|
+
else
|
21
|
+
@link_nonce_type = value
|
22
|
+
end
|
19
23
|
else
|
20
|
-
|
24
|
+
::ApplicationController.link_nonce_type(value, use_non_app: true)
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module PandaPal::Jobs
|
2
|
+
class MissingGradePassbackParams < StandardError; end
|
3
|
+
|
4
|
+
class GradePassbackFailure < StandardError; end
|
5
|
+
|
6
|
+
class GradePassbackJob < ActiveJob::Base
|
7
|
+
sidekiq_options retry: 5
|
8
|
+
|
9
|
+
attr_accessor :organization, :opts
|
10
|
+
|
11
|
+
# Required values for opts: passback_guid, passback_url, score AND/OR total_score.
|
12
|
+
# Possible values for opts: cdata_text, text, url, submitted_at, lti_launch_url.
|
13
|
+
# passback_guid is sent in launch params as 'lis_result_sourcedid'.
|
14
|
+
# passback_url is sent in LTI launch params as 'lis_outcome_service_url'.
|
15
|
+
# See https://canvas.instructure.com/doc/api/file.assignment_tools.html
|
16
|
+
def perform(organization, opts = {})
|
17
|
+
opts = opts.with_indifferent_access
|
18
|
+
raise MissingGradePassbackParams unless valid_options(opts)
|
19
|
+
|
20
|
+
@organization = organization
|
21
|
+
@opts = opts
|
22
|
+
|
23
|
+
post_to_lms
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def post_to_lms
|
29
|
+
result = tool_provider.post_extended_replace_result!(opts)
|
30
|
+
unless result.success?
|
31
|
+
Rails.logger.error "Grade passback failure: #{result.response_code} #{result.code_major} #{result.severity} #{result.description}"
|
32
|
+
raise GradePassbackFailure
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def tool_provider
|
37
|
+
@tool_provider ||= IMS::LTI::ToolProvider.new(
|
38
|
+
organization.key,
|
39
|
+
organization.secret,
|
40
|
+
'lis_result_sourcedid' => opts[:passback_guid],
|
41
|
+
'lis_outcome_service_url' => opts[:passback_url]
|
42
|
+
).extend(IMS::LTI::Extensions::OutcomeData::ToolProvider)
|
43
|
+
end
|
44
|
+
|
45
|
+
def valid_options(opts = {})
|
46
|
+
return opts[:passback_guid] && opts[:passback_url] && (opts[:score] || opts[:total_score])
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lib/panda_pal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.4.0.
|
4
|
+
version: 5.4.0.beta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure ProServe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- MIT-LICENSE
|
209
209
|
- README.md
|
210
210
|
- Rakefile
|
211
|
+
- app/assets/config/panda_pal_manifest.js
|
211
212
|
- app/assets/javascripts/panda_pal/application.js
|
212
213
|
- app/assets/javascripts/panda_pal/lti.js
|
213
214
|
- app/assets/stylesheets/panda_pal/application.css
|
@@ -243,12 +244,14 @@ files:
|
|
243
244
|
- db/migrate/20171205183457_encrypt_organization_settings.rb
|
244
245
|
- db/migrate/20171205194657_remove_old_organization_settings.rb
|
245
246
|
- lib/panda_pal.rb
|
247
|
+
- lib/panda_pal/ability_mixin.rb
|
246
248
|
- lib/panda_pal/engine.rb
|
247
249
|
- lib/panda_pal/helpers.rb
|
248
250
|
- lib/panda_pal/helpers/controller_helper.rb
|
249
251
|
- lib/panda_pal/helpers/route_helper.rb
|
250
252
|
- lib/panda_pal/helpers/secure_headers.rb
|
251
253
|
- lib/panda_pal/helpers/session_replacement.rb
|
254
|
+
- lib/panda_pal/jobs/grade_passback_job.rb
|
252
255
|
- lib/panda_pal/plugins.rb
|
253
256
|
- lib/panda_pal/version.rb
|
254
257
|
- lib/tasks/panda_pal_tasks.rake
|