npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@elearntics/xapi-events

v0.2.0

Published

Manage xAPI statements triggered by user interaction

Downloads

5

Readme

xapi-events Build Status

Manage student interactions in elearning applications using the xAPI specification

Install

$ npm install @elearntics/xapi-events

Usage

Option 1: Import xapiEvent as a module

import xapiEvents from 'xapievents';

Option 2: Load the script in your HTML

<script src="node_modules/@elearntics/xapi-events/dist/xapi-events.js" type="text/javascript"></script>

Basic example

const defaultStatement = xapiEvents.getDefaultStatement();

const events = [{
  id: 'select-text',
  callback: xapiEvents.LRS.send,
  name: 'mouseup',
  elementSelectors: ['.text'],
  isValid: false,
  status: 'OFF',
  statement: [...defaultStatement, {
    verb: 'selected',
    actor: '[email protected]'
  }]
}];

xapiEvents.LRS.setConfig({
  USERNAME: 'username',
  PASSWORD: 'password',
  URL: 'http://example.com'
});

xapiEvents.addEvents(events);
xapiEvents.enableAllEvents();
xapiEvents.listenEnabledEvents();
xapiEvents.init('[email protected]', 'xapiEvents-Example');

xAPI Event format

id

A unique identifier.

callback

The function to be executed when the event is triggered.

name

The name of the event listener. (i.e: click, mouseup, mousedown...)

elementSelector

The query selector for the HTML elements that will listen to the event.

targetElement

The array elements that are listening to the event.

statement

The statement structure that will be used when the event is triggers.

status

The event status. There are three possible states:

  • ON
  • OFF
  • DISABLED (the initial state)

The event will only be available if its state is ON.

API

xapiEvents.init(actor, authority)

Initializes xapiEvents by default.

xapiEvents.reset

Resets xapiEvents by default.

xapiEvents.setBaseStatement(author, authority)

Sets the default statement that is used to build the rest of the statements.

xapiEvents.listenEnabledEvents

It subscribes to all the events for all the xAPI events that are enabled.

xapiEvents.stopEnabledEvents

It remove the subscription to all the events for all the xAPI events that are enabled.

xapiEvents.addEvent(event)

Add a single xAPI Event.

xapiEvents.addEvents([events])

Add multiple xAPI Events.

xapiEvents.removeEventById(id)

Remove the first event it founds a given xAPI Event id;

xapiEvents.enableAllEvents

Set all the xAPI events status to ON.

xapiEvents.enableEventById

Set an xAPI event status to ON.

xapiEvents.disableEventById

Set ALL the xAPI events status to OFF.

xapiEvents.disableEvent

Set an xAPI event status to OFF.

xapiEvents.getDefaultEvent

Gets the default xAPI event structure.

xapiEvents.getDefaultStatement

Gets the default statment structure.

xapiEvents.getTargetElements

Gets all the elements that are listening to the event.

xapiEvents.isValidEvent

Returns if the event is well-formed.

LRS

You can set the credentials to connect to your LRS.

xapiEvents.LRS.setConfig

  • username: your username.
  • password: your password.
  • url: the url where your LRS is hosted.
xapiEvents.LRS.setConfig({
  USERNAME: 'username',
  PASSWORD: 'password',
  URL: 'http://example.com'
});

xapiEvents.LRS.send

Post an statement to your LRS. Can be used as a callback for an xapi-event.

License

MIT © elearntics