NAME

Liz::Survey::Question - module for Question objects of the Survey


SYNOPSIS

 use Liz::Survey;
 $survey = new Liz::Survey;

 $question = $survey->Question;
 $question = $survey->Question( $questionID );

 $question->update;


EXAMPLES


DESCRIPTION

Provide object oriented access to questions in a Survey. Usually not accessed directly, but rather through the Liz::Survey object and its Question method.


BASIC METHODS


new

Create a new Question object from a Survey object.

Input Parameters

 1 Liz::Survey object
 2 ID to created Question object with
   (default: none = new question)
Output Parameters

 1 instantiated object
Note

It is not intended to call this method directly, but rather indirectly through the Liz::Survey module.

Example

 $survey = new Liz::Survey;
 $question = $survey->Question;
 $question = $survey->Question( $questionID );


update

Update a Question object in the Liz::Survey database.

Output Parameters

 1 ID with which the object was updated (undef = error)
Example

 $questionID = $question->update;


delete

Delete a Liz::Survey::Question object from the database.

Output Parameters

 1 flag: whether action was successful
Example

 $question->delete;


OBJECT METHODS

The following methods allow you to create objects from the Liz::Survey::Question object.


Choice

Create a new Liz::Survey::Question::Choice object. Use method ChoiceOrdinals to obtain a list of ordinal numbers of choices associated with this Question.

Input Parameters

 1 ordinal number of new question to create object for
   (default: next)
Output Parameters

 1 instantiated Liz::Survey::Question::Choice object
Example

 $choice = $question->Choice;
 $choice = $question->Choice( $ordinal );


Graph

Return the first Graph object that is associated with this Question. Use method Graphs to obtain a list of Graphs if there is more than one for this question. Creates a new Graph object if there is no Graph object for this question yet.

Output Parameters

 1 first Graph object associated with this question
Example

 $graph = $question->Graph;


CONTENT METHODS

The following methods allow you to inspect and/or change certain fields of the Liz::Survey::Question object.


Created

Return the Created timestamp of the Liz::Survey::Question object.

Output Parameters

 1 current timestamp value of the Created date
Example

 $created = $question->Created;


Data

Set or return the extra data of the Liz::Survey::Question object.

Input Parameters

 1 new extra data
   (default: no change)
Output Parameters

 1 current extra data
Example

 $question->Data( $data );
 $data = $question->Data;


ID

Return the ID of the Liz::Survey::Question object.

Output Parameters

 1 current ID of the object
Example

 $ID = $question->ID;


Text

Set or return the text of the Liz::Survey::Question object.

Input Parameters

 1 new text
   (default: no change)
Output Parameters

 1 current text
Example

 $question->Text( $text );
 $text = $question->Text;


Type

Set or return the type of the Liz::Survey::Question object.

Input Parameters

 1 new type
   (default: no change)
Output Parameters

 1 current type
Example

 $question->Type( $type );
 $type = $question->Type;
Note

Currently the following types of question have been defined:

  0 open question, no alternatives, text to be stored as comment
  1 multiple choice, 1 out of number of choices available


Updated

Return the Updated timestamp of the Liz::Survey::Question object.

Output Parameters

 1 current timestamp value of the Updated date
Example

 $updated = $question->Updated;


CHOICE METHODS

The following methods are related to the choices of a Question object.


Choices

Return the (number of) choices that are associated with this Question.

Output Parameters

 1..N the choices (number of choices in a scalar context)
Example

 $choices = $question->Choices;
 @choice = $question->Choices;


Choices2Check

Return the HTML for a choices of the question in the form of a checkbox sequence. This implies that there can be more than one answer possible.

Input Parameters

 1 name of variable (optionally with namespace if checking is to be performed)
 2 extra HTML to be put between CHECK buttons
 3 flag: return HTML as dummy <CHECK...> HTML
Output Parameters

 1 HTML of complete checkbox sequence
Example

 print $question->Choices2Check( 'keuzeID',"<BR>\n" );


Choices2Pulldown

Return the HTML for a choices of the question in the form of a pulldown menu.

