JsApi

The API on the global js object in the module scripting environment.

js.config

Type
object

The currently rendered module’s config object

js.jslib

Type
Object.<alias, *>

Dictionary of alias to jslib

js.module

Type
ModuleApi

Current module object.

js.node

Type
NodeApi

Current node object, set for each node being evaluated.

js.sfile

Type
Object.<alias, SfileApi>

Dictionary of alias to sfile

js.ufile

Type
Object.<alias, UfileApi>

Dictionary of alias to ufile

js.username

Type
string

The current user’s username. Available in UFile, SFile, Module script enviornments

js.logEvent(pageview, elog, json)

Log an event.

ParamTypeDescription
pageviewboolean

indicates to call Google analytics w/ elog information

elogobject

json object of named params for GA & jsonsails logging

jsonobject

extra json field GA doesn't handle but offers more flexibility in jsonsails logging

// logging example
var json = {};
var question = model.get_question();
json.choices = model.get_choices();
json.answer = model.answer;
var correct = model.resp_correct();
var elog = {
    'eventCategory': 'nts',
    'eventAction': 'answer',
    'eventLabel': 'correct',
    'eventValue': correct
};
var elog = {}
var json = {}
js.logger.logEvent(pageview, elog, json)

js.rerender()

Rerender this module and its children