Initialization Option Reports API

cutScoreMutator

This callback can be used to manipulate or mutate the score values before the last score by item by user and last score by activity by user reports are rendered on the page.

Examples

var callbacks = {
    cutScoreMutator: function (score) {
        let performanceBand = 'none';
        let voiceOverMessage = '';
        if (score.percentageItemsCorrect <= 50) {
            performanceBand = 'fail';
            voiceOverMessage = 'Highlighted as failed';
        }
        const customDomData = {
            performance: performanceBand,
        };
        score.domData = customDomData;
        score.voiceOverMessage = voiceOverMessage;
    }
};

Values

Type function

Callback function used to mutate the score. This function is called before the score is rendered in the report.

The score argument passed to the function is a score mutator object where the score can be mutated with the available methods.

Callback arguments

The callback receives the following arguments when it is executed.

  • score object

    An object containing attributes and methods to mutate a score and assign HTML data attributes to certain elements to make them accessible for design and behavioral changes.

    • domData object

      Store custom HTML data attributes against this score's cell, for the purpose of custom logic or CSS selectors. Provide a map of key value pairs which will be stored on the DOM element as custom data attributes. Each key will be added to the score's cell as a data attribute of the form data-custom_keyname="value". The data attribute can then be used as a CSS selector for applying custom styles, or as a DOM selector to hook your own custom logic to. See an example domData customization in the demos for last score by item by user report and last score by activity by user report.

    • percentageItemsCorrect numeric

      The percentage of correct Items in the score.

Was this article helpful?