Packagewidgetfactory.events
Classpublic class QuestionWidgetEvent
InheritanceQuestionWidgetEvent Inheritance flash.events.Event

The QuestionWidgetEvent class dispatches events that deal with QuestionWidgets. The usage of QuestionWidgetEvent is exactly the same as WidgetEvent.

There are many situations that a Question Widget needs to react to. For example, the ENABLE_ANSWERS event is dispatched when the question's interactivity needs to be turned on. Whereas DISABLE_ANSWERS is dispatched when the question's interactivity needs to be turned off.

For many of these events, the QuestionWidget class has a corresponding Template Method.

Unless otherwise stated, these events are only dispatched from the QuestionWidget class.

See also

WidgetEvent


Public Properties
 PropertyDefined By
  answerID : String
[read-only] Holds the answerID property of the Answer that caused the COMPARE_ANSWERS event.
QuestionWidgetEvent
  chosenAnswer : String
[read-only] Holds the chosenAnswer property of the Answer that caused the COMPARE_ANSWERS event.
QuestionWidgetEvent
  correctAnswer : String
[read-only] Holds the correctAnswer property of the Answer that caused the COMPARE_ANSWERS event.
QuestionWidgetEvent
  questionState : String
[read-only] Holds the questionState string returned from the LMS with the SET_QUESTION_STATE event.
QuestionWidgetEvent
  quizData : QuizData
[read-only] quizData holds information about how the Captivate Author set up the quiz.
QuestionWidgetEvent
Public Methods
 MethodDefined By
  
QuestionWidgetEvent(type:String, id:String = null, chosen:String = null, correct:String = null, questionState:String = null, bubbles:Boolean = false, cancelable:Boolean = false, quizData:QuizData = null)
Creates an Event object to pass as a parameter to event listeners.
QuestionWidgetEvent
  
clone():Event
[override] Creates a copy of the QuestionWidgetEvent object and sets the value of each property to match that of the original.
QuestionWidgetEvent
Public Constants
 ConstantDefined By
  CLEAR_ANSWERS : String = clearAnswers
[static] Dispatched when this question's 'Clear' button is pressed.
QuestionWidgetEvent
  COMPARE_ANSWERS : String = compareAnswers
[static] Dispatched when the user reviews the quiz and reaches this Question Widget.
QuestionWidgetEvent
  DISABLE_ANSWERS : String = disableAnswers
[static] Dispatched when your interactivity should be turned off.
QuestionWidgetEvent
  ENABLE_ANSWERS : String = enableAnswers
[static] Dispatched when your interactivity should be turned on.
QuestionWidgetEvent
  QUESTION_SUBMITTED : String = questionSubmitted
[static] Dispatched when any native Captivate question type or Question Widget is submitted.
QuestionWidgetEvent
  SET_QUESTION_STATE : String = setQuestionState
[static] Dispatched when the LMS returns the questionState string.
QuestionWidgetEvent
  SUBMIT : String = submit
[static] Dispatched when the 'Submit' button is pressed.
QuestionWidgetEvent
Property Detail
answerIDproperty
answerID:String  [read-only]

Holds the answerID property of the Answer that caused the COMPARE_ANSWERS event.


Implementation
    public function get answerID():String

See also

chosenAnswerproperty 
chosenAnswer:String  [read-only]

Holds the chosenAnswer property of the Answer that caused the COMPARE_ANSWERS event.


Implementation
    public function get chosenAnswer():String

See also

correctAnswerproperty 
correctAnswer:String  [read-only]

Holds the correctAnswer property of the Answer that caused the COMPARE_ANSWERS event.


Implementation
    public function get correctAnswer():String

See also

questionStateproperty 
questionState:String  [read-only]

Holds the questionState string returned from the LMS with the SET_QUESTION_STATE event.


Implementation
    public function get questionState():String

See also

quizDataproperty 
quizData:QuizData  [read-only]

quizData holds information about how the Captivate Author set up the quiz.

Access to this property is only available when responding to the QuestionWidgetEvent.QUESTION_SUBMITTED, and WidgetEvent.INTERACTIVE_ITEM_SUBMITTED events.

         
         addEventListener(QuestionWidgetEvent.QUESTION_SUBMITTED, onQuestionSubmitted)
         
         private function onQuestionSubmitted(e:QuestionWidgetEvent):void 
         {
            trace(e.quizData);
            trace(e.quizData.questionAnsweredCorrectly);
         }
         
         
For more information, see the QuizData class.


Implementation
    public function get quizData():QuizData

See also

Constructor Detail
QuestionWidgetEvent()Constructor
public function QuestionWidgetEvent(type:String, id:String = null, chosen:String = null, correct:String = null, questionState:String = null, bubbles:Boolean = false, cancelable:Boolean = false, quizData:QuizData = null)

