The server works as exercise service for our test LMS (test application front-end). Its duties are:
- Serve the JSAV Visual Algorithm Simulation exercises with the Exercise Recorder embedded in them and all necessary libraries.
- Server the Exercise Player.
- Handle exercises submissions
POST
requests: - Receive the exercises submissions POST requests, which include the data recorded by the Exercise Recorder.
- Send the data to the database (the DB is not included in this repository).
- Respond to the POST request by sending an
<iframe>
as string that loads the Exercise Player and includes as URL parameter of thesrc
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>"`
- Serve the Exercise Player.
- Handle
GET
requests containing thesubmission
URL parameter: - Fetch the submission from the database according to the given submission id (in the URL parameter).
- Respond by sending the data retrieved from the database.
The files in the ./public
folder and its subfolder can be directly accessed:
app.use(express.static('public'))
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
.
- For development:
npm run dev
. Will reload each time you save a change. npm start
.