Constructor
new Question(parent, conf)
Questions for test
Constructor for creating "Question" objects. It supports a parameter with a configuration object with certain properties or attributes.
Parameters:
Name | Type | Description |
---|---|---|
parent |
Object | "Test" object |
conf |
Object | Configuration object (see |
- Source:
- See:
Members
conf :Object
Configuration Options
a Javascript object with follow structure:
{ num: 2, nA: 4, solution: 0, stopOnSuccess : false, charset: "utf-8", txt: "Question 2 ?" }
Type:
- Object
- Source:
element :Object:HTMLElement
own DOM element
Type:
- Object:HTMLElement
- Source:
marked :boolean
It keeps track marking for this Question
Type:
- boolean
- Source:
num :number
Number of this Question.
This is not equal to 'this.id' (from 0 to +Infinity)
Type:
- number
- Source:
root :namespaces:testron
"testron" Ancestor object {namespace}
Type:
- namespaces:testron
- Source:
stopOnSuccess :boolean
clone conf.stopOnSuccess
False = Only one click, True = clicks until success
Type:
- boolean
- Source:
Methods
addAnswer(answer) → {Object:Answer}
Adding an Answer object to this Question
Parameters:
Name | Type | Description |
---|---|---|
answer |
Object:testron.Test.Question.Answer | "Answer" object |
- Source:
Returns:
Return the same input parameter
- Type
- Object:Answer
createAnswer(conf) → {Object:Answer}
Create and adding an Answer object to this Test
Parameters:
Name | Type | Description |
---|---|---|
conf |
Object | Configuration object (for Answer Objects) |
- Source:
Returns:
Return the new Answer created
- Type
- Object:Answer
emitClick()
Emit the Click event for comprobations in this Question
- Source:
filterConf(conf) → {Object}
Filter the Configuration Options
The Configuration Options will are get from parent ("Test"), if not exists
Parameters:
Name | Type | Description |
---|---|---|
conf |
Object | Configuration object |
- Source:
- See:
Returns:
The sanitized configuration options
- Type
- Object
parseQuestion(test) → {string}
Create questions from 'questions' parameter.
The parameter can be a Javascript object or a JSON string object with follow structure:
questions: [ { conf: {..., txt: "Question 1 ??"}, answers: [ ... ] // see Question.parseAnswers(...) }, { ... }, ... ]
Parameters:
Name | Type | Description |
---|---|---|
test |
Object | string | a Javascript object or a JSON string object |
- Source:
Returns:
a DEBUG string with info
- Type
- string
toHtml() → {Object:HTMLElement}
Create the HTML-UI for this Question and return it as HTMLElement (HTMLUlElement)
- Source:
Returns:
- Type
- Object:HTMLElement
toJSON() → {string}
Parse this element to JSON
- Source:
Returns:
a JSON string which represents to this Question object
- Type
- string
toOK()
This changes the style for this Question DOMElement. Also shoots the 'emitNext' event
- Source:
verify() → {boolean}
This checks the solution for this Question
- Source:
Returns:
True / False
- Type
- boolean