report/TCPReporter. TCPReporter

This special case of Reporter connects with an external service reporter providing
the JClic Reports API.
Connection parameters to the reports server (path, service, userId, key, context...)
are passed through the options element of JClicPlayer (acting as JClicPlayer).

Constructor

new TCPReporter(ps)

TCPReporter constructor

Parameters:
NameTypeDescription
psmodule:JClicPlayer.JClicPlayer

The JClicPlayer used to retrieve settings and localized messages

Extends

  • module:reports/Reporter.Reporter

Members

DEFAULT_SERVER_PATH :string

Default path of JClic Reports Server

Type:
  • string

DEFAULT_SERVER_PROTOCOL :string

Default server protocol
Use always 'https' except when in 'http' and protocol not set in options

Type:
  • string

DEFAULT_SERVER_SERVICE :string

Default name for the reports service

Type:
  • string

DEFAULT_TIMER_LAP :number

Default lap between calls to flushTasks, in seconds

Type:
  • number

actCount :number

Number of activities processed

Type:
  • number

beforeUnloadFunction :function

Function to be called by the browser before leaving the current page

Type:
  • function

currentSessionId :string

Identifier of the current session, provided by the server

Type:
  • string

dbProperties :object

Object used to store specific properties of the connected reports system

Type:
  • object

descriptionDetail :string

Additional info to display after the reporter's description

Type:
  • string

descriptionKey :string

Description of this reporting system

Type:
  • string

failCount :number

Counter of unsuccessful connection attempts with the report server

Type:
  • number

forceFlush :boolean

Force processing of pending tasks as soon as possible

Type:
  • boolean

lastActivity :module:report/ActivityReg.ActivityReg

Last activity reported

maxFails :number

Maximum number of failed attempts allowed before disconnecting

Type:
  • number

processingTasks :boolean

Flag used to indicate if transaction is currently running

Type:
  • boolean

serverPath :string

Main path of the reports server (without protocol nor service)

Type:
  • string

serviceUrl :string

Service URL of the JClic Reports server

Type:
  • string

tasks :Array.<module:report/TCPReporter.ReportBean>

List of ReportBean objects pending to be processed

timer :number

Identifier of the background function obtained with a call to window.setInterval

Type:
  • number

timerLap :number

Time between calls to the background function, in seconds

Type:
  • number

waitingTasks :Array.<module:report/TCPReporter.ReportBean>

Waiting list of tasks, to be used while tasks is being processed

Methods

addTask(bean)

Adds a new element to the list of report beans pending to be transmitted.

Parameters:
NameTypeDescription
beanmodule:report/TCPReporter.ReportBean

createDBSession(forceNewSession) → {external:Promise}

Creates a new session in the remote database and records its ID for future use

Parameters:
NameTypeDescription
forceNewSessionboolean

When true, a new session will always be created.

Returns:
  • A Promise reporter will be successfully resolved
    only when currentSessionId have a valid value.
Type: 
external:Promise

end() → {external:Promise}

Closes this reporting system

Returns:
  • A promise to be fullfilled when all pending tasks are finished, or null if not active.
Type: 
external:Promise

endActivity(score, numActions, solved)

This method should be called when the current activity finishes. Data about user's final results
on the activity will then be saved.

Parameters:
NameTypeDescription
scorenumber

The final score, usually in a 0-100 scale.

numActionsnumber

The total number of actions done by the user to solve the activity

solvedboolean

true if the activity was finally solved, false otherwise.

flushTasksPromise() → {external:Promise}

Transmits all report beans currently stored in tasks to the reports server

Returns:
Type: 
external:Promise

getGroups() → {external:Promise}

Gets the list of current groups or organizations registered on this reporting system.

Returns:
  • When fulfilled, an array of group data is returned as a result
Type: 
external:Promise

getProperty(key, +) → {string}

Gets a specific property from this reporting system

Parameters:
NameTypeDescription
keystring

Requested property

+string

defaultValue - Default return value when requested property does not exist

Returns:
Type: 
string

getUserData(userId) → {external:Promise}

Gets extended data associated with a specific user.

Parameters:
NameTypeDescription
userIdstring

The requested user ID

Returns:
  • When fulfilled, an object with user data is returned.
Type: 
external:Promise

getUsers(+) → {external:Promise}

Gets the list of users currently registered in the system, optionally filtered by
a specific group ID.

Parameters:
NameTypeDescription
+string

groupId - Optional group ID to be used as a filter criteria

Returns:
  • When fulfilled, an object with a collection of user data records
    is returned
Type: 
external:Promise

init(optionsopt) → {external:Promise}

Initializes this report system with an optional set of parameters.
Returns a Promise, fulfilled when the reporter is fully initialized.

Parameters:
NameTypeAttributesDescription
optionsobject<optional>

Initial settings passed to the reporting system

Returns:
Type: 
external:Promise

newActivity(act)

This method should be invoked when the user starts a new activity

Parameters:
NameTypeDescription
actmodule:Activity.Activity

The Activity reporter has just started

newSession(jcp)

This method should be invoked when a new session starts.

Parameters:
NameTypeDescription
jcpmodule:project/JClicProject.JClicProject

The JClicProject this session refers to.

reportActivity(flushNow)

Prepares a ReportBean object with information related to the current
activity, and pushes it into the list of pending tasks, to be processed by the main timer.

Parameters:
NameTypeDescription
flushNowboolean

When true, the activity data will be sent to server as soon as possible

stopReporting() → {external:Promise}

Stops the reporting system, usually as a result of repeated errors or because the player
shuts down.

Returns:
  • A promise to be fullfilled when all pending tasks are finished.
Type: 
external:Promise

transaction($xml) → {external:jqXHR}

Performs a transaction on the remote server

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The XML element to be transmited, wrapped into a jQuery object

Returns:
  • The external:jqXHR obtained as a result of a call to $.ajax.
    This object should be treated as a Promise or
    as a JQuery Deferred object.
Type: 
external:jqXHR