Evaluator

Source: Evaluator.js:39

This class and its derivatives BasicEvaluator and
ComplexEvaluator are used to evaluate the answers written by the final users
in text activities.


Constructor

new Evaluator(className: string): Evaluator

Evaluator constructor

Parameters

  • className (string) — The class name of this evaluator.

Instance Methods

setProperties($xml: external:jQuery)

Loads the object settings from a specific JQuery XML element

Parameters

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(_locales: Array.<string>)

Initializes this evaluator

Parameters

  • _locales (Array.<string>) — An array of valid locales, to be used by Intl.Collator

checkText(text: string, match: string | Array.<string>): boolean

Checks the given text against a set of valid matches

Parameters

  • text (string) — The text to be checked
  • match (string | Array.<string>) — The valid expression or expressions with which to compare.

Returns

  • boolean

_checkText(_text: string, _match: string): boolean

Abstract method to be implemented in subclasses.
Performs the validation of a string against a single match.

Parameters

  • _text (string) — The text to be checked
  • _match (string) — A valid expression with which to compare.

Returns

  • boolean

evalText( text: string, match: string | Array.<string>, ): 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

  • text (string) — The text to be checked
  • match (string | Array.<string>) — The valid expression or expressions with which to compare.

Returns

  • Array.<number>

_evalText(_text: string, _match: string): Array.<number>

Abstract method to be implemented in subclasses.
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.

Parameters

  • _text (string) — The text to be checked
  • _match (string) — A valid expression with which to compare.

Returns

  • Array.<number>

isOk(flags: Array.<number>): boolean

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

Static Methods

getEvaluator( $xml: external:jQuery, ): 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

Returns

factory( data: object, ): 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

className: string

The type of evaluator.

initiated: boolean

Whether this evaluator has been initialized or not.

collator: external:Collator

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

checkcase: boolean

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