Class: ScormEngine::Models::RegistrationActivityDetail

Inherits:
Base
  • Object
show all
Defined in:
lib/scorm_engine/models/registration_activity_detail.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_hash

Instance Attribute Details

#activity_completionString

Represents whether the current attempt on the activity has been completed.

Returns:

  • (String)

    (UNKNOWN COMPLETED INCOMPLETE)


22
23
24
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 22

def activity_completion
  @activity_completion
end

#activity_successString

Pass/fail status of primary objective for this activity.

Returns:

  • (String)

    (UNKNOWN PASSED FAILED)


32
33
34
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 32

def activity_success
  @activity_success
end

#childrenArray<ScormEngine::Models::RegistrationActivityDetail>

A nested array of activity details


12
13
14
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 12

def children
  @children
end

#idString

The external identification of the registration.

Returns:

  • (String)

7
8
9
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 7

def id
  @id
end

#previous_attempt_completionString

Represents whether the previous attempt on the activity has been completed.

Returns:

  • (String)

    (Unknown Completed Incomplete)


27
28
29
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 27

def previous_attempt_completion
  @previous_attempt_completion
end

#runtime_interactionsArray<ScormEngine::Models::RegistrationRuntimeInteraction>


17
18
19
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 17

def runtime_interactions
  @runtime_interactions
end

Class Method Details

.get_runtime_interactions_from_api(options) ⇒ Object


59
60
61
62
63
64
# 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 = {}) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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

Instance Method Details

#all_runtime_interactionsArray<RegistrationRuntimeInteraction>

Return a flattened array of all runtime interactions

Returns:


55
56
57
# 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?Boolean

Has this activity been completed?

Returns:

  • (Boolean)

    Returns true, false or nil if completion status is unknown.


72
73
74
75
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 72

def complete?
  return nil if activity_completion == "UNKNOWN"
  activity_completion == "COMPLETED"
end

#failed?Boolean

Has this activity failed?

Returns:

  • (Boolean)

    Returns true, false or nil if success status is unknown.


127
128
129
130
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 127

def failed?
  return nil if activity_success == "UNKNOWN"
  activity_success == "FAILED"
end

#incomplete?Boolean

Is this activity incomplete?

Returns:

  • (Boolean)

    Returns true, false or nil if completion status is unknown.


83
84
85
86
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 83

def incomplete?
  return nil if activity_completion == "UNKNOWN"
  activity_completion == "INCOMPLETE"
end

#passed?Boolean

Has this activity been passed?

Returns:

  • (Boolean)

    Returns true, false or nil if success status is unknown.


116
117
118
119
# 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?Boolean

Has the previous attempt of this activity been completed?

Returns:

  • (Boolean)

    Returns true, false or nil if completion status is unknown.


94
95
96
97
# 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?Boolean

Is the previous attempt of this previous_attempt incomplete?

Returns:

  • (Boolean)

    Returns true, false or nil if completion status is unknown.


105
106
107
108
# 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