Constructor
new App(session, id)
Creates an App.
Parameters:
Name | Type | Description |
---|---|---|
session |
Session | description |
id |
String | description |
Members
activeScreen
Shown on all client playing screens if Stage.useAppActiveScreen = true.
appPath
Where the original definition of this app is stored on the server.
description :String
Description of this App.
Type:
- String
finished :boolean
TODO: Description
Type:
- boolean
groupingType
TODO:
groupMatchingType :string
The matching type to be used for groups in this App.
Type:
- string
groupSize :number
If defined, subjects are assigned randomly to groups of this size takes precedence over numGroups.
Type:
- number
hasError
Indicates whether or not the code for this app compiles to an error or not.
html :String
Shown on all client screens.
Type:
- String
htmlFile
If 'htmlFile' is not null, content of 'htmlFile' is added to client content.
Otherwise, if 'htmlFile' is null, content of this.id + ".html" is added to client content, if it exists.
id :String
The unique identifier of this App. In order of precedence, the value is given by:
- the explicit value in the .jtt file (if it has been set)
- the name of the .jtt file (if it is not app.jtt or app.js)
- the name of the folder containing the .jtt file
Type:
- String
insertJtreeRefAtStartOfClientHTML :boolean
Inserts jtree functionality to the start of client.html
Type:
- boolean
isStandaloneApp
jt :jt
Type:
keyComparisons :Array
Array of comparisons to show by default on Session -> Data tab.
Each entry consists of:
- field name (i.e. 'player.points')
- x-axis object (i.e. 'player')
- y-axis object (i.e. 'period')
Field values are aggregated using the arithmetic mean as necessary (for example, if field is player.x, but x-axis is group, then table shows arithmetic mean of all player.x in a group).
Type:
- Array
messages :Object
Messages to listen for from clients.
Type:
- Object
numGroups :number
if defined, subjects are split evenly into this number of groups
overridden by groupSize.
Type:
- number
numPeriods :number
The number of periods in this App.
Type:
- number
options :Array
The options of this app.
Type:
- Array
optionValues :Object
The option values of this app.
Type:
- Object
outputHide :array
Type:
- array
periods :Array
The periods of this App.
Type:
- Array
screen
TODO:
session :Session
The Session that this App belongs to.
Type:
stageContentEnd :string
Ends the stages of this App.
TODO:
Type:
- string
stageContentStart :string
Starts the stages of this App.
TODO:
Type:
- string
stages :Array
The stages of this app.
Type:
- Array
stageWrapPlayingScreenInFormTag :String
Set default value for Stage.wrapPlayingScreenInFormTag.
If 'yes', then form is added.
If 'no', no form is added.
If 'onlyIfNoButton', then form is added only if page has no buttons.
Type:
- String
suggestedNumPlayers
If not null and this is the first App in a Session, sets the initial number of players to this amount.
textMarkerBegin
Used by the participant client to find and create dynamic text elements.
waitForAll :boolean
Whether or not to wait for all participants before starting the app.
Type:
- boolean
waitingScreen
Shown on all client waiting screens if Stage.useWaitingScreen = true.
Methods
(static) load(json, session) → {App}
Parameters:
Name | Type | Description |
---|---|---|
json |
Object | A json object containing the properties of the app. |
session |
Session | The session this app belongs to. |
Returns:
A new app initialized with the data in json.
- Type
- App
(static) newSansId(jt, appPath) → {App}
Parameters:
Name | Type | Description |
---|---|---|
jt |
type | description |
appPath |
type | The path relative to the server process. i.e. /apps/my-app.jtt or /apps/my-complex-app/app.js |
Returns:
The given app.
- Type
- App
addClient(client)
Overwrite to add custom functionality for when a Client starts this app.
Called from:
Parameters:
Name | Type | Description |
---|---|---|
client |
Client | The client who is connecting to this app. |
addClientDefault(client)
Called when a Client connected to a Participant starts this app.
- client subscribes to this App's channel.
- client registers custom messages it may send.
- client registers automatic stage submission messages it may send.
- load custom behaviour this.addClient.
Called from:
Parameters:
Name | Type | Description |
---|---|---|
client |
Client | The client who is connecting to this app. |
addStage(name)
Adds a stage, with contents loaded from .jtt file.
Parameters:
Name | Type | Description |
---|---|---|
name |
addStages()
TODO
getGroupIdsForPeriod()
TODO
Get group ids for their current period
getNextStageForPlayer()
Get next stage for player in their current period. Return null if already at last stage of period.
DUE TO:
Stage.playerEnd
getOutputFN() → {string}
Returns:
Session path + App#indexInSession + '_' + app.id
- Type
- string
getParticipantDuration()
Returns the amount of time this participant has to play this app.
groupMoveToNextStage(group)
- clear group's timer.
- if next stage exists, let the group play it.
- for each player in the group, call App#playerMoveToNextStage.
Parameters:
Name | Type | Description |
---|---|---|
group |
Group |
indexInSession() → {number}
Returns:
The index of this app in its session's list of apps (first position = 1).
- Type
- number
initPeriod(prd)
Creates a new period with the given id + 1, saves it and adds it to this App's periods.
Called from:
- App.participantBeginPeriod
Parameters:
Name | Type | Description |
---|---|---|
prd |
number | The index to assign to the new period. |
internalEnd()
Ends this App.
- Create headers for this app, periods, groups, group tables, players and participants.
- Create output.
- Write output to this session's csv file.
CALLED FROM
metaData() → {type}
metaData - description
Returns:
description
- Type
- type
newStage(id) → {Stage}
Creates a new Stage and adds it to the App.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The identifier of the stage. |
Returns:
The new stage.
- Type
- Stage
nextStageForGroup(group) → {null|Stage}
Returns the next stage for a given group in a given stage.
- If stage is not the last stage of this app, return the next stage of this app.
- If period is not the last period of this app, return the first stage of this app.
- If app is not the last app of this session, return the first stage of the next app.
- Otherwise, return null.
TODO: Does the next stage have Stage.waitForGroup == true?
CALLED FROM
Parameters:
Name | Type | Description |
---|---|---|
group |
Group | The group |
Returns:
The next stage for this group, or null.
- Type
- null | Stage
onPlayerFinished(player)
Called when a player finishes a stage.
By default, check whether everyone in group is finished.
If yes, then advance to next stage (this.session.gotoNextStage(player.group)).
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | description |
outputFields() → {Array}
The names of fields to include in an export of this object. To be included, a field must:
- not be a function (Utils.isFunction)
- not be included in App#outputHide
- not be included in App#outputHideAuto
Returns:
An array of the field names.
- Type
- Array
participantBegin(participant)
Called when a participant begins this app.
- For each of the Clients of this participant, call App.addClientDefault.
- Set the participant's periodIndex to -1.
- Participant notifies clients about appIndex.
- Move participant to next period App.participantMoveToNextPeriod.
- Participant notified clients about starting new app.
Parameters:
Name | Type | Description |
---|---|---|
participant |
Participant | The participant. |
participantBeginPeriod(participant)
A participant begins its current period.
- Participant notifies its clients of periodIndex.
- If current period undefined, initialize it (App.initPeriod).
- Participant begins period (Period.participantBegin).
Called from:
- App.participantMoveToNextPeriod.
Parameters:
Name | Type | Description |
---|---|---|
participant |
type | The participant. |
participantEndInternal(participant)
A participant finishes playing this app.
FUNCTIONALITY
- Participant's clients unsubscribe from messages from this app.
- Try to end the app (App#tryToEndApp).
CALLED FROM
- xxx
Parameters:
Name | Type | Description |
---|---|---|
participant |
Participant | The participant. |
participantMoveToNextPeriod(participant) → {type}
A participant moves to its next period.
FUNCTIONALITY
- If participant is currently in a period, end it (Period.participantEnd).
- Increment participant's period index.
- Save participant (Participant.save).
- If participant is has finished all periods in this app, move to next app (Session.participantMoveToNextApp).
- Otherwise, begin new period (App.participantBeginPeriod).
CALLED FROM
- App#playerMoveToNextStage
- App#participantBegin
Parameters:
Name | Type | Description |
---|---|---|
participant |
type | description |
Returns:
description
- Type
- type
participantStart(participant) → {type}
Overwrite in app.jtt.
Parameters:
Name | Type | Description |
---|---|---|
participant |
type | description |
Returns:
description
- Type
- type
previousGroup(group) → {Player}
Returns the group of the current player's participant from the previous period.
Parameters:
Name | Type | Description |
---|---|---|
group |
Group | The group. |
Returns:
TODO: The previous player, if any.
- Type
- Player
previousPlayer(player) → {Player}
Returns the player of the current player's participant from the previous period.
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | The player. |
Returns:
The previous player, if any.
- Type
- Player
roomId() → {string}
roomId - description
Returns:
Session#roomId + 'app' + this.id
- Type
- string
save()
saveSelfAndChildren() → {type}
Returns:
description
- Type
- type
shell() → {Object}
A shell of this object. Excludes parent and children. The shell is a simplified version of an object and any of its fields.
CALLED FROM
Returns:
description
- Type
- Object
shellWithChildren() → {type}
Returns:
description
- Type
- type
shellWithParent() → {type}
A shell of this object. Includes parent shell, excludes child shells.
Returns:
description
- Type
- type
tryToEndApp() → {type}
If all participants have finished the app, end the app (App#end).
CALLED FROM
Returns:
description
- Type
- type