Diff for /loncom/homework/imageresponse.pm between versions 1.16 and 1.18

version 1.16, 2002/01/17 12:23:31 version 1.18, 2002/05/03 20:44:46
Line 69  sub getfoilcounts { Line 69  sub getfoilcounts {
   my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');    my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
   # +1 since instructors will count from 1    # +1 since instructors will count from 1
   my $count = $#{ $Apache::response::foilgroup{'names'} }+1;    my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
     if (&Apache::response::showallfoils()) { $max=$count; }
   return ($count,$max);    return ($count,$max);
 }  }
   
Line 79  sub whichfoils { Line 80  sub whichfoils {
   my @whichopt =();    my @whichopt =();
   while ((($#whichopt+1) < $max) && ($#names > -1)) {    while ((($#whichopt+1) < $max) && ($#names > -1)) {
     &Apache::lonxml::debug("Have $#whichopt max is $max");      &Apache::lonxml::debug("Have $#whichopt max is $max");
     my $aopt=int(rand($#names+1));      my $aopt;
       if (&Apache::response::showallfoils()) {
         $aopt=0;
       } else {
         $aopt=int(rand($#names+1));
       }
     &Apache::lonxml::debug("From $#names elms, picking $aopt");      &Apache::lonxml::debug("From $#names elms, picking $aopt");
     $aopt=splice(@names,$aopt,1);      $aopt=splice(@names,$aopt,1);
     &Apache::lonxml::debug("Picked $aopt");      &Apache::lonxml::debug("Picked $aopt");
Line 200  sub start_foil { Line 206  sub start_foil {
   if ($target eq 'web' || $target eq 'grade') {    if ($target eq 'web' || $target eq 'grade') {
     my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);      my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
     if ($name eq '') { $name=$Apache::lonxml::curdepth; }      if ($name eq '') { $name=$Apache::lonxml::curdepth; }
     if ( $Apache::imageresponse::conceptgroup ) {      if ( $Apache::imageresponse::conceptgroup
    && !&Apache::response::showallfoils()) {
       push(@{ $Apache::response::conceptgroup{'names'} }, $name);        push(@{ $Apache::response::conceptgroup{'names'} }, $name);
     } else {      } else {
       push(@{ $Apache::response::foilgroup{'names'} }, $name);        push(@{ $Apache::response::foilgroup{'names'} }, $name);
Line 225  sub end_text { Line 232  sub end_text {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   if ($target eq 'web') {    if ($target eq 'web') {
     my $name = $Apache::imageresponse::curname;      my $name = $Apache::imageresponse::curname;
     if ( $Apache::imageresponse::conceptgroup ) {      if ( $Apache::imageresponse::conceptgroup
          && !&Apache::response::showallfoils() ) {
       $Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection;        $Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection;
     } else {      } else {
       $Apache::response::foilgroup{"$name.text"} = &Apache::lonxml::endredirection;        $Apache::response::foilgroup{"$name.text"} = &Apache::lonxml::endredirection;
Line 246  sub end_image { Line 254  sub end_image {
     my $name = $Apache::imageresponse::curname;      my $name = $Apache::imageresponse::curname;
     my $image = &Apache::lonxml::endredirection;      my $image = &Apache::lonxml::endredirection;
     &Apache::lonxml::debug("out is $image");      &Apache::lonxml::debug("out is $image");
     if ( $Apache::imageresponse::conceptgroup ) {      if ( $Apache::imageresponse::conceptgroup
    && !&Apache::response::showallfoils()) {
       $Apache::response::conceptgroup{"$name.image"} = $image;        $Apache::response::conceptgroup{"$name.image"} = $image;
     } else {      } else {
       $Apache::response::foilgroup{"$name.image"} = $image;        $Apache::response::foilgroup{"$name.image"} = $image;
Line 272  sub grade_rectangle { Line 281  sub grade_rectangle {
   &Apache::lonxml::debug("Point $x1,$y1,$x2,$y2");    &Apache::lonxml::debug("Point $x1,$y1,$x2,$y2");
   if ($x1 > $x2) { my $temp=$x1;$x1=$x2;$x2=$temp; }    if ($x1 > $x2) { my $temp=$x1;$x1=$x2;$x2=$temp; }
   if ($y1 > $y2) { my $temp=$y1;$y1=$y2;$y2=$temp; }    if ($y1 > $y2) { my $temp=$y1;$y1=$y2;$y2=$temp; }
   if ($x => $x1) { if ($x <= $x2) { if ($y => $y1) { if ($y <= $y2) { return 'APPROX_ANS'; } } } }    if (($x >= $x1) && ($x <= $x2) && ($y >= $y1) && ($y <= $y2)) {
       return 'APPROX_ANS';
     }
   return 'INCORRECT';    return 'INCORRECT';
 }  }
   
Line 282  sub end_rectangle { Line 293  sub end_rectangle {
     my $name = $Apache::imageresponse::curname;      my $name = $Apache::imageresponse::curname;
     my $area = &Apache::lonxml::endredirection;      my $area = &Apache::lonxml::endredirection;
     &Apache::lonxml::debug("out is $area for $name");      &Apache::lonxml::debug("out is $area for $name");
     if ( $Apache::imageresponse::conceptgroup ) {      if ( $Apache::imageresponse::conceptgroup
    && !&Apache::response::showallfoils()) {
       push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area";        push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area";
     } else {      } else {
       push @{ $Apache::response::foilgroup{"$name.area"} },"rectangle:$area";        push @{ $Apache::response::foilgroup{"$name.area"} },"rectangle:$area";

Removed from v.1.16  
changed lines
  Added in v.1.18


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