class ScormEngine::Models::RegistrationActivityDetail

Attributes

activity_completion[RW]

@attr Represents whether the current attempt on the activity has been completed. @return [String] (UNKNOWN COMPLETED INCOMPLETE)

activity_success[RW]

@attr Pass/fail status of primary objective for this activity. @return [String] (UNKNOWN PASSED FAILED)

children[RW]

@attr A nested array of activity details @return [Array<ScormEngine::Models::RegistrationActivityDetail>]

id[RW]

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

previous_attempt_completion[RW]

@attr Represents whether the previous attempt on the activity has been completed. @return [String] (Unknown Completed Incomplete)

runtime_interactions[RW]

@attr

@return [Array<ScormEngine::Models::RegistrationRuntimeInteraction>]

Public Class Methods

get_runtime_interactions_from_api(options) click to toggle source
# File lib/scorm_engine/models/registration_activity_detail.rb, line 59
def self.get_runtime_interactions_from_api(options)
  options
    .fetch("runtime", {})
    .fetch("runtimeInteractions", [])
    .map { |e| RegistrationRuntimeInteraction.new_from_api(e) }
end
new_from_api(options = {}) click to toggle source
# File lib/scorm_engine/models/registration_activity_detail.rb, line 34
def self.new_from_api(options = {})
  this = new

  this.options = options.dup
  this.id = options["id"]
  this.activity_completion = options["activityCompletion"]&.upcase
  this.previous_attempt_completion = options["previousAttemptCompletion"]&.upcase
  this.activity_success = options["activitySuccess"]&.upcase

  this.runtime_interactions = get_runtime_interactions_from_api(options)

  this.children = options.fetch("children", []).map { |e| new_from_api(e) }

  this
end

Public Instance Methods

all_runtime_interactions() click to toggle source

Return a flattened array of all runtime interactions

@return [Array<RegistrationRuntimeInteraction>]

# File lib/scorm_engine/models/registration_activity_detail.rb, line 55
def all_runtime_interactions
  (runtime_interactions + children.map(&:all_runtime_interactions)).flatten
end
complete?() click to toggle source

Has this activity been completed?

@return [Boolean]

Returns true, false or nil if completion status is unknown.
# File lib/scorm_engine/models/registration_activity_detail.rb, line 72
def complete?
  return nil if activity_completion == "UNKNOWN"
  activity_completion == "COMPLETED"
end
failed?() click to toggle source

Has this activity failed?

@return [Boolean]

Returns true, false or nil if success status is unknown.
# File lib/scorm_engine/models/registration_activity_detail.rb, line 127
def failed?
  return nil if activity_success == "UNKNOWN"
  activity_success == "FAILED"
end
incomplete?() click to toggle source

Is this activity incomplete?

@return [Boolean]

Returns true, false or nil if completion status is unknown.
# File lib/scorm_engine/models/registration_activity_detail.rb, line 83
def incomplete?
  return nil if activity_completion == "UNKNOWN"
  activity_completion == "INCOMPLETE"
end
passed?() click to toggle source

Has this activity been passed?

@return [Boolean]

Returns true, false or nil if success status is unknown.
# File lib/scorm_engine/models/registration_activity_detail.rb, line 116
def passed?
  return nil if activity_success == "UNKNOWN"
  activity_success == "PASSED"
end
previous_attempt_complete?() click to toggle source

Has the previous attempt of this activity been completed?

@return [Boolean]

Returns true, false or nil if completion status is unknown.
# File lib/scorm_engine/models/registration_activity_detail.rb, line 94
def previous_attempt_complete?
  return nil if previous_attempt_completion == "UNKNOWN"
  previous_attempt_completion == "COMPLETED"
end
previous_attempt_incomplete?() click to toggle source

Is the previous attempt of this previous_attempt incomplete?

@return [Boolean]

Returns true, false or nil if completion status is unknown.
# File lib/scorm_engine/models/registration_activity_detail.rb, line 105
def previous_attempt_incomplete?
  return nil if previous_attempt_completion == "UNKNOWN"
  previous_attempt_completion == "INCOMPLETE"
end