Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QuestionnaireControl

A Control that asks a series of questions, where each question has the same answer-options.

Capabilities:

  • Activate the questionnaire. "I'd like to answer the personality questionnaire"
  • Answer a question directly. "Yes I have headache" // "yes to question three"
  • Bring a question in to focus. "U: skip to headache" // "U: move to question ten"
  • Confirm an answer
  • Show the entire questionnaire on APL enabled devices (with interactivity)

Hierarchy

Implements

Constructors

constructor

Properties

activatedThisTurn

activatedThisTurn: boolean = false

Readonly id

id: string

inputWasAnswerByTouch

inputWasAnswerByTouch: boolean = false

props

standardInitiativeHandlers

standardInitiativeHandlers: ControlInitiativeHandler[] = [{name: 'std::askLineItem',canTakeInitiative: this.wantsToAskLineItemQuestion,takeInitiative: this.askLineItemQuestion,},{name: 'std::askIfComplete',canTakeInitiative: this.wantsToAskIfComplete,takeInitiative: this.askIfComplete,},{name: 'std::isInitiativeViaApl',canTakeInitiative: this.wantsToKeepAplInitiative,takeInitiative: this.keepAplInitiative,},]

standardInputHandlers

standardInputHandlers: ControlInputHandler[] = [{name: 'Activate (builtin)',canHandle: this.isActivate,handle: this.handleActivate,},{// takes care of built-in Intents that match answer words, e.g. AMAZON.YesIntent/AMAZON.NoIntentname: 'MappedAnswerToAskedQuestion (builtin)',canHandle: this.isMappedAnswerToAskedQuestion,handle: this.handleMappedAnswerToAskedQuestion,},{// ValueControlIntents that provide answer (value slot)name: 'SpecificAnswerToAskedQuestion (builtin)',canHandle: this.isSpecificAnswerToAskedQuestion,handle: this.handleSpecificAnswerToAskedQuestion,},{// ValueControlIntents that mention question (target) and answer (value slot)name: 'SpecificAnswerToSpecificQuestion (builtin)',canHandle: this.isSpecificAnswerToSpecificQuestion,handle: this.handleSpecificAnswerToSpecificQuestion,},{// ValueControlIntents that mention question (target) and answer (feedback slot)name: 'FeedbackAnswerToSpecificQuestion (builtin)',canHandle: this.isFeedbackAnswerToSpecificQuestion,handle: this.handleFeedbackAnswerToSpecificQuestion,},{name: 'SpecificAnswerByTouch (builtin)',canHandle: this.isSpecificAnswerByTouch,handle: this.handleSpecificAnswerByTouch,},{name: 'CompletionRequestByVoice (builtin)',canHandle: this.isCompletionRequestByVoice,handle: this.handleCompletionRequest,},{name: 'CompletionRequestByTouch (builtin)',canHandle: this.isCompletionRequestByTouch,handle: this.handleCompletionRequest,},{name: 'BareYesToCompletionQuestion (builtin)',canHandle: this.isBareYesToCompletionQuestion,handle: this.handleCompletionRequest,},{name: 'BareNoToCompletionQuestion (builtin)',canHandle: this.isBareNoToCompletionQuestion,handle: this.handleBareNoToCompletionQuestion,},]

state

state: QuestionnaireControlState = new QuestionnaireControlState()

Methods

addCompletionActIfImplicitlyComplete

  • Parameters

    Returns void

canHandle

  • Parameters

    Returns Promise<boolean>

canTakeInitiative

clear

  • clear(): void
  • Clear the state of this control.

    Returns void

evaluateAPLProp

  • Evaluate an APL document/data source prop.

    Parameters

    • act: SystemAct

      act

    • input: ControlInput

      The input object

    • propValue: object | function

      Constant or function producing a map of key:value pairs

    Returns object

    • [key: string]: any

evaluateBooleanProp

  • evaluateBooleanProp(propValue: boolean | function, input: ControlInput): boolean
  • Evaluate a boolean prop.

    Parameters

    • propValue: boolean | function

      Constant or function producing boolean

    • input: ControlInput

      The input object

    Returns boolean

evaluateBooleanPropNewStyle

  • evaluateBooleanPropNewStyle(propValue: boolean | function, input: ControlInput): boolean
  • Evaluate a boolean prop.

    Parameters

    • propValue: boolean | function

      Constant or function producing boolean

    • input: ControlInput

      The input object

    Returns boolean

evaluateFunctionProp

  • evaluateFunctionProp<T>(prop: T | function, input: ControlInput): T

evaluatePromptProp

evaluatePromptShortForm

  • evaluatePromptShortForm(propValue: string | function, input: ControlInput): string
  • Parameters

    Returns string

getChoiceIndexById

  • Parameters

    Returns number | undefined

getQuestionContentById

  • Parameters

    Returns DeepRequired<Question>

getQuestionIndexById

  • Parameters

    Returns number

getQuestionnaireContent

  • Evaluate the questionnaireContent prop

    Parameters

    Returns QuestionnaireContent

getSerializableState

  • getSerializableState(): any
  • Gets the Control's state as an object that is serializable.

    Only durable state should be included and the object should be serializable with a straightforward application of JSON.stringify(object).

    Default: {return this.state;}

    Usage:

    • This method must be idempotent (multiple calls must not change the result).
    • The default is sufficient for Controls that use the .state variable and only store simple data.
      • Non-simple data includes functions, and objects with functions, as these will not survive the round trip.
      • Other non-simple data include types with non-enumerable properties.
    • It is safe to pass the actual state object as the framework guarantees to not mutate it.
    • Functions that operate on the Control's state should be defined as member function of the Control type, or as props.

    Framework behavior:

    • During the shutdown phase the state of the control tree is collected by calling this function for each control.
    • The framework serializes the data use a simple application of JSON.stringify.
    • On the subsequent turn the control tree is rebuilt and the state objects are re-attached to each Control via control.setSerializableState(serializedState).

    Returns any

    Serializable object defining the state of the Control

handle

isReady

  • Determines if the Control's value is ready for use by other parts of the skill.

    Note:

    • A basic invariant is isReady === !canTakeInitiative because isReady implies that no further discussion is required and thus there is no need to take the initiative.

    Parameters

    Returns Promise<boolean>

    true if the control has no further questions to ask the user such as elicitation, clarification or confirmation.

reestablishState

  • reestablishState(state: any, controlStateMap: object): void
  • Reestablishes the state of the control.

    Default implementations:

    • Control: reestablishes the state via this.setSerializableState(state).
    • ContainerControl: reestablishes the state and recursively reestablishes state for all children.
    • DynamicContainerControl: reestablishes the state, rebuilds any dynamic child controls, and recursively reestablishes state for all children.

    Parameters

    • state: any
    • controlStateMap: object
      • [index: string]: any

    Returns void

renderAPLComponent

  • Add response APL component by this control.

    This is intended to be used to provide APL rendering component for a control to process inputs, provide feedback, elicitation etc through touch events on APL screens.

    Parameters

    Returns object

    • [key: string]: any

renderAct

setSerializableState

  • setSerializableState(serializedState: any): void
  • Sets the state from a serialized state object.

    Default: {this.state = serializedState;}

    Usage:

    • This method must be idempotent (multiple calls must not change the result).
    • It is safe to use serializedState without copying as the framework guarantees to not mutate it.

    Framework behavior:

    • During the initialization phase the control tree is rebuilt and state objects are re-attached to controls by calling this method for each control.

    Parameters

    • serializedState: any

      Serializable object defining the state of the Control

    Returns void

stringifyStateForDiagram

  • stringifyStateForDiagram(): string
  • Returns string

takeInitiative

throwUnhandledActError

  • throwUnhandledActError(act: SystemAct): never

updateAnswer

  • Parameters

    Returns void

updateInteractionModel

Static mergeWithDefaultProps