Class: ScormEngine::Models::Registration
- Inherits:
-
Object
- Object
- ScormEngine::Models::Registration
- Defined in:
- lib/scorm_engine/models/registration.rb
Instance Attribute Summary collapse
-
#activity_details ⇒ Object
TODO: Not sure we want this to be settable.
-
#completed_date ⇒ Object
TODO: Not sure we want this to be settable.
-
#course ⇒ Object
TODO: Not sure we want this to be settable.
-
#created_date ⇒ Object
TODO: Not sure we want this to be settable.
-
#first_access_date ⇒ Object
TODO: Not sure we want this to be settable.
-
#id ⇒ Object
TODO: Not sure we want this to be settable.
-
#instance ⇒ Object
TODO: Not sure we want this to be settable.
-
#last_access_date ⇒ Object
TODO: Not sure we want this to be settable.
-
#learner ⇒ Object
TODO: Not sure we want this to be settable.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#registration_completion ⇒ Object
TODO: Not sure we want this to be settable.
-
#registration_completion_amount ⇒ Object
TODO: Not sure we want this to be settable.
-
#registration_success ⇒ Object
TODO: Not sure we want this to be settable.
-
#score ⇒ Object
TODO: Not sure we want this to be settable.
-
#total_seconds_tracked ⇒ Object
TODO: Not sure we want this to be settable.
-
#updated ⇒ Object
TODO: Not sure we want this to be settable.
Class Method Summary collapse
-
.get_completed_at_from_api(options = {}) ⇒ Time
Extract and normalize the completed date from the API options.
-
.get_score_from_api(options = {}) ⇒ Float
Extract and normalize the scaled passing score from the API options.
- .new_from_api(options = {}) ⇒ Object
Instance Attribute Details
#activity_details ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def activity_details @activity_details end |
#completed_date ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def completed_date @completed_date end |
#course ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def course @course end |
#created_date ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def created_date @created_date end |
#first_access_date ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def first_access_date @first_access_date end |
#id ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def id @id end |
#instance ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def instance @instance end |
#last_access_date ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def last_access_date @last_access_date end |
#learner ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def learner @learner end |
#options=(value) ⇒ Object
Sets the attribute options
13 14 15 |
# File 'lib/scorm_engine/models/registration.rb', line 13 def (value) @options = value end |
#registration_completion ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def registration_completion @registration_completion end |
#registration_completion_amount ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def registration_completion_amount @registration_completion_amount end |
#registration_success ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def registration_success @registration_success end |
#score ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def score @score end |
#total_seconds_tracked ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def total_seconds_tracked @total_seconds_tracked end |
#updated ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
19 20 21 |
# File 'lib/scorm_engine/models/registration.rb', line 19 def updated @updated end |
Class Method Details
.get_completed_at_from_api(options = {}) ⇒ Time
Extract and normalize the completed date from the API options.
74 75 76 77 78 79 |
# File 'lib/scorm_engine/models/registration.rb', line 74 def self.get_completed_at_from_api( = {}) completed_date = ["completedDate"] completed_date ||= .fetch("score", {})["completedDate"] return if completed_date.nil? Time.parse(completed_date) end |
.get_score_from_api(options = {}) ⇒ Float
Extract and normalize the scaled passing score from the API options.
59 60 61 62 63 |
# File 'lib/scorm_engine/models/registration.rb', line 59 def self.get_score_from_api( = {}) score = .fetch("score", {})["scaled"] return if score.nil? score.to_f end |
.new_from_api(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/scorm_engine/models/registration.rb', line 24 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] this.instance = ["instance"] this.updated = Time.parse(["updated"]) if .key?("updated") this.registration_completion = ["registrationCompletion"] this.registration_success = ["registrationSuccess"] this.total_seconds_tracked = ["totalSecondsTracked"] this.first_access_date = Time.parse(["firstAccessDate"]) if .key?("firstAccessDate") this.last_access_date = Time.parse(["lastAccessDate"]) if .key?("lastAccessDate") this.created_date = Time.parse(["createdDate"]) if .key?("createdDate") this.updated = Time.parse(["updated"]) if .key?("updated") this.registration_completion_amount = ["registrationCompletionAmount"].to_f # Sometimes it returns "NaN" this.score = get_score_from_api() this.completed_date = get_completed_at_from_api() this.activity_details = RegistrationActivityDetail.new_from_api(["activityDetails"]) if .key?("activityDetails") this.course = Course.new_from_api(["course"]) if .key?("course") this.learner = Learner.new_from_api(["learner"]) if .key?("learner") this end |