Hi
I am trying to set up a Quiz Server based on the book Designing Elixir Systems with OTP. (A Quiz Game), where I want to be able to choose a template, create a quiz with it, and then follow as the user goes through the questions one by one.
The design works well in iex, and I am now trying to set up an interface in Phoenix.
Currently, there are two inputs that are automatically generated using functions, the validator (to test if the answer provided is correct) and the input generator (that basically generates the list of inputs to answer).
For instance a multiplication template would accept a list of inputs {left: [7}, right: 1…10} and generate out of it all the combinations so the kid can test the full table. In this case the validator just tests that the input is left * right. But the validator could test the distance in the case of the capital of a country to see if it is “close enough”, and say it is correct.
My problem is that now I want to store the functions in Ecto. I have thought of serializing the function but I don’t know if there is an easy way of doing that and I’ve read this thread (How to serialize anonymous function in disk - #6 by OvermindDL1) that seems to be against it.
Is there a good way of storing the functions in Ecto?