--- loncom/homework/optionresponse.pm 2006/02/06 21:59:23 1.132
+++ loncom/homework/optionresponse.pm 2007/03/27 19:20:49 1.139
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.132 2006/02/06 21:59:23 albertel Exp $
+# $Id: optionresponse.pm,v 1.139 2007/03/27 19:20:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -183,8 +183,10 @@ sub end_foilgroup {
$safeeval,'-2');
if ($target eq 'web' || $target eq 'tex') {
$result.=&displayfoils($target,$max,$randomize,$TeXlayout,@opt);
+ $Apache::lonxml::post_evaluate=0;
} elsif ( $target eq 'answer') {
$result.=&displayanswers($max,$randomize,@opt);
+
} elsif ( $target eq 'analyze') {
my @shown = &whichfoils($max,$randomize);
&Apache::response::analyze_store_foilgroup(\@shown,
@@ -353,6 +355,27 @@ sub check_for_invalid {
}
}
+sub setup_prior_tries_hash {
+ my ($whichopt) = @_;
+ my $part=$Apache::inputtags::part;
+ my $id=$Apache::inputtags::response[-1];
+ foreach my $i (1..$Apache::lonhomework::history{'version'}) {
+ my $key = "$i:resource.$part.$id.submission";
+ next if (!exists($Apache::lonhomework::history{"$key"}));
+ my %lastresponse=
+ &Apache::lonnet::str2hash($Apache::lonhomework::history{$key});
+ my $output;
+ foreach my $name (@$whichopt) {
+ next if (!defined($lastresponse{$name}));
+ $output .= '
'.$lastresponse{$name}.' | ';
+ }
+ next if (!defined($output));
+ $output =
+ '';
+ $Apache::inputtags::submission_display{$key} = $output;
+ }
+}
+
sub displayfoils {
my ($target,$max,$randomize,$TeXlayout,@opt)=@_;
if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
@@ -414,14 +437,15 @@ sub displayfoils {
foreach my $option (@opt) {
my $escopt=&HTML::Entities::encode($option,'\'"&<>');
if ($option eq $lastopt) {
- $optionlist.="\n";
+ $optionlist.="\n";
} else {
$optionlist.="\n";
}
}
if ($target ne 'tex') {
if ($Apache::lonhomework::type ne 'exam') {
- $optionlist='\n";
} else {
@@ -448,7 +472,7 @@ sub displayfoils {
$texoptionlist = &optionlist_correction($TeXlayout,@opt);
}
if ($text=~//) {
- $text=~s|| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |;
+ $text=~s|| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |g;
}
if ($text=~m/\\item /) {
@@ -473,6 +497,11 @@ sub displayfoils {
}
}
}
+
+ if ($target eq 'web') {
+ &setup_prior_tries_hash(\@whichopt);
+ }
+
if ($target ne 'tex') {
return $result.$break;
} else {
@@ -688,14 +717,14 @@ sub end_foil {
sub start_drawoptionlist {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- if ($target ne 'meta') {
+ if (($target ne 'meta') && ($target ne 'answer')) {
return $token->[4];
}
}
sub end_drawoptionlist {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- if ($target ne 'meta') {
+ if (($target ne 'meta') && ($target ne 'answer')) {
return $token->[2];
}
}