Class: ScormEngine::Models::Registration
- Defined in:
- lib/scorm_engine/models/registration.rb
Overview
rubocop:disable Metrics/AbcSize
Instance Attribute Summary collapse
- #activity_details ⇒ ScormEngine::Models::RegistrationActivityDetail
-
#completed_date ⇒ Time
Time of the learner’s first completion of this registration.
- #course ⇒ ScormEngine::Models::Course
-
#created_date ⇒ Time
Time of the creation of this registration.
-
#first_access_date ⇒ Time
Time of the learner’s first interaction with this registration.
-
#id ⇒ String
The external identification of the registration.
- #instance ⇒ String
-
#last_access_date ⇒ Time
Time of the learner’s last interaction with this registration.
- #learner ⇒ ScormEngine::Models::Learner
-
#registration_completion ⇒ String
Has this registration been completed?.
-
#registration_completion_amount ⇒ Float
A decimal value between 0 and 1 representing the percentage of this course that the learner has completed so far, if known.
-
#registration_success ⇒ String
Has this registration been passed?.
-
#score ⇒ Float
Scaled score between 0 and 100.
-
#total_seconds_tracked ⇒ Integer
How long the learner spent taking this registration, in seconds.
- #updated ⇒ Time
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 Method Summary collapse
-
#complete? ⇒ Boolean
Has this registration been completed?.
-
#failed? ⇒ Boolean
Has this registration failed?.
-
#incomplete? ⇒ Boolean
Is this registration incomplete?.
-
#passed? ⇒ Boolean
Has this registration been passed?.
Methods inherited from Base
Instance Attribute Details
#activity_details ⇒ ScormEngine::Models::RegistrationActivityDetail
64 65 66 |
# File 'lib/scorm_engine/models/registration.rb', line 64 def activity_details @activity_details end |
#completed_date ⇒ Time
Time of the learner’s first completion of this registration.
79 80 81 |
# File 'lib/scorm_engine/models/registration.rb', line 79 def completed_date @completed_date end |
#course ⇒ ScormEngine::Models::Course
54 55 56 |
# File 'lib/scorm_engine/models/registration.rb', line 54 def course @course end |
#created_date ⇒ Time
Time of the creation of this registration.
84 85 86 |
# File 'lib/scorm_engine/models/registration.rb', line 84 def created_date @created_date end |
#first_access_date ⇒ Time
Time of the learner’s first interaction with this registration.
69 70 71 |
# File 'lib/scorm_engine/models/registration.rb', line 69 def first_access_date @first_access_date end |
#id ⇒ String
The external identification of the registration.
8 9 10 |
# File 'lib/scorm_engine/models/registration.rb', line 8 def id @id end |
#instance ⇒ String
34 35 36 |
# File 'lib/scorm_engine/models/registration.rb', line 34 def instance @instance end |
#last_access_date ⇒ Time
Time of the learner’s last interaction with this registration.
74 75 76 |
# File 'lib/scorm_engine/models/registration.rb', line 74 def last_access_date @last_access_date end |
#learner ⇒ ScormEngine::Models::Learner
59 60 61 |
# File 'lib/scorm_engine/models/registration.rb', line 59 def learner @learner end |
#registration_completion ⇒ String
Has this registration been completed?
13 14 15 |
# File 'lib/scorm_engine/models/registration.rb', line 13 def registration_completion @registration_completion end |
#registration_completion_amount ⇒ Float
A decimal value between 0 and 1 representing the percentage of this course that the learner has completed so far, if known. Note: for learning standards other than SCORM 2004 4th Edition, this value is based on the percentage of activities completed/passed. This means that single-activity courses in those standards will always return either 0 or 1.
28 29 30 |
# File 'lib/scorm_engine/models/registration.rb', line 28 def registration_completion_amount @registration_completion_amount end |
#registration_success ⇒ String
Has this registration been passed?
18 19 20 |
# File 'lib/scorm_engine/models/registration.rb', line 18 def registration_success @registration_success end |
#score ⇒ Float
Scaled score between 0 and 100.
49 50 51 |
# File 'lib/scorm_engine/models/registration.rb', line 49 def score @score end |
#total_seconds_tracked ⇒ Integer
How long the learner spent taking this registration, in seconds.
44 45 46 |
# File 'lib/scorm_engine/models/registration.rb', line 44 def total_seconds_tracked @total_seconds_tracked end |
#updated ⇒ Time
39 40 41 |
# File 'lib/scorm_engine/models/registration.rb', line 39 def updated @updated end |
Class Method Details
.get_completed_at_from_api(options = {}) ⇒ Time
Extract and normalize the completed date from the API options.
180 181 182 183 184 185 |
# File 'lib/scorm_engine/models/registration.rb', line 180 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.
165 166 167 168 169 |
# File 'lib/scorm_engine/models/registration.rb', line 165 def self.get_score_from_api( = {}) score = .fetch("score", {})["scaled"] return if score.nil? score.to_f end |
.new_from_api(options = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/scorm_engine/models/registration.rb', line 86 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"]&.upcase this.registration_success = ["registrationSuccess"]&.upcase this.total_seconds_tracked = ["totalSecondsTracked"]&.to_i 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 |
Instance Method Details
#complete? ⇒ Boolean
Has this registration been completed?
118 119 120 121 |
# File 'lib/scorm_engine/models/registration.rb', line 118 def complete? return nil if registration_completion == "UNKNOWN" registration_completion == "COMPLETED" end |
#failed? ⇒ Boolean
Has this registration failed?
151 152 153 154 |
# File 'lib/scorm_engine/models/registration.rb', line 151 def failed? return nil if registration_success == "UNKNOWN" registration_success == "FAILED" end |
#incomplete? ⇒ Boolean
Is this registration incomplete?
129 130 131 132 |
# File 'lib/scorm_engine/models/registration.rb', line 129 def incomplete? return nil if registration_completion == "UNKNOWN" registration_completion == "INCOMPLETE" end |
#passed? ⇒ Boolean
Has this registration been passed?
140 141 142 143 |
# File 'lib/scorm_engine/models/registration.rb', line 140 def passed? return nil if registration_success == "UNKNOWN" registration_success == "PASSED" end |