ComplexEvaluator
Extends: module:activities/text/Evaluator.BasicEvaluator
Source: Evaluator.js:348
ComplexEvaluator acts like BasicEvaluator, but providing feedback about
the location of mistakes on the user's answer.
Constructor
new ComplexEvaluator(className: string): ComplexEvaluatorComplexEvaluator constructor
Parameters
className(string) — The class name of this evaluator.
Instance Methods
_evalText(text: string, match: string): Array.<number>
Performs the evaluation of a string against an array of valid matches, returning an array of
flags useful to indicate where the mistakes are located.
In BasicEvaluator, all characters are just marked as 1 (error) or 0 (OK). See
ComplexEvaluator for more detailed analysis of answers.
Parameters
text(string) — The text to be checkedmatch(string) — A valid expression with which to compare.
Returns
Array.<number>
countFlagsOk(flags: Array.<number>): number
Counts the number of flags on the provided array that are zero.
Parameters
flags(Array.<number>)
Returns
number
compareSegment(
src: string,
ls: number,
ok: string,
lok: number,
attr: Array.<number>,
iterate: boolean,
): boolean
Compares two segments of text.
This function should make recursive calls.
Parameters
src(string) — Text to be comparedls(number) — Offset insrcwhere to start the comparisonok(string) — Text to match against.lok(number) — Offset inokwhere to start the comparison.attr(Array.<number>) — Array of integers that will be filled with information about the
validity or error of each character insrc.iterate(boolean) — Whentrue, the segment will be iterated looking for other
coincident fragments.
Returns
boolean
init(locales: Array.<string>)
Inherited from module:activities/text/Evaluator.BasicEvaluator#init
Initializes the collator.
Parameters
locales(Array.<string>) — An array of valid locales to be used by the Inlt.Collator object
_checkText(text: string, match: string): boolean
Inherited from module:activities/text/Evaluator.BasicEvaluator#_checkText
Performs the validation of a string against a single match.
Parameters
text(string) — The text to be checkedmatch(string) — A valid expression with which to compare.
Returns
boolean
_evalText(text: string, match: string): Array.<number>
Inherited from module:activities/text/Evaluator.ComplexEvaluator#_evalText
Overrides: module:activities/text/Evaluator.BasicEvaluator#_evalText
Performs the evaluation of a string against an array of valid matches, returning an array of
flags useful to indicate where the mistakes are located.
In BasicEvaluator, all characters are just marked as 1 (error) or 0 (OK). See
ComplexEvaluator for more detailed analysis of answers.
Parameters
text(string) — The text to be checkedmatch(string) — A valid expression with which to compare.
Returns
Array.<number>
getClearedText(src: string, skipped: Array.<boolean>): string
Inherited from module:activities/text/Evaluator.BasicEvaluator#getClearedText
Overrides: module:activities/text/Evaluator.BasicEvaluator#getClearedText
Removes double spaces and erroneous characters from a given text expression.
Parameters
src(string) — The text to be processed.skipped(Array.<boolean>) — An array of boolean indicating which characters should be removed
from the string.
Returns
string
setProperties($xml: external:jQuery)
Inherited from module:activities/text/Evaluator.Evaluator#setProperties
Overrides: module:activities/text/Evaluator.BasicEvaluator#setProperties
Loads the object settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The jQuery XML element to parse
getAttributes(): object
Inherited from module:activities/text/Evaluator.Evaluator#getAttributes
Overrides: module:activities/text/Evaluator.BasicEvaluator#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
checkText(text: string, match: string | Array.<string>): boolean
Inherited from module:activities/text/Evaluator.Evaluator#checkText
Overrides: module:activities/text/Evaluator.BasicEvaluator#checkText
Checks the given text against a set of valid matches
Parameters
text(string) — The text to be checkedmatch(string | Array.<string>) — The valid expression or expressions with which to compare.
Returns
boolean
evalText(
text: string,
match: string | Array.<string>,
): Array.<number>
Inherited from module:activities/text/Evaluator.Evaluator#evalText
Overrides: module:activities/text/Evaluator.BasicEvaluator#evalText
Evaluates the given text against a set of valid matches, returning an array of flags useful
to indicate where the mistakes are located.
Parameters
text(string) — The text to be checkedmatch(string | Array.<string>) — The valid expression or expressions with which to compare.
Returns
Array.<number>
isOk(flags: Array.<number>): boolean
Inherited from module:activities/text/Evaluator.Evaluator#isOk
Overrides: module:activities/text/Evaluator.BasicEvaluator#isOk
Checks if the given array of flags (usually returned by evalText) can be considered as a
valid or erroneous answer.
Parameters
flags(Array.<number>)
Returns
boolean
init(locales: Array.<string>)
Inherited from module:activities/text/Evaluator.BasicEvaluator#init
Initializes the collator.
Parameters
locales(Array.<string>) — An array of valid locales to be used by the Inlt.Collator object
_checkText(text: string, match: string): boolean
Inherited from module:activities/text/Evaluator.BasicEvaluator#_checkText
Performs the validation of a string against a single match.
Parameters
text(string) — The text to be checkedmatch(string) — A valid expression with which to compare.
Returns
boolean
_evalText(text: string, match: string): Array.<number>
Inherited from module:activities/text/Evaluator.ComplexEvaluator#_evalText
Overrides: module:activities/text/Evaluator.BasicEvaluator#_evalText
Performs the evaluation of a string against an array of valid matches, returning an array of
flags useful to indicate where the mistakes are located.
In BasicEvaluator, all characters are just marked as 1 (error) or 0 (OK). See
ComplexEvaluator for more detailed analysis of answers.
Parameters
text(string) — The text to be checkedmatch(string) — A valid expression with which to compare.
Returns
Array.<number>
Static Methods
getEvaluator(
$xml: external:jQuery,
): module:activities/text/Evaluator.Evaluator
Inherited from module:activities/text/Evaluator.Evaluator
Factory constructor that returns a specific type of Evaluator based on the class
attribute declared in the $xml element.
Parameters
$xml(external:jQuery) — The XML element to be parsed.
Returns
factory(
data: object,
): module:activities/text/Evaluator.Evaluator
Inherited from module:activities/text/Evaluator.Evaluator
Builds a new Evaluator, based on the properties specified in a data object
Parameters
data(object) — The data object to be parsed
Returns
Instance Fields
detail: boolean
Whether to detail or not the location of errors found on the analyzed text.
checkSteps: number
Number of times to repeat the evaluation process if an error is found, eliminating in each
cycle the extra characters that caused the error.
checkScope: number
When an eror is detected in the analyzed expression, this variable indicates the number of
characters the checking pointer will be moved forward and back looking for a coincident
expression.
For example, comparing the answer "one lardzy dog" with the correct answer "one lazy dog"
will detect an error at position 6 (an "r" instead of "z"). If checkSteps is set to 2 or
greater, the "zy dog" expression at position 8 will be found and evaluated as valid, while
a value of 1 or less will not found any coincident expression beyond the error position, thus
evaluating all the remaining sentence as erroneous.
checkAccents: boolean
Inherited from module:activities/text/Evaluator.BasicEvaluator#checkAccents
Overrides: module:activities/text/Evaluator.BasicEvaluator#checkAccents
Whether accented letters must be considered equivalent or not.
checkPunctuation: boolean
Inherited from module:activities/text/Evaluator.BasicEvaluator#checkPunctuation
Overrides: module:activities/text/Evaluator.BasicEvaluator#checkPunctuation
Whether to check or not dots, commas and other punctuation marks when comparing texts.
checkDoubleSpaces: boolean
Inherited from module:activities/text/Evaluator.BasicEvaluator#checkDoubleSpaces
Overrides: module:activities/text/Evaluator.BasicEvaluator#checkDoubleSpaces
Whether to check or not the extra spaces added between words.
PUNCTUATION: string
Inherited from module:activities/text/Evaluator.BasicEvaluator#PUNCTUATION
Overrides: module:activities/text/Evaluator.BasicEvaluator#PUNCTUATION
String containing all the characters considered as punctuation marks (currently ".,;:")
className: string
Inherited from module:activities/text/Evaluator.Evaluator#className
Overrides: module:activities/text/Evaluator.BasicEvaluator#className
The type of evaluator.
initiated: boolean
Inherited from module:activities/text/Evaluator.Evaluator#initiated
Overrides: module:activities/text/Evaluator.BasicEvaluator#initiated
Whether this evaluator has been initialized or not.
collator: external:Collator
Inherited from module:activities/text/Evaluator.Evaluator#collator
Overrides: module:activities/text/Evaluator.BasicEvaluator#collator
The Intl.Collator object used to compare strings, when available.
checkcase: boolean
Inherited from module:activities/text/Evaluator.Evaluator#checkcase
Overrides: module:activities/text/Evaluator.BasicEvaluator#checkcase
Whether uppercase and lowercase expressions must be considered equivalent or not.