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

@b-flower/bdm-base-sdk

v1.0.9

Published

module sdk de base permettant l'intégration de wrapper de communication autour des modules b-eden MROCS

Downloads

15

Readme

bdm-base-sdk

module sdk de base permettant l'intégration de wrapper de communication autour des modules b-eden MROCS.

Install

npm i @b-flower/bdm-base-sdk

API

getSdkInterpreter(actions)

Cette méthode doit être implémentée par un wrapper. (cf bdm-scorm-wrapper)

Retourne une fonction.

Params

actions est un objet obligatoire

Retour de getSdkInterpreter

La fonction de retour est une fonction de démarrage de l'interpréteur du SDK. Elle doit être démarrer dans le module final que vous construisez.

Elle prend comme premier paramètre un store. Le store doit implémenter les propriétés et méthodes suivantes:

  store.interpreter.onTransition // function
  store.interpreter.onEvent // function
  store.getSuspendData // function
  store.getScore // function
  store.getLocation // function
  store.getCurrentResponse // function
  store.setExternalData // function

Le deuxième paramètre est optionel et correspond au devtools bdm-base-sdk-devtools

Exemple d'intégration dans le wrapper

// index.js
import getSdkInterpreter from '@b-flower/bdm-base-sdk'
import * as actions from './actions'

const startSdkInterpreter = getSdkInterpreter(actions)

export default startSdkInterpreter

Définition actions de getSdkInterpreter

L'object actions est un ensemble de callback d'évènement.

- {Object} actions
- {function} actions.start - function(context, eventObject)
- {function} actions.setInteraction - function(context, eventObject)
- {function} actions.setLocation - function(context, eventObject)
- {function} actions.setCompleted - function(context, eventObject)
- {function} actions.setScore - function(context, eventObject)
- {function} actions.stopAsSuspend - function(context, eventObject)
- {function} actions.stop - function(context, eventObject)

Chaque propriétés de actions est une fonction avec la signature function(context, eventObject)

Description de context

Exemple d'utilisation du context

function saveSuspend(ctx, evObj) {
  const { slideshowStore } = evObj

  // ici recordSuspendData est commandé par le devtools et permet au développeur de réagir en fonction
  if (ctx.recordSuspendData) {
    SCORM_API.saveSuspend(JSON.stringify(slideshowStore.getSuspendData()))
  } else {
    SCORM_API.saveSuspend(JSON.stringify({}))
  }
}

Description de eventObject

Description de slideshowStore

slideshowStore = {
  // récupère l'id de la slide en cours
  getLocation() => String
  // récupère la réponse de la slide en cours
  getCurrentResponse() => {
    id,
    description,
    learnerResponse,
    correctResponse = null,
    result = null,
    latency = null,
    weighting = null,
    objectiveId = null,
    dtmTime = new Date(),
  },
  // récupère le score du module
  getScore() => { score, scaled, min = 0, max = 100 },
  // récupère les données en suspend pour le module
  getSuspendData() => restoreData
  // informe le module d'un ensemble de données en lecture seule
  setExternalData({
    suspendData: Object,
    learnerName: String|null,
    learnerId: String|Number|null,
    language: String|null,
    maxTimeAllowed: String|Number|null,
    mode: Enum (preview, review, normal),
    // “preview”
    //    The module is presented without the intent of recording any
    //    information about the current learner session.
    // “normal”
    //    The module is presented with the intent of recording information
    //    about the current learner session.
    //    This is the default value if no mechanism is in place to identify
    //    the mode.
    // “review”
    //    The module has previously recorded information about the learner
    //    attempt and is presented without the intent of updating this
    //    information with data from the current learner session.
    credit: Enum (credit, no-credit, null),
  })
}

Exemple mise en place des actions

Dans les exemples ci-dessous, SCORM_API est un facilitateur de Scorm 2004

start

export function start(ctx, evObj) {
  const { slideshowStore } = evObj
  SCORM_API.start()

  const { slideshowStore } = evObj
  SCORM_API.start()

  const externalData = {
    learnerId: SCORM_API.get('cmi.learner_id'),
    learnerName: SCORM_API.get('cmi.learner_name'),
    language: SCORM_API.get('cmi.learner_preference.language'),
    maxTimeAllowed: SCORM_API.get('cmi.max_time_allowed'),
    mode: SCORM_API.get('cmi.mode'),
    credit: SCORM_API.get('cmi.credit'),
  }

  externalData.suspendData = getSuspendData()

  slideshowStore.setExternalData(externalData)
}

function getSuspendData(ctx, evObj) {
  try {
    return JSON.parse(SCORM_API.getSuspendData())
  } catch (e) {
    return {}
  }
}

stop

export function stop(ctx, evObj) {
  // ici SCORM_API est un facilitateur de Scorm 2004
  SCORM_API.stop()
}

stopAsSuspend

export function stopAsSuspend(ctx, evObj) {
  saveSuspend(ctx, evObj)
  // ici SCORM_API est un facilitateur de Scorm 2004
  SCORM_API.stop(true)
}

function saveSuspend(ctx, evObj) {
  const { recordSuspendData } = ctx
  const { slideshowStore } = evObj
  if (recordSuspendData) {
    SCORM_API.saveSuspend(JSON.stringify(slideshowStore.getSuspendData()))
  } else {
    SCORM_API.saveSuspend(JSON.stringify({}))
  }
}

setScore

export function setScore(ctx, evObj) {
  const { slideshowStore } = evObj

  const {
    score,
    scaled,
    min = 0,
    max = 100,
  } = slideshowStore.getScore()
  SCORM_API.setScore({ score, min, max, threshold })
}

setLocation

export function setLocation(ctx, evObj) {
  const { slideshowStore } = evObj

  SCORM_API.setLocation(slideshowStore.getLocation())
}

setCompleted

export function setCompleted() {
  SCORM_API.complete()
}

setInteraction

export function setInteraction() {
  const { slideshowStore } = evObj
  const {
    id,
    description,
    learnerResponse,
    correctResponse = null,
    result,
    latency = null,
    weighting = null,
    objectiveId = null,
    dtmTime = new Date(),
  } = slideshowStore.getCurrentResponse()

  SCORM_API.interaction.setInteractionJSON(
    id, // interaction Id
    learnerResponse, // learner_response
    result, // result field
    correctResponse, // correctResponse - devrait être présent sur slide.interaction
    description, // description
    weighting, //weighting - devrait être présent sur slide.interaction
    latency, //latency
    objectiveId, // objectiveid - devrait être présent sur slide.interaction
    dtmTime //dtmTime
  )
}