Skip to content

pwcoleman/TinCanRuby

Repository files navigation

TinCanApi

A Ruby library for implementing Tin Can API (Experience API).

For more information about the Tin Can API visit:

http://tincanapi.com/

Warning

Please regard this as alpha software. It was created to solve an urgent problem and has not been fully tested in a live environment.

Installation

Add this line to your application's Gemfile:

gem 'tin_can_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tin_can_api

Usage

Create a remote LRS using basic auth

remote_lrs = TinCanApi::RemoteLRS.new do |c|
  c.end_point = 'https://some.endpoint.com'
  c.user_name = 'user'
  c.password = 'password'
end

Connect to the 'about' endpoint to get version information

# use the remote LRS from above
response = remote_lrs.about
# check if it is successful
if response.success
    # access the TinCanApi::About instance
    response.content
end

Create a statement

agent = TinCanApi::Agent.new(mbox: 'mailto:info@tincanapi.com')
verb = TinCanApi::Verb.new(id: 'http://adlnet.gov/expapi/verbs/attempted')
activity = TinCanApi::Activity.new(id: 'http://pwcoleman.github.com/TinCanRuby')

statement = TinCanApi::Statement.new do |s|
  s.actor = agent
  s.verb = verb
  s.object = activity
end

response = remote_lrs.save_statement(statement)
if response.success
  # access the statement
  response.content
end

For more API calls check out the TinCanApi::RemoteLRS class

About

Tin Can ruby client library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages