Packagewidgetfactory
Classpublic class QuestionWidget
InheritanceQuestionWidget Inheritance StaticWidget Inheritance flash.display.MovieClip

A Question Widget is a Static Widget that acts as a Captivate question type.

Question Widgets behave quite differently in Captivate than Static and Interactive Widgets. For example, when you insert a Static or Interactive Widget into Captivate, they are added as an object of the slide you are currently on. Whereas, when you insert a Question Widget, Captivate creates a new slide, with the question widget being treated as part of the slide.

In Captivate 4, the Widget Properties are located in Edit Question...

...under the main Question tab.

In Captivate 5, you access the Widget Properties in the same place as Static and Interactive Widgets. By selecting the widget, and going to the Properties panel > Animation Accordion > Widget Properties button.

With QuestionWidget comes the addition of QuestionWidgetEvent, which provides many new events specifically for use with quizzing.

Just like when creating a StaticWidget or an InteractiveWidget, to write a QuestionWidget you must create a class and have it extend the QuestionWidget class.

    
    package {
    
        import widgetfactory.QuestionWidget;
    
        public class YourClassName extends QuestionWidget {
        
           public function YourClassName () {
             
          }
       }
    }
    
    

See also

widgetfactory.events.QuestionWidgetEvent


Public Properties
 PropertyDefined By
  backButton : MovieClip
The Back button for the QuestionWidget.
QuestionWidget
 InheritedcaptivateMainTimeline : MovieClip
[read-only] Same as cpVariables, but under more correct name.
StaticWidget
  clearButton : MovieClip
The Clear button for the QuestionWidget.
QuestionWidget
 InheritedcpVariables : MovieClip
Holds Captivate System variables, and user-defined Captivate Variables created by the Author.
StaticWidget
 InheritedcurrentSlide : MovieClip
[read-only] Gives access to the slide currently being viewed in the Captivate Movie.
StaticWidget
 InheritedcurrentWidgetMode : String
[read-only] Holds a string name of the current Widget Mode.
StaticWidget
 InheriteddispatchRuntimeAfterRewind : Boolean
Sets whether or not WidgetEvent.ENTER_RUNTIME and enterRuntime() are called when the Captivate movie is rewound and viewed again.
StaticWidget
 InheritedeventDispatcher : IEventDispatcher
The default dispatcher of the com.adobe.captivate.events in Captivate 5.
StaticWidget
 InheritedisCaptivate4 : Boolean
[read-only] Returns true if the widget is being used by Captivate 4.
StaticWidget
 InheritedisCaptivate4Embedded : Boolean
[read-only] Returns true if the widget is in Captivate 4 and embedded in the movie.
StaticWidget
 InheritedisCaptivate5 : Boolean
[read-only] Returns true if the widget is being used by Captivate 5.
StaticWidget
  isCompleteAnswer : Boolean
Determines if Captivate sees the question as complete (true) or incomplete (false).
QuestionWidget
  isCorrectAnswer : Boolean
Determines if Captivate marks the question as correct (true) or incorrect (false).
QuestionWidget
 InheritedisFirstRuntime : Boolean
[read-only] Indicates whether this is the first time runtime has been dispatched for this widget.
StaticWidget
 InheritedisInAggregator : Boolean
[read-only] Indicates whether the Captivate Movie is inside an aggregator.
StaticWidget
 InheritedisInRuntime : Boolean
[read-only] Indicates whether the movie's current position is within the widget's set period to be active.
StaticWidget
 InheritedisReadyForStageSnapShot : Boolean
Tells Captivate if the widget is prepared to have the Stage snapshot taken.
StaticWidget
 InheriteditemName : String
[read-only] Hold the item name that the Captivate Author gave the widget.
StaticWidget
 InheritedmovieVariables : Object
Allows you to control, and get information from, Captivate.
StaticWidget
 Inheritedproperties : Object
Stores settings given by the Captivate Author in the Properties Dialog interface.
StaticWidget
 InheritedpropertiesDialogHeight : int
Sets the height of the Properties Dialog in Captivate 5.
StaticWidget
 InheritedpropertiesDialogWidth : int
