Forum archive 2000-2006

Michael Gage - List.pm

Michael Gage - List.pm

by Arnold Pizer -
Number of replies: 0
inactiveTopicList.pm topic started 6/9/2000; 11:47:24 AM
last post 6/9/2000; 11:47:24 AM
userMichael Gage - List.pm  blueArrow
6/9/2000; 11:47:24 AM (reads: 3037, responses: 0)


NAME

    List.pm -- super-class for all list structures


SYNOPSIS

List.pm is not intended to be used as a stand alone object.

It is a super-class designed to be inherited by sub-classes that, through small changes, can be used for a variety of different questions that involve some sort of list of questions and/or answers.

List.pm has been used to construct Match.pm, Select.pm, and Multiple.pm.

These three classes are objects that can be used to create the following question types:

Matching list: Given a list of questions and answers, match the correct answers to the questions. Some answers may be used more than once and some may not be used at all. The order of the answers is usually random but some answers can be appended to the end in a set order (i.e. 'None of the above'). Answers are given corresponding letters as shortcuts to typing in the full answer. (i.e. the answer to #1 is A).

Select list: Given a list of questions and (usually) implied answers, give the correct answer to each question. This is intended mainly for true/false questions or other types of questions where the answers are short and can therefore be typed in by the user easily. If a select list is desired but the answers are too long to really type in, a popup-list of the answers can be used.

Multiple choice: Given a single question and a list of answers, select the single correct answer. This structure creates a standard multiple choice question as would be seen on a standardize test. Extra answers are entered along with the question in a simple format and (as with Match.pm), if necessary, can be appended in order at the end (i.e. 'None of the above')

See Match.pm, Select.pm, Multiple.pm, and PGchoicemacros.pl


DESCRIPTION

Variables and methods available to sub-classes

Variables

    questions               # array of questions as entered using qa()
answers # array of answers as entered using qa()
extras # array of extras as entered using extra()
    selected_q              # randomly selected subset of "questions"
selected_a # the answers for the selected questions
selected_e # randomly selected subset of "extras"
    ans_rule_len            # determines the length of the answer blanks
# default is 4
    slice                   # index used to select specific questions
shuffle # permutation array which can be applied to slice
# to shuffle the answers
    inverted_shuffle        # the inverse permutation array
    rf_print_q              # reference to any subroutine which should
# take ($self, @questions) as parameters and
# output the questions in a formatted string.
# If you want to change the way questions are
# printed, write your own print method and set
# this equal to a reference to to that method
# (i.e. $sl->rf_print_q = ~~&printing_routine_q)
    rf_print_a              # reference to any subroutine which should
# take ($self, @answers) as parameters and
# output the answers in a formatted string.
# If you want to change the way answers are
# printed, write your own print method and set
# this equal to a reference to to that method
# (i.e. $sl->rf_print_a = ~~&printing_routine_a)
    ra_pop_up_list      # Field used in sub classes that use pop_up_list_print_q
# to format the questions. (Placing a pop_up_list next
to
# each question instead of an answer blank.
# It is initialized to
# => [no_answer =>' ?', T => 'True', F => 'False']
    ans_rule_len            # field which can be used in the question printing routines
# to determine the length of the answer blanks before
the questions.

Methods

    qa( array )             # accepts an array of strings which can be used
# for questions and answers
    extra( array )          # accepts an array of strings which can be used
# as extra answers
    print_q                 # yields a formatted string of question to be
# matched with answer blanks
print_a # yields a formatted string of answers
    choose([3, 4], 1)       # chooses questions indexed 3 and 4 and one other
# randomly
choose_extra([3, 4], 1) # choooses extra answers indexed 3 and 4 and one
# other
makeLast( array ) # accepts an array of strings (like qa) which will
# be forced to the end of the list of answers.
    ra_correct_ans          # outputs a reference to the array of correct answers
correct_ans # outputs a concatenated string of correct answers (only
for Multiple)

Usage

    None -- see SYNOPSIS above
File path = /ww/webwork/pg/lib/List.pm

<| Post or View Comments |>