qalam_lti_provider_engine 1.1.6 → 2.0.4

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: 966db98bfcaa29cbf05e8b3b38f270f50cc4ea27480a2245dd08804f09f502a8
4
- data.tar.gz: 2d7be0649b8c6cf2b2e34bf41224de7e31896255e58969adf109c78f9f108add
3
+ metadata.gz: a12df9097c8a33e018107f6fe2446bbd1a655f72988f05037a4680dccb65fa43
4
+ data.tar.gz: 70b02c5a7360a0469d1ebfa874fc4cafe425beea44027607257db7278a82d11f
5
5
  SHA512:
6
- metadata.gz: c52b467a447ca10b21669f601caf1e31bdbd9e2e00f6cd5f2f094d8424da8c706c93ca17d476797200cf46b3cd8da7cab66cfad9a0dd312a311e1d0147da213e
7
- data.tar.gz: 5a2eb1b5611808ecc4a896c2e6e11a0e491ae3831fc6c74e0eb09bfd3aaa789c002c974be00d5f716beecc63f5cb00c143fdfd4041e6828081a6b458c0999cbe
6
+ metadata.gz: d0cadd596322889662e35483eed0d7ad2b8abf1d77d84e401775affdeeea6e34f7719d85efda57496e297466d22bc0db181c2e2e5364d6a59595be076e05dd99
7
+ data.tar.gz: a650191d9d1b696adaa4d3ad2a53f0a5d0912b3e61fa2eed1d53990f055b970072d30c6377c58ba2c211e38b3ce25927b9e7efeaa05fcc476c636793e1376dea
@@ -8,13 +8,20 @@ module LtiProvider
8
8
  def launch
9
9
  provider = IMS::LTI::ToolProvider.new(params['oauth_consumer_key'], LtiProvider::Config.secret, params)
10
10
  launch = Launch.initialize_from_request(provider, request)
11
-
11
+
12
12
  if !launch.valid_provider?
13
- msg = "#{launch.lti_errormsg} Please be sure you are launching this tool from the link provided in Canvas."
13
+ msg = "#{launch.lti_errormsg} Please be sure you are launching this tool from the link provided in Qalam."
14
14
  return show_error msg
15
15
  elsif launch.save
16
16
  session[:cookie_test] = true
17
- redirect_to cookie_test_path(nonce: launch.nonce, launch: params[:launch], timetable_date: params[:timetable_date], section_room: params[:section_room])
17
+
18
+ ### QALAM ###
19
+ if params[:timetable_date] && params[:section_room]
20
+ redirect_to cookie_test_path(nonce: launch.nonce, timetable_date: params[:timetable_date], section_room: params[:section_room])
21
+ else
22
+ redirect_to cookie_test_path(nonce: launch.nonce)
23
+ end
24
+ ### END ###
18
25
  else
19
26
  return show_error "Unable to launch #{LtiProvider::XmlConfig.tool_title}. Please check your External Tools configuration and try again."
20
27
  end
@@ -32,24 +39,21 @@ module LtiProvider
32
39
  def consume_launch
33
40
  launch = Launch.where("created_at > ?", 5.minutes.ago).find_by_nonce(params[:nonce])
34
41
 
35
- puts params.inspect.yellow
36
-
37
42
  if launch
38
43
  [:account_id, :course_name, :course_id, :canvas_url, :tool_consumer_instance_guid,
39
- :user_id, :user_name, :user_roles, :user_avatar_url].each do |attribute|
44
+ :user_id, :user_name, :user_roles, :user_avatar_url, :launch_tool].each do |attribute|
40
45
  session[attribute] = launch.public_send(attribute)
41
46
  end
42
47
 
48
+ ### QALAM ###
49
+ if params[:timetable_date] && params[:section_room]
50
+ session[:timetable_date] = params[:timetable_date]
51
+ session[:section_room] = params[:section_room]
52
+ end
53
+ ### END ###
54
+
43
55
  launch.destroy
44
56
 
45
- session.delete(:launch)
46
- session.delete(:timetable_date)
47
- session.delete(:section_room)
48
-
49
- session[:launch] = params[:launch] if params[:launch]
50
- session[:timetable_date] = params[:timetable_date] if params[:timetable_date]
51
- session[:section_room] = params[:section_room] if params[:section_room]
52
-
53
57
  redirect_to main_app.root_path
54
58
  else
55
59
  return show_error "The tool was not launched successfully. Please try again."
@@ -69,5 +73,4 @@ module LtiProvider
69
73
  render plain: message
70
74
  end
71
75
  end
72
- end
73
-
76
+ end
@@ -7,6 +7,7 @@ module LtiProvider
7
7
  attr_accessor :lti_errormsg
8
8
 
9
9
  serialize :provider_params
10
+ # serialize :tool_params
10
11
 
11
12
  def self.initialize_from_request(provider, request)
12
13
  launch = new
@@ -17,6 +18,11 @@ module LtiProvider
17
18
  launch.canvas_url = launch.api_endpoint(provider)
18
19
  launch.nonce = launch.provider_params['oauth_nonce']
19
20
 
21
+ ### QALAM ###
22
+ launch.launch_tool = request.params[:launch_tool] if request.params[:launch_tool]
23
+ # launch.tool_params = {timetable_date: request.params[:timetable_date], section_room: request.params[:section_room]}.to_params if request.params[:timetable_date] && request.params[:section_room]
24
+ ### END ###
25
+
20
26
  launch
