Module: ScormEngine::Api::Endpoints::Courses
- Included in:
- ScormEngine::Api::Endpoints
- Defined in:
- lib/scorm_engine/api/endpoints/courses.rb,
lib/scorm_engine/api/endpoints/courses/import.rb,
lib/scorm_engine/api/endpoints/courses/configuration.rb
Defined Under Namespace
Modules: Configuration, Import
Instance Method Summary collapse
-
#delete_course(options = {}) ⇒ ScormEngine::Response
Delete a course.
-
#get_course_detail(options = {}) ⇒ ScormEngine::Models::Course
Get the details of a course.
-
#get_course_preview(options = {}) ⇒ String
Returns the launch link to use to preview this course.
-
#get_courses(options = {}) ⇒ Enumerator<ScormEngine::Models::Course>
Get the list of courses.
Instance Method Details
#delete_course(options = {}) ⇒ ScormEngine::Response
Delete a course
59 60 61 62 63 64 65 |
# File 'lib/scorm_engine/api/endpoints/courses.rb', line 59 def delete_course( = {}) (, :course_id) response = delete("courses/#{[:course_id]}") Response.new(raw_response: response) end |
#get_course_detail(options = {}) ⇒ ScormEngine::Models::Course
Get the details of a course
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/scorm_engine/api/endpoints/courses.rb', line 83 def get_course_detail( = {}) (, :course_id) = .dup course_id = .delete(:course_id) response = get("courses/#{course_id}/detail", ) result = response.success? ? ScormEngine::Models::Course.new_from_api(response.body) : nil Response.new(raw_response: response, result: result) end |
#get_course_preview(options = {}) ⇒ String
Returns the launch link to use to preview this course
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/scorm_engine/api/endpoints/courses.rb', line 120 def get_course_preview( = {}) (, :course_id) = .dup course_id = .delete(:course_id) [:redirectOnExitUrl] = .delete(:redirect_on_exit_url) if .key?(:redirect_on_exit_url) response = get("courses/#{course_id}/preview", ) result = response.success? ? response.body["launchLink"] : nil Response.new(raw_response: response, result: result) end |
#get_courses(options = {}) ⇒ Enumerator<ScormEngine::Models::Course>
Get the list of courses
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scorm_engine/api/endpoints/courses.rb', line 26 def get_courses( = {}) = .dup path = "courses" path = "courses/#{.delete(:course_id)}" if [:course_id] response = get(path, ) result = Enumerator.new do |enum| loop do response.success? && response.body["courses"].each do |course| enum << ScormEngine::Models::Course.new_from_api(course) end break if !response.success? || response.body["more"].nil? response = get(response.body["more"]) end end Response.new(raw_response: response, result: result) end |