Forum archive 2000-2006

Michael Gage - pop_up_list_print_q -- plugin method used in "List.pm" type objects

Michael Gage - pop_up_list_print_q -- plugin method used in "List.pm" type objects

by Arnold Pizer -
Number of replies: 0
inactiveTopicpop_up_list_print_q -- plugin method used in "List.pm" type objects topic started 8/28/2001; 1:10:34 AM
last post 8/28/2001; 1:10:34 AM
userMichael Gage - pop_up_list_print_q -- plugin method used in "List.pm" type objects  blueArrow
8/28/2001; 1:10:34 AM (reads: 1815, responses: 0)

pop_up_list_print_q -- plugin method used in \"List.pm\" type objects

Description
This is another method ( i.e. a subroutine whose first argument is a reference to a parent object ) which defines how the list of questions is printed from a List.pm object. It formats the questions vertically in an ordered list, indexed by numbers and each question is preceeded by the same popup menu list. The popup menu list can be initialized using, for example, $ml->ra_pop_up_list([no_answer =>' ?', T => 'True', F => 'False']) which is the default setting.

This formatting method is particularly useful for true/false questions.

Syntax

std_print_q( $self, @array)

Params

$self is a reference to the parent list object and can be used to reference preferences stored there.
@array is the list of questions to be displayed.

Returns

A string, containing the questions, properly formatted.

Examples


$ml = new_match_list();
$ml->rf_print_q(~~&pop_up_list_print_q); # set the question format to use the std_print_q method
$ml->ra_pop_up_list([no_answer =>' ?', red => 'Red', blue => 'Blue', green => 'Green' ])
# The values returned by a selection are the keys (e.g. red) of the hash, while the values (e.g. Red) appear as choices on the pop up menu list.
# enter three questions and their answers
$ml->qa( "What color is a rose?",
"red",
"What color is the sky?",
"blue",
"What color is the sea?",
"green"
);
# choose two of these questions, ordered at random,
# which will be printed in the problem.
$ml->choose(2);
BEGIN_TEXT
Choose the correct answer to each of these questions from the popup menu.$BR
\{$ml->print_q\} Print the questions$BR

END_TEXT
# Notice that the list of answers doesn't need to be printed -- it appears in each pop up menu.
ANS( $ml->ra_correct_ans() ); #submit the correct answers

Notes

This method is defined in PGchoicemacros.pl.
The code illustrates a more involved subroutine providing a format for listing questions or answers.

See Also

std_print_a
std_print_q
Match.pm
Select.pm,
List.pm
PGchoicemacros.pl

 

<| Post or View Comments |>