Documentation
Custom Scoring
Description
The Custom Scoring module allows to dictate how the score should be calculated by the player.
Properties
The list starts with the common properties, learn more about them by visiting the Modules description section. The other available properties are described below.
Property name | Description |
---|---|
Script | Script that will be executed when the evaluate() command is called or the Check button is used. |
Max Score | The maximum score of the activity. |
Script
The code provided in a module's property is in fact a fully functional JavaScript script. Within it, a user has access to the PlayerController object (saved in the presenter.playerController variable as in Advanced Connector), thanks to which it can gain access to all modules placed inside a page. Additionally, the presenter variable has two additional methods:
- setScore
- setErrors
Both are used to set the activity result. They take zero or positive integer values for the parameter. When this score is higher than the 'Max Score' property or is invalid - the score will not be saved.
Remember that after the script is evaluated, it might be necessary to do some work with the Advanced Connector module to restore the state before the evaluation (like in the example below where the mark classes have been removed).
Script example
The script used in the demo presentation works with three Image Identification modules (with IDs: 'balloon', 'plane' and 'helicopter') and looks like this:
var balloon = presenter.playerController.getModule('balloon'),
plane = presenter.playerController.getModule('plane'),
helicopter = presenter.playerController.getModule('helicopter');
if (balloon.isSelected() && !plane.isSelected() && helicopter.isSelected()) {
presenter.setScore(1);
presenter.setErrors(0);
} else {
presenter.setScore(0);
presenter.setErrors(1);
}
In addition, the Advanced Connector script looks like this:
EVENTSTART
Name:Check
SCRIPTSTART
var balloon = presenter.playerController.getModule('balloon'),
plane = presenter.playerController.getModule('plane'),
helicopter = presenter.playerController.getModule('helicopter');
if (balloon.isSelected() && !plane.isSelected() && helicopter.isSelected()) {
balloon.markAsCorrect();
plane.markAsCorrect();
helicopter.markAsCorrect();
} else {
balloon.markAsWrong();
plane.markAsWrong();
helicopter.markAsWrong();
}
SCRIPTEND
EVENTEND
EVENTSTART
Name:Uncheck
SCRIPTSTART
var balloon = presenter.playerController.getModule('balloon'),
plane = presenter.playerController.getModule('plane'),
helicopter = presenter.playerController.getModule('helicopter');
balloon.removeMark();
plane.removeMark();
helicopter.removeMark();
SCRIPTEND
EVENTEND
Supported commands
Command name | Params | Description |
---|---|---|
evaluate | --- | Evaluates specified script. |
setScore | score | Sets score value for the module. The score value must be a natural number. |
setErrors | errors | Sets errors value for the module. The errors value must be a natural number. |
CSS classes
Class name | Description |
---|---|
--- | --- |
Demo presentation
Demo presentation contains examples of how to use the Custom Scoring module.