smerf_answer.rb

Path: app/models/smerf_answer.rb
Last Update: Sat Jan 12 15:57:19 +1100 2008

This class contains details about answers to form questions, it derives from SmerfItem.

It knows how to handle subquestions. Subquestions are additional questions that a user can answer if certain answers are selected. An example subquestion would be where an Other is provided as one of the answers to a question, a subquestion can be defined to display a text field to accept more information.

Question answers are defined using the following fields:

code:Code to uniquely identify the answer, code needs to be unique for each question (mandatory). The value specified here will be saved as the users response when the answer is selected.
answer:The text that will be displayed to the user (mandatory)
default:If set to Y then this answer will be selected by default (optional)
sort_order:The sort order for this answer (mandatory)
subquestions:Some answers may need additional information, another question can be defined to obtain this information. To define a subquestion the same fields that define a normal question is used (optional)

Here is an example answer definition:

     answers:
       1_20:
         code: 1
         answer: | 1-20
         sort_order: 1
         default: N
         ...

[Validate]