Ruby course creation

We have provided sample ruby code to demonstrate how to use the Bridge API. While not complete, it does show a broad usage of the API. Demonstrated here (in ruby code) are API’s for course creation, user creation and enrolling users in courses.

Setup

The first thing you will need is the URL to bridge that your company is allowed to use. Second you will need your unique ID, and password.

Get the token

Check the API overview for instructions on how to get an authorization token.

Use the token

Pass the token to the header in your http request for the API you want to call. For instance to list details about a course, you could write a function that accepts your token:

 # Global path to Bridge URL. Your URL will be different.
 $bridge_url = "http://bridge.local.bridgeops.sh:3000"

 # List details about a course
 def inspect_course(token, id)
   url = "#{$bridge_url}/api/author/course_templates/#{id}"
   headers = {AUTHORIZATION: "Basic #{token}"}
   response = RestClient.get(url, headers)
   json_response = JSON.parse(response)
   json_response["course_templates"].each do |course|
     puts "#{course["id"]}: #{course["title"]} "
     ...
   end
 end

For more information see the examples on the following topics:

Samples for

Course management

User management

Enrollments

Live Course Trainings

Live Course Training Sessions

Roles

User management