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
1 change: 1 addition & 0 deletions lib/scorm_cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'scorm_cloud/base_object'
require 'scorm_cloud/course'
require 'scorm_cloud/registration'
require 'scorm_cloud/registration_result'

require 'scorm_cloud/base_service'
require 'scorm_cloud/debug_service'
Expand Down
4 changes: 2 additions & 2 deletions lib/scorm_cloud/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Registration < ScormCloud::BaseObject
attr_accessor :id, :courseid, :app_id, :registration_id, :course_id,
:course_title, :learner_id, :learner_first_name, :learner_last_name,
:email, :create_date, :first_access_date, :last_access_date,
:completed_date, :instances, :last_course_version_launched
:completed_date, :instances, :last_course_version_launched,:tin_can_registration_id

def self.from_xml(element)
r = Registration.new
Expand All @@ -16,4 +16,4 @@ def self.from_xml(element)
end

end
end
end
16 changes: 16 additions & 0 deletions lib/scorm_cloud/registration_result.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module ScormCloud
class RegistrationResult < ScormCloud::BaseObject

attr_accessor :complete, :success, :totaltime, :score, :format, :instanceid, :regid

def self.from_xml(element)
r = RegistrationResult.new
r.set_attributes(element.attributes)
element.children.each do |element|
r.set_attr(element.name, element.text)
end
r
end

end
end
12 changes: 10 additions & 2 deletions lib/scorm_cloud/registration_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def create_registration(course_id, reg_id, first_name, last_name, learner_id, op
!xml.elements["/rsp/success"].nil?
end

def get_registration_detail(reg_id)
xml = connection.call("rustici.registration.getRegistrationDetail", {:regid => reg_id })
!xml.elements["/rsp/success"].nil?

Registration.from_xml(xml.elements["/rsp/registration"])
end

def delete_registration(reg_id)
xml = connection.call("rustici.registration.deleteRegistration", {:regid => reg_id })
!xml.elements["/rsp/success"].nil?
Expand All @@ -28,8 +35,9 @@ def get_registration_list(options = {})
end

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 })
xml = connection.call("rustici.registration.getRegistrationResult", { :regid => reg_id })

RegistrationResult.from_xml(xml.elements["/rsp/registrationreport"])
end

def launch(reg_id, redirect_url, options = {})
Expand Down
1 change: 1 addition & 0 deletions spec/registration_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
it { should respond_to(:get_registration_result).with(2).arguments }
it { should respond_to(:launch).with(2).arguments }
it { should respond_to(:launch).with(3).arguments }
it { should respond_to(:get_registration_detail).with(1).arguments }

# not implemented
it { should respond_to(:get_registration_list_results)}
Expand Down