Skip to content

Adding a Question Type

mnipper edited this page Oct 15, 2013 · 1 revision

Adding a new type of question involves several simple steps.

  1. Add a constant to serve as the name of the new question type in the QuestionType enum in the Question model class. This name must match the value written to the database in the back-end.
  2. Add the same name you specified as a constant in the enum to the QuestionFragmentFactory class. This will generate the correct QuestionFragment for your new question type.
  3. Add a new class for your question type fragment to the QuestionFragments package.

Other things to know:

  • The questionComponent is an injected layout that acts as a placeholder for the question input. Add your generated views in your fragment to this ViewGroup.
  • You can get access to the current Survey, Question, and Response with the protected accessor methods in QuestionFragment.
  • The question text and buttons are all set in the SurveyFragment. The changing of the various QuestionFragments also takes place here.