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

jaxpi

v1.0.0

Published

The JaXpi library is design to integrate with games developed in JavaScript or TypeScript for e-Learning purposes, allowing the capture of player data through xAPI-formatted traces for later analysis.

Downloads

84

Readme

Library - JaXpi

The JaXpi library is design to integrate with games developed in JavaScript or TypeScript for e-Learning purposes, allowing the capture of player data through xAPI-formatted traces for later analysis.

1. Installation guide

1.1. JaXpi module

To install the module, you need previosly installed Node.js and npm, then simply install it from Node:

$ npm install jaxpi

and install all the references needed

$ npm install

and import the Jaxpi class into your main file.

1.2. JaXpi File

You can also download the jaxpi.ts or jaxpi.js files if desired. It does not require additional imports and they're ready for use in global scope projects.

2. Use guide

Once installed, create a Jaxpi object in your main file and configure the actor performing the actions in the statement, the server where the statements will be sent, and the authentication token for the server if needed.

export const jaxpi = new Jaxpi({name: ACTOR_NAME, mail: ACTOR_MAIL}, SERVER_URL, GAME_TOKEN_POP);

In the constructor, you can also configure the time interval for sending the statements (disabled by default) and the number of statements stored before sending (default is 5). Statements can also be sent manually whenever the developer wants using the jaxpi.flush() method.

Each time the player performs an action you want to analyze, add a line with the Jaxpi function to generate the statement that best fits your needs. These are created with jaxpi.verb().object().

For example:

function attacked(){
    this.hp -= 1;

    if (this.hp <= 0) {
      jaxpi.died().character(`${this.player.name}`)
      this.hp = 0;
      this.alive = false;
    }
}

If none of the existing functions meet your needs, you can always use jaxpi.customVerb(), which accepts a verb and an object parameters in any JSON format. To make it even easier, you can use jaxpi.verbs.verb and jaxpi.objects.object with the verbs and objects already available in the library, adding whatever you need.

The statements are configurable, allowing you to add the context, result, and authority fields from the xAPI standard, as well as additional parameters in the objects.extensions field in any function that generates a statement, if needed.

3. Adding Verb-Object Functions to JaXpi

New functions can be automatically added to the JaXpi library. You just need to add new verbs or objects in JSON format to the verbs or objects folder, respectively, following the format in which they are created, and run the command $ npm run generate. To add objects to an existing verb, simply add their names in the objects field of the desired verb's JSON.

JSON examples:

{
  "id": "https://github.com/UCM-FDI-JaXpi/lib/accepted",
  "display": {
      "en-US": "accepted",
      "es": "aceptado"
  },
  "objects": ["achievement","award","mission","reward","task"],
  "description": "The player accepts an object like a task or a reward"
}
{
  "id": "https://github.com/UCM-FDI-JaXpi/objects/achievement",
  "definition": {
      "type": "https://github.com/UCM-FDI-JaXpi/object",
      "name": {
          "en-US": "Default achievement",
          "es": "Logro por defecto"
      },
      "description": {
          "en-US": "A recognition or accomplishment gained by meeting certain criteria",
          "es": "Un reconocimiento o logro obtenido al cumplir ciertos criterios"
      }
  }
}

4. Integration with JaXpi Server

If you want to use the LRS server provided by JaXpi, you should add a way for the user to enter a 6-digit password. This can be validated with jaxpi.validateKey(key), which returns a boolean value. If the key is correct, it should be set in the JaXpi object using the jaxpi.setKey(key) method. Additionally, in the JaXpi object constructor, you should use http://localhost:3000/records as the server value and the game token for the authentication token like this:

let SERVER_URL = 'http://localhost:3000/records';
let GAME_TOKEN = 'cEPTx-GsXov-dJBXe-pY7jc-NPyQ9';
...
const jaxpi = new Jaxpi({name: ACTOR_NAME, mail: ACTOR_MAIL}, SERVER_URL, GAME_TOKEN);

Follow the steps described at https://github.com/UCM-FDI-JaXpi/server to deploy the server and use it.