Sets the width of the Properties Dialog in Captivate 5.
StaticWidget
  questionState : String
Holds a string that is sent to the Learning Management System (LMS) when the question is submitted.
QuestionWidget
  questionText : MovieClip
The container of the Question Text field for the QuestionWidget.
QuestionWidget
  questionTitle : MovieClip
The container of the Question Title text field for the QuestionWidget.
QuestionWidget
  quizReporter : QuizReporterProxy
[read-only] The Quiz Reporter object that is associated with this quiz question.
QuestionWidget
  reportScore : int
The score that will be reported to the quiz (assuming the question reports as correct).
QuestionWidget
  skipButton : MovieClip
The Skip button for the QuestionWidget.
QuestionWidget
  submitButton : MovieClip
The Submit button for the QuestionWidget.
QuestionWidget
 InheritedwidgetInfo : WidgetInfo
[read-only] Holds information about how the Captivate Author set up the widget.
StaticWidget
 InheritedwidgetSlide : MovieClip
The slide to which the Widget was added by the Captivate Author.
StaticWidget
Public Methods
 MethodDefined By
  
QuestionWidget(propertiesDialogWidth:Number, propertiesDialogHeight:Number, propertiesObject:ICaptivateWidgetData = null)
Creates a new instance of the QuestionWidget class.
QuestionWidget
  
addAnswer(addToAnswerList:Answer):void
Adds an answer to the Answer list.
QuestionWidget
  
Clears the Answer List of all Answers.
QuestionWidget
  
A Template Method that is called when this question's 'Clear' button is pressed.
QuestionWidget
  
A Template Method that is called when the question's interactivity should be turned off.
QuestionWidget
 Inherited
drawPropertiesDialogBackground(useStageGraphics:Boolean = true):void
Makes the Widget's background colour consistent with the Properties Dialog boarder in Captivate 5.
StaticWidget
  
A Template Method that is called when the question's interactivity should be turned on.
QuestionWidget
 Inherited
getSlide(slide:*):MovieClip
Returns a reference to the slide with the number or label you pass in.
StaticWidget
 Inherited
getSlideObjectByName(slideObject:String, slide:* = -1):*
Returns a reference to any object on a Captivate slide that matches the name you passed in.
StaticWidget
 Inherited
gotoSlide(slide:*):void
Jumps to the slide with the number or label you pass in.
StaticWidget
  
setQuestionState(questionState:String):void
A Template Method called when the LMS returns the questionState string.
QuestionWidget
  
Tells Captivate to start the Question Widget's submit process.
QuestionWidget
 Inherited
updateRuntimeStatus(hasEnteredRuntime:Boolean):void
StaticWidget
Protected Methods
 MethodDefined By
  
compareAnswers(answerID:String, chosenAnswer:String, correctAnswer:String):void
A Template Method that is called when the user reviews the quiz and reaches this Question Widget.
QuestionWidget
 Inherited
Turns off the Properties Dialog in Captivate 5.
StaticWidget
 Inherited
enterMovie():void
A Template Method that is called when the Captivate Movie begins.
StaticWidget
 Inherited
A Template Method that is called when the Properties Dialog (Widget Parameters tab in Captivate 4) is opened.
StaticWidget
 Inherited
A Template Method that is called when Captivate 4 displays your widget in the preview area of the Properties Dialog Widget tab.
StaticWidget
 Inherited
A Template Method that is called when the Captivate Movie enters the period in which this widget is supposed to appear.
StaticWidget
 Inherited
enterStage():void
A Template Method that is called when your widget is displayed on the Captivate stage.
StaticWidget
 Inherited
A Template Method that is called when your widget is being previewed in the Widget Panel.
StaticWidget
 Inherited
A Template Method that is called when the Captivate Movie leaves the period of time in which the widget is supposed to appear.
StaticWidget
 Inherited
A Template Method that is called when the OK button inside the Properties Dialog is clicked.
StaticWidget
  
submit():void
A Template Method that is called when the 'Submit' button is pressed.
QuestionWidget
 Inherited
