bags/ActivitySequence. ActivitySequence

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)

ActivitySequence constructor

Parameters:
NameTypeDescription
projectmodule:project/JClicProject.JClicProject

The JClic project to which this ActivitySequence belongs

Members

currentAct :number

Pointer to the ActivitySequenceElement currently running (points inside
the elements array).

Type:
  • number

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.

Methods

checkCurrentActivity(activity)

Utility function to check if the current sequence element corresponds to the specified
activity. If negative, the currentAct will be accordingly set.

Parameters:
NameTypeDescription
activitystring

The name of the activity to check

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:
  • The resulting object, with minimal attrributes
Type: 
object

getCurrentAct() → {module:bags/ActivitySequenceElement.ActivitySequenceElement}

Gets the sequence element pointed by the currentAct member.

Returns:
  • The current sequence element, or null if not set.
Type: 
module:bags/ActivitySequenceElement.ActivitySequenceElement

getElement(n, updateCurrentAct) → {module:bags/ActivitySequenceElement.ActivitySequenceElement}

Returns the nth element of the sequence.

Parameters:
NameTypeDescription
nnumber

Index of the requested element

updateCurrentActboolean

when true, the currentAct index will be updated.

Returns:
  • The requested element, or null if out of range.
Type: 
module:bags/ActivitySequenceElement.ActivitySequenceElement

getElementByActivityName(activity) → {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:
NameTypeDescription
activitystring

The name of the activity to search for.

Returns:

The requested element or null if not found.

Type: 
module:bags/ActivitySequenceElement.ActivitySequenceElement

getElementByTag(tag, updateCurrentAct) → {module:bags/ActivitySequenceElement.ActivitySequenceElement}

Search into the sequence for a element with the provided tag

Parameters:
NameTypeDescription
tagstring

The tag to search

updateCurrentActboolean

when true, the currentAct index will be updated.

Returns:
  • The requested element, or null if not found.
Type: 
module:bags/ActivitySequenceElement.ActivitySequenceElement

getElementIndex(ase) → {number}

Returns the index of the specified element in the sequence.

Parameters:
NameTypeDescription
asemodule:bags/ActivitySequenceElement.ActivitySequenceElement

The element to search.

Returns:
  • The requested index, or null if not found.
Type: 
number

getJump(back, reporter) → {module:bags/JumpInfo.JumpInfo}

Computes the jump to perform from the current position on the sequence

Parameters:
NameTypeDescription
backboolean

When true, the request is for the 'go back' button. Otherwise, is
for the 'next' one.

reportermodule: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:
  • The jump info if a valid jump is possible, null otherwise.
Type: 
module:bags/JumpInfo.JumpInfo

getNavButtonsFlag() → {string}

Gets the current state for the 'next' and 'prev' buttons.

Returns:
  • One of the possible values of navButtons,
    thus: none, fwd, back or both
Type: 
string

getSequenceForElement(num) → {string}

Finds the nearest sequence element with a valid 'tag', looking back in the elements list.

Parameters:
NameTypeDescription
numnumber

The point of the sequence from which to start looking back.

Returns:
  • The nearest 'tag', or null if not found.
Type: 
string

hasNextAct(hasReturn) → {boolean}

Checks if it's possible to go forward from the current position in the sequence.

Parameters:
NameTypeDescription
hasReturnboolean

Indicates whether the history of jumps done since the beginning
of the JClic session is empty or not. When not empty, a RETURN action is still possible.

Returns:
  • true when the user is allowed to go ahead to a next activity,
    false otherwise.
Type: 
boolean

hasPrevAct(hasReturn) → {boolean}

Checks if it's possible to go back from the current position in the sequence.

Parameters:
NameTypeDescription
hasReturnboolean

Indicates whether the history of jumps done since the beginning
of the JClic session is empty or not. When not empty, a RETURN action is still possible.

Returns:
  • true when the user is allowed to go back to a previous activity,
    false otherwise.
Type: 
boolean

setAttributes(data)

Loads the object settings from a data object

Parameters:
NameTypeDescription
dataobject

The data object to parse

setProperties($xml)

Loads the object settings from a specific JQuery XML element

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The XML element to parse