Implement template creation

Now question templates work in both directions: turning a question
into a template, and creating a new question based on a template.