Building Our Quizzes
Explore how to construct quizzes in Elixir by leveraging quiz builder functions and question templates. Understand the process of merging default attributes with overrides to create flexible quiz structures. This lesson demonstrates building a quiz with multiple templates and testing its implementation to ensure functionality.
We'll cover the following...
With the templates out of the way, the hard work is mostly done.
Building quizzes
We can focus on building quizzes now, which is nearly trivial at this point. We’ll add the following code to /test/support/quiz_builders.exs:
-
Our
quiz_fieldsfunction returns some default attributes and merges in overrides. -
Then all
build_quizhas to do is take the overrides, pipe them intoquiz_fields, and pipe that intoQuiz.new.
Building a question is also easy. Since we need only a template to generate a ...