--- loncom/homework/matchresponse.pm 2003/10/27 20:04:34 1.29
+++ loncom/homework/matchresponse.pm 2004/02/09 19:38:00 1.33
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.29 2003/10/27 20:04:34 albertel Exp $
+# $Id: matchresponse.pm,v 1.33 2004/02/09 19:38:00 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -123,6 +123,10 @@ sub end_itemgroup {
@names=&Apache::response::whichorder($#names+1,$randomize,0,
\%Apache::response::itemgroup);
}
+ if ($target eq 'analyze') {
+ my $partid="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+ push (@{ $Apache::lonhomework::analyze{"$partid.items"} }, @names);
+ }
my %letter_name_map;
my %name_letter_map;
my @alphabet=('A'..'Z');
@@ -163,7 +167,7 @@ sub end_itemgroup {
sub start_item {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
&Apache::lonxml::startredirection;
} elsif ($target eq 'edit') {
my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
@@ -189,11 +193,11 @@ sub end_item {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $text ='';
my $result = '';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
$text=&Apache::lonxml::endredirection;
}
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
- $target eq 'edit' || $target eq 'tex') {
+ $target eq 'edit' || $target eq 'tex' || $target eq 'analyze') {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
my $location=&Apache::lonxml::get_param('location',$parstack,
$safeeval);
@@ -302,19 +306,21 @@ sub grade_response {
if (!defined($ENV{'form.submitted'})) { return; }
my %responsehash;
my %grade;
- my ($temp,$right,$wrong,$ignored)=(0,0,0,0);
+ my ($temp,$right,$wrong,$ignored)=(1,0,0,0);
my %letter_name_map;
if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) {
%letter_name_map=
%{ $Apache::response::itemgroup{'letter_name_map'} };
}
+ my @items;
foreach my $name (@whichfoils) {
my $response = &Apache::response::getresponse($temp);
+ push(@items,$response);
my $responsename = $letter_name_map{$response};
- $responsehash{$name}=$responsename;
my $value=$Apache::response::foilgroup{$name.'.value'};
if ( $response =~ /[^\s]/) {
- &Apache::lonxml::debug("submitted a $response for $value
\n");
+ $responsehash{$name}=$responsename;
+ &Apache::lonxml::debug("submitted a $response($responsename) for $value
\n");
if ($value eq $responsename) {
$grade{$name}='1'; $right++;
} else {
@@ -328,9 +334,9 @@ sub grade_response {
my $part=$Apache::inputtags::part;
my $id = $Apache::inputtags::response['-1'];
my $responsestr=&Apache::lonnet::hash2str(%responsehash);
+ my $itemstr =&Apache::lonnet::array2str(@items);
my $gradestr =&Apache::lonnet::hash2str(%grade);
- my %previous =&Apache::response::check_for_previous($responsestr,
- $part,$id);
+ my %previous=&Apache::response::check_for_previous($responsestr,$part,$id);
&Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored ");
my $ad;
if ($wrong==0 && $ignored==0) {
@@ -346,6 +352,8 @@ sub grade_response {
}
$Apache::lonhomework::results{"resource.$part.$id.submission"}=
$responsestr;
+ $Apache::lonhomework::results{"resource.$part.$id.submissionitems"}=
+ $itemstr;
$Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=
$gradestr;
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
@@ -457,11 +465,19 @@ sub displayfoils {
} elsif ($result=&itemdisplay('bottom')) {
$result=$question.$result;
} elsif ($result=&itemdisplay('right')) {
- $result='
'.$question.' | '.$result.
- ' |
';
+ if ($target ne 'tex') {
+ $result=''.$question.' | '.$result.
+ ' |
';
+ } else {
+ $result='\begin{tabular}{p{\textwidth/2}p{\textwidth/2}}\begin{minipage}{\textwidth/2}'.$question.'\end{minipage}&\begin{minipage}{\textwidth/2}'.$result.'\end{minipage}\end{tabular}';
+ }
} elsif ($result=&itemdisplay('left')) {
- $result=''.$result.' | '.$question.
- ' |
';
+ if ($target ne 'tex') {
+ $result=''.$result.' | '.$question.
+ ' |
';
+ } else {
+ $result='\begin{tabular}{p{\textwidth/2}p{\textwidth/2}}\begin{minipage}{\textwidth/2}'.$result.'\end{minipage}&\begin{minipage}{\textwidth/2}'.$question.'\end{minipage}\end{tabular}';
+ }
}
if ($target ne 'tex') {$result.="
";} else {$result.=' \\\\ ';}
return $result;