...

/

Moving Our Tokens Through Transformations

Moving Our Tokens Through Transformations

Let’s learn how our tokens will progress throughout the course of the quiz.

We'll cover the following...

Moving our tokens

Remember, our quiz is a token, like a token on a game board.

  • Think of our token advancing through the game board squares where each square is a new question.

  • The most critical advancements happen when we choose a question and when the user answers questions.

  • The Quiz token will need to seamlessly move through states just as a token moves through the game.

Transitioning our template

We can now move a template from our master quiz.templates list to quiz.used with a question chosen. We’ll fill this in /lib/mastery/core/quiz.ex.

defp move_template(quiz, field) do
quiz
|> remove_template_from_category
|> add_template_to_field(field)
end
defp template(quiz), do: quiz.current_question.template

Moving a template to used or any other field is the same, so we generalize the concept:

  • We remove the template from the quiz.templates list.

  • We then add the template to the specified field of the ...