From 8b648c54ebd2be2c1869d3209e8f72a1d1f8ef7e Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Thu, 11 Sep 2014 13:56:08 -0400 Subject: [PATCH 01/10] Update auth_ping to accept appid --- lib/scorm_cloud/debug_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scorm_cloud/debug_service.rb b/lib/scorm_cloud/debug_service.rb index 4a0e779..8de5cc9 100644 --- a/lib/scorm_cloud/debug_service.rb +++ b/lib/scorm_cloud/debug_service.rb @@ -8,8 +8,8 @@ def ping() "pong" end - def auth_ping() - xml = connection.call("rustici.debug.authPing") + def auth_ping(appid) + xml = connection.call("rustici.debug.authPing", {appid: appid}) raise "Bad Server Response" unless xml.elements["/rsp/pong"] "pong" end From 48824ffc76295e2643065a1003048a7e92de9125 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Mon, 22 Sep 2014 12:41:13 -0400 Subject: [PATCH 02/10] Update connection.rb --- lib/scorm_cloud/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scorm_cloud/connection.rb b/lib/scorm_cloud/connection.rb index ade84be..061f28b 100644 --- a/lib/scorm_cloud/connection.rb +++ b/lib/scorm_cloud/connection.rb @@ -51,7 +51,7 @@ def prepare_url(method, params = {}) join sig = Digest::MD5.hexdigest(raw) - "http://cloud.scorm.com/api?#{html_params}&sig=#{sig}" + "https://cloud.scorm.com/api?#{html_params}&sig=#{sig}" end From 3a313873d4fe4349c1e266c3ab689a1610efbea7 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Tue, 23 Sep 2014 15:42:05 -0400 Subject: [PATCH 03/10] Implemented test_registration_post_url Added test_registration_post_url method to test postback url. --- lib/scorm_cloud/registration_service.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/scorm_cloud/registration_service.rb b/lib/scorm_cloud/registration_service.rb index 3b518fd..8ed64fe 100644 --- a/lib/scorm_cloud/registration_service.rb +++ b/lib/scorm_cloud/registration_service.rb @@ -3,7 +3,7 @@ class RegistrationService < BaseService not_implemented :get_registration_list_results, :get_launch_history, :get_launch_info, :reset_global_objectives, - :update_learner_info, :test_registration_post_url + :update_learner_info def create_registration(course_id, reg_id, first_name, last_name, learner_id, options = {}) params = options.merge({ @@ -44,6 +44,16 @@ def reset_registration(reg_id) xml = connection.call("rustici.registration.resetRegistration", {:regid => reg_id }) !xml.elements["/rsp/success"].nil? end + + def test_registration_post_url(postbackurl, urlname, urlpass, options ={}) + params = options.merge({ + :postbackurl => postbackurl, + :urlname => urlname, + :urlpass => urlpass + }) + xml = connection.call("rustici.registration.testRegistrationPostUrl", params) + !xml.elements["/rsp/success"].nil? + end end From ad54fe7e12cc1e6b01f94f645b7632ced31ed1d9 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Wed, 24 Sep 2014 16:01:24 -0400 Subject: [PATCH 04/10] Update readme.textile We had better success writing the config in two lines instead of a block. --- readme.textile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/readme.textile b/readme.textile index 863e2f4..3f8dc06 100644 --- a/readme.textile +++ b/readme.textile @@ -25,10 +25,9 @@ bc. require 'scorm_cloud', :git => 'git@github.com:aeseducation/scorm-cloud.git' _Place the following in: config/initializers/scorm_cloud.rb_ bc. # Change MyApplication to the name of your application -MyApplication::Application.configure do |config| - config.scorm_cloud.appid = "my_app_id" - config.scorm_cloud.secretkey = "my_secret_key" -end +MyApplication::Application.config.scorm_cloud.appid = "my_app_id" +MyApplication::Application.config.scorm_cloud.secretkey = "my_secret_key" + _Place the following in: /app/controllers.course_controller.rb_ From 8e74e7db2e9a9dd36712656df94412cdd04aa545 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Wed, 24 Sep 2014 16:07:23 -0400 Subject: [PATCH 05/10] Include course upload example in readme --- readme.textile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/readme.textile b/readme.textile index 3f8dc06..79136da 100644 --- a/readme.textile +++ b/readme.textile @@ -53,3 +53,13 @@ bq. # app/views/course/index.html.erb     </li> <% end %> </ul> + +_Uploading a course_ + +bc. # app/models/scorm_training.rb, using scorm_zip as a paperclip attachment in our upload form +def upload_to!(scorm_cloud) + path = scorm_cloud.upload.upload_file(scorm_cloud.upload.get_upload_token, self.scorm_zip.path) + scorm_cloud.course.import_course(self.scorm_course_id, path) +end + + From 9d29b73b8b4ae20e243da7e9eef9aa00f485ad0c Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Wed, 24 Sep 2014 16:11:50 -0400 Subject: [PATCH 06/10] Update get_registration_result Method takes "resultsformat" not "format" parameter --- lib/scorm_cloud/registration_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scorm_cloud/registration_service.rb b/lib/scorm_cloud/registration_service.rb index 8ed64fe..ad23968 100644 --- a/lib/scorm_cloud/registration_service.rb +++ b/lib/scorm_cloud/registration_service.rb @@ -29,7 +29,7 @@ def get_registration_list(options = {}) def get_registration_result(reg_id, format="course") raise "Illegal format argument: #{format}" unless ["course","activity","full"].include?(format) - connection.call_raw("rustici.registration.getRegistrationResult", { :regid => reg_id, :format => format }) + connection.call_raw("rustici.registration.getRegistrationResult", { :regid => reg_id, :resultsformat => format }) end def launch(reg_id, redirect_url, options = {}) From 341d958e3251fda268a89f10f8f28b89a286b926 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Wed, 24 Sep 2014 16:13:51 -0400 Subject: [PATCH 07/10] Implement get_launch_info --- lib/scorm_cloud/registration_service.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/scorm_cloud/registration_service.rb b/lib/scorm_cloud/registration_service.rb index ad23968..8cb04b8 100644 --- a/lib/scorm_cloud/registration_service.rb +++ b/lib/scorm_cloud/registration_service.rb @@ -54,6 +54,11 @@ def test_registration_post_url(postbackurl, urlname, urlpass, options ={}) xml = connection.call("rustici.registration.testRegistrationPostUrl", params) !xml.elements["/rsp/success"].nil? end + + def get_launch_info(launch_id) + xml = connection.call("rustici.registration.getLaunchInfo", {:launchid => launch_id }) + !xml.elements["/rsp/success"].nil? + end end From 8225678e046519376f34ff339fbb244374874ad3 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Wed, 24 Sep 2014 16:15:24 -0400 Subject: [PATCH 08/10] Implement get_launch_history --- lib/scorm_cloud/registration_service.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/scorm_cloud/registration_service.rb b/lib/scorm_cloud/registration_service.rb index 8cb04b8..7904a69 100644 --- a/lib/scorm_cloud/registration_service.rb +++ b/lib/scorm_cloud/registration_service.rb @@ -59,6 +59,11 @@ def get_launch_info(launch_id) xml = connection.call("rustici.registration.getLaunchInfo", {:launchid => launch_id }) !xml.elements["/rsp/success"].nil? end + + def get_launch_history(reg_id) + xml = connection.call("rustici.registration.getLaunchHistory", {:regid => reg_id }) + !xml.elements["/rsp/success"].nil? + end end From b7e56af268af90a93c75599864c725b70a9eb6ec Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Wed, 24 Sep 2014 16:16:23 -0400 Subject: [PATCH 09/10] Removed not_implemented for launch info/history --- lib/scorm_cloud/registration_service.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/scorm_cloud/registration_service.rb b/lib/scorm_cloud/registration_service.rb index 7904a69..062970f 100644 --- a/lib/scorm_cloud/registration_service.rb +++ b/lib/scorm_cloud/registration_service.rb @@ -1,9 +1,7 @@ module ScormCloud class RegistrationService < BaseService - not_implemented :get_registration_list_results, - :get_launch_history, :get_launch_info, :reset_global_objectives, - :update_learner_info + not_implemented :get_registration_list_results, :reset_global_objectives, :update_learner_info def create_registration(course_id, reg_id, first_name, last_name, learner_id, options = {}) params = options.merge({ From 3e581a82e3942b42c7a0bf7026b750b0f539b496 Mon Sep 17 00:00:00 2001 From: Dan Kleiman Date: Fri, 26 Sep 2014 09:52:11 -0400 Subject: [PATCH 10/10] Implement https call to scorm cloud --- lib/scorm_cloud/connection.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/scorm_cloud/connection.rb b/lib/scorm_cloud/connection.rb index 061f28b..9d320c3 100644 --- a/lib/scorm_cloud/connection.rb +++ b/lib/scorm_cloud/connection.rb @@ -14,7 +14,12 @@ def call(method, params = {}) def call_raw(method, params = {}) url = prepare_url(method, params) execute_call_plain(url) - end + end + + def call_https(method, params = {}) + url = prepare_url(method, params) + execute_call_https(url) + end # Get plain response body and parse the XML doc def execute_call_xml(url) @@ -36,6 +41,24 @@ def execute_call_plain(url) raise "HTTP Error connecting to scorm cloud: #{res.inspect}" end end + + def execute_call_https(url) + uri = URI.parse(url) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + + case res + when Net::HTTPRedirection + # Return the new URL + res['location'] + when Net::HTTPSuccess + res.body + else + raise "HTTP Error connecting to scorm cloud: #{res.inspect}" + end + end # Get the URL for the call def prepare_url(method, params = {})