[LON-CAPA-cvs] cvs: loncom /homework optionresponse.pm radiobuttonresponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 06 Dec 2005 10:03:57 -0000
albertel Tue Dec 6 05:03:57 2005 EDT
Modified files:
/loncom/homework radiobuttonresponse.pm optionresponse.pm
Log:
- add correct bubble to exam printout
- optionrepsonse prints multiple answer lines for exam printout
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.104 loncom/homework/radiobuttonresponse.pm:1.105
--- loncom/homework/radiobuttonresponse.pm:1.104 Tue Oct 11 16:02:31 2005
+++ loncom/homework/radiobuttonresponse.pm Tue Dec 6 05:03:57 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# mutliple choice style responses
#
-# $Id: radiobuttonresponse.pm,v 1.104 2005/10/11 20:02:31 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.105 2005/12/06 10:03:57 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -522,10 +522,15 @@
my ($max,$randomize)=@_;
my ($answer,@whichopt) = &whichfoils($max,$randomize);
my $result=&Apache::response::answer_header('radiobuttonresponse');
+ if ($Apache::lonhomework::type eq 'exam') {
+ my $correct = ('A'..'Z')[$answer];
+ $result.=&Apache::response::answer_part('radiobuttonresponse',
+ $correct);
+ }
foreach my $name (@whichopt) {
$result.=&Apache::response::answer_part('radiobuttonresponse',
- $Apache::response::foilgroup{$name.'.value'})
- }
+ $Apache::response::foilgroup{$name.'.value'});
+ }
$result.=&Apache::response::answer_footer('radiobuttonresponse');
return $result;
}
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.129 loncom/homework/optionresponse.pm:1.130
--- loncom/homework/optionresponse.pm:1.129 Wed Jun 22 08:03:23 2005
+++ loncom/homework/optionresponse.pm Tue Dec 6 05:03:57 2005
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.129 2005/06/22 12:03:23 albertel Exp $
+# $Id: optionresponse.pm,v 1.130 2005/12/06 10:03:57 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -295,17 +295,34 @@
}
sub displayanswers {
- my ($max,$randomize,@opt)=@_;
- if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
- my @names = @{ $Apache::response::foilgroup{'names'} };
- my @whichopt = &whichfoils($max,$randomize);
- my $result=&Apache::response::answer_header('optionresponse');
- foreach my $name (@whichopt) {
- $result.=&Apache::response::answer_part('optionresponse',
- $Apache::response::foilgroup{$name.'.value'})
- }
- $result.=&Apache::response::answer_footer('optionresponse');
- return $result;
+ my ($max,$randomize,@opt)=@_;
+ if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
+ my @names = @{ $Apache::response::foilgroup{'names'} };
+ my @whichopt = &whichfoils($max,$randomize);
+ my $result;
+ if ($Apache::lonhomework::type eq 'exam') {
+ my $i = 0;
+ my %opt = map { ($_,$i++) } @opt;
+
+ $i = 0;
+ my @alphabet = ('A'..'Z');
+ foreach my $name (@whichopt) {
+ $result.=&Apache::response::answer_header('optionresponse',$i++);
+ $result.=&Apache::response::answer_part('optionresponse',
+ $alphabet[$opt{$Apache::response::foilgroup{$name.'.value'}}]);
+ $result.=&Apache::response::answer_part('optionresponse',
+ $Apache::response::foilgroup{$name.'.value'});
+ $result.=&Apache::response::answer_footer('optionresponse');
+ }
+ } else {
+ $result=&Apache::response::answer_header('optionresponse');
+ foreach my $name (@whichopt) {
+ $result.=&Apache::response::answer_part('optionresponse',
+ $Apache::response::foilgroup{$name.'.value'});
+ }
+ $result.=&Apache::response::answer_footer('optionresponse');
+ }
+ return $result;
}
sub check_for_invalid {