Laying Grounds for QuizSession Implementation

Let's start making our second GenServer, the quiz session.

The quiz session will use the code we implemented in our functional core along with the code that answers and selects questions for a given user. Our core implements the business functions that advance the state of the quiz based on mastery. The quiz session will add the process machinery we’ll need to manage state independently.

Data required by the user

Each of our users will need the following to give the quiz:

  • The state for the quiz they’re working through.

  • Their own email address for their answers.

The state for our GenServer will be a tuple with quiz email.

For now, we won’t worry about starting and stopping that server. We’ll just make sure it works with a single process.

Creating the quiz session

Let’s start with the quiz session. We’ll open the new file lib/mastery/boundary/quiz_session.ex and key this in:

Get hands-on with 1200+ tech skills courses.