Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. The script receives the launch_token and the anonymous_id from URL parameters.

  2. 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").

  3. It then initializes the user’s score (0), and a container to record the user’s responses ([]).

  4. A function is defined, checkAnswer(), which is called when the answer button (answer-btn) is pressed. The checkAnswer() function…

    1. records a timestamp of the user’s response (in Unix timestamp format, the number of milliseconds since January 1, 1970)

    2. establishes the correct answer

    3. evaluates the correctness of the user’s response

    4. updates the user’s score

    5. pushes the user’s response into the response container

    6. displays the contents of the response container and enables a final submit button

  5. 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.