Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Package com.RuntimeCollective.questionnaire.bean

The Questionnaire modules allows for the creation of complex Questionnaires, and the processing of data submitted by Users.

See:
          Description

Interface Summary
Answer Interface to implement if you want to create a new kind of Answer for Questionnaires.
Question Interface to implement if you want to create a new kind of Question for Questionnaires.
 

Class Summary
ClusterSafeQuestionnaire An extension of Questionnaire that is (I really hope) cluster-safe (i.e.
ManyInManyStringsQuestion Question implementation which offers the choice of many Strings between many.
ManyStringAnswer Answer implementation which consists of a Collection of Strings.
OneInManyStringsQuestion Question implementation which offers the choice of one String between many.
OneStringAnswer Answer implementation which consists of a String.
Questionnaire The Questionnaire class, which is basically a Publishable container of Questions and UserAnswers.
QuestionnaireLink The QuestionnaireLink class implements the abstract Link class, by linking to a Questionnaire.
SimpleAnswer Basic and incomplete implementation of the Answer interface, which you can subclass at will to create new types of Answers.
SimpleQuestion Basic and incomplete implementation of the Question interface, which you can subclass at will to create new types of Questions.
UserAnswers The UserAnswers class, which is basically a set of Answers given by a User to a Questionnaire.
XInManyStringsQuestion Common superclass for OneInManyStringsQuestion and ManyInManyStringsQuestion - contains methods useful for both.
 

Package com.RuntimeCollective.questionnaire.bean Description

The Questionnaire modules allows for the creation of complex Questionnaires, and the processing of data submitted by Users.


1. General framework

questionnaire.bean.Questionnaire defines a Questionnaire as a list of questionnaire.bean.Questions. Questionnaires are sitemap.bean.Publishables, ie they have a life span.

questionnaire.bean.UserAnswers defines what a User's answers to a Questionnaire is: a list of questionnaire.bean.Answers.

The questionnaire.bean.Question interface defines a generic contract for all types of Questions. It is at the moment implemented by questionnaire.bean.SimpleQuestion, questionnaire.bean.OneInManyStringsQuestion, questionnaire.bean.ManyInManyStringsQuestion. OneStringQuestion may happen one day.

The questionnaire.bean.Answer interface defines a generic contract for all types of Answers. It is at the moment implemented by questionnaire.bean.SimpleAnswer, questionnaire.bean.OneStringAnswer, and questionnaire.bean.ManyStringAnswer.

2. Processing a Questionnaire

The processing of a Questionnaire is handled by questionnaire.action.ProcessQuestionnaireAction. This action should not be extended - it is sufficient as is. What it does is call a particular subclass of questionnaire.form.QuestionnaireForm, which will be able to process the data submitted by the user.

The processing consists in gathering the data (as a list of Objects - Strings usually), and giving them to a newly created UserAnswers. The UserAnswers will pass on each element of the answer to the Question it is meant to answer. The Question will test if that element of data is valid: a Question knows which Answers would satisfy it. For example, OneInManyStringsQuestion is only satisfied by a String whose value is one of the possible choices. If the element of data is not valid, a questionnaire.InvalidAnswerException will be thrown. Otherwise, the Question will create a new Answer encapsulating the valid data, and will return it to the UserAnswers. Thus the UserAnswers will collect all validated Answers, and save itself.

3. Creating a Questionnaire

If you want to create new types of Questionnaires, you will have to:
  1. create new types of Questions and new types of Answers, if the existing ones are not sufficient
  2. write a fancy JSP which will let people fill in this type of Questionnaire
  3. create a new subclass of QuestionnaireForm, which will be able to collect the data submitted by the User in the JSP above. It will pass the data onto a UserAnswers
  4. write some Forms (to complement the basic questionnaire.form.EditQuestionnaireForm) and an Action to let admin users configure questionnaires
You can get some further help by looking at how Polls were implemented:
  1. Polls use OneInManyStringsQuestion and OneStringAnswer, or optionally ManyInManyStringsQuestion and ManyStringAnswer, if using multiple-choice questions
  2. /web/viewPoll.jsp in the Sussex Enterprise project displays a Poll for the User to answer
  3. questionnaire.form.PollForm lets Users submit one String, or a String[], if using ManyStringAnswers
  4. questionnaire.form.PollQuestionsForm, questionnaire.form.EditPollForm and questionnaire.action.EditPollAction let admin User edit the Polls
Ideally, once we have created classes which support dynamic (n-questions) questionnaires, steps 2 and 3 may not be necessary anymore.