JSAV-Palyer-Application-server

The server works as exercise service for our test LMS (test application front-end). Its duties are:

  1. Serve the JSAV Visual Algorithm Simulation exercises with the Exercise Recorder embedded in them and all necessary libraries.
  2. Server the Exercise Player.
  3. Handle exercises submissions POST requests:
  4. Receive the exercises submissions POST requests, which include the data recorded by the Exercise Recorder.
  5. Send the data to the database (the DB is not included in this repository).
  6. Respond to the POST request by sending an <iframe> as string that loads the Exercise Player and includes as URL parameter of the src attribute the URL for fetching the data recorded by the Exercise Recorder:
`"<iframe id="player" title="player" src="${server}/jsav-player/player.html?submission=${url}"</frame>"`
  1. Serve the Exercise Player.
  2. Handle GET requests containing the submission URL parameter:
  3. Fetch the submission from the database according to the given submission id (in the URL parameter).
  4. Respond by sending the data retrieved from the database.

Configurations

The files in the ./public folder and its subfolder can be directly accessed:

app.use(express.static('public'))

Database URL

The server is written to work with a MongoDB database, so you will need to set up one of your own and then follow the instructions below on where to add the user username, password and collection that the server should use.

If you run the server locally, for example during development, the database URL (which includes username and password) should be defined in a file called .dbConf.js under ./db/. An example of .dbConf.js file is shown in /db/.dbConf-sample.js(https://github.com/MarianiGiacomo/jsav-palyer-application-test-server/blob/master/db/.dbConf-sample.js).

When you deploy your server, the database URI should instead be given as DATABASE_URL environment variable.

In ./db/db.js you might want to redefine the collection name where the received data will be save. Currently DBCOLLECTION is set to submissions.

Starting the Server

  • For development: npm run dev. Will reload each time you save a change.
  • npm start.