scoreMutator - Initialization - Reports API

Reports API Initialization

scoreMutator()

Callback function used in the learning outcomes report to mutate scores shown in each cell of the report.

This function is called before scores are rendered in the report. The scores argument passed to the function is an array of score mutator objects. The score can be mutated using these methods. The return value of scoreMutator is ignored.

Examples

scoreMutator: function (scores) {
    for (var i = 0; i < scores.length; i++) {

        // apply a custom business rule to treat
        // unattempted questions as incorrect
        var unattempted = scores[i].unattempted();
        var incorrect = scores[i].incorrect();

        scores[i].unattempted(0);
        scores[i].incorrect(incorrect + unattempted);

    }
}

Arguments

  • scores array[scoreMutatorObject]

    An array of objects, each corresponding to a single cell in the report. Each object exposes methods for mutating the score shown in the report. See scoreMutatorObject definition for details of each method.

Return value

None (undefined).

Type definitions

  • scoreMutatorObject object

    An object containing methods to mutate a score, as well as assign HTML data attributes to certain elements to make them accessible for design and behavioral changes. The individual correct, incorrect, unattempted and unmarked components of the score are exposed as getters, and each component can be overridden using the corresponding setter methods. The components of the score will be used to render score percentages, score bars and tooltips.

    Additional countSeen() and percentScore() methods are also available.

    • countSeen() function

      Returns the number of items from which this score is calculated, ie. the number of Items presented to the user that meet the filters for this particular report (or cell within the report).

    • correct() function

      Returns the correct component of the score.

    • domData(object) function

      Used to store custom data attributes against this score's cell, for the purpose of custom logic or CSS selectors. Pass a map of key value pairs which will be stored on the DOM 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 a DOM selector to hook your own custom logic to. See an example domData() customization at our Learnosity Demos Learning Outcomes - Class Demo

    • correct(Number) function

      Sets the correct component of the score.

    • incorrect() function

      Returns the incorrect component of the score.

    • incorrect(Number) function

      Sets the incorrect component of the score.

    • unmarked() function

      Returns the unmarked component of the score.

    • unmarked(Number) function

      Sets the unmarked component of the score.

    • unattempted() function

      Returns the unattempted component of the score.

    • unattempted(Number) function

      Sets the unattempted component of the score.

    • percentScore(Number) function

      Sets the overall percent score. Normally, Learnosity uses correct / maxScore to calculate the percentScore, but this setter can be used to override the displayed percentage regardless of the values of the individual score components.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.