Module: ScormEngine::Api::Endpoints::Registrations
- Included in:
- ScormEngine::Api::Endpoints
- Defined in:
- lib/scorm_engine/api/endpoints/registrations.rb,
lib/scorm_engine/api/endpoints/registrations/configuration.rb,
lib/scorm_engine/api/endpoints/registrations/launch_history.rb
Defined Under Namespace
Modules: Configuration, LaunchHistory
Instance Method Summary collapse
-
#delete_registration(options = {}) ⇒ ScormEngine::Response
Delete a registration.
-
#get_registration_exists(options = {}) ⇒ ScormEngine::Response
Does this registration exist? You can also use the ‘instance’ parameter to check if a particular instance of a registrations exists.
-
#get_registration_instances(options = {}) ⇒ Enumerator<ScormEngine::Models::Registration>
Get all the instances of this the registration specified by the registration ID.
-
#get_registration_progress(options = {}) ⇒ ScormEngine::Models::Registration
Get registration summary.
-
#get_registrations(options = {}) ⇒ Enumerator<ScormEngine::Models::Registration>
Gets a list of registrations including a summary of the status of each registration.
-
#post_registration(options = {}) ⇒ ScormEngine::Response
Create a registration.
Instance Method Details
#delete_registration(options = {}) ⇒ ScormEngine::Response
Delete a registration.
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/scorm_engine/api/endpoints/registrations.rb', line 188 def delete_registration( = {}) (, :registration_id) = .dup registration_id = .delete(:registration_id) response = delete("registrations/#{registration_id}") Response.new(raw_response: response) end |
#get_registration_exists(options = {}) ⇒ ScormEngine::Response
Does this registration exist? You can also use the ‘instance’ parameter to check if a particular instance of a registrations exists.
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/scorm_engine/api/endpoints/registrations.rb', line 126 def get_registration_exists( = {}) (, :registration_id) = .dup registration_id = .delete(:registration_id) response = get("registrations/#{registration_id}", ) result = response.success? ? response.body["exists"] : nil Response.new(raw_response: response, result: result) end |
#get_registration_instances(options = {}) ⇒ Enumerator<ScormEngine::Models::Registration>
Get all the instances of this the registration specified by the registration ID
Multiple instances of a registration are created based on the value you have for the setting “WhenToRestartRegistration”. By default, Engine will “restart” a registration once that registration is completed and there is a newer version of that registration’s package is available. If both of those conditions are met when the registration is launched, then Engine will create a new instance for that registration.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/scorm_engine/api/endpoints/registrations.rb', line 87 def get_registration_instances( = {}) (, :registration_id) = .dup registration_id = .delete(:registration_id) response = get("registrations/#{registration_id}/instances", ) result = Enumerator.new do |enum| loop do response.success? && response.body["registrations"].each do |registration| enum << ScormEngine::Models::Registration.new_from_api(registration) end break if !response.success? || response.body["more"].nil? response = get(response.body["more"]) end end Response.new(raw_response: response, result: result) end |
#get_registration_progress(options = {}) ⇒ ScormEngine::Models::Registration
Get registration summary
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/scorm_engine/api/endpoints/registrations.rb', line 159 def get_registration_progress( = {}) (, :registration_id) = .dup registration_id = .delete(:registration_id) detail = !!.delete(:detail) url = "registrations/#{registration_id}/progress" url += "/detail" if detail response = get(url, ) result = response.success? ? ScormEngine::Models::Registration.new_from_api(response.body) : nil Response.new(raw_response: response, result: result) end |
#get_registrations(options = {}) ⇒ Enumerator<ScormEngine::Models::Registration>
Note the “since” parameter exists to allow retreiving only registrations that have changed, and the “before” parameter exists to allow retreiving only registrations that haven’t changed.
Gets a list of registrations including a summary of the status of each registration.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/scorm_engine/api/endpoints/registrations.rb', line 37 def get_registrations( = {}) = .dup [:courseId] = .delete(:course_id) if .key?(:course_id) [:learnerId] = .delete(:learner_id) if .key?(:learner_id) response = get("registrations", ) result = Enumerator.new do |enum| loop do response.success? && response.body["registrations"].each do |registration| enum << ScormEngine::Models::Registration.new_from_api(registration) end break if !response.success? || response.body["more"].nil? response = get(response.body["more"]) end end Response.new(raw_response: response, result: result) end |
#post_registration(options = {}) ⇒ ScormEngine::Response
Create a registration.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/scorm_engine/api/endpoints/registrations.rb', line 256 def post_registration( = {}) (, :course_id, :registration_id, [:learner, :id], [:learner, :first_name], [:learner, :last_name]) = .dup body = { courseId: [:course_id], registrationId: [:registration_id], learner: { id: [:learner][:id], firstName: [:learner][:first_name], lastName: [:learner][:last_name], }, } if [:post_back] body[:postBack] = { url: [:post_back][:url], authType: [:post_back][:auth_type]&.upcase, userName: [:post_back][:user_name], password: [:post_back][:password], resultsFormat: [:post_back][:results_format]&.upcase, }.reject { |_k, v| v.nil? } end response = post("registrations", {}, body) Response.new(raw_response: response) end |