Documentation
Math
Description
The Math addon has been developed for users who prepare math presentations. With this addon, they can create both simple and complicated equations and as inputs use Text module gaps.
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 |
---|---|
Variables | A list of variables assigned to Text/Image Gap module gaps separated with newlines. Each variable is defined by its name, equality character, and a module ID with a gap index after each dot (i.e. 'gap01 = Text2.3' means that gap01 holds a value of the 3rd gap in a text module with ID Text2). For the Image Gap module, the gap index is always 1. |
Expressions | A list of JavaScript boolean expressions (i.e. 'gap01 == 3 && 1 + 2 > 2' will evaluate to true if a gap assigned to a variable gap01 will hold '3' string). It's crucial to remember that all expressions are JavaScript boolean expressions! |
Decimal separator | By default, the decimal separator in Math expressions is a dot character. When this field is filled, e.g., with a comma, all expressions containing this character will have it replaced with a dot character. This enables the user to write and use expressions with other but default decimal separators. |
Thousand separator | By default, in Math expressions numbers are written without any thousand separators. When this field is filled, e.g., with a dot, all expressions containing this character will have it removed. Thousand separator and decimal separator cannot be the same! |
onCorrect | User event code is to be executed if all expressions are evaluated as true |
onIncorrect | User event code is to be executed if at least one expression is evaluated as false |
onPartiallyCompleted | User event code is to be executed if at least one gap was left empty |
Show Answers | A list of gaps' answers separated with newlines. Each answer is defined by a gap name set in Variables and value that will be displayed in the Show Answers mode (e.g., 'gap01 = 1' means that for gap01 the answer displayed will be '1'). The Text/Table/Image Gap modules, where the answers from the Math module should be displayed, must be set to the 'not activity' mode. |
Empty Answer | The empty answer is specially dedicated to dropdown gaps in the Text module with the default option "---". It's treated by the Math module as an answer, not as an empty value. This property allows defining that it should be treated as an empty answer, not the triple dash value. Only one single word without spaces is allowed, e.g.: "---". |
Note about expressions:
Because each expression is a JavaScript boolean expression, users can use immediate execution functions inside them, as long as those evaluate to a boolean value. Variables (gaps values) can be accessed inside those functions by passing 'this.variables' parameter (see the example below).
(function (variables) { var sum; for (var variable in variables) {
sum += variables[variable]; } return sum > 10; })(this.variables)
If the user wants to use variables by name, the immediate execution function must be constructed in a special way:
(function (variables) { this.variables = variables;
return gap1 > 5; })(this.variables)
This pattern is necessary due to the variables parsing mechanism in the Math addon.
Remember that the whole expression (in this case whole immediate execution function) has to be placed in one line (without line breaks)!
Supported commands
Command name | Params | Description |
---|---|---|
evaluate | --- | Evaluates all specified expressions. Text gaps will not be marked as (in)correct! |
isAttempted | --- | Returns true if all gaps are filled in. |
isAllOK | --- | Returns true if all gaps are filled in correctly. |
Events
When a user fills in all gaps correctly without any error, the module sends the 'ALL OK' event. This event is different from a normal event, so its structure is shown below.
Field name | Description |
---|---|
Item | all |
Value | N/A |
Score | N/A |
Advanced Connector integration
Each command supported by Math Addon can be used in the Advanced Connector addon scripts. The example below shows how to react to each gap content change and evaluate expressions.
EVENTSTART
Source:Text2
SCRIPTSTART
var mathModule = presenter.playerController.getModule('Math1');
mathModule.evaluate();
SCRIPTEND
EVENTEND
Scoring
The Math addon allows the user to create exercises as well as activities. Scoring is calculated based on variables and expressions evaluation results. Number of expressions is not taken into consideration in this process. Please remember that the score and error count are calculated only when all necessary gaps are filled. It's essential to turn off the 'Is Activity' option in the Text module whose gaps are variables in Math Addon! Otherwise scoring for the whole page will be counted incorrectly!
Property | Description |
---|---|
maxScore | maximum score is equal to the number of specified variables |
score | if the overall result of the evaluation of the expression is true then the score is equal the maxScore, otherwise it's 0 |
errorCount | if the overall result of expressions evaluation is false then the errorCount is equal to the maxScore, otherwise it's 0 |
CSS classes
Class name | Description |
---|---|
--- | --- |
Math addon doesn't expose any CSS classes because its internal structure should not be changed (neither via Advanced Connector nor CSS styles).
Demo presentation
Demo presentation contains examples of how to use a Math addon.