views:

77

answers:

1

Scenario: There is this online questionaire that will be filled in by various departments in a company. The questions are data driven and are different for each department. But for some of the questions, the way the input is taken is also different; for some departments the same question is asked to be replied to, by selecting values from a drop down, for the others its free text entry; again, for some departments you change the caption against the area for entry. This caption is not part of the question. its also not coming from the database as of now and Id rather not put it all in the database and increase the joins for each select. Out of the twenty odd questions which have such captions, there are just 3 such captions which change.

for eg.

Department A.)

Q.) How would you like to get here? {caption:"Enter your prefered transport method"} [Free Text Box]

Department B.)

Q.) How would you like to get here? {caption:"Select option"} [Drop Down]

What would be the best way to design and code such web based questionairre of the ways below?

  • Implement it using if-else conditions for each department and show and hide input controls as per department
  • Abstract all common inputs into a parent class and have multiple child classes for each department which contain their own specific behavior for data input

Any other better way?

Thanks for your time. :)

A: 

I would recommend using if/else statements to show and hide the various questions.

The reason why I say if/else instead of sub-classing is that you'll come across a case where a question which used to be "common" to all Departments becomes specific to a few, and you'll have to refactor that question to the sub-classes and delete it where it's not applicable. The if/else code may get tedious, but not more tedious than the refactor I mention above.

In addition, I would also urge you to strongly consider normalizing the questions of your survey. In other words, in the example you provided above, I would make the free text and option two different questions. This doesn't change how the answers are input, it just changes how you consider the different questions.

The reason why I'm saying this is that any analysis you will be doing on the answers is dependent on comparing apples to apples -- when you restrict or free the list of available choices, you're comparing apples to oranges.

micahtan
thanks for the answer. About the database structure. We decided not to normalize it to that level because there are already too many tables in join queries for one of the read only pages which is used heavily by upto 500 concurrent users during peak time,and this being an internal app with not so much spending done on hardware, we decided to keep the table count to as less as we could. I see your point abt the analysis part though. However those fields that are accepted in free text/dropdown are not included for the analysis.