...

/

Adding Notifications to Mastery and the Boundary

Adding Notifications to Mastery and the Boundary

Let’s start working on the notifications to start and end our quizzes.

Adding a notification to start the quiz

Let’s add the notification to start_quiz in proctor.ex:

Press + to interact
def start_quiz(quiz, now) do
Logger.info "Starting quiz #{quiz.fields.title}..."
notify_start(quiz)
QuizManager.build_quiz(quiz.fields)
Enum.each(quiz.templates, &add_template(quiz, &1))
timeout = DateTime.diff(quiz.end_at, now, :millisecond)
Process.send_after(
self(),
{:end_quiz, quiz.fields.title, quiz.notify_pid},
timeout)
end

In start_quiz, we have two changes to make:

  • After we log the start of the quiz, we call our new notify_start function, ...