Documentation

Math

Description

The Math module has been developed for users who prepare math presentations. With this module, they can create both simple and complex equations and use the Text module's gaps as inputs.

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 the text gaps (Text,Table) or image gaps (Image Gap) separated with new lines. Each variable is defined by its name, equality character, and the module's ID with the gap index after each dot (i.e., 'gap01 = Text2.3' means that gap01 holds a value of the 3rd gap in the 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!
Show Answers A list of gaps' answers separated with newlines. Each answer is defined by the gap's name set in the '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 or/and Image Gap modules, where the answers from the Math module should be displayed, must be set to the 'not activity' mode.
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 than the 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!
On correct The user event code to be executed if all expressions are evaluated as true.
On incorrect The user event code to be executed if at least one expression is evaluated as false.
On partially completed The user event code is to be executed if at least one gap is left empty.
Empty answer The empty answer is specially dedicated to dropdown gaps in the Text or Table modules 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 (gap 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 module.

Remember that the whole expression (in this case, the 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. The 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 the user fills in all the 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 the Math module can be used in the Advanced Connector module's 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 module allows the user to create exercises as well as activities. Scoring is calculated based on variables and expressions evaluation results. The 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 uncheck the 'Is activity' property for the Text and Image Gap module, or check the 'Is not an activity' property for the Table module which gaps are variables in the Math module! Otherwise, scoring for the whole page will be counted incorrectly!

Property Description
maxScore The 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 to the maxScore, otherwise it is 0.
errorCount If the overall result of the expression's evaluation is false then the errorCount is equal to the maxScore, otherwise it's 0.

CSS classes

Class name Description
--- ---

The Math module doesn't expose any CSS classes because its internal structure should not be changed (neither via the Advanced Connector nor CSS styles).

Demo presentation

Demo presentation contains examples of how to use the Math module.