[system] / branches / gage_dev / pg / lib / Multiple.pm Repository:
ViewVC logotype

Diff of /branches/gage_dev/pg/lib/Multiple.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 6330 Revision 6331
1 1
2#Construct for Multiple Choice. 2#Construct for Multiple Choice.
3#Inherits from List.pm 3#Inherits from ChoiceList.pm
4#VS 6/16/2000 4#VS 6/16/2000
5 5
6 6
7=head1 NAME 7=head1 NAME
8 8
9Multiple.pm -- sub-class of List that implements a multiple choice question. 9Multiple.pm -- sub-class of ChoiceList that implements a multiple choice question.
10 10
11All items accessed by $out=$mc->item($in); 11All items accessed by $out=$mc->item($in);
12 12
13=head1 SYNOPSIS 13=head1 SYNOPSIS
14 14
185 185
186#use strict; 186#use strict;
187package Multiple; 187package Multiple;
188 188
189@Multiple::ISA = undef; 189@Multiple::ISA = undef;
190#require "${Global::mainDirectory}courseScripts/List.pm";
191@Multiple::ISA = qw( Exporter List ); 190@Multiple::ISA = qw( Exporter ChoiceList );
192 191
193# *** Subroutines which overload List.pm *** 192# *** Subroutines which overload ChoiceList.pm ***
194sub choose { warn "Multiple choice does not support choosing answers.\n(You can't use \$mc->choose().)"; } 193sub choose { warn "Multiple choice does not support choosing answers.\n(You can't use \$mc->choose().)"; }
195sub choose_extra { warn "Multiple choice does not support choosing answers.\n(You can't use \$mc->choose_extra().)"; } 194sub choose_extra { warn "Multiple choice does not support choosing answers.\n(You can't use \$mc->choose_extra().)"; }
196sub extras { warn "Extras() is not a method of Multiple.pm.\nUse the extra() method to add extra answers."; } 195sub extras { warn "Extras() is not a method of Multiple.pm.\nUse the extra() method to add extra answers."; }
197 196
198sub qa { 197sub qa {
210 my @input = @_; 209 my @input = @_;
211 210
212 push( @{ $self->{extras} }, @input); 211 push( @{ $self->{extras} }, @input);
213 212
214 #call as a method of $self 213 #call as a method of $self
215 &List::choose_extra($self, scalar(@{ $self->{extras} })); 214 &ChoiceList::choose_extra($self, scalar(@{ $self->{extras} }));
216} 215}
217 216
218#This means rf_print_q is not used but still exists for user customization 217#This means rf_print_q is not used but still exists for user customization
219sub print_q { 218sub print_q {
220 my $self = shift; 219 my $self = shift;
237sub selectQA { 236sub selectQA {
238 my $self = shift; 237 my $self = shift;
239 238
240 $self->{selected_q} = $self->{questions}; 239 $self->{selected_q} = $self->{questions};
241 $self->{selected_a} = [ @{ $self->{answers} }[@{ $self->{shuffle} }] ]; 240 $self->{selected_a} = [ @{ $self->{answers} }[@{ $self->{shuffle} }] ];
242 $self->{inverted_shuffle} = [ &List::invert(@{ $self->{shuffle} }) ]; 241 $self->{inverted_shuffle} = [ &ChoiceList::invert(@{ $self->{shuffle} }) ];
243} 242}
244 243
245#Multiple 244#Multiple
246sub ra_correct_ans { 245sub ra_correct_ans {
247 warn "Multiple does not use ra_correct_ans because radio_cmp and checkbox_cmp expect a string.\nYou should use correct_ans instead."; 246 warn "Multiple does not use ra_correct_ans because radio_cmp and checkbox_cmp expect a string.\nYou should use correct_ans instead.";
249 248
250#sends letters for comparison instead of actual answers 249#sends letters for comparison instead of actual answers
251#actual answers aren't used because they might contain LaTeX or HTML 250#actual answers aren't used because they might contain LaTeX or HTML
252sub correct_ans { 251sub correct_ans {
253 my $self = shift; 252 my $self = shift;
254 my @ans = &List::ALPHABET( sort { $a <=> $b } @{$self->{inverted_shuffle}} ); 253 my @ans = &ChoiceList::ALPHABET( sort { $a <=> $b } @{$self->{inverted_shuffle}} );
255 254
256 #radio_cmp and checkbox_cmp expect a string, not a reference to an array like str_cmp, etc 255 #radio_cmp and checkbox_cmp expect a string, not a reference to an array like str_cmp, etc
257 join "", @ans; 256 join "", @ans;
258} 257}
259 258

Legend:
Removed from v.6330  
changed lines
  Added in v.6331

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9