Forum archive 2000-2006

Michael Gage - Match.pm

Michael Gage - Match.pm

by Arnold Pizer -
Number of replies: 0
inactiveTopicMatch.pm topic started 5/22/2000; 10:46:06 PM
last post 5/22/2000; 10:46:06 PM
userMichael Gage - Match.pm  blueArrow
5/22/2000; 10:46:06 PM (reads: 3331, responses: 0)


NAME

Match.pm -- sub-class of List that implements a matching list.

All items accessed by $out = $ml -> item( $in );


SYNOPSIS

Match.pm is intended to be used to create standard matching questions in which the the student is given a list of questions and a list of answers and is asked to match the correct answers to those questions. Some answers may be used more than once while others are not used at all. The order of answers is usually random but some answers can be appended to the end of the list in a set order (i.e. 'None of the above', 'All of the above'). Answers are not directly typed in but are given a corresponding letter that is the answer that the system expects. (i.e. 'the answer to #1 is A' not 'the answer to #1 is the square root of 2'). Also, students can be given different sets of questions (to avoid students sharing answers) by entering many questions and then using choose with a number less than the total so that each student only receive a sub-set of those questions.


DESCRIPTION

Variables and methods available to Match

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)

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

Usage

Create a match list using the new_match_list call.

    $ml = new_match_list

Use qa() first to enter questions and answers in alternating pairs. Note that multiple questions can have the same answer. Any duplicates will be eliminated.

    $ml->qa(
'\( x^2 \)',
'quadratic',
'\( x^3 \)',
'cubic',
'\( x^3/x \)',
'quadratic',
'\( log(x) \)',
'logarithmic',
'\( 2^x \)',
'None of the above',
);

After you call qa you can use extra() to enter extra 'answers'. Again all duplicates will be eliminated.

    $ml->extra(
'linear',
'quartic',
'really curvy',
);

After calling extra you can use choose to select which questions and/or how many each student sees. This helps give students different sub-sets of the full question set so that students cannot cheat as easily. A list of numbers in brackets indicates which questions every student sees (counting starts with 0) and the final number outside of brackets is how many more questions should be randomly picked for each student. Though it is available, the use of selecting specific extra answers is not recommended for novices as the indexing is complicated (see below).

    $ml->choose([0], 1);

would show the first question and a random question while

    $ml->choose(3);

would show 3 random questions (but never call choose more than once).

After calling choose, use choose_extra to select which of the extra 'answers' will be given to each student. Note that unused answers are dumped into the list of extra 'answers' so the indexing may be difficult to grasp at first. (This can be stopped by doing the following: $ml->dumpExtra = "";)

    $ml->choose_extra([0], 2);

would show 3 extra answers besides the correct one note that these extra answers may consist of answers from the questions that were not used.

After calling choose_extra you can use makeLast to add specific answers to the end of the list of answers or to force already existing answers to be moved to the end of the list. This is usually done for 'None of the above', or 'All of the above' type answers.

    $ml->makeLast(
'All of the above',
'None of the above'
);

If you want you can change the size of the answer boxes at any time (the default is 4).

    $ml->ans_rule_len(10);

Now you would start your problem with a BEGIN_TEXT tag and print the questions and answers with the print_q() and print_a() commands. Within the BEGIN_TEXT/END_TEXT block, all calls to objects must be enclosed in \( \). (The $PAR start a new paragraph by printing a blank line).

    BEGIN_TEXT
$PAR
\{ $ml->print_q() \}
$PAR
\{ $ml->print_a() \}
END_TEXT

Now all that's left is sending the students answers to the answer evaluator along with the correct answers so that the students answers can be checked and a score can be given. This is done using ANS, an answer evaluator and the ra_correct_ans variable.

    ANS(str_cmp($ml->ra_correct_ans));
File path = /ww/webwork/pg/lib/Match.pm

<| Post or View Comments |>