Test-driving the two user sessions crashes (as one might already expect while refactoring for the Lifecycle part) because the returned session handle from the new take_quiz
function is not a :via
tuple, yet it is passed directly to GenServer.call
in the deliberately unchanged select_question
and answer_question
functions.
As long as we do not want API users to have to call Mastery.Boundary.QuizSession.via
themselves, we should either call it in the two mentioned API functions before calling GenServer
, or just return a :via
tuple as the session token, which I think is easier:
def take_quiz(title, email) do
with %Quiz{}=quiz <- QuizManager.lookup_quiz_by_title(title),
{:ok, _} <- QuizSession.take_quiz(quiz, email)
do
QuizSession.via({title, email})
else
error -> error
end
end