Creates an Event object to pass as a parameter to event listeners.

Parameters
type:String — The type of the event.
 
id:String (default = null) — The answerID property of the Answer that caused the COMPARE_ANSWERS event.
 
chosen:String (default = null) — The chosenAnswer property of the Answer that caused the COMPARE_ANSWERS event.
 
correct:String (default = null) — The correctAnswer property of the Answer that caused the COMPARE_ANSWERS event.
 
questionState:String (default = null) — The value of questionState when the SET_QUESTION_STATE event is dispatched.
 
bubbles:Boolean (default = false) — Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
 
cancelable:Boolean (default = false) — Determines whether the Event object can be canceled. The default values is false.
 
quizData:QuizData (default = null)
Method Detail
clone()method
override public function clone():Event

Creates a copy of the QuestionWidgetEvent object and sets the value of each property to match that of the original.

Returns
Event — A new QuestionWidgetEvent object that is identical to the original.
Constant Detail
CLEAR_ANSWERSConstant
public static const CLEAR_ANSWERS:String = clearAnswers

Dispatched when this question's 'Clear' button is pressed. Depending on what your Question Widget does, clearing it may mean any number of things.

In responding to this event, you should code your widget so that it restores the question to its initial state. For example: In a drag and drop widget, you would move all draggable items back to their starting positions.

See also

COMPARE_ANSWERSConstant 
public static const COMPARE_ANSWERS:String = compareAnswers

Dispatched when the user reviews the quiz and reaches this Question Widget. It is dispatched once for each Answer in the Answer List. This event is dispatched regardless of whether the question was answered correctly or incorrectly.

You can access the properties of the Answer object through the QuestionWidgetEvent object that is passed into the function.

        
        addEventListener(QuestionWidgetEvent.COMPARE_ANSWERS, onCompareAnswer);
        
           function onCompareAnswer (event:QuestionWidgetEvent):void {
           trace(event.answerID);
           trace(event.correctAnswer);
           trace(event.chosenAnswer);
        }
        
        

You need to enter an answerID when you create an Answer object, because otherwise, there would be no way to identify the current answer from any others that were in the Answer List.

See also

DISABLE_ANSWERSConstant 
public static const DISABLE_ANSWERS:String = disableAnswers

Dispatched when your interactivity should be turned off.

This event is dispatched after the question has been answered. It's dispatched again when the Question Widget is being reviewed.

DISABLE_ANSWERS has a matching event of ENABLE_ANSWERS, which is dispatched when the interactivity for the widget should be turned on. Ideally, these events should cancel each other out, meaning that Captivate could enable or disable the question as many times as it needs, and still result in no error.

See also

ENABLE_ANSWERSConstant 
public static const ENABLE_ANSWERS:String = enableAnswers

Dispatched when your interactivity should be turned on.

This event usually fires at the point when the question appears on screen. It is considered better practice in the case of Question Widgets to use ENABLE_ANSWERS than ENTER_RUNTIME. The reason for this recomendation is that ENABLE_ANSWERS has a matching event of DISABLE_ANSWERS, which is dispatched when the interactivity for the widget should be turned off. Ideally, these events should cancel each other out, meaning that Captivate could enable or disable the question as many times as it needs, and still result in no error.

See also

QUESTION_SUBMITTEDConstant 
public static const QUESTION_SUBMITTED:String = questionSubmitted

Dispatched when any native Captivate question type or Question Widget is submitted. With this event you can also read information about the quiz setup through the quizData property.

This event can be listened to by Static and Interactive Widgets, not just Question Widgets.

See also

SET_QUESTION_STATEConstant 
public static const SET_QUESTION_STATE:String = setQuestionState

Dispatched when the LMS returns the questionState string. The questionState string can be read via the passed in questionState property on the event object...

         public function ConstructorFunction ()
         {
             addEventListener(QuestionWidgetEvent.SET_QUESTION, onSetQuestionState);
         }
         
         override public function onSetQuestionState(event:QuestionWidget):void {
            onStage_txt.text = event.questionState;
         }
         
...or the questionState property in the QuestionWidget class.
         ublic function ConstructorFunction ()
         {
             addEventListener(QuestionWidgetEvent.SET_QUESTION, onSetQuestionState);
         }
         
         override public function onSetQuestionState(event:QuestionWidget):void {
            onStage_txt.text = questionState;
         }
         

See also

QuestionWidget.questionState
QuestionWidget.setQuestionState()
SUBMITConstant 
public static const SUBMIT:String = submit

Dispatched when the 'Submit' button is pressed. This event is fired just before the question's results are sent off to Captivate. In responding to this event, you should check whether the answer submitted by your widget is complete and correct, then set the QuestionWidget's isCompleteAnswer and isCorrectAnswer properties accordingly.

See also