Class: App

App(session, id)

Class that represents an app.

Constructor

new App(session, id)

Creates an App.

Parameters:
Name Type Description
session Session

description

id String

description

Source:

Members

activeScreen

Shown on all client playing screens if Stage.useAppActiveScreen = true.

Default Value:
  • null
Source:

appPath

Where the original definition of this app is stored on the server.

Source:

description :String

Description of this App.

Type:
  • String
Default Value:
  • 'No description provided.'
Source:

finished :boolean

TODO: Description

Type:
  • boolean
Default Value:
  • false
Source:

groupingType

TODO:

Source:

groupMatchingType :string

The matching type to be used for groups in this App.

Type:
  • string
Default Value:
  • 'STRANGER'
Source:

groupSize :number

If defined, subjects are assigned randomly to groups of this size takes precedence over numGroups.

Type:
  • number
Default Value:
  • undefined
Source:

hasError

Indicates whether or not the code for this app compiles to an error or not.

Source:

html :String

Shown on all client screens.

Type:
  • String
Source:

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.

Source:

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
Source:

insertJtreeRefAtStartOfClientHTML :boolean

Inserts jtree functionality to the start of client.html

Type:
  • boolean
Default Value:
  • true
Source:

isStandaloneApp

Source:

jt :jt

Type:
Source:

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
Default Value:
  • []
Source:

messages :Object

Messages to listen for from clients.

Type:
  • Object
Default Value:
  • {}
Source:

numGroups :number

if defined, subjects are split evenly into this number of groups
overridden by groupSize.

Type:
  • number
Default Value:
  • undefined
Source:

numPeriods :number

The number of periods in this App.

Type:
  • number
Default Value:
  • 1
Source:

options :Array

The options of this app.

Type:
  • Array
Default Value:
  • []
Source:

optionValues :Object

The option values of this app.

Type:
  • Object
Default Value:
  • {}
Source:

outputHide :array

Type:
  • array
Default Value:
  • []
Source:

periods :Array

The periods of this App.

Type:
  • Array
Default Value:
  • []
Source:

screen

TODO:

Source:

session :Session

The Session that this App belongs to.

Type:
Source:

stageContentEnd :string

Ends the stages of this App.
TODO:

Type:
  • string
Default Value:
  • ''
Source:

stageContentStart :string

Starts the stages of this App.
TODO:

Type:
  • string
Default Value:
  • ''
Source:

stages :Array

The stages of this app.

Type:
  • Array
Default Value:
  • []
Source:

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
Default Value:
  • true
Source:

suggestedNumPlayers

If not null and this is the first App in a Session, sets the initial number of players to this amount.

Source:

textMarkerBegin

Used by the participant client to find and create dynamic text elements.

Source:

waitForAll :boolean

Whether or not to wait for all participants before starting the app.

Type:
  • boolean
Default Value:
  • true
Source:

waitingScreen

Shown on all client waiting screens if Stage.useWaitingScreen = true.

Source:

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.

Source:
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

Source:
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.

Source:

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.

Source:

addStage(name)

Adds a stage, with contents loaded from .jtt file.

Parameters:
Name Type Description
name
Source:

addStages()

TODO

Source:

getGroupIdsForPeriod()

TODO
Get group ids for their current period

Source:

getNextStageForPlayer()

Get next stage for player in their current period. Return null if already at last stage of period.

DUE TO:
Stage.playerEnd

Source:

getOutputFN() → {string}

Source:
Returns:

Session path + App#indexInSession + '_' + app.id

Type
string

getParticipantDuration()

Returns the amount of time this participant has to play this app.

Source:

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
Source:

indexInSession() → {number}

Source:
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.

Source:

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

Source:

metaData() → {type}

metaData - description

Source:
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.

Source:
Returns:

The new stage.

Type
Stage

nextStageForGroup(group) → {null|Stage}

Returns the next stage for a given group in a given stage.

  1. If stage is not the last stage of this app, return the next stage of this app.
  2. If period is not the last period of this app, return the first stage of this app.
  3. If app is not the last app of this session, return the first stage of the next app.
  4. Otherwise, return null.

TODO: Does the next stage have Stage.waitForGroup == true?

CALLED FROM

Parameters:
Name Type Description
group Group

The group

Source:
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

Source:

outputFields() → {Array}

The names of fields to include in an export of this object. To be included, a field must:

Source:
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.

Source:

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.

Source:

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.

Source:

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

Parameters:
Name Type Description
participant type

description

Source:
Returns:

description

Type
type

participantStart(participant) → {type}

Overwrite in app.jtt.

Parameters:
Name Type Description
participant type

description

Source:
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.

Source:
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.

Source:
Returns:

The previous player, if any.

Type
Player

roomId() → {string}

roomId - description

Source:
Returns:

Session#roomId + 'app' + this.id

Type
string

save()

Save this App to the session .gsf file.

CALLED FROM:

Source:

saveSelfAndChildren() → {type}

saveSelfAndChildren - description

CALLED FROM:

Source:
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

Source:
Returns:

description

Type
Object

shellWithChildren() → {type}

A shell of this object. Excludes parent, includes child shells.

CALLED FROM:

Source:
Returns:

description

Type
type

shellWithParent() → {type}

A shell of this object. Includes parent shell, excludes child shells.

Source:
Returns:

description

Type
type

tryToEndApp() → {type}

If all participants have finished the app, end the app (App#end).

CALLED FROM

Source:
Returns:

description

Type
type