The "r" key of the $self object no longer exists. That was the modPerl Apache::Request object. WeBWorK 2.18 and 2.19 do not use modPerl anymore. Now there is a Mojolicious::Controller object. You can access that in the "c" key of the $self object. So use $self->{c} instead. The Mojolicious::Controller object has a "param" method that works the same as before. So the rest of your code should work.
Great! Thanks!