{{warning}}

Launching the Player

The item player presents a question or questions to a student, captures the student's response, and enables the viewing of or analysis of a set of responses for a student or for a group of students. To launch the item player:

  1. Choose options to pass to the player on launch (itemId or sessionId is required at a minimum)
  2. Choose the mode in which to launch the player (gather, view, or evaluate)
  3. Create a player access token to grant access to the player on a browser
  4. Load the player javascript in the page, passing the player access token and API client id
  5. Launch the player

Example

After creating a player access tokenthe item player may be loaded in a page with this url and these parameters:

http://platform.corespring.org/v2/player/player.js

Parameter Description
playerToken The player access token created for player access settings
apiClient The API client id. The system will use this to locate the organization's client secret to decrypt the token
    <head>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
      <script type='text/javascript' src='http://platform.corespring.org/v2/player/player.js?playerToken=[playerAccessToken]&apiClient=[apiClientId]'></script>

      <script type='text/javascript'>
      // callbacks
      function inputReceived(itemStatus) {
        console.log(itemStatus);
      }
      function sessionCreated(sessionId) {
        console.log(sessionId);
      }

      $(function() {
        var options = {
          mode: 'gather',
          onInputReceived: inputReceived,
          onSessionCreated: sessionCreated
        };

        new org.corespring.players.ItemPlayer('#player', options,
          // failure callback
          function(e) {
            console.log(e);
          }
        );
      });
    </script>
  </head>
  <body>
    <div id="player"/>
  </body>

Removing the Player

To remove the player call remove().

    $(function(){
      var player = new org.corespring.players.ItemPlayer('#player', options);
      //do stuff..
      player.remove();
    });

If using a modern browser (e.g., Chrome, Firefox, Opera) and the app removes the dom node that contains the player, then explicitly calling remove() is not necessary. An explicit call to remove() is required for IE.