Class: TextChoiceFieldStep

mathex. TextChoiceFieldStep

new TextChoiceFieldStep(tpl, result, end_message, options) → {Object}

Exercises - Text plus one radio input

Parameters:
Name Type Argument Description
tpl String The exercise template.

The math to be parsed by mathjax must be placed inside the tag {%%}, i.e. {% 2^4=16 %}

The available choices must be written this way: [[0]] my choice. Then the [[0]] is parsed and a radio buton is created.

result Number The index of the correct radio answer
end_message String <optional>
A message to be displayed at the end of the step
options Object <optional>
The step options
Properties
Name Type Argument Default Description
container Boolean <optional>
true Whether or not to insert the exercise text inside a div container
Source:
Returns:
TextChoiceFieldStep instance
Type
Object
Example
 var step = new mathex.TextChoiceFieldStep(
   '<h3>Title</h3>' + 
   '<p>Which color is yellow?</p>' + 
   '<ul>' + 
   '<li>[[0]] red</li>' + 
   '<li>[[1]] {% 2^7 = 32 %}</li>' + 
   '<li>[[2]] yellow</li>' + 
   '</ul>',
   2
 );

Extends

Methods

addInputEvents()

Adds events to the radio buttons

Source:
Returns:
void

checkChoiceFieldResult(field, id)

Checks the user answer

Parameters:
Name Type Description
field Object The mootools radio button object
id Number The index of the clicked radio button
Source:
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:

deactivate()

Deactivates all inputs

Source:
Returns:
void

removeInputEvents()

Removes events from the radio buttons

Source:
Returns:
void

run(router)

Executes the step

Renders the template and activates radio buttons
Parameters:
Name Type Description
router Object a mathex.Router instance
Source:
Returns:
void