lib/BpmnQuestionnaire.js
function (index, options, questionnaire) {

    this.index         = index;
    this.options       = options;
    this.questionnaire = questionnaire;
    if (options.diagram) {
      this.diagram = new Diagram(index, options.diagram, this);
    }

    // Initial state is immutable
    this.initState = Immutable({
      validAnswer: false,
      rightAnswer: false,
      view:        'question'
    });

    // Prevent overwriting default properties of state and assign provided properties to initial state
    if (has(spec, 'addToState')) {
      if(!has(spec.addToState, 'validAnswer')
        && !has(spec.addToState, 'rightAnswer')
        && !has(spec.addToState, 'view')) {

          // Merge immutable with object
          this.initState = this.initState.merge(spec.addToState);
      }
    }

    // Set state to mutable copy of initial state
    this.state = this.initState.asMutable({deep: true});

  }
function (index, options, questionnaire) {

    this.index         = index;
    this.options       = options;
    this.questionnaire = questionnaire;
    if (options.diagram) {
      this.diagram = new Diagram(index, options.diagram, this);
    }

    // Initial state is immutable
    this.initState = Immutable({
      validAnswer: false,
      rightAnswer: false,
      view:        'question'
    });

    // Prevent overwriting default properties of state and assign provided properties to initial state
    if (has(spec, 'addToState')) {
      if(!has(spec.addToState, 'validAnswer')
        && !has(spec.addToState, 'rightAnswer')
        && !has(spec.addToState, 'view')) {

          // Merge immutable with object
          this.initState = this.initState.merge(spec.addToState);
      }
    }

    // Set state to mutable copy of initial state
    this.state = this.initState.asMutable({deep: true});

  }
function ( index , options , questionnaire ) { this . index = index ; this . options = options ; this . questionnaire = questionnaire ; if ( options . diagram ) { this . diagram = new Diagram ( index , options . diagram , this ) ; } // Initial state is immutable this . initState = Immutable ( { validAnswer : false , rightAnswer : false , view : 'question' } ) ; // Prevent overwriting default properties of state and assign provided properties to initial state if ( has ( spec , 'addToState' ) ) { if ( ! has ( spec . addToState , 'validAnswer' ) && ! has ( spec . addToState , 'rightAnswer' ) && ! has ( spec . addToState , 'view' ) ) { // Merge immutable with object this . initState = this . initState . merge ( spec . addToState ) ; } } // Set state to mutable copy of initial state this . state = this . initState . asMutable ( { deep : true } ) ; }
Contructor function that serves as a base for every type.
Methods and properties defined in spec will be assigned to the prototype of this constructor.

@param {number} index - Index of question inside the array of questions.
@param {Object} options - Object containing the actual question.
@param {Object} questionnaire - Reference to the questionnaire instance.
Contructor function that serves as a base for every type . Methods and properties defined in spec will be assigned to the prototype of this constructor .