0.0.5 • Published 4 years ago

@taylora/xapi-statement-builder v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

xApi Statement Builder

The aim of this library is to ease the creation of xApi statements providing a builder with a fluent interface to configure mandatory and optional parts of it

Install and usage

$ npm i @taylora/xapi-statement-builder 
import xApi from '@taylora/xapi-statement-builder';

const authority = xApi.IFI.account({
    name: 'authority-username',
    homePage: 'http://www.example.com/learning-record-provider'
});
const alice = xApi.cmi5.actor(xApi.IFI.account({name: 'Alice', homePage: 'http://alice.me'}));

const statement = xApi.cmi5.completed()
    .actor(alice)
    .activityId('http://www.awsome-courses.com/course-id')
    .activityName({value: 'The Awesome course'})
    .result('PT8H0M0S')
    .authority({name: 'Learning Record Provider', IFI: authority})
    .when(new Date('2020-01-01'));

const element = document.createElement('code');
element.innerHTML = JSON.stringify(statement.getStatement());
return element;

for more example refer to lib/index.spec.js test file

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago