class ScormEngine::Models::Dispatch

Attributes

allow_new_registrations[RW]

@attr If true, then new registrations can be created for this dispatch. @return [Boolean]

course_id[RW]

@attr The external identification of the course. @return [String]

destination_id[RW]

@attr The external identification of the destination. @return [String]

enabled[RW]

@attr If true, then this dispatch can be launched. @return [Boolean]

expiration_date[RW]

@attr The date after which this dispatch will be disabled as an ISO 8601 string, or “none” for no expiration date. @return [Time]

external_config[RW]

@attr Serialized external configuration information to include when launching the dispatched package. @return [String]

id[RW]

@attr The external identification of this dispatch. @return [String]

instanced[RW]

@attr If true, then a new registration instance will be created if the client LMS doesn't provide launch data for an existing one. Otherwise, the same instance will always be used for the given cmi.learner_id. @return [Boolean]

registration_cap[RW]

@attr The maximum number of registrations that can be created for this dispatch, where '0' means 'unlimited registrations'. @return [Integer]

registration_count[RW]

@attr The number of registrations created for this dispatch. @return [Integer]

Public Class Methods

get_expiration_date(options = {}) click to toggle source

Extract and normalize the expiration date from the API options.

@param [Hash] options

The API options hash

@return [Time]

a date/time or nil if undefined.
# File lib/scorm_engine/models/dispatch.rb, line 92
def self.get_expiration_date(options = {})
  expiration_date = options["expirationDate"]
  return if expiration_date.nil? || expiration_date == "none"
  Time.parse(expiration_date)
end
new_from_api(options = {}) click to toggle source
# File lib/scorm_engine/models/dispatch.rb, line 61
def self.new_from_api(options = {})
  this = new

  this.options = options.dup
  this.id = options["id"]

  # get_dispatches (plural) returns values in a nested 'data' field.
  # get_dispatches (singular) does not.
  data = options["data"] || options
  this.destination_id = data["destinationId"]
  this.course_id = data["courseId"]
  this.allow_new_registrations = data["allowNewRegistrations"]
  this.instanced = data["instanced"]
  this.registration_cap = data["registrationCap"]&.to_i
  this.registration_count = data["registrationCount"]&.to_i
  this.expiration_date = get_expiration_date(data)
  this.enabled = data["enabled"]
  this.external_config = data["externalConfig"]

  this
end