Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QuestionMetrics<Data>

The question metrics bind to a Generator and process the question feature that can be contained in the formation metadata. It tracks when questions begin, when attempts are made and when the question ends (completed). The lifecycle for the events are: ` Generator | Metrics

+---------+ +-------+ | feature +---> | begin | +---------+ +---+---+ | ........v......... | yield question <-------------------+ ''''''''+''''''''' | | | +----v----+ | +---------> | attempt | | | +----+----+ | | | | | ~v~~ | | ( correct? ) | | ~+~~+~ | | | | | | yes +- no -+ | | | | | | | ~~v~~~ | | | ( attempts left? ) | | | ~+~~+~ | | | | | | | | no yes | | | | | | | +---+--+ | | | | ~v~ +---+---+ | | ( redirect? )- no -> retry | | | ~+~ +---^---+ | | | | | | | .........+........ | | +- yes -> yield redirect | | | '''''''''''''''''' +--+---+ +--v--+ | step +-------> | end | +--+---+ +--+--+ | | | ~v~~ | ( group? )- yes -+ | ~+~~~~' | | | | | | .....v.... | | | submit | | | '''''+'''' | | |

  • +------------+ | | | ~v~ | ( redirect? )- no -+ | ~+~' | | | | | | ........v......... | | | yield redirect | | | ''''''''+'''''''' | | | | +----v----+ | +---------> | finally <-------+ +---------+ ` The events that are generated are:

Type parameters

  • Data

Hierarchy

Implements

Index

Constructors

constructor

Properties

attempts

attempts: ITally = new Tally()

bonus

bonus: number = 0

correct

correct: number = 0

incorrect

incorrect: number = 0

multiplier

multiplier: number = 1

points

points: ITally = new Tally()

result

result: boolean | undefined = undefined

streak

streak: number = 0

Accessors

processing

  • get processing(): boolean

reward

  • get reward(): number

Methods

bind

Protected bindings

  • Sets the bindings that should be added to the generator, should be called after super. It will automatically bind this to the listeners.

    example
    constructor(init: QuestionMetricsInit<Data>) {
      super();
    
      this.bindings({
        'feature': this.handleFeature,
        'input': this.handleInput,
        'suggestions': this.handleSuggestions,
        'step': this.handleStep,
      });

    Parameters

    Returns this

dispose

  • dispose(): this

Protected invoke

off

on

once

reset

  • reset(): this

subscribe

unbind

  • unbind(): this