Look up mandatory questions via database
Remove commented out code
Only select question id instead of loading whole model
Simplify logic of filter
Move all progress calculation to server side

I don’t think the math in the previous version was correct
so neither is the new one.

Untested as yet as setting up a survey is difficult
Use scope defined in question
Greater than on strings is undefined

check for not null instead as there are no blank strings in the questionnaires
Store certificate in local variable

It is referenced so often that it cleans up the template a bit