Diff for /loncom/homework/radiobuttonresponse.pm between versions 1.70 and 1.71

version 1.70, 2003/04/18 17:10:08 version 1.71, 2003/05/16 19:25:08
Line 295  sub whichfoils { Line 295  sub whichfoils {
     &Apache::lonxml::debug("Max is $max, From $#truelist elms, picking $whichtrue");      &Apache::lonxml::debug("Max is $max, From $#truelist elms, picking $whichtrue");
     my (@toplist, @bottomlist);      my (@toplist, @bottomlist);
     my $topcount=0;      my $topcount=0;
       my $bottomcount=0;
     # assign everyone to either toplist/bottomlist or whichfalse      # assign everyone to either toplist/bottomlist or whichfalse
     # which false is randomized, toplist bottomlist are in order      # which false is randomized, toplist bottomlist are in order
     while ((($#whichfalse) < $max-2) && ($#falselist > -1)) {      while ((($#whichfalse+$topcount+$bottomcount) < $max-2) && ($#falselist > -1)) {
  &Apache::lonxml::debug("Have $#whichfalse max is $max");   &Apache::lonxml::debug("Have $#whichfalse max is $max");
  my $afalse=int(&Math::Random::random_uniform() * ($#falselist+1));   my $afalse=int(&Math::Random::random_uniform() * ($#falselist+1));
  &Apache::lonxml::debug("From $#falselist elms, picking $afalse");   &Apache::lonxml::debug("From $#falselist elms, picking $afalse");
Line 310  sub whichfoils { Line 311  sub whichfoils {
     $topcount++;      $topcount++;
  } elsif ($bottom{$afalse}) {   } elsif ($bottom{$afalse}) {
     $bottomlist[$bottom{$afalse}]=$afalse;      $bottomlist[$bottom{$afalse}]=$afalse;
       $bottomcount++;
  } else {   } else {
     push (@whichfalse,$afalse);      push (@whichfalse,$afalse);
  }   }
     }      }
       &Apache::lonxml::debug("Answer wants $answer");
     my $truename=$truelist[$whichtrue];      my $truename=$truelist[$whichtrue];
     my $dosplice=1;      my $dosplice=1;
     #insert the true statement, keeping track of where it wants to be      #insert the true statement, keeping track of where it wants to be
Line 335  sub whichfoils { Line 338  sub whichfoils {
  $answer+=$topcount+$#whichfalse+1;   $answer+=$topcount+$#whichfalse+1;
  $dosplice=0;   $dosplice=0;
     } else {      } else {
  if ($topcount>0) {    if ($topcount>0 || $bottomcount>0) {
   $answer = int(&Math::Random::random_uniform() * ($#whichfalse+1))      $answer = int(&Math::Random::random_uniform() * ($#whichfalse+1))
     + $topcount;   + $topcount;
  }   }
     }      }
       &Apache::lonxml::debug("Answer now wants $answer");
     #add the top items to the top, bottom items to the bottom      #add the top items to the top, bottom items to the bottom
     for (my $i=0;$i<=$#toplist;$i++) {      for (my $i=0;$i<=$#toplist;$i++) {
  if ($toplist[$i]) { unshift(@whichfalse,$toplist[$i]) }   if ($toplist[$i]) { unshift(@whichfalse,$toplist[$i]) }

Removed from v.1.70  
changed lines
  Added in v.1.71


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