Sha256: dd6b9caa1a689206ea469ba1e292241647782e5139cf8f79c35263906d509c1e
Contents?: true
Size: 1.65 KB
Versions: 55
Compression:
Stored size: 1.65 KB
Contents
module PandaPal::Jobs class MissingGradePassbackParams < StandardError; end class GradePassbackFailure < StandardError; end class GradePassbackJob < ActiveJob::Base attr_accessor :organization, :opts sidekiq_options(retry: 5) if respond_to?(:sidekiq_options) # Required values for opts: passback_guid, passback_url, score AND/OR total_score. # Possible values for opts: cdata_text, text, url, submitted_at, lti_launch_url. # passback_guid is sent in launch params as 'lis_result_sourcedid'. # passback_url is sent in LTI launch params as 'lis_outcome_service_url'. # See https://canvas.instructure.com/doc/api/file.assignment_tools.html def perform(organization, opts = {}) opts = opts.with_indifferent_access raise MissingGradePassbackParams unless valid_options(opts) @organization = organization @opts = opts post_to_lms end private def post_to_lms result = tool_provider.post_extended_replace_result!(opts) unless result.success? Rails.logger.error "Grade passback failure: #{result.response_code} #{result.code_major} #{result.severity} #{result.description}" raise GradePassbackFailure end end def tool_provider @tool_provider ||= IMS::LTI::ToolProvider.new( organization.key, organization.secret, 'lis_result_sourcedid' => opts[:passback_guid], 'lis_outcome_service_url' => opts[:passback_url] ).extend(IMS::LTI::Extensions::OutcomeData::ToolProvider) end def valid_options(opts = {}) return opts[:passback_guid] && opts[:passback_url] && (opts[:score] || opts[:total_score]) end end end
Version data entries
55 entries across 55 versions & 1 rubygems