Packageimpression.players
Classpublic class MultipleChoicePlayer
InheritanceMultipleChoicePlayer Inheritance BasePlayer Inheritance flash.events.EventDispatcher

The MultipleChoicePlayer class supports playback of multiple-choice type storyboards, including multiple-choice text and multiple-choice graphics. A multiple-choice storyboard consists of a question, a correct answer, and up to three distractors. These properties are assigned position indicies, which are used to determine the onscreen ordering of the items.

Once the question and responses have been placed onscreen, the user will select a response. Once the a response has been selected, it can be evaluated and scored.

The MultipleChoicePlayer class is a face-based player; all drawing and interaction is handled by the shell. Like most face-based players, the MultipleChoicePlayer class is designed to encapsulate the logic required to manage multiple-choice questions and make the development of multiple-choice question interfaces as simple as possible.



Public Properties
 PropertyDefined By
 InheritedalwaysCheckComplete : Boolean
Specifies how the object should handle storyboard completion.
BasePlayer
  correct : Boolean
[read-only] true if the question has been correctly evaulated, false else.
MultipleChoicePlayer
  evaluatedIndex : Number
[read-only] The index of the currently evaluated response.
MultipleChoicePlayer
  isPracticeQuestion : Boolean
[read-only] true if the question is marked as a practice question, false else.
MultipleChoicePlayer
  locked : Boolean
Indicates whether the responses for the storyboard are locked, preventing selection.
MultipleChoicePlayer
  maximumDistractors : int
[static] Indicates the maximum number of distractors to be processed.
MultipleChoicePlayer
 InheritednarrationComplete : Boolean
Indicates whether narration has finished playing.
BasePlayer
  selectedIndex : Number
[read-only] The index of the currently selected response.
MultipleChoicePlayer
  status : String
[read-only] The status of the question in the current storyboard.
MultipleChoicePlayer
  storyboard : Storyboard
[override] Specifies the storyboard for the player.
MultipleChoicePlayer
  strictSelection : Boolean
Specifies how the class should handle selection of invalid response indices.
MultipleChoicePlayer
  totalResponses : Number
[read-only] The total number of valid responses in the current storyboard.
MultipleChoicePlayer
Public Methods
 MethodDefined By
 Inherited
Causes the player to examine the completion criteria for the current storyboard.
BasePlayer
  
evaluate():void
Evaluates the selected response.
MultipleChoicePlayer
  
[static] Creates a string describing the state of the storyboard.
MultipleChoicePlayer
  
indexOf(propertyName:String):Number
Returns the index of the propertyName.
MultipleChoicePlayer
  
Resets the selected and evaluated reponse values.
MultipleChoicePlayer
  
[static] Removes all properties set by the player.
MultipleChoicePlayer
  
responseAt(index:Number):String
Returns the persisted property name of the response at index.
MultipleChoicePlayer
  
responseValueAt(index:Number, defaultValue:*):*
Returns the persisted property value of the response at index.
MultipleChoicePlayer
  
selectResponseAt(index:Number):void
Selects the response at index.
MultipleChoicePlayer
  
setStoryboardState(sb:Storyboard, state:String):void
[static] Modifies the storyboard to match the described state passed.
MultipleChoicePlayer
Protected Methods
 MethodDefined By
  
[override] Initializes the storyboard.
MultipleChoicePlayer
 Inherited
Loads the storyboard.
BasePlayer
  
[override] Removes known completion criteria from the CompleteRemaining storyboard persisted property.
MultipleChoicePlayer
 Inherited
Performs cleanup actions when a storyboard is unloaded.
BasePlayer
Events
 Event Summary Defined By
 InheritedDispatched when the BasePlayer needs to resolve completion criteria beyond those defined for the class.BasePlayer
 InheritedDispatched when a storyboard is marked as complete.BasePlayer
 InheritedDispatched after a storyboard is initialized.BasePlayer
 InheritedDispatched when storyboard loading is complete.BasePlayer
 InheritedDispatched when a storyboard is loaded, but before any processing occurs.BasePlayer
  Dispatched when the evaluate() method is invoked.MultipleChoicePlayer
  Dispatched when a selection is changed, or when the storyboard is first loaded.MultipleChoicePlayer
 InheritedDispatched before a storyboard is unloaded.BasePlayer
Property Detail
correctproperty
correct:Boolean  [read-only]

true if the question has been correctly evaulated, false else. If the storyboard property value is null, false is returned.

This method returns the value of the current storyboard's Correct persisted property.


Implementation
    public function get correct():Boolean
evaluatedIndexproperty 
evaluatedIndex:Number  [read-only]

The index of the currently evaluated response. If the storyboard property value is null, -1 is returned. If no response has been evaluated, 0 is returned.

This method returns the value of the current storyboard's EvaluatedIndex persisted property.


Implementation
    public function get evaluatedIndex():Number
isPracticeQuestionproperty 
isPracticeQuestion:Boolean  [read-only]

true if the question is marked as a practice question, false else. If the storyboard property value is null, true is returned.

This method returns the value of the current storyboard's IsPracticeQuestion persisted property.


