Parent Directory
|
Revision Log
removed unneccesary shebang lines
1 2 #Construct for selection list. 3 #Inherits from List.pm 4 #VS 6/16/2000 5 6 =head1 NAME 7 8 Select.pm -- sub-class of List that implements a select list. 9 10 All items accessed by $out = $sl -> item( $in ); 11 12 =head1 SYNOPSIS 13 14 Select.pm is intended to be used to create standard true/false questions 15 or questions where all the questions have the same set of short one to 16 two word answers as possible answers. Unlike a matching list, where 17 answers are indicated by typing in the corresponding letter, in a select 18 list the actual answer is typed in. A select list also has the option 19 of having a pop-up list of the answers so that the correct answer 20 can just be selected instead of typed. But like match lists, students 21 can be given different sets of questions (to avoid students sharing 22 answers) by entering many questions and then having each student only 23 receive a sub-set of those questions by using choose. 24 25 =head1 DESCRIPTION 26 27 =head2 Variables and methods available to Select 28 29 =head3 Variables 30 31 questions # array of questions as entered using qa() 32 answers # array of answers as entered using qa() 33 34 selected_q # randomly selected subset of "questions" 35 selected_a # the answers for the selected questions 36 37 ans_rule_len # determines the length of the answer blanks 38 # default is 4 39 40 slice # index used to select specific questions 41 shuffle # permutation array which can be applied to slice 42 # to shuffle the answers 43 44 inverted_shuffle # the inverse permutation array 45 46 rf_print_q # reference to any subroutine which should 47 # take ($self, @questions) as parameters and 48 # output the questions in a formatted string. 49 # If you want to change the way questions are 50 # printed, write your own print method and set 51 # this equal to a reference to to that method 52 # (i.e. $sl->rf_print_q = ~~&printing_routine_q) 53 54 rf_print_a # reference to any subroutine which should 55 # take ($self, @answers) as parameters and 56 # output the answers in a formatted string. 57 # If you want to change the way answers are 58 # printed, write your own print method and set 59 # this equal to a reference to to that method 60 # (i.e. $sl->rf_print_a = ~~&printing_routine_a) 61 62 =head3 Methods 63 64 qa( array ) # accepts an array of strings which can be used 65 # for questions and answers 66 67 print_q # yields a formatted string of question to be 68 # matched with answer blanks 69 70 choose([3, 4], 1) # chooses questions indexed 3 and 4 and one other 71 # randomly 72 73 ra_correct_ans # outputs a reference to the array of correct answers 74 75 =head2 Usage 76 77 78 =head3 Regualar Select List 79 80 81 Create a select list using the new_select_list call. 82 83 =for html 84 <PRE> 85 <I>$sl = new_select_list;</I> 86 </PRE> 87 88 Use qa() to enter questions and answers in alternating pairs. 89 90 =for html 91 <PRE> 92 <I>$sl->qa( 93 '\( y = x^2 \) is increasing to the right', 94 'T', 95 '\( y = x^3 \) is decreasing to the right', 96 'F', 97 '\( y = -x^2 + x^3 + 2 \) is decreasing to the right', 98 'F', 99 '\( y = -x^2 + x - 15 \) is decreasing to the left', 100 'F', 101 '\( y = 2^x \) is decreasing to the left', 102 'T', 103 );</I></PRE> 104 105 After calling qa, use choose to select which questions and/or how many each 106 student sees. A list of numbers in brackets indicates which questions every 107 student sees (counting starts with 0) and the final number outside of brackets 108 is how many more questions should be randomly picked for each student. 109 110 =for html 111 <PRE> 112 <I>$sl->choose([0], 1);</I></PRE> 113 114 would show the first question and a random question while 115 116 =for html 117 <PRE> 118 <I>$sl->choose(3);</I></PRE> 119 120 would show 3 random questions (but never call choose more than once). 121 122 If you want you can change the size of the answer boxes at any time (the default is 4). 123 124 =for html 125 <PRE> 126 <I>$sl->ans_rule_len = 10;</I></PRE> 127 128 Now you would start your problem with a BEGIN_TEXT tag and print the questions 129 with the print_q() command. Within the BEGIN_TEXT/END_TEXT block, all calls to 130 objects must be enclosed in \( \). (The $PAR start a new paragraph by printing 131 a blank line). 132 133 =for html 134 <PRE> 135 <I>BEGIN_TEXT 136 $PAR 137 \{ $sl->print_q() \} 138 END_TEXT</I></PRE> 139 140 Now all that''s left is sending the students answers to the answer evaluator 141 along with the correct answers so that the students answers can be checked and 142 a score can be given. This is done using ANS, an answer evaluator and the 143 ra_correct_ans variable. 144 145 =for html 146 <PRE> 147 <I>ANS(str_cmp($sl->ra_correct_ans));</I></PRE> 148 149 150 =head3 Pop-Up Select List 151 152 153 A Pop-up select list problem is identical to a regular select list problem with 154 only a few exceptions. 155 156 First, you would create a pop-up select list using the new_pop_up_select_list call. 157 158 =for html 159 <PRE> 160 <I>$sl = new_pop_up_select_list;</I> 161 </PRE> 162 163 Then you would use qa() and choose() (and optionally ans_rule_len) as normal but 164 before writing the actual problem within the BEGIN_TEXT/END_TEXT headers, you could 165 optionally specify value=>label pairs for the pop-up list where you first specify 166 the value of an answer to one of your questions and you link it to a label (using =>) 167 that will be shown to the students. For example, 168 169 =for html 170 <PRE> 171 <I>$sl->ra_pop_up_list([no_answer => ' ?', T => 'True', F => 'False']);</I></PRE> 172 173 indicates that instead of seeing the letter T (which was used as the actual 174 answer), the student will see the word 'True'. Also, before they choose 175 their answer the student will first see a question mark in each pop-up list 176 indicating that they have not yet selected an answer there because the special 177 variable no_answer has been selected. This is optional, however, because if no 178 $sl->ra_pop_up_list is specified, it will default to the one shown above. So if 179 this is want you want, you don't need to do any of this, but if you use ra_pop_up_list 180 at all, these defaults will be lost and 'T' will just be 'T'. Also, if you don't 181 specify a label for a particular answer, the label for that answer will be the 182 answer (like I just said, 'T' will be 'T'). 183 184 Other than those two differences, a pop-up select list problem is exactly the same 185 as a regular select list problem as described above. 186 187 =cut 188 189 BEGIN { 190 be_strict(); 191 } 192 #' 193 package Select; 194 195 #require "${Global::mainDirectory}courseScripts/List.pm"; 196 @Select::ISA = qw( Exporter List ); 197 198 # *** Subroutines which overload List.pm *** 199 200 #these 201 sub extra { warn "Select lists do not use extra answers.\n(You can't use \$sl->extra().)" } 202 sub choose_extra { warn "Select lists do not use extra answers.\n(You can't use \$sl->choose_extra().)" } 203 sub makeLast { warn "Select lists do not use extra answers.\n(You can't use \$sl->makeLast().)" } 204 205 #overload choose so that the answers don't get randomized 206 sub choose { 207 my $self = shift; 208 my @input = @_; 209 210 211 $self->getRandoms(scalar(@{ $self->{questions} }), @input); 212 $self->selectQA(); 213 $self->dumpExtra(); 214 } 215 216 sub selectQA { 217 my $self = shift; 218 219 $self->{selected_q} = [ @{ $self->{questions} }[ @{ $self->{slice} } ] ]; 220 $self->{selected_a} = [ @{ $self->{answers} }[@{ $self->{slice} } ] ]; 221 $self->{inverted_shuffle} = [ &List::invert(@{ $self->{shuffle} }) ]; 222 } 223 224 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |