Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.155 and 1.156

version 1.155, 2004/10/18 20:28:23 version 1.156, 2004/10/21 02:43:34
Line 62  sub start_numericalresponse { Line 62  sub start_numericalresponse {
  if ($token->[1] eq 'numericalresponse') {   if ($token->[1] eq 'numericalresponse') {
     $constructtag=&Apache::edit::get_new_args($token,$parstack,      $constructtag=&Apache::edit::get_new_args($token,$parstack,
       $safeeval,'answer',        $safeeval,'answer',
       'incorrect','unit',         'incorrect','unit',
       'format');        'format');
  } elsif ($token->[1] eq 'formularesponse') {   } elsif ($token->[1] eq 'formularesponse') {
     $constructtag=&Apache::edit::get_new_args($token,$parstack,      $constructtag=&Apache::edit::get_new_args($token,$parstack,
Line 103  sub start_numericalresponse { Line 103  sub start_numericalresponse {
  } else {   } else {
     $format=$formats[0];      $format=$formats[0];
  }   }
    if ($unit=~/\$/) { $format="\$".$format; $unit=~s/\$//g; }
    if ($unit=~/\,/) { $format="\,".$format; $unit=~s/\,//g; }
  my $formatted=&format_number($answer,$format,$target,   my $formatted=&format_number($answer,$format,$target,
      $safeeval);       $safeeval);
  $answertxt.=$formatted.',';   $answertxt.=$formatted.',';
Line 134  sub end_numericalresponse { Line 136  sub end_numericalresponse {
  if ($Apache::lonhomework::type eq 'exam' &&    if ($Apache::lonhomework::type eq 'exam' && 
     $tag eq 'formularesponse') {      $tag eq 'formularesponse') {
     $increment=&Apache::response::scored_response($partid,$id);      $increment=&Apache::response::scored_response($partid,$id);
    } elsif ($Apache::lonhomework::type eq 'survey') {
       if ( !defined($ENV{'form.submitted'})) { return ''; }
       my $response = &Apache::response::getresponse();
       if ( $response =~ /[^\s]/) {
    my %previous=&Apache::response::check_for_previous($response,
    $partid,$id);
    $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
    my $ad=$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}='SUBMITTED';
    &Apache::response::handle_previous(\%previous,$ad);
       }
  } else {   } else {
     my $response = &Apache::response::getresponse();      my $response = &Apache::response::getresponse();
     if ( $response =~ /[^\s]/) {      if ( $response =~ /[^\s]/) {
Line 326  sub end_numericalresponse { Line 338  sub end_numericalresponse {
     }      }
     if ($fmt && $tag eq 'numericalresponse') {      if ($fmt && $tag eq 'numericalresponse') {
  $fmt=~s/e/E/g;   $fmt=~s/e/E/g;
    if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; }
    if ($unit=~/\,/) { $fmt="\,".$fmt; $unit=~s/\,//g; }
  $ans = &format_number($ans,$fmt,$target,$safeeval);   $ans = &format_number($ans,$fmt,$target,$safeeval);
  #if ($high) {   #if ($high) {
  #    $high=&format_number($high,$fmt,$target,$safeeval);   #    $high=&format_number($high,$fmt,$target,$safeeval);
Line 435  sub format_number { Line 449  sub format_number {
     $format = 'd';      $format = 'd';
  }   }
     }      }
       if (!$Apache::lonxml::default_homework_loaded) {
    &Apache::lonxml::default_homework_load($safeeval);
       }
     $ans=&Apache::run::run("&prettyprint(q\0$number\0,q\0$format\0,q\0$target\0)",$safeeval);      $ans=&Apache::run::run("&prettyprint(q\0$number\0,q\0$format\0,q\0$target\0)",$safeeval);
     return $ans;      return $ans;
 }  }

Removed from v.1.155  
changed lines
  Added in v.1.156


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