- Clone the repository
- Add questions to the
questions.json
file - Run
node server.js
to start the server - Open
localhost:3000
in your browser
Note: the legacy way of doing it was python server.py
but python does not support websockets out of the box where Node.js does. So server.py
is deprecated in favor of server.js
.
Questions are stored in the questions.json
file. The questions are stored in an array of objects. Each object represents a question and has the following properties:
name
: The name of the questiontitle
: The title of the questiontype
: The type of question
See the SurveyJS documentation for the different question types and their properties. There are a lot of them, so I won't go into detail here.
As the user interacts with the quiz, the answers are stored in the answers.json
file. The answers are stored in an array of objects. Each object represents a question and has the following properties:
name
: The name of the questionvalue
: The value of the questioncorrectAnswer
: The correct answer to the questionisCorrect
: Whether the answer is correct
To run the solution, run python format_answers.py
. This will read the questions.json
and answers.json
files and format the answers into a human readable format.
First, you must use the node
version of the server (server.js
). It exposes a websocket and a /validate
endpoint you can POST to. It will request the HTML to annotate the UX.
If you want the Web UX to display the correct/incorrect state to the user, you can make a request to the quiz server:
curl -X POST localhost:3000/validate &> /dev/null