activities/text/Evaluator. BasicEvaluator

A basic evaluator that just compares texts, without looking for possible coincidences of text
fragments once erroneous characters removed.

Constructor

new BasicEvaluator(className)

BasicEvaluator constructor

Parameters:
NameTypeDescription
classNamestring

The class name of this evaluator.

Extends

Members

PUNCTUATION :string

String containing all the characters considered as punctuation marks (currently ".,;:")

Type:
  • string

checkAccents :boolean

Whether accented letters must be considered equivalent or not.

Type:
  • boolean

checkDoubleSpaces :boolean

Whether to check or not the extra spaces added between words.

Type:
  • boolean

checkPunctuation :boolean

Whether to check or not dots, commas and other punctuation marks when comparing texts.

Type:
  • boolean

checkcase :boolean

Whether uppercase and lowercase expressions must be considered equivalent or not.

Type:
  • boolean

className :string

The type of evaluator.

Type:
  • string

collator :external:Collator

The Intl.Collator object used to compare strings, when available.

initiated :boolean

Whether this evaluator has been initialized or not.

Type:
  • boolean

Methods

_checkText(text, match) → {boolean}

Performs the validation of a string against a single match.

Parameters:
NameTypeDescription
textstring

The text to be checked

matchstring

A valid expression with which to compare.

Returns:
  • true when the two expressions can be considered equivalent.
Type: 
boolean

_evalText(text, match) → {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:
NameTypeDescription
textstring

The text to be checked

matchstring

A valid expression with which to compare.

Returns:
  • An array of flags (one number for character) indicating whether each
    position is erroneous or OK.
Type: 
Array.<number>

checkText(text, match) → {boolean}

Checks the given text against a set of valid matches

Parameters:
NameTypeDescription
textstring

The text to be checked

matchstring | Array.<string>

The valid expression or expressions with which to compare.

Returns:
  • true if the checked expression is valid, false otherwise.
Type: 
boolean

evalText(text, match) → {Array.<number>}

Evaluates the given text against a set of valid matches, returning an array of flags useful
to indicate where the mistakes are located.

Parameters:
NameTypeDescription
textstring

The text to be checked

matchstring | Array.<string>

The valid expression or expressions with which to compare.

Returns:
  • An array of flags (one number for character) indicating whether each
    position is erroneous or ok.
Type: 
Array.<number>

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:
  • The resulting object, with minimal attrributes
Type: 
object

getClearedText(src, skipped) → {string}

Removes double spaces and erroneous characters from a given text expression.

Parameters:
NameTypeDescription
srcstring

The text to be processed.

skippedArray.<boolean>

An array of boolean indicating which characters should be removed
from the string.

Returns:
Type: 
string

init(locales)

Initializes the collator.

Parameters:
NameTypeDescription
localesArray.<string>

An array of valid locales to be used by the Inlt.Collator object

isOk(flags) → {boolean}

Checks if the given array of flags (usually returned by evalText) can be considered as a
valid or erroneous answer.

Parameters:
NameTypeDescription
flagsArray.<number>
Returns:
  • true when there is at least one flag and all flags are 0 (meaning no error).
Type: 
boolean

setProperties($xml)

Loads the object settings from a specific JQuery XML element

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The jQuery XML element to parse