Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.211 and 1.214

version 1.211, 2007/04/16 23:25:12 version 1.214, 2007/05/22 00:45:43
Line 465  sub add_in_tag_answer { Line 465  sub add_in_tag_answer {
     my @answer=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval,      my @answer=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval,
       $response_level);        $response_level);
     &Apache::lonxml::debug('answer is'.join(':',@answer));      &Apache::lonxml::debug('answer is'.join(':',@answer));
     if (@answer && defined($answer[0])) {      if (@answer && $answer[0] =~ /\S/) {
  $answer{$tag_internal_answer_name}= {'type' => 'ordered',   $answer{$tag_internal_answer_name}= {'type' => 'ordered',
      'answers' => [\@answer] };       'answers' => [\@answer] };
     }      }
Line 601  sub end_numericalresponse { Line 601  sub end_numericalresponse {
  }   }
     }      }
  }   }
  &setup_prior_tries_hash();   &Apache::response::setup_prior_tries_hash(\&format_prior_response_numerical);
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.='</td></tr>'.&Apache::edit::end_table;   $result.='</td></tr>'.&Apache::edit::end_table;
     } elsif ($target eq 'answer' || $target eq 'analyze') {      } elsif ($target eq 'answer' || $target eq 'analyze') {
Line 792  sub end_numericalresponse { Line 792  sub end_numericalresponse {
     return $result;      return $result;
 }  }
   
 sub setup_prior_tries_hash {  sub format_prior_response_numerical {
     #FIXME support multi answer numericals/formula      my ($mode,$answer) = @_;
     my $part=$Apache::inputtags::part;      if (ref($answer)) {
     my $id=$Apache::inputtags::response[-1];   my $result = '<table class="LC_prior_numerical"><tr>';
     foreach my $i (1..$Apache::lonhomework::history{'version'}) {   foreach my $element (@{ $answer }) {
  my $key = "$i:resource.$part.$id.submission";      $result.= '<td><span class="LC_prior_numerical">'.
  next if (!exists($Apache::lonhomework::history{"$key"}));   &HTML::Entities::encode($element,'"<>&').'</span></td>';
  $Apache::inputtags::submission_display{$key} =   }
     '<span class="LC_prior_numerical">'.   $result.='</tr></table>';
     &HTML::Entities::encode($Apache::lonhomework::history{$key},   return $result;
     '"<>&').'</span>';  
     }      }
       return '<span class="LC_prior_numerical">'.
       &HTML::Entities::encode($answer,'"<>&').'</span>';
   
 }  }
   
 sub check_for_answer_errors {  sub check_for_answer_errors {
Line 825  sub check_for_answer_errors { Line 827  sub check_for_answer_errors {
     use Data::Dumper;      use Data::Dumper;
     &Apache::lonxml::debug("count dump is ".&Dumper(\%counts));      &Apache::lonxml::debug("count dump is ".&Dumper(\%counts));
     my $expected_number_of_inputs = (keys(%counts))[0];      my $expected_number_of_inputs = (keys(%counts))[0];
     if ( $expected_number_of_inputs != scalar(@Apache::inputtags::inputlist)) {      if ( $expected_number_of_inputs > 0 
    && $expected_number_of_inputs != scalar(@Apache::inputtags::inputlist)) {
  &Apache::lonxml::error(&mt("Expected [_1] input fields, but there were only [_2] seen.",    &Apache::lonxml::error(&mt("Expected [_1] input fields, but there were only [_2] seen.", 
    $expected_number_of_inputs,     $expected_number_of_inputs,
    scalar(@Apache::inputtags::inputlist)));     scalar(@Apache::inputtags::inputlist)));
Line 1025  sub get_sigrange { Line 1028  sub get_sigrange {
     return ($sig_ubound,$sig_lbound);      return ($sig_ubound,$sig_lbound);
 }  }
   
 sub setup_prior_tries_hash_string {  sub format_prior_response_string {
     my $part=$Apache::inputtags::part;      my ($mode,$answer) =@_;
     my $id=$Apache::inputtags::response[-1];      return '<span class="LC_prior_string">'.
     foreach my $i (1..$Apache::lonhomework::history{'version'}) {      &HTML::Entities::encode($answer,'"<>&').'</span>';
  my $key = "$i:resource.$part.$id.submission";  
  next if (!exists($Apache::lonhomework::history{"$key"}));  
  $Apache::inputtags::submission_display{$key} =  
     '<span class="LC_prior_string">'.  
     &HTML::Entities::encode($Apache::lonhomework::history{$key},  
     '"<>&').'</span>';  
     }  
 }  }
   
 sub start_stringresponse {  sub start_stringresponse {
Line 1216  sub end_stringresponse { Line 1212  sub end_stringresponse {
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.='</td></tr>'.&Apache::edit::end_table;   $result.='</td></tr>'.&Apache::edit::end_table;
     } elsif ($target eq 'web' || $target eq 'tex') {      } elsif ($target eq 'web' || $target eq 'tex') {
  &setup_prior_tries_hash_string();   &Apache::response::setup_prior_tries_hash(\&format_prior_response_string);
     }      }
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||       if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || 
  $target eq 'tex' || $target eq 'analyze') {   $target eq 'tex' || $target eq 'analyze') {

Removed from v.1.211  
changed lines
  Added in v.1.214


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