| Package | widgetfactory.events |
| Class | public class QuestionWidgetEvent |
| Inheritance | QuestionWidgetEvent flash.events.Event |
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
| Property | Defined 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 | ||
| Method | Defined 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 | ||
| Constant | Defined 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 | ||
| answerID | property |
answerID:String [read-only]
Holds the answerID property of the Answer that caused the COMPARE_ANSWERS event.
public function get answerID():StringSee also
| chosenAnswer | property |
chosenAnswer:String [read-only]
Holds the chosenAnswer property of the Answer that caused the COMPARE_ANSWERS event.
public function get chosenAnswer():StringSee also
| correctAnswer | property |
correctAnswer:String [read-only]
Holds the correctAnswer property of the Answer that caused the COMPARE_ANSWERS event.
public function get correctAnswer():StringSee also
| questionState | property |
questionState:String [read-only]
Holds the questionState string returned from the LMS with the SET_QUESTION_STATE event.
public function get questionState():StringSee also
| quizData | property |
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);
}
public function get quizData():QuizDataSee also
| 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.
Parameterstype: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) |
| clone | () | method |
override public function clone():EventCreates a copy of the QuestionWidgetEvent object and sets the value of each property to match that of the original.
ReturnsEvent — A new QuestionWidgetEvent object that is identical to the original.
|
| CLEAR_ANSWERS | Constant |
public static const CLEAR_ANSWERS:String = clearAnswersDispatched 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_ANSWERS | Constant |
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_ANSWERS | Constant |
public static const DISABLE_ANSWERS:String = disableAnswersDispatched 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_ANSWERS | Constant |
public static const ENABLE_ANSWERS:String = enableAnswersDispatched 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_SUBMITTED | Constant |
public static const QUESTION_SUBMITTED:String = questionSubmittedDispatched 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_STATE | Constant |
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;
}
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
| SUBMIT | Constant |
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