Class: Answer

Answer

A class to build Answer for Questions Tests, configurable and dynamically

Constructor

new Answer(parent, conf)

Answer for any Question of test

Constructor for creating "Answer" objects. It supports a parameter with a configuration object with certain properties or attributes.

Parameters:
Name Type Description
parent Object

"Question" object

conf Object

Configuration object (see conf)

Source:
See:

Members

checked :boolean

It keeps track marking for this Answer

Type:
  • boolean
Source:

conf :Object

Configuration Options

a Javascript object with follow structure:

{
   num: 1,
   name: "A",
   charset: "utf-8",
  txt: "Answer 1"
}
Type:
  • Object
Source:

element :Object:HTMLElement

own DOM element

Type:
  • Object:HTMLElement
Source:

id :string

Exclusive id (+ or -)

Type:
  • string
Source:

name :string

clone of conf.name

Its name ('A', '1', 'a', 'IV', 'pepito', ...)

Type:
  • string
Source:

num :number

Number of this answer.

This is not equal to 'this.id' (from 0 to +Infinity)

Type:
  • number
Source:

parent :Object:Question

"Question" Parent object

Type:
  • Object:Question
Source:

root :namespace:testron

"testron" ancestor object {namespace}

Type:
  • namespace:testron
Source:

valid :boolean

is valid this Answer ?

Type:
  • boolean
Source:

Methods

emitClick()

Emit the Click event for comprobations in this Answer

Source:

filterConf(conf)

Filter the Configuration Options

The Configuration Options will are get from parent ("Question"), if not exists

Parameters:
Name Type Description
conf Object

Configuration object

Source:
See:

getCounter()

Get the self own-counter

Source:

parseAnswer(test) → {string}

Create answers from 'answers' parameter.

The parameter can be a Javascript object or a JSON string object with follow structure:

answers: [
      { name: "A", txt: "Answer 1"}, {...}, ...
]
Parameters:
Name Type Description
test Object | string

a Javascript object or a JSON string object

Source:
Returns:

a DEBUG string with info

Type
string

remove()

Remove this Answer

Source:

toFail()

Change the style to FAIL for this Answer DOMElement

Source:

toHtml()

Create the HTML-UI for this Answer and return it as HTMLElement (HTMLLiElement)

Source:

toJSON() → {string}

Parse this element to JSON

Source:
Returns:

a JSON string which represents to this Answer object

Type
string

toOK()

Change the style to OK for this Answer DOMElement

Source:

based on the 'Doctron template'   by
Δ