panda_pal 5.3.13 → 5.4.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/panda_pal_manifest.js +3 -0
- data/app/lib/lti_xml/base_platform.rb +1 -1
- 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.rb +2 -0
- data/lib/panda_pal/ability_mixin.rb +85 -0
- data/lib/panda_pal/engine.rb +20 -1
- data/lib/panda_pal/helpers/controller_helper.rb +2 -2
- data/lib/panda_pal/jobs/grade_passback_job.rb +50 -0
- data/lib/panda_pal/version.rb +1 -1
- data/panda_pal.gemspec +2 -2
- metadata +23 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 269670787a0bf5a9e2e9c758ee6e3e4689915e08fabb4a6eb80901658f1e9108
|
4
|
+
data.tar.gz: 2d4ed3aa0c345551e20e4cd9d12c6bf14ec373d10067417d74516040d3244f66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53601808a0539cc03f98d859ade70ccd47e11914e958f23b8a544f5062a10b540714d29f047dd80981ac66184e89cd891929f435d0589db37a21f0d1d1c75b0c
|
7
|
+
data.tar.gz: 1cbac9f8d3c006d16c6fba0c0616facdcdf2bd2125b8563fb320d7606a49f47e0d47f76ec2bbf6fc24c9ccd531b76f75c0c4976bcb6157fb555e9717dd359a25
|
@@ -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
|
|
data/lib/panda_pal.rb
CHANGED
@@ -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
@@ -24,9 +24,24 @@ module PandaPal
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
initializer 'interop dependencies' do
|
28
|
+
if $LOADED_FEATURES.grep(/\/ros-apartment-\d/).present?
|
29
|
+
if $LOADED_FEATURES.grep(/\/apartment-\d/).present? || $LOADED_FEATURES.grep(/\/apartment-sidekiq-\d/).present?
|
30
|
+
raise "ros-apartment is used, but apartment or apartment-sidekiq is loaded. Do not mix legacy and ros- variants! (You most likely need to update your Gemfile to use the ros- variant)"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
if defined?(Sidekiq)
|
34
|
+
begin
|
35
|
+
require 'apartment-sidekiq'
|
36
|
+
rescue LoadError
|
37
|
+
raise "Sidekiq is used, but apartment-sidekiq is not installed. Add [gem 'ros-apartment-sidekiq'] to your Gemfile"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
27
42
|
initializer 'Sidekiq Scheduler Hooks' do
|
28
43
|
ActiveSupport.on_load(:active_record) do
|
29
|
-
if Sidekiq.server? && PandaPal::Organization.respond_to?(:sync_schedules)
|
44
|
+
if defined?(Sidekiq) && Sidekiq.server? && PandaPal::Organization.respond_to?(:sync_schedules)
|
30
45
|
PandaPal::Organization.sync_schedules
|
31
46
|
end
|
32
47
|
end
|
@@ -50,6 +65,10 @@ module PandaPal
|
|
50
65
|
end
|
51
66
|
end
|
52
67
|
|
68
|
+
initializer "panda_pal.assets.precompile" do |app|
|
69
|
+
app.config.assets.precompile << "panda_pal_manifest.js"
|
70
|
+
end
|
71
|
+
|
53
72
|
initializer :secure_headers do |app|
|
54
73
|
begin
|
55
74
|
::SecureHeaders::Configuration.default do |config|
|
@@ -50,8 +50,8 @@ module PandaPal::Helpers
|
|
50
50
|
safe_unexpected_params.each do |p|
|
51
51
|
sanitized_params.delete(p)
|
52
52
|
end
|
53
|
-
|
54
|
-
authorized =
|
53
|
+
tp = IMS::LTI::ToolProvider.new(@organization.key, @organization.secret, sanitized_params)
|
54
|
+
authorized = tp.valid_request?(request)
|
55
55
|
end
|
56
56
|
|
57
57
|
if !authorized
|
@@ -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
data/panda_pal.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = Dir["spec/**/*"]
|
17
17
|
|
18
18
|
s.add_dependency "rails", ">= 4.2"
|
19
|
+
s.add_dependency 'ros-apartment', '~> 2.2'
|
19
20
|
s.add_dependency 'pg', '>= 0.20', '< 1.0.0'
|
20
|
-
s.add_dependency '
|
21
|
-
s.add_dependency 'ims-lti', '~> 2.2.3'
|
21
|
+
s.add_dependency 'ims-lti', '~> 1.2.4'
|
22
22
|
s.add_dependency 'browser', '2.5.0'
|
23
23
|
s.add_dependency 'attr_encrypted', '~> 3.0.0'
|
24
24
|
s.add_dependency 'secure_headers', '~> 6.1'
|
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
|
+
version: 5.4.0.beta5
|
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-
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ros-apartment
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: pg
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,34 +58,20 @@ dependencies:
|
|
44
58
|
- - "<"
|
45
59
|
- !ruby/object:Gem::Version
|
46
60
|
version: 1.0.0
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: apartment
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.2.0
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 2.2.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: ims-lti
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 1.2.4
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 1.2.4
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: browser
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -312,9 +315,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
312
315
|
version: '0'
|
313
316
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
317
|
requirements:
|
315
|
-
- - "
|
318
|
+
- - ">"
|
316
319
|
- !ruby/object:Gem::Version
|
317
|
-
version:
|
320
|
+
version: 1.3.1
|
318
321
|
requirements: []
|
319
322
|
rubygems_version: 3.0.3
|
320
323
|
signing_key:
|