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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4eb559da6c58e1d094b117f7309f63a57fd0ce8420f20f1b29e70db9ced197d5
|
4
|
+
data.tar.gz: a257cbd1dc47e8b30ff8aa23e4b6ec7179dafa476e137ef65ef14652aa62668d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0991ec18af0234a57b7d331a270b7149cc02e1d921f1c507d437138c38bb637d044789fb56c8a2e10ab5489585f90a24d34ce5a10a0d4a1cf0b59699aa705640'
|
7
|
+
data.tar.gz: c0312e3e6251c0de3cd92d620211e6a2d47098d7b30aaba3608e190ab347d5d3ffc6ff81d35bee5c25ec2d0c630585d7dfa731ada8d94c9d2cb1f20a90189caa
|
data/.rspec
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "yard"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
task default: :spec
|
8
|
+
|
9
|
+
YARD::Rake::YardocTask.new do |t|
|
10
|
+
t.files = ["lib/**/*.rb"]
|
11
|
+
t.options = []
|
12
|
+
t.stats_options = ["--list-undoc"]
|
13
|
+
end
|
data/lib/scorm_engine.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
require "scorm_engine/version"
|
5
|
+
require "scorm_engine/utils"
|
6
|
+
require "scorm_engine/configuration"
|
7
|
+
require "scorm_engine/models"
|
8
|
+
require "scorm_engine/api/endpoints"
|
9
|
+
require "scorm_engine/client"
|
10
|
+
require "scorm_engine/response"
|
11
|
+
|
12
|
+
module ScormEngine
|
13
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative "endpoints/about"
|
2
|
+
require_relative "endpoints/courses"
|
3
|
+
require_relative "endpoints/courses/configuration"
|
4
|
+
require_relative "endpoints/courses/import"
|
5
|
+
require_relative "endpoints/ping"
|
6
|
+
require_relative "endpoints/registrations"
|
7
|
+
require_relative "endpoints/registrations/configuration"
|
8
|
+
require_relative "endpoints/registrations/launch_history"
|
9
|
+
|
10
|
+
module ScormEngine
|
11
|
+
module Api
|
12
|
+
module Endpoints
|
13
|
+
include About
|
14
|
+
include Courses
|
15
|
+
include Courses::Configuration
|
16
|
+
include Courses::Import
|
17
|
+
include Ping
|
18
|
+
include Registrations
|
19
|
+
include Registrations::Configuration
|
20
|
+
include Registrations::LaunchHistory
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
#
|
25
|
+
# Ensure that all of the keys are present in the hash passed and raise an error if not.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# require_options({foo: 1, bar: {"baz" => 2}}, :foo, [:bar, :baz], :moo)
|
29
|
+
# # will raise an errror due to lack of :moo
|
30
|
+
#
|
31
|
+
# @param [Hash] haystack
|
32
|
+
# The option hash in which to search for the given, optionally nested, key[s].
|
33
|
+
#
|
34
|
+
# @param [Array] sets_of_needles
|
35
|
+
# A splat of keys or array of nested keys to search for.
|
36
|
+
#
|
37
|
+
# @raise [ArgumentError] if any needle isn't found.
|
38
|
+
#
|
39
|
+
def require_options(haystack = {}, *sets_of_needles)
|
40
|
+
sets_of_needles.each { |needles| require_option(haystack, *needles) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def require_option(haystack, *needles)
|
44
|
+
value = needles.reduce(haystack) { |m, o| m[o.to_sym] || m[o.to_s] }
|
45
|
+
return unless value.nil? # || (value.respond_to?(:empty?) && value.empty?)
|
46
|
+
raise ArgumentError, "Required option #{needles.join("/")} missing"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ScormEngine
|
2
|
+
module Api
|
3
|
+
module Endpoints
|
4
|
+
module About
|
5
|
+
#
|
6
|
+
# Get back the version and platform of the running instance of Engine
|
7
|
+
#
|
8
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__about_get
|
9
|
+
#
|
10
|
+
# @return [ScormEngine::Response]
|
11
|
+
#
|
12
|
+
def get_about
|
13
|
+
response = get("about")
|
14
|
+
|
15
|
+
result = OpenStruct.new(response.body)
|
16
|
+
|
17
|
+
Response.new(raw_response: response, result: result)
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Gets the number of users across all tenants.
|
22
|
+
#
|
23
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__about_userCount_get
|
24
|
+
#
|
25
|
+
# @param [Hash] options
|
26
|
+
#
|
27
|
+
# @option options [DateTime] :before
|
28
|
+
# Only userCount updated before the specified time (inclusive) are included.
|
29
|
+
# If a time zone is not specified, the server's time zone will be used.
|
30
|
+
#
|
31
|
+
# @option options [DateTime] :since
|
32
|
+
# Only userCount updated since the specified time (inclusive) are included.
|
33
|
+
# If a time zone is not specified, the server's time zone will be used.
|
34
|
+
#
|
35
|
+
# @return [ScormEngine::Response]
|
36
|
+
#
|
37
|
+
def get_about_user_count(options = {})
|
38
|
+
response = get("about/userCount", options)
|
39
|
+
|
40
|
+
result = OpenStruct.new
|
41
|
+
result.total = response.body["combinedTenants"]["total"]
|
42
|
+
result.dispatched = response.body["combinedTenants"]["dispatched"]
|
43
|
+
result.non_dispatched = response.body["combinedTenants"]["nonDispatched"]
|
44
|
+
result.by_tenant = {}
|
45
|
+
|
46
|
+
response.body["byTenant"].each do |tenant|
|
47
|
+
result.by_tenant[tenant["tenantName"]] = OpenStruct.new(
|
48
|
+
total: tenant["total"],
|
49
|
+
dispatched: tenant["dispatched"],
|
50
|
+
non_dispatched: tenant["nonDispatched"]
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
Response.new(raw_response: response, result: result)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module ScormEngine
|
2
|
+
module Api
|
3
|
+
module Endpoints
|
4
|
+
module Courses
|
5
|
+
|
6
|
+
#
|
7
|
+
# Get the list of courses
|
8
|
+
#
|
9
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses_get
|
10
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses__courseId__get
|
11
|
+
#
|
12
|
+
# @param [Hash] options
|
13
|
+
#
|
14
|
+
# @option options [String] :course_id
|
15
|
+
# The ID of the single course to retrieve. If set no other options
|
16
|
+
# are respected. Note that multiple results may be returned if the
|
17
|
+
# course has multiple versions.
|
18
|
+
#
|
19
|
+
# @option options [DateTime] :since
|
20
|
+
# Only courses updated since the specified ISO 8601 TimeStamp
|
21
|
+
# (inclusive) are included. If a time zone is not specified, the
|
22
|
+
# server's time zone will be used.
|
23
|
+
#
|
24
|
+
# @return [Enumerator<ScormEngine::Models::Course>]
|
25
|
+
#
|
26
|
+
def get_courses(options = {})
|
27
|
+
options = options.dup
|
28
|
+
|
29
|
+
path = "courses"
|
30
|
+
path = "courses/#{options.delete(:course_id)}" if options[:course_id]
|
31
|
+
|
32
|
+
response = get(path, options)
|
33
|
+
|
34
|
+
result = Enumerator.new do |enum|
|
35
|
+
loop do
|
36
|
+
response.success? && response.body["courses"].each do |course|
|
37
|
+
enum << ScormEngine::Models::Course.new_from_api(course)
|
38
|
+
end
|
39
|
+
break if !response.success? || response.body["more"].nil?
|
40
|
+
response = get(response.body["more"])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Response.new(raw_response: response, result: result)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Delete a course
|
49
|
+
#
|
50
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses__courseId__delete
|
51
|
+
#
|
52
|
+
# @param [Hash] options
|
53
|
+
#
|
54
|
+
# @option options [String] :course_id
|
55
|
+
# The ID of the course to delete.
|
56
|
+
#
|
57
|
+
# @return [ScormEngine::Response]
|
58
|
+
#
|
59
|
+
def delete_course(options = {})
|
60
|
+
require_options(options, :course_id)
|
61
|
+
|
62
|
+
response = delete("courses/#{options[:course_id]}")
|
63
|
+
|
64
|
+
Response.new(raw_response: response)
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Get the details of a course
|
69
|
+
#
|
70
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses__courseId__detail_get
|
71
|
+
#
|
72
|
+
# @param [Hash] options
|
73
|
+
#
|
74
|
+
# @option options [String] :course_id
|
75
|
+
# The ID of the course to get.
|
76
|
+
#
|
77
|
+
# @option options [Integer] :version (nil)
|
78
|
+
# The version of this course to use. If not provided, the latest
|
79
|
+
# version will be used.
|
80
|
+
#
|
81
|
+
# @return [ScormEngine::Models::Course]
|
82
|
+
#
|
83
|
+
def get_course_detail(options = {})
|
84
|
+
require_options(options, :course_id)
|
85
|
+
|
86
|
+
options = options.dup
|
87
|
+
course_id = options.delete(:course_id)
|
88
|
+
|
89
|
+
response = get("courses/#{course_id}/detail", options)
|
90
|
+
|
91
|
+
result = response.success? && ScormEngine::Models::Course.new_from_api(response.body)
|
92
|
+
|
93
|
+
Response.new(raw_response: response, result: result)
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Returns the launch link to use to preview this course
|
98
|
+
#
|
99
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses__courseId__preview_get
|
100
|
+
#
|
101
|
+
# @param [Hash] options
|
102
|
+
#
|
103
|
+
# @option options [String] :course_id
|
104
|
+
# The ID of the course to get.
|
105
|
+
#
|
106
|
+
# @option options [Integer] :version (nil)
|
107
|
+
# The version of this course to use. If not provided, the latest
|
108
|
+
# version will be used.
|
109
|
+
#
|
110
|
+
# @option options [Integer] :expiry (0)
|
111
|
+
# Number of seconds from now this link will expire in. Use 0 for no
|
112
|
+
# expiration.
|
113
|
+
#
|
114
|
+
# @option options [String] :redirect_on_exit_url
|
115
|
+
# The URL the application should redirect to when the learner exits a
|
116
|
+
# course. If not specified, configured value will be used.
|
117
|
+
#
|
118
|
+
# @return [String]
|
119
|
+
#
|
120
|
+
def get_course_preview(options = {})
|
121
|
+
require_options(options, :course_id)
|
122
|
+
|
123
|
+
options = options.dup
|
124
|
+
course_id = options.delete(:course_id)
|
125
|
+
options[:redirectOnExitUrl] = options.delete(:redirect_on_exit_url) if options.key?(:redirect_on_exit_url)
|
126
|
+
|
127
|
+
response = get("courses/#{course_id}/preview", options)
|
128
|
+
|
129
|
+
result = response.success? && response.body["launchLink"]
|
130
|
+
|
131
|
+
Response.new(raw_response: response, result: result)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#
|
2
|
+
# TODO: Consider consolidating this and Registrations::Configuration, but only
|
3
|
+
# after we're sure they are really 99.9% the same in terms of functionality.
|
4
|
+
#
|
5
|
+
module ScormEngine
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module Courses
|
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__courses__courseId__configuration_get
|
16
|
+
#
|
17
|
+
# @param [Hash] options
|
18
|
+
#
|
19
|
+
# @option options [String] :course_id
|
20
|
+
# The ID of the course to get.
|
21
|
+
#
|
22
|
+
# @option options [Integer] :version (nil)
|
23
|
+
# The version of this course to use. If not provided, the latest
|
24
|
+
# version will be used.
|
25
|
+
#
|
26
|
+
# @return [ScormEngine::Models::CourseConfiguration]
|
27
|
+
#
|
28
|
+
def get_course_configuration(options = {})
|
29
|
+
require_options(options, :course_id)
|
30
|
+
|
31
|
+
options = options.dup
|
32
|
+
course_id = options.delete(:course_id)
|
33
|
+
|
34
|
+
response = get("courses/#{course_id}/configuration", options)
|
35
|
+
|
36
|
+
result = response.success? && ScormEngine::Models::CourseConfiguration.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__courses__courseId__configuration_post
|
45
|
+
#
|
46
|
+
# @param [Hash] options
|
47
|
+
#
|
48
|
+
# @option options [String] :course_id
|
49
|
+
# The ID of the course to set.
|
50
|
+
#
|
51
|
+
# @option options [Integer] :version (nil)
|
52
|
+
# The version of this course to use. If not provided, the latest
|
53
|
+
# version 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_course_configuration(options = {})
|
61
|
+
require_options(options, :course_id, :settings)
|
62
|
+
|
63
|
+
options = options.dup
|
64
|
+
course_id = options.delete(:course_id)
|
65
|
+
settings = options.delete(:settings)
|
66
|
+
|
67
|
+
body = { settings: settings.map { |k, v| { "settingId" => k, "value" => v.to_s } } }
|
68
|
+
|
69
|
+
response = post("courses/#{course_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__courses__courseId__configuration__settingId__get
|
78
|
+
#
|
79
|
+
# @param [Hash] options
|
80
|
+
#
|
81
|
+
# @option options [String] :course_id
|
82
|
+
# The ID of the course to get.
|
83
|
+
#
|
84
|
+
# @option options [String] :setting_id
|
85
|
+
# The ID of the setting to get.
|
86
|
+
#
|
87
|
+
# @option options [Integer] :version (nil)
|
88
|
+
# The version of this course to use. If not provided, the latest
|
89
|
+
# version will be used.
|
90
|
+
#
|
91
|
+
# @return [String]
|
92
|
+
#
|
93
|
+
def get_course_configuration_setting(options = {})
|
94
|
+
require_options(options, :course_id, :setting_id)
|
95
|
+
|
96
|
+
options = options.dup
|
97
|
+
course_id = options.delete(:course_id)
|
98
|
+
setting_id = options.delete(:setting_id)
|
99
|
+
|
100
|
+
response = get("courses/#{course_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__courses__courseId__configuration__settingId__put
|
111
|
+
#
|
112
|
+
# @param [Hash] options
|
113
|
+
#
|
114
|
+
# @option options [String] :course_id
|
115
|
+
# The ID of the course 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] :version (nil)
|
124
|
+
# The version of this course to use. If not provided, the latest
|
125
|
+
# version will be used.
|
126
|
+
#
|
127
|
+
# @return [ScormEngine::Response]
|
128
|
+
#
|
129
|
+
def put_course_configuration_setting(options = {})
|
130
|
+
require_options(options, :course_id, :setting_id)
|
131
|
+
|
132
|
+
options = options.dup
|
133
|
+
course_id = options.delete(:course_id)
|
134
|
+
setting_id = options.delete(:setting_id)
|
135
|
+
|
136
|
+
body = { value: options.delete(:value).to_s }
|
137
|
+
|
138
|
+
response = put("courses/#{course_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
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module ScormEngine
|
2
|
+
module Api
|
3
|
+
module Endpoints
|
4
|
+
module Courses
|
5
|
+
module Import
|
6
|
+
|
7
|
+
#
|
8
|
+
# Import a course
|
9
|
+
#
|
10
|
+
# Either the actual contents of the zip file to import may be posted,
|
11
|
+
# or JSON that references the remote location to import from.
|
12
|
+
#
|
13
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses_importJobs_post
|
14
|
+
#
|
15
|
+
# @param [Hash] options
|
16
|
+
#
|
17
|
+
# @option options [String] :url
|
18
|
+
# URL path to the .zip package representing the course or the manifest file defining the course.
|
19
|
+
#
|
20
|
+
# @option options [String] :course_id
|
21
|
+
# A unique identifier your application will use to identify the
|
22
|
+
# course after import. Your application is responsible both for
|
23
|
+
# generating this unique ID and for keeping track of the ID for later
|
24
|
+
# use.
|
25
|
+
#
|
26
|
+
# @option options [Boolean] :may_create_new_version (false)
|
27
|
+
# Is it OK to create a new version of this course? If this is set to
|
28
|
+
# false and the course already exists, the upload will fail. If true
|
29
|
+
# and the course already exists then a new version will be created.
|
30
|
+
# No effect if the course doesn't already exist.
|
31
|
+
#
|
32
|
+
# @option options [String] :name (value of :course)
|
33
|
+
# A unique identifier that may be used as part of the directory name on disk.
|
34
|
+
#
|
35
|
+
# @return [ScormEngine::Models::CourseImport]
|
36
|
+
#
|
37
|
+
def post_course_import(options = {})
|
38
|
+
require_options(options, :course_id, :url)
|
39
|
+
|
40
|
+
query_params = {
|
41
|
+
course: options[:course_id],
|
42
|
+
mayCreateNewVersion: !!options[:may_create_new_version]
|
43
|
+
}
|
44
|
+
|
45
|
+
body = {
|
46
|
+
url: options[:url],
|
47
|
+
courseName: options[:name] || options[:course_id]
|
48
|
+
}
|
49
|
+
|
50
|
+
response = post("courses/importJobs", query_params, body)
|
51
|
+
|
52
|
+
result = response&.success? && ScormEngine::Models::CourseImport.new_from_api(response.body)
|
53
|
+
|
54
|
+
Response.new(raw_response: response, result: result)
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# This method will check the status of a course import.
|
59
|
+
#
|
60
|
+
# @see http://rustici-docs.s3.amazonaws.com/engine/2017.1.x/api.html#tenant__courses_importJobs__importJobId__get
|
61
|
+
#
|
62
|
+
# @param [Hash] options
|
63
|
+
#
|
64
|
+
# @option options [String] :id
|
65
|
+
# The id of the import to check.
|
66
|
+
#
|
67
|
+
# @return [ScormEngine::Models::CourseImport]
|
68
|
+
#
|
69
|
+
def get_course_import(options = {})
|
70
|
+
require_options(options, :id)
|
71
|
+
|
72
|
+
response = get("courses/importJobs/#{options[:id]}")
|
73
|
+
|
74
|
+
# jobId is not always returned. :why:
|
75
|
+
result = response&.success? && ScormEngine::Models::CourseImport.new_from_api({ "jobId" => options[:id] }.merge(response.body))
|
76
|
+
|
77
|
+
Response.new(raw_response: response, result: result)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|