Identifying the Data of Our Project—Continued
Let’s define the remaining modules for our project.
The user answers with responses
When a user answers a question, we’ll generate a response. Our responses don’t need too much data. We’ll track extra data we might have otherwise computed to make it easy to debug and reason about the program. This is the data we want to track:
-
quiz_title
(String.t): Title field from the quiz. -
template_name
(atom): Name field identifying the template. -
to
(String.t): The question being answered, as in “this is a response to the asked question.” -
email
(String.t): The email address of the user answering the question. -
answer
(String.t): The answer provided by the user. -
correct
(boolean): Whether the given answer was correct. -
timestamp
(Time.t): The time the answer was provided.
The code to implement those fields is, as we might expect, a struct. We’ll create a new file named response.ex
in /lib/mastery/core
and make it look like this:
Get hands-on with 1200+ tech skills courses.