21
27
  end
22
28
 
@@ -79,8 +85,8 @@ module LtiProvider
79
85
  "Consumer key not provided."
80
86
  elsif provider.consumer_secret.blank?
81
87
  "Consumer secret not configured on provider."
82
- ### QALAM ###
83
88
  elsif !provider.valid_request?(request) && false
89
+ ### Should remove false from condition, by solving its problem with attendance per da from 'ims-lti' gem
84
90
  "The OAuth signature was invalid."
85
91
  elsif oauth_timestamp_too_old?(provider.request_oauth_timestamp)
86
92
  "Your request is too old."
@@ -103,4 +109,4 @@ module LtiProvider
103
109
  Time.now.utc.to_i - timestamp.to_i > 1.hour.to_i
104
110
  end
105
111
  end
106
- end
112
+ end
@@ -1,4 +1,4 @@
1
1
  <p>
2
2
  It appears your browser is blocking cookies. You can try
3
- <%= link_to "launching the tool in a new window", consume_launch_url(nonce: params[:nonce], url: params[:url]), target: '_blank' %>.
3
+ <%= link_to "launching the tool in a new window", consume_launch_url(nonce: params[:nonce]), target: '_blank' %>.
4
4
  </p>
@@ -7,10 +7,29 @@ default: &default
7
7
  privacy_level: 'public'
8
8
 
9
9
  # url defaults to lti_launch_url, but can be overridden in each of these
10
- course_navigation:
10
+ account_navigation:
11
11
  text: 'Dummy'
12
12
  visibility: 'admins'
13
- # account_navigation and user_navigation are also available with similar options
13
+ url: 'ssd'
14
+ enabled: true
15
+ default: 'enabled'
16
+ windowTarget: '_self'
17
+ custom_fields:
18
+ key1: 'value1'
19
+ labels:
20
+ en: 'Attendance'
21
+ ar: 'الحضور'
22
+ # course_navigation and user_navigation are also available with similar options
23
+
24
+ editor_button:
25
+ enabled: true
26
+ icon_url: ''
27
+ selection_width: ''
28
+ selection_height: ''
29
+ labels:
30
+ en: ''
31
+ ar: ''
32
+
14
33
 
15
34
  development:
16
35
  <<: *default
@@ -4,8 +4,12 @@ class CreateLtiProviderLaunches < ActiveRecord::Migration[4.2]
4
4
  t.string "canvas_url"
5
5
  t.string "nonce"
6
6
  t.text "provider_params"
7
+ ### QALAM ###
8
+ t.string "launch_tool", null: true
9
+ t.text "tool_params", null: true
10
+ ### END ###
7
11
 
8
12
  t.timestamps
9
13
  end
10
14
  end
11
- end
15
+ end
@@ -18,7 +18,7 @@ module LtiProvider
18
18
  end
19
19
 
20
20
  def prompt_for_launch
21
- render plain: 'Please launch this tool from Canvas and then try again.'
21
+ render plain: 'Please launch this tool from Qalam and then try again.'
22
22
  end
23
23
 
24
24
  def canvas_url
@@ -53,6 +53,28 @@ module LtiProvider
53
53
  session[:user_roles]
54
54
  end
55
55
 
56
+ ### QALAM ###
57
+ def launch_tool
58
+ session[:launch_tool]
59
+ end
60
+
61
+ def student_launch?
62
+ user_roles.split(',').include? 'urn:lti:role:ims/lis/Learner'
63
+ end
64
+
65
+ def teacher_launch?
66
+ user_roles.split(',').include? 'urn:lti:role:ims/lis/Instructor'
67
+ end
68
+
69
+ def account_admin_launch?
70
+ user_roles.split(',').include? 'urn:lti:instrole:ims/lis/Administrator'
71
+ end
72
+
73
+ def root_admin_launch?
74
+ user_roles.split(',').include? 'urn:lti:sysrole:ims/lis/SysAdmin'
75
+ end
76
+ ### END ###
77
+
56
78
  def not_acceptable
57
79
  render plain: "Unable to process request", status: 406
58
80
  end
@@ -1,3 +1,3 @@
1
1
  module LtiProvider
2
- VERSION = "1.1.6"
2
+ VERSION = "2.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qalam_lti_provider_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 2.0.4
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-05-22 00:00:00.000000000 Z
14
+ date: 2021-08-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '4.2'
23
23
  - - "<"
24
24
  - !ruby/object:Gem::Version
25
- version: '5.3'
25
+ version: '6.1'
26
26
  type: :runtime
27
27
  prerelease: false
28
28
  version_requirements: !ruby/object:Gem::Requirement
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '4.2'
33
33
  - - "<"
34
34
  - !ruby/object:Gem::Version
35
- version: '5.3'
35
+ version: '6.1'
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ims-lti
38
38
  requirement: !ruby/object:Gem::Requirement
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  - !ruby/object:Gem::Version
313
313
  version: '0'
314
314
  requirements: []
315
- rubygems_version: 3.2.15
315
+ rubygems_version: 3.2.21
316
316
  signing_key:
317
317
  specification_version: 4
318
318
  summary: LtiProvider is a mountable engine for handling the LTI launch and exposing