Input Parameters

 1 name of variable (optionally with namespace if checking is to be performed)
 2 extra HTML to be added at the beginning
 3 flag: return HTML as dummy <PULLDOWN...> HTML
 4 flag: extra fields (0=add empty field at beginning, 1=don't, ref(@list)=list)
   (default: add empty field at beginning
Output Parameters

 1 HTML of complete pulldown menu
Example

 print $question->Choices2Pulldown( 'keuzeID' );


Choices2Radio

Return the HTML for a choices of the question in the form of a radiobutton sequence. This implies that there can be only one answer possible.

Input Parameters

 1 name of variable (optionally with namespace if checking is to be performed)
 2 extra HTML to be put between RADIO buttons
 3 flag: return HTML as dummy <RADIO...> HTML
Output Parameters

 1 HTML of complete radiobutton sequence
Example

 print $question->Choices2Radio( 'keuzeID',"<BR>\n" );


ChoiceTextIDListHash

Return a reference to the list of the textIDs of the choices of this Question and a reference to a hash with the texts of the choices.

Output Parameters

 1 reference to list of textID's of the choices
 2 reference to hash with texts of 
Example

 ($list,$text) = $question->ChoiceTextIDListHash;
 foreach (@{$list)) {
  print "$_: $$text{$_}\n";
 }


ChoiceTextIDResult

Return a SQL-result handle for a query in which the first field is the textID and the second field is the associated text.

Output Parameters

 1 SQL-result handle
Example

 $result = $question->ChoiceTextIDResult;
 print $result->Result2Radio( $result );


ChoiceTextIDs

Return the list of the textIDs of the choices of this Question if it is a multiple choice type object.

Output Parameters

 1..N textID's of the choices
Example

 @choiceID = $question->ChoiceTextIDs;


ChoiceOrdinals

Return the list of the ordinal numbers of the choices of this Question if it is a multiple choice type object.

Output Parameters

 1..N ordinal numbers of the choices
Example

 foreach ($question->ChoiceOrdinals) {
   $choice = $question->Choice( $_ );
 }


DropChoices

Remove all the choices that are associated with this Question.

Input Parameters

 1 ordinal number above which all choices should be removed
   (default: 0 = all)
Example

 $question->DropChoices;


AnswersListHash

Return a reference to the list of possible choices (textID's) and a hash that contains the number of answers that matched that choice.

Input Parameters

 1 extra condition to apply to Answers
   (default: none)
Output Parameters

 1 reference to a list of choices of that question
 2 reference to a hash with the number of answers for the choice
 3 total number of answers found
Example

 ($list,$freq) = $survey->QuestionID2AnswersListHash;


LIST METHODS

The following methods provides lists in various forms.


Graphs

Return an SQL statement handle for a list of graphs for this question.

The following fields may be specified with the first parameter:

 ID
 The ID of the graph

 legenda
 The legenda (title) of this graph

 finalpictureID
 The pictureID of the finished image for the graph

 created
 Timestamp value when this graph was created

 updated
 Timestamp when the graph was last updated

 pictureID
 The pictureID of the base image for the graph

 direction
 The direction of the bars in the graph

 alignment
 The alignment of the bars in the graph

 sizing
 The sizing of the bars in the graph

 fontID
 The fontID of the font of the legenda of the graph

 barfontID
 The fontID of the font of the legenda of the bars of the graph
Input Parameters

 1 fields to return (comma delimited)
   (default: 'ID,legenda,finalpictureID,created,updated,pictureID,direction,alignment,sizing,fontID,barfontID' );
 2 fieldname on which to order the result
   (default: 'created')
 3 extra condition to be applied
   (default: none)
Output Parameters

 1 SQL statement handle (on which method "fetchrow" can be applied)


AUTHOR

Elizabeth Mattijsen ( lizperl@INC.nl )


COPYRIGHT

(C) 1999-2000 International Network Consultants


HISTORY

Version 0.24, 14 June 2000

Fixed problem in new that would occur if the given ID did not exist (missing ``no strict qw(refs)'').

Version 0.23, 25 November 1999

Put module name between quotes to fix obscure bug in Perl 5.005x under ModPerl in method Choice.

Version 0.22, 30 September 1999

Now no longer puts Exporter in ISA: it was not needed.

Version 0.21, 28 September 1999

Method new now properly sets the SURVEY field.

Version 0.2, 27 September 1999

Support for method Graph and Graphs added.

Version 0.1, 21 September 1999

First version of this true Perl module.