Implementation
    public function get isPracticeQuestion():Boolean
lockedproperty 
locked:Boolean

Indicates whether the responses for the storyboard are locked, preventing selection.

This property sets or returns the value of the current storyboard's Locked persisted property.


Implementation
    public function get locked():Boolean
    public function set locked(value:Boolean):void
maximumDistractorsproperty 
maximumDistractors:int

Indicates the maximum number of distractors to be processed.

The player will process properties named "Distractor[n]" where [n] is a number between 1 and maximumDistractors.

The default value is 3.


Implementation
    public static function get maximumDistractors():int
    public static function set maximumDistractors(value:int):void
selectedIndexproperty 
selectedIndex:Number  [read-only]

The index of the currently selected response. If the storyboard property value is null, -1 is returned. If no response has been selected, 0 is returned.

This method returns the value of the current storyboard's SelectedIndex persisted property.


Implementation
    public function get selectedIndex():Number
statusproperty 
status:String  [read-only]

The status of the question in the current storyboard. If the storyboard property value is null, the empty string ("") is returned. This value will be one of the QuestionStatusTypes constant values.

This method returns the value of the current storyboard's Status persisted property.


Implementation
    public function get status():String

See also

storyboardproperty 
storyboard:Storyboard[override]

Specifies the storyboard for the player.

If null is passed, the current storyboard is unloaded, the StoryboardEvent.UNLOAD event is dispatched, and no further action occurs.

If a non- null storyboard object is passed, the following actions occur, in order:

  1. If the previously loaded storyboard is not null, the StoryboardEvent.UNLOAD event is dispatched. If the event is not cancelled, the current storyboard is unloaded. If the event is cancelled, further processing stops.
  2. The StoryboardEvent.LOAD_START event is dispatched. If the event is not cancelled, the new storyboard is associated with the player. If the event is cancelled, further processing stops and the value of this property is set to null.
  3. If the value of the new storyboard's Initialized persisted property is false, the storyboard is initialized and the StoryboardEvent.INITIALIZE event is dispatched.
  4. The MultipleChoiceEvent.SELECTION_CHANGE event is dispatched.
  5. The StoryboardEvent.LOAD_COMPLETE event is dispatched.
  6. The checkForComplete() method is invoked. If all completion criteria have been met, the StoryboardEvent.COMPLETE event is dispatched.


Implementation
    public function get storyboard():Storyboard
    public function set storyboard(value:Storyboard):void

See also

strictSelectionproperty 
strictSelection:Boolean

Specifies how the class should handle selection of invalid response indices.

If this property value is true, invoking the selectResponseAt() method causes the player to examine the value of the response at the passed index prior to selection. If the index paramter is invalid, or the response at index is null, the empty string (""), or an AssetData object whose filename member value is null or the empty string, no action is taken. If this property value is false, no additional checks are performed.

The default value is true.


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

See also

totalResponsesproperty 
totalResponses:Number  [read-only]

The total number of valid responses in the current storyboard. If the storyboard property value is null, -1 is returned.

This method returns the value of the current storyboard's TotalResponses persisted property.


Implementation
    public function get totalResponses():Number
Method Detail
evaluate()method
public function evaluate():void

Evaluates the selected response.

Invoking this method causes the selected index to be cleared, and the evaluated index to be set to the selected index, assuming the question had a non-zero selected reponse index value. The Correct storyboard persisted property is set to true if the evaluated index is the index of the answer. Summary information (status) is updated, and a MultipleChoiceEvent.EVALUATE event is dispatched. Finally, since the selected index is cleared, the player dispatches a MultipleChoiceEvent.SELECTION_CHANGE event.

See also

getStoryboardState()method 
public static function getStoryboardState(sb:Storyboard):String

Creates a string describing the state of the storyboard.

This method returns a multiple-character string to describe the state of the storyboard. The size of the string will depend on the number of distractors and the aggregate state. Index data, selected/evaluated response data, lock data, and scoring data are all included (or can be recreated from) the state string. The returned string may contain upper- and lower-case letters, numbers, and the dot (.) character.

Note that this string only describes the state that the player is aware of. If the shell stores additional data in the storyboard, it is the shell's responsibility to store the additional data if it is needed.

Parameters

sb:Storyboard — The storyboard to describe the state of.

Returns
String — The state of the storyboard.

See also

indexOf()method 
public function indexOf(propertyName:String):Number

Returns the index of the propertyName. If the storyboard property value is null, -1 is returned. If propertyName is null or the empty string (""), 0 is returned. If no index value can be found for propertyName, -1 is returned.

This method returns the value of the current storyboard's [propertyName]Index persisted property.

Parameters

propertyName:String — The property name to return the index of.

Returns
Number — The index of propertyName.
initializeStoryboard()method 
override protected function initializeStoryboard():void

Initializes the storyboard.

This method is invoked by the storyboard property set method when a non-null storyboard object is loaded and its Initialized persisted property value is false. The storyboard property set method will dispatch the initialized event after invoking this method.

The MultipleChoicePlayer initializes a storyboard by performing the following actions:

