src/factory/question-factory.ts
Methods |
|
Public createQuestion | ||||||||
createQuestion(question: Question
|
||||||||
Defined in src/factory/question-factory.ts:5
|
||||||||
Parameters :
Returns :
Question<any>
|
Public createQuestionList | ||||||||
createQuestionList(questionList: Question[])
|
||||||||
Defined in src/factory/question-factory.ts:20
|
||||||||
Parameters :
Returns :
[]
|
import { Question, QuestionType, Text, TextArea, Checkbox, Radio, Select } from '../question';
export class QuestionFactory {
public static createQuestion(question: Question<any>): Question<any> {
switch (question.type) {
case QuestionType.CHECKBOX:
return Checkbox.fromJson(<Checkbox>question);
case QuestionType.RADIO:
return Radio.fromJson(<Radio>question);
case QuestionType.SELECT:
return Select.fromJson(<Select>question);
case QuestionType.TEXTAREA:
return TextArea.fromJson(<TextArea>question);
default:
return Text.fromJson(<Text>question);
}
}
public static createQuestionList(questionList: Question<any>[]): Question<any>[] {
return questionList.map((question: Question<any>) => QuestionFactory.createQuestion(question));
}
}