Converts the properties XML into a formatted object.
StaticWidget
Events
 Event Summary Defined By
   Dispatched when this question's 'Clear' button is pressed.QuestionWidget
   Dispatched when the user reviews the quiz and reaches this Question Widget.QuestionWidget
   Dispatched when your interactivity should be turned off.QuestionWidget
   Dispatched when your interactivity should be turned on.QuestionWidget
 Inherited Dispatched when the Captivate Movie begins.StaticWidget
 Inherited Dispatched when the Properties Dialog (Widget Parameters tab in Captivate 4) is opened.StaticWidget
 Inherited Dispatched when Captivate 4 displays your widget in the preview area of the Properties Dialog Widget tab.StaticWidget
 Inherited Dispatched when the Captivate Movie enters the period in which this widget is supposed to appear.StaticWidget
 Inherited Dispatched when the Captivate movie progresses into a new slide (except for the very first slide of the movie).StaticWidget
 Inherited Dispatched when Captivate displays your widget on the stage.StaticWidget
 Inherited Dispatched when your widget is being previewed in the Widget Panel.StaticWidget
 Inherited Dispatched when the Captivate Movie leaves the period of time in which the widget is supposed to appear.StaticWidget
 Inherited Dispatched when the Captivate movie has reached the last frame of the current slide, and is about to move on to the next slide.StaticWidget
 Inherited Dispatched whenever an interactive object sends information back to Captivate.StaticWidget
 Inherited Dispatched when the published Captivate movie reaches its last frame.StaticWidget
 Inherited Dispatched whenever the Captivate movie is paused.StaticWidget
 Inherited Dispatched if the Widget Properties do not load correctly.StaticWidget
   Dispatched when any native Captivate question type or Question Widget is submitted.QuestionWidget
 Inherited Dispatched when the movie resumes after being paused.StaticWidget
 Inherited Dispatched when the OK button inside the Properties Dialog is clicked.StaticWidget
   Dispatched when the LMS returns the questionState string.QuestionWidget
   Dispatched when the 'Submit' button is pressed.QuestionWidget
Public Constants
 ConstantDefined By
 InheritedINTERACTIVE_WIDGET_SUFFIX : String = _iWidgetAS3
[static] The suffix that Captivate places on the end of an Interactive Widget's item name.
StaticWidget
 InheritedPROPERTIES_DIALOG_BACKGROUND_COLOUR : Number = 0xD7D7D7
[static] The colour of the Properties Dialog in Captivate 5.
StaticWidget
Property Detail
backButtonproperty
backButton:MovieClip

The Back button for the QuestionWidget.


Implementation
    public function get backButton():MovieClip
    public function set backButton(value:MovieClip):void

See also

clearButtonproperty 
clearButton:MovieClip

The Clear button for the QuestionWidget.


Implementation
    public function get clearButton():MovieClip
    public function set clearButton(value:MovieClip):void

See also

isCompleteAnswerproperty 
isCompleteAnswer:Boolean

Determines if Captivate sees the question as complete (true) or incomplete (false). If Captivate picks up that the question is incomplete, it will not accept the question as correct or incorrect, and will show the 'You must answer the question' callout.

The audience is then given another opportunity to answer the question.

It is best to set the value of this property in the submit() Template Method, or during the QuestionWidgetEvent.SUBMIT event.

The default value is true.


Implementation
    public function get isCompleteAnswer():Boolean
    public function set isCompleteAnswer(value:Boolean):void

See also

isCorrectAnswerproperty 
isCorrectAnswer:Boolean

Determines if Captivate marks the question as correct (true) or incorrect (false). Captivate will first look to see if isCompleteAnswer equals true. If so, then it will check isCorrectAnswer. If not, then Captivate will skip over isCorrectAnswer and give the audience another chance to answer the question.

When isCorrectAnswer is returned as true, Captivate marks the question as correct, and displays the success caption.

When isCorrectAnswer is returned as false, Captivate marks the question as incorrect, and displays the failure caption.

Depending on how the Captivate Author has set up the question, the audience may be allowed another chance at answering the question after submitting a wrong answer.

Once the question has been answered correctly, or the last failure level reached, the QuestionWidgetEvent.DISABLE_ANSWERS event and disableAnswers() Template Method are fired, and the movie moves on to the next question.

