ActivitySequence
Source: ActivitySequence.js:44
This class stores the definition of the sequence to follow to show the activities of a
JClicProject. The sequence are formed by an ordered list of objects of type
ActivitySequenceElement.
It stores also a transient pointer to the current sequence element.
Constructor
new ActivitySequence(
project: module:project/JClicProject.JClicProject,
): ActivitySequenceActivitySequence constructor
Parameters
project(module:project/JClicProject.JClicProject) — The JClic project to which this ActivitySequence belongs
Instance Methods
setProperties($xml: external:jQuery)
Loads the object settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element to parse
getAttributes(): object
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
Returns
object
setAttributes(data: object)
Loads the object settings from a data object
Parameters
data(object) — The data object to parse
getElementIndex(
ase: module:bags/ActivitySequenceElement.ActivitySequenceElement,
): number
Returns the index of the specified element in the sequence.
Parameters
ase(module:bags/ActivitySequenceElement.ActivitySequenceElement) — The element to search.
Returns
number
getElement(
n: number,
updateCurrentAct: boolean,
): module:bags/ActivitySequenceElement.ActivitySequenceElement
Returns the nth element of the sequence.
Parameters
n(number) — Index of the requested elementupdateCurrentAct(boolean) — whentrue, thecurrentActindex will be updated.
Returns
getElementByTag(
tag: string,
updateCurrentAct: boolean,
): module:bags/ActivitySequenceElement.ActivitySequenceElement
Search into the sequence for a element with the provided tag
Parameters
tag(string) — The tag to searchupdateCurrentAct(boolean) — whentrue, thecurrentActindex will be updated.
Returns
getCurrentAct(
): module:bags/ActivitySequenceElement.ActivitySequenceElement
Gets the sequence element pointed by the currentAct member.
Returns
hasNextAct(hasReturn: boolean): boolean
Checks if it's possible to go forward from the current position in the sequence.
Parameters
hasReturn(boolean) — Indicates whether the history of jumps done since the beginning
of the JClic session is empty or not. When not empty, aRETURNaction is still possible.
Returns
boolean
hasPrevAct(hasReturn: boolean): boolean
Checks if it's possible to go back from the current position in the sequence.
Parameters
hasReturn(boolean) — Indicates whether the history of jumps done since the beginning
of the JClic session is empty or not. When not empty, aRETURNaction is still possible.
Returns
boolean
getNavButtonsFlag(): string
Gets the current state for the 'next' and 'prev' buttons.
Returns
string
getJump(
back: boolean,
reporter: module:report/Reporter.Reporter,
): module:bags/JumpInfo.JumpInfo
Computes the jump to perform from the current position on the sequence
Parameters
back(boolean) — Whentrue, the request is for the 'go back' button. Otherwise, is
for the 'next' one.reporter(module:report/Reporter.Reporter) — The reporting engine that will provide values about score average
and time spend on the activities, used only to compute conditional jumps.
Returns
getSequenceForElement(num: number): string
Finds the nearest sequence element with a valid 'tag', looking back in the elements list.
Parameters
num(number) — The point of the sequence from which to start looking back.
Returns
string
getElementByActivityName(
activity: string,
): module:bags/ActivitySequenceElement.ActivitySequenceElement
Gets the first ActivitySequenceElement in the elements list pointing to the
specified activity name.
The search is always case-insensitive.
Parameters
activity(string) — The name of the activity to search for.
Returns
module:bags/ActivitySequenceElement.ActivitySequenceElement— The requested element ornullif not found.
checkCurrentActivity(activity: string)
Utility function to check if the current sequence element corresponds to the specified
activity. If negative, the currentAct will be accordingly set.
Parameters
activity(string) — The name of the activity to check
Instance Fields
elements: Array.<module:bags/ActivitySequenceElement.ActivitySequenceElement>
The ordered list of ActivitySequenceElement objects
project: module:project/JClicProject.JClicProject
The JClic project to which this ActivitySequence belongs.
currentAct: number
Pointer to the ActivitySequenceElement currently running (points inside
the elements array).