Integrate isRequired into templates

Note that this involved a minor change to the function: instead of
returning a boolean, it now returns either 'required' or ''  (to
simplify integration with HTML5 form elements.

Also note that in addition to the HTML5 form element attribute, a
'required' CSS class is added to the div which contains the question.