Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions lib/scorm_cloud/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 = {})
Expand All @@ -51,7 +74,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


Expand Down
4 changes: 2 additions & 2 deletions lib/scorm_cloud/debug_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 22 additions & 4 deletions lib/scorm_cloud/registration_service.rb
Original file line number Diff line number Diff line change
@@ -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, :test_registration_post_url
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({
Expand All @@ -29,7 +27,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 = {})
Expand All @@ -44,6 +42,26 @@ 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

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
Expand Down
17 changes: 13 additions & 4 deletions readme.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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_

Expand All @@ -54,3 +53,13 @@ bq. # app/views/course/index.html.erb
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;
&lt;% end %&gt;
&lt;/ul&gt;

_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