Player state

Parsing the player state

Getting state

The player state is available by using the following method: playerObj.getState(); which results in the JSON string.


  • JSON object – a string which returns an object when parsing it in any JSON parser. Examples: "{}", "{a: 123}"

Player state description

There is the possibility of parsing the player state string, e.g. by the JavaScript function JSON.parse(state); As a result, the JSON parser should return an object with 5 fields:

  • isReportable – a JSON object in which the keys are page ids and the values indicate the reportable state of this page. The Player fills this object when the page reportable state is changed during the lesson execution, e.g. by calling setAsNonReportable or setAsReportable.
  • score – a JSON object in which the keys are page ids and the values indicate another JSON object. Warning: This object contains only the pages, which have been visited by the user. The Player is not able to calculate scores, maxScores, etc. for the pages which have not visited.
    • value – as mentioned above, the value is the JSON object. This object contains the specific fields:
      • score – score of the page,
      • maxScore – max score of the page,
      • checkCount – numbers of checks on the page,
      • errorCount – number of errors,
      • mistakeCount - Number of mistakes.
  • state – a JSON object in which the keys are the concatenated page id (player.getPlayerServices().getPresentation().getPage(<page number>).getId();) with the module id and the module state as values. The key is created by "<page_id><module_id>" template string. In case of finding all modules on the page, it is necessary to provide a relevant page id. It can be extracted from the player. Additionally, there is one more entry of the state used internally by the player. It is defined as "<page_id>ICPLAYER_PAGE_HEIGHT_MODIFICATIONS"and contains the list of page height modifications during the lesson execution.
  • time – JSON string which contains
    • pages_times – an object where the key is a page id and the value is time in seconds (How much time the user has spent on this page in miliseconds)
  • visitedPages – a list of pages ids visited by the user. This list is separated by ;