Diff for /loncom/homework/matchresponse.pm between versions 1.28 and 1.32

version 1.28, 2003/10/27 19:27:09 version 1.32, 2004/01/06 20:16:17
Line 123  sub end_itemgroup { Line 123  sub end_itemgroup {
  @names=&Apache::response::whichorder($#names+1,$randomize,0,   @names=&Apache::response::whichorder($#names+1,$randomize,0,
  \%Apache::response::itemgroup);   \%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 %letter_name_map;
     my %name_letter_map;      my %name_letter_map;
     my @alphabet=('A'..'Z');      my @alphabet=('A'..'Z');
Line 163  sub end_itemgroup { Line 167  sub end_itemgroup {
 sub start_item {  sub start_item {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';      my $result='';
     if ($target eq 'web' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  &Apache::lonxml::startredirection;   &Apache::lonxml::startredirection;
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  my $randomize=&Apache::lonxml::get_param('randomize',$parstack,   my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
Line 189  sub end_item { Line 193  sub end_item {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $text ='';      my $text ='';
     my $result = '';      my $result = '';
     if ($target eq 'web' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  $text=&Apache::lonxml::endredirection;   $text=&Apache::lonxml::endredirection;
     }      }
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||      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 $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
  my $location=&Apache::lonxml::get_param('location',$parstack,   my $location=&Apache::lonxml::get_param('location',$parstack,
  $safeeval);   $safeeval);
Line 251  sub end_foilgroup { Line 255  sub end_foilgroup {
  } elsif ( $target eq 'analyze') {   } elsif ( $target eq 'analyze') {
     my @shown=&whichfoils($max,$randomize);      my @shown=&whichfoils($max,$randomize);
     &Apache::response::analyze_store_foilgroup(\@shown,      &Apache::response::analyze_store_foilgroup(\@shown,
        ['text','value']);   ['text','value','location']);
     #FIXME need to store options in some way      #FIXME need to store options in some way
  }   }
  &Apache::lonxml::increment_counter(&getfoilcounts($max));   &Apache::lonxml::increment_counter(&getfoilcounts($max));
Line 261  sub end_foilgroup { Line 265  sub end_foilgroup {
     return $result;      return $result;
 }  }
   
   sub whichfoils {
       my ($max,$randomize)=@_;
       return &Apache::response::whichorder(&getfoilcounts($max),
    $randomize,
    &Apache::response::showallfoils(),
    \%Apache::response::foilgroup);
   }
   
 sub displayanswers {  sub displayanswers {
     my ($max,$randomize,@opt)=@_;      my ($max,$randomize,@opt)=@_;
     if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; }      if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; }
Line 300  sub grade_response { Line 312  sub grade_response {
  %letter_name_map=   %letter_name_map=
     %{ $Apache::response::itemgroup{'letter_name_map'} };      %{ $Apache::response::itemgroup{'letter_name_map'} };
     }      }
       my @items;
     foreach my $name (@whichfoils) {      foreach my $name (@whichfoils) {
  my $response = &Apache::response::getresponse($temp);   my $response = &Apache::response::getresponse($temp);
    push(@items,$response);
  my $responsename = $letter_name_map{$response};   my $responsename = $letter_name_map{$response};
  $responsehash{$name}=$responsename;  
  my $value=$Apache::response::foilgroup{$name.'.value'};   my $value=$Apache::response::foilgroup{$name.'.value'};
  if ( $response =~ /[^\s]/) {   if ( $response =~ /[^\s]/) {
       $responsehash{$name}=$responsename;
     &Apache::lonxml::debug("submitted a $response for $value<br />\n");      &Apache::lonxml::debug("submitted a $response for $value<br />\n");
     if ($value eq $responsename) {      if ($value eq $responsename) {
  $grade{$name}='1'; $right++;   $grade{$name}='1'; $right++;
Line 320  sub grade_response { Line 334  sub grade_response {
     my $part=$Apache::inputtags::part;      my $part=$Apache::inputtags::part;
     my $id = $Apache::inputtags::response['-1'];      my $id = $Apache::inputtags::response['-1'];
     my $responsestr=&Apache::lonnet::hash2str(%responsehash);      my $responsestr=&Apache::lonnet::hash2str(%responsehash);
       my $itemstr    =&Apache::lonnet::array2str(@items);
     my $gradestr   =&Apache::lonnet::hash2str(%grade);      my $gradestr   =&Apache::lonnet::hash2str(%grade);
     my %previous =&Apache::response::check_for_previous($responsestr,      my %previous=&Apache::response::check_for_previous($responsestr,$part,$id);
  $part,$id);  
     &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored ");      &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored ");
     my $ad;      my $ad;
     if ($wrong==0 && $ignored==0) {      if ($wrong==0 && $ignored==0) {
Line 338  sub grade_response { Line 352  sub grade_response {
     }      }
     $Apache::lonhomework::results{"resource.$part.$id.submission"}=      $Apache::lonhomework::results{"resource.$part.$id.submission"}=
  $responsestr;   $responsestr;
       $Apache::lonhomework::results{"resource.$part.$id.submissionitems"}=
    $itemstr;
     $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=      $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=
  $gradestr;   $gradestr;
     $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;      $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
Line 449  sub displayfoils { Line 465  sub displayfoils {
     } elsif ($result=&itemdisplay('bottom')) {      } elsif ($result=&itemdisplay('bottom')) {
  $result=$question.$result;   $result=$question.$result;
     } elsif ($result=&itemdisplay('right')) {      } elsif ($result=&itemdisplay('right')) {
  $result='<table><tr><td>'.$question.'</td><td>'.$result.   if ($target ne 'tex') {
     '</td></tr></table>';      $result='<table><tr><td>'.$question.'</td><td>'.$result.
    '</td></tr></table>';
    } 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')) {      } elsif ($result=&itemdisplay('left')) {
  $result='<table><tr><td>'.$result.'</td><td>'.$question.   if ($target ne 'tex') {
     '</td></tr></table>';      $result='<table><tr><td>'.$result.'</td><td>'.$question.
    '</td></tr></table>';
    } 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.="<br />";} else {$result.=' \\\\ ';}      if ($target ne 'tex') {$result.="<br />";} else {$result.=' \\\\ ';}
     return $result;      return $result;

Removed from v.1.28  
changed lines
  Added in v.1.32


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>