scorm_engine 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/Rakefile +13 -0
- data/lib/scorm_engine.rb +13 -0
- data/lib/scorm_engine/api/endpoints.rb +50 -0
- data/lib/scorm_engine/api/endpoints/about.rb +59 -0
- data/lib/scorm_engine/api/endpoints/courses.rb +136 -0
- data/lib/scorm_engine/api/endpoints/courses/configuration.rb +146 -0
- data/lib/scorm_engine/api/endpoints/courses/import.rb +83 -0
- data/lib/scorm_engine/api/endpoints/ping.rb +20 -0
- data/lib/scorm_engine/api/endpoints/registrations.rb +321 -0
- data/lib/scorm_engine/api/endpoints/registrations/configuration.rb +146 -0
- data/lib/scorm_engine/api/endpoints/registrations/launch_history.rb +47 -0
- data/lib/scorm_engine/client.rb +17 -0
- data/lib/scorm_engine/configuration.rb +43 -0
- data/lib/scorm_engine/faraday/connection.rb +35 -0
- data/lib/scorm_engine/faraday/request.rb +54 -0
- data/lib/scorm_engine/models.rb +9 -0
- data/lib/scorm_engine/models/course.rb +66 -0
- data/lib/scorm_engine/models/course_configuration.rb +37 -0
- data/lib/scorm_engine/models/course_import.rb +42 -0
- data/lib/scorm_engine/models/learner.rb +24 -0
- data/lib/scorm_engine/models/registration.rb +82 -0
- data/lib/scorm_engine/models/registration_activity_detail.rb +37 -0
- data/lib/scorm_engine/models/registration_configuration.rb +37 -0
- data/lib/scorm_engine/models/registration_launch_history.rb +92 -0
- data/lib/scorm_engine/models/registration_runtime_interaction.rb +52 -0
- data/lib/scorm_engine/response.rb +26 -0
- data/lib/scorm_engine/utils.rb +13 -0
- data/lib/scorm_engine/version.rb +3 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about/knows_the_platform.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about/knows_the_version.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about_user_count/accepts_before_option.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about_user_count/accepts_since_option.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about_user_count/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about_user_count/tracks_combined_counts.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_About/_get_about_user_count/tracks_per_tenantcounts.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_delete_course/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_delete_course/works.yml +32 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_course_detail/is_successful.yml +41 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_course_detail/results/sucessfully_creates_the_Course_attributes.yml +41 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_course_preview/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_course_preview/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_course_preview/results/returns_a_URL_string.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/_course_id_option/fetches_a_single_course_but_perhaps_multiple_versions.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/_course_id_option/returns_404_when_ID_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/_more_option_pagination_/returns_all_the_courses.yml +89 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/_more_option_pagination_/returns_the_more_key_in_the_raw_response.yml +48 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/_since_option/fails_when_passed_an_invalid_value.yml +37 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/_since_option/works.yml +43 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/is_successful.yml +43 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/results/is_an_enumerator_of_Course_models.yml +43 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses/_get_courses/results/sucessfully_creates_the_Course_attributes.yml +43 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration/results/makes_settings_available_as_key/value_pairs.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration_setting/fails_when_course_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration_setting/fails_when_setting_id_is_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration_setting/is_successful.yml +65 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_get_course_configuration_setting/results/returns_the_value_as_a_string.yml +65 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_post_course_configuration/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_post_course_configuration/fails_when_settings_are_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_post_course_configuration/is_successful.yml +32 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_post_course_configuration/persists_the_settings.yml +131 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_put_course_configuration_setting/fails_when_course_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_put_course_configuration_setting/fails_when_setting_id_is_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_put_course_configuration_setting/is_successful.yml +65 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Configuration/_put_course_configuration_setting/results/persists_the_changes.yml +98 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Import/_get_course_import/successful_imports/works.yml +147 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Import/_get_course_import/unsuccessful_imports/fails_to_import_given_an_invalid_url.yml +326 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Import/_post_course_import/successful_imports/works.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Courses_Import/_post_course_import/unsuccessful_imports/fails_to_import_a_previously_existing_course.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Ping/_get_ping/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Ping/_get_ping/reports_the_api_is_up.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Ping/_get_ping/with_invalid_password/is_unsuccessful.yml +41 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Ping/_get_ping/with_invalid_password/returns_status_403.yml +41 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_delete_registration/is_failure_when_registration_does_not_exist.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_delete_registration/is_successful_when_registration_exists.yml +32 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_exists/is_false_when_registration_does_not_exist.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_exists/is_true_when_registration_exists.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_instances/includes_results_we_expect.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_instances/is_successful.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_instances/returns_an_array_of_registrations.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_launch_link/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_launch_link/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_launch_link/results/returns_a_URL_string.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_progress/detail/does_not_return_activity_details_by_default.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_progress/detail/returns_activity_details_if_requested.yml +41 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_progress/fails_when_registration_does_not_exist.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registration_progress/returns_a_registration_when_it_exists.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/filtering_by_course_id/excludes_results.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/filtering_by_course_id/includes_results.yml +40 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/filtering_by_learner_id/excludes_results.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/filtering_by_learner_id/includes_results.yml +39 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/includes_results_we_expect.yml +40 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/is_successful.yml +40 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_get_registrations/returns_an_array_of_registrations.yml +40 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_post_registration/fails_if_course_id_is_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_post_registration/fails_if_registration_id_already_exists.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations/_post_registration/is_successful.yml +61 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration/is_successful.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration/results/makes_settings_available_as_key/value_pairs.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration_setting/fails_when_registration_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration_setting/fails_when_setting_id_is_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration_setting/is_successful.yml +65 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_get_registration_configuration_setting/results/returns_the_value_as_a_string.yml +65 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_post_registration_configuration/fails_when_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_post_registration_configuration/fails_when_settings_are_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_post_registration_configuration/is_successful.yml +32 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_post_registration_configuration/persists_the_settings.yml +131 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_put_registration_configuration_setting/fails_when_registration_id_is_invalid.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_put_registration_configuration_setting/fails_when_setting_id_is_invalid.yml +36 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_put_registration_configuration_setting/is_successful.yml +65 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_Configuration/_put_registration_configuration_setting/results/persists_the_changes.yml +98 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_LaunchHistory/_get_registration_launch_history/fails_when_registration_does_not_exist.yml +38 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_LaunchHistory/_get_registration_launch_history/is_successful.yml +54 -0
- data/spec/fixtures/vcr/ScormEngine_Api_Endpoints_Registrations_LaunchHistory/_get_registration_launch_history/returns_an_array_of_registration_launch_histories.yml +54 -0
- data/spec/fixtures/zip/Non-working SCORM.zip +0 -0
- data/spec/fixtures/zip/RuntimeBasicCalls_SCORM20043rdEdition.zip +0 -0
- data/spec/scorm_engine/api/endpoints/about_spec.rb +59 -0
- data/spec/scorm_engine/api/endpoints/courses/configuration_spec.rb +143 -0
- data/spec/scorm_engine/api/endpoints/courses/import_spec.rb +92 -0
- data/spec/scorm_engine/api/endpoints/courses_spec.rb +155 -0
- data/spec/scorm_engine/api/endpoints/ping_spec.rb +27 -0
- data/spec/scorm_engine/api/endpoints/registrations/configuration_spec.rb +154 -0
- data/spec/scorm_engine/api/endpoints/registrations/launch_history_spec.rb +46 -0
- data/spec/scorm_engine/api/endpoints/registrations_spec.rb +201 -0
- data/spec/scorm_engine/configuration_spec.rb +29 -0
- data/spec/scorm_engine/models/course_configuration_spec.rb +16 -0
- data/spec/scorm_engine/models/course_import_spec.rb +86 -0
- data/spec/scorm_engine/models/course_spec.rb +92 -0
- data/spec/scorm_engine/models/learner_spec.rb +27 -0
- data/spec/scorm_engine/models/registration_activity_detail_spec.rb +101 -0
- data/spec/scorm_engine/models/registration_launch_history_spec.rb +86 -0
- data/spec/scorm_engine/models/registration_runtime_interaction_spec.rb +91 -0
- data/spec/scorm_engine/models/registration_spec.rb +82 -0
- data/spec/scorm_engine/utils_spec.rb +15 -0
- data/spec/scorm_engine/version_spec.rb +5 -0
- data/spec/scorm_engine_spec.rb +2 -0
- data/spec/spec_helper.rb +47 -0
- data/spec/support/scorm_engine.rb +72 -0
- data/spec/support/scorm_engine_client.rb +6 -0
- data/spec/support/scorm_engine_configuration.rb +7 -0
- data/spec/support/vcr.rb +53 -0
- metadata +329 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module ScormEngine
|
2
|
+
module Api
|
3
|
+
module Endpoints
|
4
|
+
module Ping
|
5
|
+
#
|
6
|
+
# Get back a message indicating that the API is working.
|
7
|
+
#
|
8
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__ping_get
|
9
|
+
#
|
10
|
+
# @return [ScormEngine::Response]
|
11
|
+
#
|
12
|
+
def get_ping
|
13
|
+
response = get("ping")
|
14
|
+
|
15
|
+
Response.new(raw_response: response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,321 @@
|
|
1
|
+
module ScormEngine
|
2
|
+
module Api
|
3
|
+
module Endpoints
|
4
|
+
module Registrations
|
5
|
+
|
6
|
+
#
|
7
|
+
# Gets a list of registrations including a summary of the status of
|
8
|
+
# each registration.
|
9
|
+
#
|
10
|
+
# @note Note the "since" parameter exists to allow
|
11
|
+
# retreiving only registrations that have changed, and the
|
12
|
+
# "before" parameter exists to allow retreiving only
|
13
|
+
# registrations that haven't changed.
|
14
|
+
#
|
15
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations_get
|
16
|
+
#
|
17
|
+
# @param [Hash] options
|
18
|
+
#
|
19
|
+
# @option options [DateTime] :before ()
|
20
|
+
# Only registrations updated before the specified ISO 8601 TimeStamp (inclusive)
|
21
|
+
# are included. If a time zone is not specified, the server's time zone will be
|
22
|
+
# used.
|
23
|
+
#
|
24
|
+
# @option options [DateTime] :since ()
|
25
|
+
# Only registrations updated since the specified ISO 8601 TimeStamp (inclusive)
|
26
|
+
# are included. If a time zone is not specified, the server's time zone will be
|
27
|
+
# used.
|
28
|
+
#
|
29
|
+
# @option options [String] :course_id ()
|
30
|
+
# Only registrations for the specified course id will be included.
|
31
|
+
#
|
32
|
+
# @option options [String] :learner_id ()
|
33
|
+
# Only registrations for the specified learner id will be included.
|
34
|
+
#
|
35
|
+
# @return [Enumerator<ScormEngine::Models::Registration>]
|
36
|
+
#
|
37
|
+
def get_registrations(options = {})
|
38
|
+
options = options.dup
|
39
|
+
options[:courseId] = options.delete(:course_id) if options.key?(:course_id)
|
40
|
+
options[:learnerId] = options.delete(:learner_id) if options.key?(:learner_id)
|
41
|
+
|
42
|
+
response = get("registrations", options)
|
43
|
+
|
44
|
+
result = Enumerator.new do |enum|
|
45
|
+
loop do
|
46
|
+
response.success? && response.body["registrations"].each do |registration|
|
47
|
+
enum << ScormEngine::Models::Registration.new_from_api(registration)
|
48
|
+
end
|
49
|
+
break if !response.success? || response.body["more"].nil?
|
50
|
+
response = get(response.body["more"])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Response.new(raw_response: response, result: result)
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Get all the instances of this the registration specified by the registration ID
|
59
|
+
#
|
60
|
+
# Multiple instances of a registration are created based on the value
|
61
|
+
# you have for the setting "WhenToRestartRegistration". By default,
|
62
|
+
# Engine will "restart" a registration once that registration is
|
63
|
+
# completed and there is a newer version of that registration's package
|
64
|
+
# is available. If both of those conditions are met when the
|
65
|
+
# registration is launched, then Engine will create a new instance for
|
66
|
+
# that registration.
|
67
|
+
#
|
68
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__instances_get
|
69
|
+
#
|
70
|
+
# @param [Hash] options
|
71
|
+
#
|
72
|
+
# @option options [String] :registration_id
|
73
|
+
# ID for the registration.
|
74
|
+
#
|
75
|
+
# @option options [DateTime] :before ()
|
76
|
+
# Only registrations updated before the specified ISO 8601 TimeStamp (inclusive)
|
77
|
+
# are included. If a time zone is not specified, the server's time zone will be
|
78
|
+
# used.
|
79
|
+
#
|
80
|
+
# @option options [DateTime] :since ()
|
81
|
+
# Only registrations updated since the specified ISO 8601 TimeStamp (inclusive)
|
82
|
+
# are included. If a time zone is not specified, the server's time zone will be
|
83
|
+
# used.
|
84
|
+
#
|
85
|
+
# @return [Enumerator<ScormEngine::Models::Registration>]
|
86
|
+
#
|
87
|
+
def get_registration_instances(options = {})
|
88
|
+
require_options(options, :registration_id)
|
89
|
+
|
90
|
+
options = options.dup
|
91
|
+
registration_id = options.delete(:registration_id)
|
92
|
+
|
93
|
+
response = get("registrations/#{registration_id}/instances", options)
|
94
|
+
|
95
|
+
result = Enumerator.new do |enum|
|
96
|
+
loop do
|
97
|
+
response.success? && response.body["registrations"].each do |registration|
|
98
|
+
enum << ScormEngine::Models::Registration.new_from_api(registration)
|
99
|
+
end
|
100
|
+
break if !response.success? || response.body["more"].nil?
|
101
|
+
response = get(response.body["more"])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
Response.new(raw_response: response, result: result)
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Does this registration exist? You can also use the 'instance'
|
110
|
+
# parameter to check if a particular instance of a registrations
|
111
|
+
# exists.
|
112
|
+
#
|
113
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__get
|
114
|
+
#
|
115
|
+
# @param [Hash] options
|
116
|
+
#
|
117
|
+
# @option options [String] :registration_id
|
118
|
+
# ID for the registration.
|
119
|
+
#
|
120
|
+
# @option options [String] :instance ()
|
121
|
+
# The instance of this registration to use. If not provided, the
|
122
|
+
# latest instance will be used.
|
123
|
+
#
|
124
|
+
# @return [ScormEngine::Response]
|
125
|
+
#
|
126
|
+
def get_registration_exists(options = {})
|
127
|
+
require_options(options, :registration_id)
|
128
|
+
|
129
|
+
options = options.dup
|
130
|
+
registration_id = options.delete(:registration_id)
|
131
|
+
|
132
|
+
response = get("registrations/#{registration_id}", options)
|
133
|
+
|
134
|
+
result = response.success? && response.body["exists"]
|
135
|
+
|
136
|
+
Response.new(raw_response: response, result: result)
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# Get registration summary
|
141
|
+
#
|
142
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__progress_get
|
143
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__progress_detail_get
|
144
|
+
#
|
145
|
+
# @param [Hash] options
|
146
|
+
#
|
147
|
+
# @option options [String] :registration_id
|
148
|
+
# ID for the registration.
|
149
|
+
#
|
150
|
+
# @option options [String] :instance ()
|
151
|
+
# The instance of this registration to use. If not provided, the
|
152
|
+
# latest instance will be used.
|
153
|
+
#
|
154
|
+
# @option options [Boolean] :detail (false)
|
155
|
+
# Whether or not to populate 'activityDetails'.
|
156
|
+
#
|
157
|
+
# @return [ScormEngine::Models::Registration]
|
158
|
+
#
|
159
|
+
def get_registration_progress(options = {})
|
160
|
+
require_options(options, :registration_id)
|
161
|
+
|
162
|
+
options = options.dup
|
163
|
+
registration_id = options.delete(:registration_id)
|
164
|
+
detail = !!options.delete(:detail)
|
165
|
+
|
166
|
+
url = "registrations/#{registration_id}/progress"
|
167
|
+
url += "/detail" if detail
|
168
|
+
|
169
|
+
response = get(url, options)
|
170
|
+
|
171
|
+
result = response.success? && ScormEngine::Models::Registration.new_from_api(response.body)
|
172
|
+
|
173
|
+
Response.new(raw_response: response, result: result)
|
174
|
+
end
|
175
|
+
|
176
|
+
#
|
177
|
+
# Delete a registration.
|
178
|
+
#
|
179
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__delete
|
180
|
+
#
|
181
|
+
# @param [Hash] options
|
182
|
+
#
|
183
|
+
# @option options [String] :registration_id
|
184
|
+
# ID for the registration.
|
185
|
+
#
|
186
|
+
# @return [ScormEngine::Response]
|
187
|
+
#
|
188
|
+
def delete_registration(options = {})
|
189
|
+
require_options(options, :registration_id)
|
190
|
+
|
191
|
+
options = options.dup
|
192
|
+
registration_id = options.delete(:registration_id)
|
193
|
+
|
194
|
+
response = delete("registrations/#{registration_id}")
|
195
|
+
|
196
|
+
Response.new(raw_response: response)
|
197
|
+
end
|
198
|
+
|
199
|
+
#
|
200
|
+
# Create a registration.
|
201
|
+
#
|
202
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations_post
|
203
|
+
#
|
204
|
+
# @param [Hash] options
|
205
|
+
#
|
206
|
+
# @option options [String] :course_id
|
207
|
+
# The course ID.
|
208
|
+
#
|
209
|
+
# @option options [String] :registration_id
|
210
|
+
# The registration's ID. Must be unique.
|
211
|
+
#
|
212
|
+
# @option options [String] :learner/:id
|
213
|
+
# The learner's ID.
|
214
|
+
#
|
215
|
+
# @option options [String] :learner/:first_name
|
216
|
+
# The learner's first name.
|
217
|
+
#
|
218
|
+
# @option options [String] :learner/:last_name
|
219
|
+
# The learner's last name.
|
220
|
+
#
|
221
|
+
# @option options [String] :post_back/:url ()
|
222
|
+
# Specifies an optional override URL for which to post activity and
|
223
|
+
# status data in real time as the course is completed. By default all
|
224
|
+
# of these settings are read from your configuration, so only specify
|
225
|
+
# this if you need to control it on a per-registration basis.
|
226
|
+
#
|
227
|
+
# @option options [String] :post_back/:auth_type ("form")
|
228
|
+
# Optional parameter to specify how to authorize against the given
|
229
|
+
# postbackurl, can be 'form' or 'httpbasic'. If form authentication,
|
230
|
+
# the username and password for authentication are submitted as form
|
231
|
+
# fields 'username' and 'password', and the registration data as the
|
232
|
+
# form field 'data'. If HTTP Basic Authentication is used, the
|
233
|
+
# username and password are placed in the standard Authorization HTTP
|
234
|
+
# header, and the registration data is the body of the message (sent
|
235
|
+
# as application/json content type).
|
236
|
+
#
|
237
|
+
# @option options [String] :post_back/:user_name ()
|
238
|
+
# The user name to be used in authorizing the postback of data to the
|
239
|
+
# URL specified by postback url.
|
240
|
+
#
|
241
|
+
# @option options [String] :post_back/:password ()
|
242
|
+
# The password to be used in authorizing the postback of data to the
|
243
|
+
# URL specified by postback url.
|
244
|
+
#
|
245
|
+
# @option options [String] :post_back/:results_format ("course")
|
246
|
+
# This parameter allows you to specify a level of detail in the
|
247
|
+
# information that is posted back while the course is being taken. It
|
248
|
+
# may be one of three values: 'course' (course summary), 'activity'
|
249
|
+
# (activity summary), or 'full' (full detail), and is set to 'course'
|
250
|
+
# by default. The information will be posted as JSON using the same
|
251
|
+
# schema as what is returned in the /progress and /progress/detail
|
252
|
+
# endpoints.
|
253
|
+
#
|
254
|
+
# @return [ScormEngine::Response]
|
255
|
+
#
|
256
|
+
def post_registration(options = {})
|
257
|
+
require_options(options, :course_id, :registration_id, [:learner, :id], [:learner, :first_name], [:learner, :last_name])
|
258
|
+
|
259
|
+
options = options.dup
|
260
|
+
|
261
|
+
body = {
|
262
|
+
courseId: options[:course_id],
|
263
|
+
registrationId: options[:registration_id],
|
264
|
+
learner: {
|
265
|
+
id: options[:learner][:id],
|
266
|
+
firstName: options[:learner][:first_name],
|
267
|
+
lastName: options[:learner][:last_name],
|
268
|
+
},
|
269
|
+
}
|
270
|
+
|
271
|
+
if options[:post_back]
|
272
|
+
body[:postBack] = {
|
273
|
+
authType: options[:post_back][:auth_type],
|
274
|
+
userName: options[:post_back][:user_name],
|
275
|
+
password: options[:post_back][:password],
|
276
|
+
resultsFormat: options[:post_back][:results_format],
|
277
|
+
}.reject { |_k, v| v.nil? }
|
278
|
+
end
|
279
|
+
|
280
|
+
response = post("registrations", {}, body)
|
281
|
+
|
282
|
+
Response.new(raw_response: response)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
#
|
287
|
+
# Returns the link to use to launch this registration
|
288
|
+
#
|
289
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__launchLink_get
|
290
|
+
#
|
291
|
+
# @param [Hash] options
|
292
|
+
#
|
293
|
+
# @option options [String] :registration_id
|
294
|
+
# The ID of the registration.
|
295
|
+
#
|
296
|
+
# @option options [Integer] :expiry (0)
|
297
|
+
# Number of seconds from now this link will expire in. Use 0 for no
|
298
|
+
# expiration.
|
299
|
+
#
|
300
|
+
# @option options [String] :redirect_on_exit_url
|
301
|
+
# The URL the application should redirect to when the learner exits a
|
302
|
+
# course. If not specified, configured value will be used.
|
303
|
+
#
|
304
|
+
# @return [String]
|
305
|
+
#
|
306
|
+
def get_registration_launch_link(options = {})
|
307
|
+
require_options(options, :registration_id)
|
308
|
+
|
309
|
+
options = options.dup
|
310
|
+
registration_id = options.delete(:registration_id)
|
311
|
+
options[:redirectOnExitUrl] = options.delete(:redirect_on_exit_url) if options.key?(:redirect_on_exit_url)
|
312
|
+
|
313
|
+
response = get("registrations/#{registration_id}/launchLink", options)
|
314
|
+
|
315
|
+
result = response.success? && response.body["launchLink"]
|
316
|
+
|
317
|
+
Response.new(raw_response: response, result: result)
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#
|
2
|
+
# TODO: Consider consolidating this and Courses::Configuration, but only after we're
|
3
|
+
# sure they are really 99.9% the same in terms of functionality.
|
4
|
+
#
|
5
|
+
module ScormEngine
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module Registrations
|
9
|
+
module Configuration
|
10
|
+
|
11
|
+
#
|
12
|
+
# Returns the effective value of every setting at this level, as well
|
13
|
+
# as the effective value of any setting at a more specific level.
|
14
|
+
#
|
15
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__configuration_get
|
16
|
+
#
|
17
|
+
# @param [Hash] options
|
18
|
+
#
|
19
|
+
# @option options [String] :registration_id
|
20
|
+
# The ID of the registration to get.
|
21
|
+
#
|
22
|
+
# @option options [Integer] :instance (nil)
|
23
|
+
# The instance of this registration to use. If not provided, the
|
24
|
+
# latest instance will be used.
|
25
|
+
#
|
26
|
+
# @return [ScormEngine::Models::RegistrationConfiguration]
|
27
|
+
#
|
28
|
+
def get_registration_configuration(options = {})
|
29
|
+
require_options(options, :registration_id)
|
30
|
+
|
31
|
+
options = options.dup
|
32
|
+
registration_id = options.delete(:registration_id)
|
33
|
+
|
34
|
+
response = get("registrations/#{registration_id}/configuration", options)
|
35
|
+
|
36
|
+
result = response.success? && ScormEngine::Models::RegistrationConfiguration.new_from_api(response.body)
|
37
|
+
|
38
|
+
Response.new(raw_response: response, result: result)
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Bulk set configuration settings via POST request.
|
43
|
+
#
|
44
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__configuration_post
|
45
|
+
#
|
46
|
+
# @param [Hash] options
|
47
|
+
#
|
48
|
+
# @option options [String] :registration_id
|
49
|
+
# The ID of the registration to set.
|
50
|
+
#
|
51
|
+
# @option options [Integer] :instance (nil)
|
52
|
+
# The instance of this registration to use. If not provided, the
|
53
|
+
# latest instance will be used.
|
54
|
+
#
|
55
|
+
# @option options [Hash] :settings
|
56
|
+
# Key/value pairs of configuration options to set.
|
57
|
+
#
|
58
|
+
# @return [ScormEngine::Response]
|
59
|
+
#
|
60
|
+
def post_registration_configuration(options = {})
|
61
|
+
require_options(options, :registration_id, :settings)
|
62
|
+
|
63
|
+
options = options.dup
|
64
|
+
registration_id = options.delete(:registration_id)
|
65
|
+
settings = options.delete(:settings)
|
66
|
+
|
67
|
+
body = { settings: settings.map { |k, v| { "settingId" => k, "value" => v.to_s } } }
|
68
|
+
|
69
|
+
response = post("registrations/#{registration_id}/configuration", options, body)
|
70
|
+
|
71
|
+
Response.new(raw_response: response)
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Returns the effective value for this configuration setting for the resource being configured.
|
76
|
+
#
|
77
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__configuration__settingId__get
|
78
|
+
#
|
79
|
+
# @param [Hash] options
|
80
|
+
#
|
81
|
+
# @option options [String] :registration_id
|
82
|
+
# The ID of the registration to get.
|
83
|
+
#
|
84
|
+
# @option options [String] :setting_id
|
85
|
+
# The ID of the setting to get.
|
86
|
+
#
|
87
|
+
# @option options [Integer] :instance (nil)
|
88
|
+
# The instance of this registration to use. If not provided, the
|
89
|
+
# latest instance will be used.
|
90
|
+
#
|
91
|
+
# @return [String]
|
92
|
+
#
|
93
|
+
def get_registration_configuration_setting(options = {})
|
94
|
+
require_options(options, :registration_id, :setting_id)
|
95
|
+
|
96
|
+
options = options.dup
|
97
|
+
registration_id = options.delete(:registration_id)
|
98
|
+
setting_id = options.delete(:setting_id)
|
99
|
+
|
100
|
+
response = get("registrations/#{registration_id}/configuration/#{setting_id}", options)
|
101
|
+
|
102
|
+
result = response.success? && response.body["value"]
|
103
|
+
|
104
|
+
Response.new(raw_response: response, result: result)
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Sets the value for this configuration setting, for the resource being configured.
|
109
|
+
#
|
110
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__registrations__registrationId__configuration__settingId__put
|
111
|
+
#
|
112
|
+
# @param [Hash] options
|
113
|
+
#
|
114
|
+
# @option options [String] :registration_id
|
115
|
+
# The ID of the registration to set.
|
116
|
+
#
|
117
|
+
# @option options [String] :setting_id
|
118
|
+
# The ID of the setting to set.
|
119
|
+
#
|
120
|
+
# @option options [String] :value ("")
|
121
|
+
# The value of the setting to set.
|
122
|
+
#
|
123
|
+
# @option options [Integer] :instance (nil)
|
124
|
+
# The instance of this registration to use. If not provided, the
|
125
|
+
# latest instance will be used.
|
126
|
+
#
|
127
|
+
# @return [ScormEngine::Response]
|
128
|
+
#
|
129
|
+
def put_registration_configuration_setting(options = {})
|
130
|
+
require_options(options, :registration_id, :setting_id)
|
131
|
+
|
132
|
+
options = options.dup
|
133
|
+
registration_id = options.delete(:registration_id)
|
134
|
+
setting_id = options.delete(:setting_id)
|
135
|
+
|
136
|
+
body = { value: options.delete(:value).to_s }
|
137
|
+
|
138
|
+
response = put("registrations/#{registration_id}/configuration/#{setting_id}", options, body)
|
139
|
+
|
140
|
+
Response.new(raw_response: response)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|