-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathMatch.pm
More file actions
197 lines (145 loc) · 6.58 KB
/
Copy pathMatch.pm
File metadata and controls
197 lines (145 loc) · 6.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#Construct for matching list.
#Inherits from ChoiceList.pm
#VS 6/16/2000
=head1 NAME
Match.pm -- sub-class of ChoiceList that implements a matching list.
All items accessed by $out = $ml -> item( $in );
=head1 SYNOPSIS
Match.pm is intended to be used to create standard matching questions in which 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.
=head1 DESCRIPTION
=head2 Variables and methods available to Match
=head3 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 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 that method
# (i.e. $sl->rf_print_a = ~~&printing_routine_a)
=head3 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
=head2 Usage
Create a match list using the new_match_list call.
=for html
<PRE>
<I>$ml = new_match_list</I></PRE>
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.
=for html
<PRE>
<I>$ml->qa(
'\( x^2 \)',
'quadratic',
'\( x^3 \)',
'cubic',
'\( x^3/x \)',
'quadratic',
'\( log(x) \)',
'logarithmic',
'\( 2^x \)',
'None of the above',
);</I></PRE>
After you call qa you can use extra() to enter extra 'answers'. Again all
duplicates will be eliminated.
=for html
<PRE>
<I>$ml->extra(
'linear',
'quartic',
'really curvy',
);</I></PRE>
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).
=for html
<PRE>
<I>$ml->choose([0], 1);</I></PRE>
would show the first question and a random question while
=for html
<PRE>
<I>$ml->choose(3);</I></PRE>
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 = "";)
=for html
<PRE>
<I>$ml->choose_extra([0], 2);</I></PRE>
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.
=for html
<PRE>
<I>$ml->makeLast(
'All of the above',
'None of the above'
);</I></PRE>
If you want you can change the size of the answer boxes at any time (the default is 4).
=for html
<PRE>
<I>$ml->ans_rule_len(10);</I></PRE>
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).
=for html
<PRE>
<I>BEGIN_TEXT
$PAR
\{ $ml->print_q() \}
$PAR
\{ $ml->print_a() \}
END_TEXT</I></PRE>
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.
=for html
<PRE>
<I>ANS(str_cmp($ml->ra_correct_ans));</I></PRE>
=cut
package Match;
use strict;
@Match::ISA = qw( ChoiceList );
# *** Subroutines which overload ChoiceList.pm ***
#sends letters for comparison instead of actual answers
sub ra_correct_ans {
my $self = shift;
my @ans = &ChoiceList::ALPHABET(@{ $self->{inverted_shuffle} });
\@ans;
}
1;