The default value is false.


Implementation
    public function get isCorrectAnswer():Boolean
    public function set isCorrectAnswer(value:Boolean):void

See also

questionStateproperty 
questionState:String

Holds a string that is sent to the Learning Management System (LMS) when the question is submitted. The LMS will return the string to the widget if the user revisits the lesson later to pick up where they left off.

When the user opens up the course again, the widget will have to reload, but will have no memory of how it was set up when the user left it. The widget developer must include enough information in the questionState string to enable the Question Widget to be configured exactly as it appeared when it was submitted by the user. Additionally, the developer must code the widget so when it receives this information, when the QuestionWidgetEvent.QUESTION_STATE_SET is dispatched, it will know what to do with it.


Implementation
    public function get questionState():String
    public function set questionState(value:String):void

See also


Example

A good way to store information in the questionState string, is to write the data you need as XML. Then set the questionState equal to the XML object. When the QuestionWidgetEvent.QUESTION_STATE_SET event or setQuestionState Template Method are fired, you know that the LMS has returned the questionState. You can then format that string back into an XML object. Like so:

        
        var xml:XML = new XML(<questionState/>);
        xml.textField = "Hello";
        xml.selectedAnswer = "Answer1";
        questionState = xml;
        
          addEventListener(QuestionWidgetEvent.QUESTION_STATE_SET, questionStateReturn);
        
          function questionStateReturn (event:QuestionWidgetEvent):void {
           var questionStateXML:XML = new XML(questionState); // Turns the string into XML data
           onstage_txt.text = questionStateXML.textField; // The on stage text field will read the value of the 'textField' property we wrote on the XML object.
        }
        
        
questionTextproperty 
questionText:MovieClip

The container of the Question Text field for the QuestionWidget.


Implementation
    public function get questionText():MovieClip
    public function set questionText(value:MovieClip):void

See also

questionTitleproperty 
questionTitle:MovieClip

The container of the Question Title text field for the QuestionWidget.


Implementation
    public function get questionTitle():MovieClip
    public function set questionTitle(value:MovieClip):void

See also

quizReporterproperty 
quizReporter:QuizReporterProxy  [read-only]

The Quiz Reporter object that is associated with this quiz question. For more information see the QuizReporterProxy class.


Implementation
    public function get quizReporter():QuizReporterProxy

See also

reportScoreproperty 
reportScore:int

The score that will be reported to the quiz (assuming the question reports as correct).

This can be altered to give a partial score which is different to the one the Captivate Author set up under the Quiz Properties panel > General Settings > Points.


Implementation
    public function get reportScore():int
    public function set reportScore(value:int):void
skipButtonproperty 
skipButton:MovieClip

The Skip button for the QuestionWidget.


Implementation
    public function get skipButton():MovieClip
    public function set skipButton(value:MovieClip):void

See also

submitButtonproperty 
submitButton:MovieClip

The Submit button for the QuestionWidget.


Implementation
    public function get submitButton():MovieClip
    public function set submitButton(value:MovieClip):void

See also

Constructor Detail
QuestionWidget()Constructor
public function QuestionWidget(propertiesDialogWidth:Number, propertiesDialogHeight:Number, propertiesObject:ICaptivateWidgetData = null)

Creates a new instance of the QuestionWidget class.

Parameters
propertiesDialogWidth:Number (default = NaN) — Defines the width of the Properties Dialog in Captivate 5.
 
propertiesDialogHeight:Number (default = NaN) — Defines the height of the Properties Dialog in Captivate 5.
 
propertiesObject:ICaptivateWidgetData (default = null) — Where your pass in your custom properties class.
Method Detail
addAnswer()method
public function addAnswer(addToAnswerList:Answer):void

Adds an answer to the Answer list.

The Answer List is requested by Captivate after the question has been submitted by the user. Make sure you set up all your answers before or during the QuestionWidgetEvent.SUBMIT event, or submit() Template Method.

See the Answer class for more information on Answers.

Parameters

addToAnswerList:Answer — The answer being added to the Answer list.

See also

clearAnswerList()method 
public function clearAnswerList():void

