AutoContentProvider
Source: AutoContentProvider.js:40
This abstract class is the base for classes that create on-time automatic content for JClic
activities, usually using random parameters to assure different content in each session.
Activities with AutoContentProvider objects rely on them to build new content on every start.
Constructor
new AutoContentProvider(): AutoContentProviderAutoContentProvider 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
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
init()
Initializes the content provider
generateContent(
nRows: number,
nCols: number,
content: Array.<module:boxes/ActiveBagContent.ActiveBagContent>,
useIds: boolean,
): boolean
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
Generates the automatized content
Parameters
_kit(module:automation/AutoContentProvider.ActiveBagContentKit) — The objects to be filled with content
Returns
boolean
Static Methods
getProvider(
$xml: external.jQuery,
): 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
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
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
numericContent: boolean
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
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
ActiveBagContentKit
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.