new TextFieldStep(tpl, inputs, end_message, options) → {Object}
Exercises - Text plus one active field
Parameters:
Name | Type | Argument | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tpl |
String | The exercise template. The math to be parsed by mathjax (latex syntax) must be placed inside the tag {%%}, i.e. {% 2^4=16 %} The input fields inside the math must be formatted this way: \\FormInput2, where 2 is the id of the input which is described through the inputs parameter. |
|||||||||||
inputs |
Object | The object describing the inputs in the template | |||||||||||
end_message |
String |
<optional> |
A message to be displayed at the end of the step | ||||||||||
options |
Object |
<optional> |
The step options
Properties
|
- Source:
- mathex/res-otto/js/mathex.js, line 705
Returns:
TextFieldStep instance
- Type
- Object
Example
var step1 = new mathex.TextFieldStep(
'<h3> Show that {% 2^7 : 2^4 = 2^(7-4) = 2^3 %}</h3>' +
'<p>Demonstration:</p>' +
'<p>{% 2^7 = \\FormInput0 %}</p>' +
'<p>{% 2^4 = \\FormInput1 %}</p>' +
'<p>etc...</p>',
{
0: {
size: 3,
active: true,
result: '128',
type: 'string'
},
1: {
size: 2,
active: false,
}
},
'a message'
);
Extends
Methods
-
addInputEvents()
Adds events to the input fields
-
- Source:
- mathex/res-otto/js/mathex.js, line 734
Returns:
void -
checkFieldResult(field, result, fieldobj)
Checks the result of a text field
-
Parameters:
Name Type Description field
Object The mootools input field object result
Mixed The right result fieldobj
Object The input object - Inherited From:
- Source:
- mathex/res-otto/js/mathex.js, line 616
-
deactivate()
Deactivates all inputs
-
- Source:
- mathex/res-otto/js/mathex.js, line 771
Returns:
void -
removeInputEvents()
Removes events from active input fields
-
- Source:
- mathex/res-otto/js/mathex.js, line 756
Returns:
void -
run(router)
Executes the step
-
Renders the template and activates the input fields
Parameters:
Name Type Description router
Object a mathex.Router instance - Source:
- mathex/res-otto/js/mathex.js, line 709
Returns:
void