Class: CoalescingPanda::PersistentSession

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/coalescing_panda/persistent_session.rb

Class Method Summary collapse

Class Method Details

.create_from_launch(launch_params, account_id) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/coalescing_panda/persistent_session.rb', line 12

def self.create_from_launch(launch_params, )
  session = PersistentSession.new(coalescing_panda_lti_account_id: )
  session.data[:launch_params] = launch_params.to_unsafe_h.with_indifferent_access
  session.data[:roles] = launch_params['roles'].split(',').map { |role|
    case role.downcase.strip
    when 'admin'
      :admin
    when 'urn:lti:instrole:ims/lis/administrator'
      :admin
    when 'learner'
      :student
    when 'instructor'
      :teacher
    when 'urn:lti:role:ims/lis/teachingassistant'
      :ta
    when 'contentdeveloper'
      :designer
    when 'urn:lti:instrole:ims/lis/observer'
      :observer
    else
      :none
    end
  }.uniq
  session.save!
  session
end