Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 1.96 KB

readme.textile

File metadata and controls

65 lines (45 loc) · 1.96 KB

Rustici SCORM Cloud Ruby Client

Let me know if you are interested in taking it over. I developed the code but never
actually used it in production. Use with caution.

This ruby gem is provides a ruby interface to the Rustici Scorm Cloud.

Shell CLI Interface

$ gem install ‘scorm_cloud’
$ scorm_cloud rustici.course.getCourseList —appid myappid —secret mysecret

Standard Ruby Use

require 'scorm_cloud'
sc = ScormCloud::ScormCloud.new("my_app_id","my_secret_key")
sc.course.get_course_list.each { |c| puts "#{c.id} #{c.title}"}

Ruby on Rails Use

Place the following in: Gemfile

require 'scorm_cloud', :git => '[email protected]:aeseducation/scorm-cloud.git'

Place the following in: config/initializers/scorm_cloud.rb

# Change MyApplication to the name of your application
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

# app/controllers/course_controller.rb
class CourseController < ApplicationController
	def index
		@courses = scorm_cloud.course.get_course_list
	end
	def launch
		return_url = course_index_url
		reg = scorm_cloud.registrations.create_registration(...)
		redirect_to scorm_cloud.registrations.launch(...)
	end
end

Place the following in: /app/views/course/index.html.erb

# app/views/course/index.html.erb
<ul>
<%= @courses.each |course| >
    <li>
        <
= link_to course_launch_path(course.title,course.id) >
    </li>
<
end %>
</ul>

Uploading a course

# 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