Sha256: 57d719b17faf891cc4e8b8ddadae63cafba4c4b67210d57bea8f8d061b467966
Contents?: true
Size: 1.19 KB
Versions: 29
Compression:
Stored size: 1.19 KB
Contents
module CoalescingPanda class PersistentSession < ActiveRecord::Base serialize :data, JSONWithIndifferentAccess belongs_to :coalescing_panda_lti_account, :class_name => 'CoalescingPanda::LtiAccount' validates :coalescing_panda_lti_account_id, presence: true after_initialize do self.data ||= {} self.session_key ||= SecureRandom.urlsafe_base64(60) end def self.create_from_launch(launch_params, account_id) session = PersistentSession.new(coalescing_panda_lti_account_id: 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 end end
Version data entries
29 entries across 29 versions & 1 rubygems