Arith
Extends: module:automation/AutoContentProvider.AutoContentProvider
Source: Arith.js:54
Arith provides randomly generated mental arithmetics operations, ready to be used in JClic activities.
The operations can be additions, subtractions, multiplications or divides. The unknown of these
operations can be the result of the operation (A op B = ?), any of the two operators
(A op ? = C or ? op B = C) or also the operator itself (A ? B = C).
Constructor
new Arith(): ArithArith constructor
Instance Methods
setProperties($xml: external:jQuery)
Loads the object settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element to parse
getAttributes(): object
Overrides: module:automation/AutoContentProvider.AutoContentProvider#getAttributes
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
Returns
object
setAttributes(data: object): object
Reads the properties of this Arith object from a dataset
Parameters
data(object) — The data object to be parsed
Returns
object
genNum(
n: module:automation/arith/Arith.Num,
op: module:automation/arith/Arith.Operator,
limInf2: number,
limSup2: number,
): boolean
Fills the n parameter (an Num) with a value in accordance with the
specifications of op (an Operator), between two limits.
Parameters
n(module:automation/arith/Arith.Num) — The numberop(module:automation/arith/Arith.Operator) — The operatorlimInf2(number) — Lower limitlimSup2(number) — Upper limit
Returns
boolean
genOp(o: module:automation/arith/Arith.Operator): boolean
Fills the provided Operator with real values
Parameters
o(module:automation/arith/Arith.Operator) — The operator to use to generate the operation
Returns
boolean
process(
kit: module:automation/AutoContentProvider.ActiveBagContentKit,
): boolean
Fills the provided ActiveBagContentKit with randomly generated operations
Parameters
kit(module:automation/AutoContentProvider.ActiveBagContentKit) — The composite object to be filled with data.
Returns
boolean
setProperties($xml: external:jQuery)
Inherited from module:automation/arith/Arith.Arith#setProperties
Overrides: module:automation/AutoContentProvider.AutoContentProvider#setProperties
Loads the object settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element to parse
init()
Inherited from module:automation/AutoContentProvider.AutoContentProvider#init
Overrides: module:automation/AutoContentProvider.AutoContentProvider#init
Initializes the content provider
generateContent(
nRows: number,
nCols: number,
content: Array.<module:boxes/ActiveBagContent.ActiveBagContent>,
useIds: boolean,
): boolean
Inherited from module:automation/AutoContentProvider.AutoContentProvider#generateContent
Overrides: module:automation/AutoContentProvider.AutoContentProvider#generateContent
Builds an ActiveBagContentKit and generates the automatized content.
Parameters
nRows(number) — Number of rows to be processednCols(number) — Number of columns to be processedcontent(Array.<module:boxes/ActiveBagContent.ActiveBagContent>) — Array with one or more containers of ActiveBoxContent
objects to be filled with new content.useIds(boolean) — Whentrue, theidfield of ActiveBoxContent objects is significant
Returns
boolean
process(
kit: module:automation/AutoContentProvider.ActiveBagContentKit,
): boolean
Inherited from module:automation/arith/Arith.Arith#process
Overrides: module:automation/AutoContentProvider.AutoContentProvider#process
Fills the provided ActiveBagContentKit with randomly generated operations
Parameters
kit(module:automation/AutoContentProvider.ActiveBagContentKit) — The composite object to be filled with data.
Returns
boolean
setProperties($xml: external:jQuery)
Inherited from module:automation/arith/Arith.Arith#setProperties
Overrides: module:automation/AutoContentProvider.AutoContentProvider#setProperties
Loads the object settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element to parse
process(
kit: module:automation/AutoContentProvider.ActiveBagContentKit,
): boolean
Inherited from module:automation/arith/Arith.Arith#process
Overrides: module:automation/AutoContentProvider.AutoContentProvider#process
Fills the provided ActiveBagContentKit with randomly generated operations
Parameters
kit(module:automation/AutoContentProvider.ActiveBagContentKit) — The composite object to be filled with data.
Returns
boolean
Static Methods
DecFormat(val: number, dec: number, pre: number): string
Formats the number with a fixed number of decimals, optionally filling the result with leading
zeroes to have a fixed number of digits.
Parameters
val(number) — The value to formatdec(number) — Number of decimalspre(number) — Minimal number of digits before dot.
Returns
string
Operator#setProperties($xml: external:jQuery)
Loads Operator settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element to parse
Operator#getAttributes(): object
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
Returns
object
Operator#setAttributes(
data: object,
): module:automation/arith/Arith.Arith
Reads the properties of this operator from a dataset
Parameters
data(object) — The data object to be parsed
Returns
getProvider(
$xml: external.jQuery,
): module:automation/AutoContentProvider.AutoContentProvider
Inherited from module:automation/AutoContentProvider.AutoContentProvider
Dynamic constructor that returns a specific type of AutoContentProvider based on the class
attribute declared on an $xml element.
It should be called only from Activity.setProperties
Parameters
$xml(external.jQuery) — The XML element to parse
Returns
factory(
data: object,
params: Array.<object>,
): module:shapers/Shaper.Shaper
Inherited from module:automation/AutoContentProvider.AutoContentProvider
Builds a new AutoContentProvider, based on the properties specified in a data object
Parameters
data(object) — The data object to be parsedparams(Array.<object>) — Optional parameters to be passed tosetAttributes
Returns
registerClass(
providerName: string,
providerClass: function,
): module:automation/AutoContentProvider.AutoContentProvider
Inherited from module:automation/AutoContentProvider.AutoContentProvider
Registers a new type of AutoContentProvider
Parameters
providerName(string) — The name used to identify this AutoContentProviderproviderClass(function) — The activity class, usually extending AutoContentProvider
Returns
Instance Fields
opA: module:automation/arith/Arith.Operator
First operator
opB: module:automation/arith/Arith.Operator
Second operator
use_add: boolean
Allow additions
use_subst: boolean
Allow subtractions
use_mult: boolean
Allow multiplications
use_div: boolean
Allow divides
exp_abx: boolean
Allow expressions of type A op B = X
exp_axc: boolean
Allow expressions of type A op X = C
exp_xbc: boolean
Allow expressions of type X op B = C
exp_axbc: boolean
Allow expressions of type A x B = C
exp_caxb: boolean
Allow inverse expressions, like C = A op B
resultLimInf: number
Lower limit of the result
resultLimSup: number
Upper limit of the result
resultCarry: boolean
Allow carry operations
resultNoDup: boolean
Avoid operations with the same result
resultOrder: string
Type of sorting of results. Possible values are: 'NOSORT', 'SORTASC' and 'SORTDESC'
opCond: string
Sorting of the operands in commutative operations. Possible values are: 'AGB' (A greater than B),
'BGA' (B greater tan A) and 'INDIF' (default)
numericContent: boolean
Inherited from module:automation/AutoContentProvider.AutoContentProvider#numericContent
Overrides: module:automation/AutoContentProvider.AutoContentProvider#numericContent
This AutoContentProvider manages numeric expressions, so text literals should be
converted to numbers for comparisions, taking in account the
number format of the current locale (dot or comma as decimal separator)
Static Fields
CLASSES: object
Inherited from module:automation/AutoContentProvider.AutoContentProvider
Contains the current list of classes derived from AutoContentProvider.
This object should be updated by real automation classes at declaration time.
Currently, only two types of "AutoContentProvider" are defined: Arith and TagReplace.
Other
Operator
Operator is an Utility class used by Arith to encapsulate the properties and methods related
to the members of the operations.
ActiveBagContentKit
Inherited from module:automation/AutoContentProvider.AutoContentProvider
Utility class used to encapsulate multiple sets of box contents
Parameters
nRows(number) — Number of rows to be processednCols(number) — Number of columns to be processedcontent(Array.<module:boxes/ActiveBagContent.ActiveBagContent>) — Array with one or more containers of ActiveBoxContent
objects to be filled with new content.useIds(boolean) —truewhen theidfield of ActiveBoxContent objects is significant.