Clears the Answer List of all Answers.

See also

clearAnswers()method 
public function clearAnswers():void

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

In overriding this Template Method, 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.

If you do not call super.resetAnswer() at the end of this function, the QuestionWidgetEvent.RESET_ANSWER Event will not be dispatched.

See also

QuestionWidgetEvent.CLEAR_ANSWERS
compareAnswers()method 
protected function compareAnswers(answerID:String, chosenAnswer:String, correctAnswer:String):void

A Template Method that is called when the user reviews the quiz and reaches this Question Widget. It is called once for each Answer in the Answer List. This method is called regardless of whether the question was answered correctly or incorrectly.

You can access the properties of the Answer through the passed in parameters.

        
        override public function resetAnswer(answerID:String, chosenAnswer:String, correctAnswer:String):void {
           trace(answerID);
           trace(correctAnswer);
           trace(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.

Parameters

answerID:String
 
chosenAnswer:String
 
correctAnswer:String

See also

disableAnswers()method 
public function disableAnswers():void

A Template Method that is called when the question's interactivity should be turned off.

This method is called when the question has been answered. It's called again when the Question Widget is being reviewed.

disableAnswers has a matching method of enableAnswers, which is called when the interactivity for the widget should be turned on. Ideally, the actions of both these methods should cancel each other out, meaning Captivate could enable or disable the question as many times as it needs, and still result in no error.

If you do not call super.disableAnswers() at the end of this function, the QuestionWidgetEvent.ENABLE_ANSWERS Event will not be dispatched.

See also

enableAnswers()method 
public function enableAnswers():void

A Template Method that is called when the question's interactivity should be turned on.

This method is usually called right when the question appears on screen. It is considered better practice in the case of Question Widgets to override and put your runtime code in the enableAnswers() method instead of enterRuntime().

enableAnswers has a matching method of disableAnswers, which is called when the interactivity for the widget should be turned off. Ideally, the actions of both these methods should cancel each other out, meaning Captivate could enable or disable the question as many times as it needs, and still result in no error.

If you do not call super.enableAnswers() at the end of the method, then the QuestionWidgetEvent.ENABLE_ANSWERS Event will not be dispatched.

See also

setQuestionState()method 
public function setQuestionState(questionState:String):void

A Template Method called when the LMS returns the questionState string. The questionState string can be read via the passed in questionState property...

         override public function setQuestionState(questionState:String):void {
            onStage_txt.text = questionState;
         }
         
...or the questionState property in the QuestionWidget class.
         override public function setQuestionState(questionState:String):void {
            onStage_txt.text = this.questionState;
         }
         

Because, as you see, there is a whole lotta difference there.

Parameters

questionState:String — The widget question state that has been passed in via the LMS.

See also

submit()method 
protected function submit():void

A Template Method that is called when the 'Submit' button is pressed. This method is called just before the question's results are sent off to Captivate. In overriding to this Template Method, you should check whether the answer submitted by your widget is complete and correct, then set the isCompleteAnswer and isCorrectAnswer properties accordingly.

See also

triggerSubmitProcess()method 
public function triggerSubmitProcess():void

Tells Captivate to start the Question Widget's submit process.

This is useful in the case that you have created a question where clicking the Submit button at the end would not make sense. For example, if you had a widget where you had to win a car race, it wouldn't make sense to click the submit button after the car has crossed the finish line. In that situation, you would call this method at the end of the race. The submit() template method and WidgetEvent.SUBMIT event will both still be fired as if the user had clicked the submit button.

Event Detail
clearAnswers Event
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.CLEAR_ANSWERS

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

compareAnswers Event  
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.COMPARE_ANSWERS

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

disableAnswers Event  
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.DISABLE_ANSWERS

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

enableAnswers Event  
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.ENABLE_ANSWERS

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

questionSubmitted Event  
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.QUESTION_SUBMITTED

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.

setQuestionState Event  
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.SET_QUESTION_STATE

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

submit Event  
Event Object Type: widgetfactory.events.QuestionWidgetEvent
QuestionWidgetEvent.type property = widgetfactory.events.QuestionWidgetEvent.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