GithubHelp home page GithubHelp logo

tincanruby's Introduction

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:[email protected]')
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

tincanruby's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tincanruby's Issues

Wrong version may be used when serializing in RemoteLRS

When serializing Statements in RemoteLRS, the latest_version is always used, regardless of the version provided in the initializer.

This repo seems to be relatively unmaintained, but in case it helps the next person 🤷 here ya go!

'Choices' interaction in Activity Definition model class

Any advice on how to add interactions specifically choices to the Activity Definition model class to create the following activity definition

"definition": {
	"description": {
		"en-US": "Which of these prototypes are available at the beta site?"
	},
	"type": "http://adlnet.gov/expapi/activities/cmi.interaction",
	"interactionType": "choice",
	"correctResponsesPattern": [
		"golf[,]tetris"
	],
	"choices": [
		{
			"id": "golf", 
			"description": {
				"en-US": "Golf Example"
			}
		},
		{
			"id": "facebook", 
			"description": {
				"en-US": "Facebook App"
			}
		},
		{
			"id": "tetris", 
			"description": {
				"en-US": "Tetris Example"
			}
		},
		{
			"id": "scrabble", 
			"description": {
				"en-US": "Scrabble Example"
			}
		}
	]
}

Correct TinCanApi::Activity and TinCanApi::Result calls

Am attempting to pass a statement for an activity with name and decription, including a result

agent = TinCanApi::Agent.new(mbox: 'mailto:[email protected]')
verb = TinCanApi::Verb.new(id: 'http://adlnet.gov/expapi/verbs/completed', name: 'completed')
object = TinCanApi::Activity.new(id: "https://somelms/quizzes/numerical-reasoning", 
         name: 'Numerical Reasoning', 
         type: 'http://adlnet.gov/expapi/activities/assessment', 
         description: 'Numerical ability tests are used to establish a candidate’s ability to read and understand the information presented in numerical form and then use the correct and most effective operations to find the right answer. Although it is senior-school level maths, you will still need to be efficient and well-practiced.',
         extensions: { "http://id.tincanapi.com/extension/planned-duration" => 'PT20M' }
                              )
result = TinCanApi::Result.new(
         response: 'Passed', 
         score: {min: 0, raw: 1, max: 2}, 
         success: true, 
         extensions: {"https://somelms/quizzes/numerical-reasoning" => [
                     'Xavier calls each of his employees on Monday mornings. He speaks to John second, Henry third, Joanna fifth and Layla sixth. Based on the information above, which of the following statements CANNOT be true?',
                     'Lola lives in the United States of America but visits Canada twice a year, bringing her three dogs with her. She needs to buy new insurance for her dogs. Which plan is the best for Lola’s needs?'
                     ]})

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

response = remote_lrs.save_statement(statement)

Can somebody help with the correct syntax to make the above calls.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.