Liz::Survey::Question - module for Question objects of the Survey
use Liz::Survey; $survey = new Liz::Survey;
$question = $survey->Question; $question = $survey->Question( $questionID );
$question->update;
Provide object oriented access to questions in a Survey. Usually not accessed directly, but rather through the Liz::Survey object and its Question method.
Create a new Question object from a Survey object.
1 Liz::Survey object 2 ID to created Question object with (default: none = new question)
1 instantiated object
It is not intended to call this method directly, but rather indirectly through the Liz::Survey module.
$survey = new Liz::Survey; $question = $survey->Question; $question = $survey->Question( $questionID );
Update a Question object in the Liz::Survey database.
1 ID with which the object was updated (undef = error)
$questionID = $question->update;
Delete a Liz::Survey::Question object from the database.
1 flag: whether action was successful
$question->delete;
The following methods allow you to create objects from the Liz::Survey::Question object.
Create a new Liz::Survey::Question::Choice object. Use method ChoiceOrdinals to obtain a list of ordinal numbers of choices associated with this Question.
1 ordinal number of new question to create object for (default: next)
1 instantiated Liz::Survey::Question::Choice object
$choice = $question->Choice; $choice = $question->Choice( $ordinal );
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.
1 first Graph object associated with this question
$graph = $question->Graph;
The following methods allow you to inspect and/or change certain fields of the Liz::Survey::Question object.
Return the Created timestamp of the Liz::Survey::Question object.
1 current timestamp value of the Created date
$created = $question->Created;
Set or return the extra data of the Liz::Survey::Question object.
1 new extra data (default: no change)
1 current extra data
$question->Data( $data ); $data = $question->Data;
Return the ID of the Liz::Survey::Question object.
1 current ID of the object
$ID = $question->ID;
Set or return the text of the Liz::Survey::Question object.
1 new text (default: no change)
1 current text
$question->Text( $text ); $text = $question->Text;
Set or return the type of the Liz::Survey::Question object.
1 new type (default: no change)
1 current type
$question->Type( $type ); $type = $question->Type;
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
Return the Updated timestamp of the Liz::Survey::Question object.
1 current timestamp value of the Updated date
$updated = $question->Updated;
The following methods are related to the choices of a Question object.
Return the (number of) choices that are associated with this Question.
1..N the choices (number of choices in a scalar context)
$choices = $question->Choices; @choice = $question->Choices;
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.
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
1 HTML of complete checkbox sequence
print $question->Choices2Check( 'keuzeID',"<BR>\n" );
Return the HTML for a choices of the question in the form of a pulldown menu.
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
1 HTML of complete pulldown menu
print $question->Choices2Pulldown( 'keuzeID' );
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.
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
1 HTML of complete radiobutton sequence
print $question->Choices2Radio( 'keuzeID',"<BR>\n" );
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.
1 reference to list of textID's of the choices 2 reference to hash with texts of
($list,$text) = $question->ChoiceTextIDListHash;
foreach (@{$list)) {
print "$_: $$text{$_}\n";
}
Return a SQL-result handle for a query in which the first field is the textID and the second field is the associated text.
1 SQL-result handle
$result = $question->ChoiceTextIDResult; print $result->Result2Radio( $result );
Return the list of the textIDs of the choices of this Question if it is a multiple choice type object.
1..N textID's of the choices
@choiceID = $question->ChoiceTextIDs;
Return the list of the ordinal numbers of the choices of this Question if it is a multiple choice type object.
1..N ordinal numbers of the choices
foreach ($question->ChoiceOrdinals) {
$choice = $question->Choice( $_ );
}
Remove all the choices that are associated with this Question.
1 ordinal number above which all choices should be removed (default: 0 = all)
$question->DropChoices;
Return a reference to the list of possible choices (textID's) and a hash that contains the number of answers that matched that choice.
1 extra condition to apply to Answers (default: none)
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
($list,$freq) = $survey->QuestionID2AnswersListHash;
The following methods provides lists in various forms.
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
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)
1 SQL statement handle (on which method "fetchrow" can be applied)
Elizabeth Mattijsen ( lizperl@INC.nl )
(C) 1999-2000 International Network Consultants
Fixed problem in new that would occur if the given ID did not exist (missing ``no strict
qw(refs)'').
Put module name between quotes to fix obscure bug in Perl 5.005x under ModPerl in method Choice.
Now no longer puts Exporter in ISA: it was not needed.
Method new now properly sets the SURVEY field.
First version of this true Perl module.