Package | impression.players |
Class | public class MultipleChoicePlayer |
Inheritance | MultipleChoicePlayer ![]() ![]() |
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.
Property | Defined By | ||
---|---|---|---|
![]() | alwaysCheckComplete : 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 | ||
![]() | narrationComplete : 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 |
Method | Defined By | ||
---|---|---|---|
![]() | checkForComplete():void
Causes the player to examine the completion criteria for the current storyboard. | BasePlayer | |
evaluate():void
Evaluates the selected response. | MultipleChoicePlayer | ||
getStoryboardState(sb:Storyboard):String [static]
Creates a string describing the state of the storyboard. | MultipleChoicePlayer | ||
indexOf(propertyName:String):Number
Returns the index of the propertyName. | MultipleChoicePlayer | ||
resetResponse():void
Resets the selected and evaluated reponse values. | MultipleChoicePlayer | ||
resetStoryboard(sb:Storyboard):void [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 |
Method | Defined By | ||
---|---|---|---|
initializeStoryboard():void [override]
Initializes the storyboard. | MultipleChoicePlayer | ||
![]() | loadStoryboard():void
Loads the storyboard. | BasePlayer | |
[override]
Removes known completion criteria from the CompleteRemaining storyboard persisted property. | MultipleChoicePlayer | ||
![]() | unloadStoryboard():void
Performs cleanup actions when a storyboard is unloaded. | BasePlayer |
Event | Summary | Defined By | ||
---|---|---|---|---|
![]() | Dispatched when the BasePlayer needs to resolve completion criteria beyond those defined for the class. | BasePlayer | ||
![]() | Dispatched when a storyboard is marked as complete. | BasePlayer | ||
![]() | Dispatched after a storyboard is initialized. | BasePlayer | ||
![]() | Dispatched when storyboard loading is complete. | BasePlayer | ||
![]() | Dispatched 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 | |||
![]() | Dispatched before a storyboard is unloaded. | BasePlayer |
correct | property |
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.
public function get correct():Boolean
evaluatedIndex | property |
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.
public function get evaluatedIndex():Number
isPracticeQuestion | property |
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.
public function get isPracticeQuestion():Boolean
locked | property |
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.
public function get locked():Boolean
public function set locked(value:Boolean):void
maximumDistractors | property |
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
.
public static function get maximumDistractors():int
public static function set maximumDistractors(value:int):void
selectedIndex | property |
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.
public function get selectedIndex():Number
status | property |
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.
public function get status():String
See also
storyboard | property |
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:
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.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
. Initialized
persisted property is false
, the storyboard is initialized and the StoryboardEvent.INITIALIZE
event is dispatched.MultipleChoiceEvent.SELECTION_CHANGE
event is dispatched.StoryboardEvent.LOAD_COMPLETE
event is dispatched.checkForComplete()
method is invoked. If all completion criteria have been met, the StoryboardEvent.COMPLETE
event is dispatched. public function get storyboard():Storyboard
public function set storyboard(value:Storyboard):void
See also
strictSelection | property |
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
.
public function get strictSelection():Boolean
public function set strictSelection(value:Boolean):void
See also
totalResponses | property |
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.
public function get totalResponses():Number
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.
|
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.
|
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:
AnswerIndex
and Distractor[n]Index
persisted properties are set.TotalQuestions
and TotalResponses
persisted property values are set.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:
Substring | Meaning |
---|---|
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:
SelectedIndex
EvaluatedIndex
NumberCorrect
NumberIncorrect
Correct
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:
For values of [n] between
|
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.
|
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.
|
* — 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
multipleChoiceEvaluate | Event |
impression.events.MultipleChoiceEvent
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:Property | Value |
---|---|
bubbles | false |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
sb | The Storyboard object assigned to the target. |
selectedIndex | The index of the selected item. |
evaluatedIndex | The index of the evaluated item. |
correct | Indicates whether or not evaluatedIndex is the index of the answer. |
See also
multipleChoiceSelectionChange | Event |
impression.events.MultipleChoiceEvent
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:Property | Value |
---|---|
bubbles | false |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
sb | The Storyboard object assigned to the target. |
selectedIndex | The index of the selected item. |
evaluatedIndex | The index of the evaluated item |
correct | Indicates whether or not evaluatedIndex is the index of the answer. |
See also