...
The script receives the launch_token and the anonymous_id from URL parameters.
If the launch_token is missing, it assumes that the activity is a preview and assigns the reserved preview token ("0000000-0000-4000-a000B000-000000000000").
It then initializes the user’s score (0), and a container to record the user’s responses ([]).
A function is defined, checkAnswer(), which is called when the answer button (answer-btn) is pressed. The checkAnswer() function…
records a timestamp of the user’s response (in Unix timestamp format, the number of milliseconds since January 1, 1970)
establishes the correct answer
evaluates the correctness of the user’s response
updates the user’s score
pushes the user’s response into the response container
displays the contents of the response container and enables a final submit button
The function submit() is called when the user presses the submit button, which redirects the user back to Terracotta with the provided launch_token and calculated score.