See also

removeCompleteRemainingCriteria()method 
override protected function removeCompleteRemainingCriteria():void

Removes known completion criteria from the CompleteRemaining storyboard persisted property.

This method is invoked by the checkForComplete() method if the value of the storyboard property is not null, and the complete event has not been dispatched since the storyboard was loaded.

In addition to the substrings processed by the BasePlayer, the MultipleChoicePlayer will remove the following substrings from the completeRemaining persisted property:

SubstringMeaning
answerCorrect;The value of the correct property is true.
answerEvaluated;The value of the evaluatedIndex property is > 0.

See also

resetResponse()method 
public function resetResponse():void

Resets the selected and evaluated reponse values.

Invoking this method will remove the following persisted properties from the current storyboard:

If either the SelectedIndex or EvaluatedIndex persisted properties had non-zero values, the player will dispatch a MatchingSelectionEvent.SELECTION_CHANGE event.

See also

resetStoryboard()method 
public static function resetStoryboard(sb:Storyboard):void

Removes all properties set by the player.

Note that this method also removes interim completion properties used by the player, but not necessarily set by the player.

Parameters

sb:Storyboard — The storyboard to remove properties from.

This method removes the following properties from a storyboard:

  • Initialized
  • CompleteRemaining
  • Complete
  • NarrationComplete
  • The Complete property of each ChildElement object in the storyboard's Commands ChildElementCollection property, if it exists.
  • TotalQuestions
  • TotalResponses
  • Locked
  • SelectedIndex
  • EvaluatedIndex
  • NumberCorrect
  • NumberIncorrect
  • Correct
  • Status
  • ResponseIndexesGenerated
  • AnswerIndex (if the ResponseIndexesGenerated persisted property value was false)

For values of [n] between 1 and MultipleChoicePlayer.maximumDistractors, the following properties will be removed:

  • Distractor[n]Index (if the ResponseIndexesGenerated persisted property value was true)

See also

responseAt()method 
public function responseAt(index:Number):String

Returns the persisted property name of the response at index. If the storyboard property value is null, index is less than 1, or no response property can be found at index, the empty string (quot;quot;) is returned.

The return value (if not the empty string) will be of the form "Answer" or "Distractor[n]" where [n] is a value between 1 and MultipleChoicePlayer.maximumDistractors. This method uses the AnswerIndex and Distractor[n]Index persisted property values of the current storyboard.

Parameters

index:Number — The index to retrieve the response's persisted property name of.

Returns
String — The property name of the response at index.
responseValueAt()method 
public function responseValueAt(index:Number, defaultValue:*):*

Returns the persisted property value of the response at index. If the storyboard property value is null, index is less than 1, or no response property can be found at index, the defaultValue is returned.

This method uses the AnswerIndex and Distractor[n]Index persisted property values of the current storyboard.

Parameters

index:Number — The index to retrieve the response's persisted property value of.
 
defaultValue:* — A default value to return if the property at index cannot be found.

Returns
* — The property value of the response at index, or defaultValue.
selectResponseAt()method 
public function selectResponseAt(index:Number):void

Selects the response at index.

If the response at index is locked, the storyboard property value is null, or the strictSelection property value is true and the response at index does not exist or is empty, invoking this method has no effect.

Invoking this method will remove the previously selected response, and may cause the status and selectedIndex property values to change. The player will dispatch a MultipleChoiceEvent.SELECTION_CHANGE event.

Parameters

index:Number — The index of the response to select.

See also

setStoryboardState()method 
public static function setStoryboardState(sb:Storyboard, state:String):void

Modifies the storyboard to match the described state passed.

If the value of state indicates a completed storyboard, interim completion criteria will be marked as complete in addition to the overall storyboard state.

State values created using a function other than getStoryboardState may not work.

Parameters

sb:Storyboard — The Storyboard object to modify.
 
state:String — A String created using the getStoryboardState() method containing the state to restore.

See also

Event Detail
multipleChoiceEvaluate Event
Event Object Type: impression.events.MultipleChoiceEvent
MultipleChoiceEvent.type property = impression.events.MultipleChoiceEvent.EVALUATE

Dispatched when the evaluate() method is invoked.

The MultipleChoiceEvent.EVALUATE constant defines the value of the type property of a evaluate event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
sbThe Storyboard object assigned to the target.
selectedIndexThe index of the selected item.
evaluatedIndexThe index of the evaluated item.
correctIndicates whether or not evaluatedIndex is the index of the answer.

See also

multipleChoiceSelectionChange Event  
Event Object Type: impression.events.MultipleChoiceEvent
MultipleChoiceEvent.type property = impression.events.MultipleChoiceEvent.SELECTION_CHANGE

Dispatched when a selection is changed, or when the storyboard is first loaded.

The MultipleChoiceEvent.SELECTION_CHANGE constant defines the value of the type property of a multiple choice selection change event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
sbThe Storyboard object assigned to the target.
selectedIndexThe index of the selected item.
evaluatedIndexThe index of the evaluated item
correctIndicates whether or not evaluatedIndex is the index of the answer.

See also