Diff for /loncom/homework/radiobuttonresponse.pm between versions 1.99 and 1.106

version 1.99, 2005/01/31 22:00:40 version 1.106, 2006/03/27 21:18:16
Line 30  package Apache::radiobuttonresponse; Line 30  package Apache::radiobuttonresponse;
 use strict;  use strict;
 use HTML::Entities();  use HTML::Entities();
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::lonnet;
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));      &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));
Line 59  sub start_radiobuttonresponse { Line 60  sub start_radiobuttonresponse {
     $token,'4').      $token,'4').
     &Apache::edit::select_arg('Randomize Foil Order','randomize',      &Apache::edit::select_arg('Randomize Foil Order','randomize',
       ['yes','no'],$token).        ['yes','no'],$token).
       &Apache::edit::select_arg('Display Direction','direction',
         ['vertical','horizontal'],$token).
       &Apache::edit::end_row().        &Apache::edit::end_row().
       &Apache::edit::start_spanning_row()."\n";        &Apache::edit::start_spanning_row()."\n";
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my $constructtag=&Apache::edit::get_new_args($token,$parstack,   my $constructtag=&Apache::edit::get_new_args($token,$parstack,
      $safeeval,'max',       $safeeval,'max',
      'randomize');       'randomize','direction');
  if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }   if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  my $type=&Apache::lonxml::get_param('TeXtype',$parstack,$safeeval,   my $type=&Apache::lonxml::get_param('TeXtype',$parstack,$safeeval,
Line 115  sub start_foilgroup { Line 118  sub start_foilgroup {
   
 sub storesurvey {  sub storesurvey {
     if ( !&Apache::response::submitted() ) { return ''; }      if ( !&Apache::response::submitted() ) { return ''; }
     my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1']};      my $response = $env{'form.HWVAL_'.$Apache::inputtags::response['-1']};
     &Apache::lonxml::debug("Here I am!:$response:");      &Apache::lonxml::debug("Here I am!:$response:");
     if ( $response !~ /[0-9]+/) { return ''; }      if ( $response !~ /[0-9]+/) { return ''; }
     my $part = $Apache::inputtags::part;      my $part = $Apache::inputtags::part;
Line 139  sub grade_response { Line 142  sub grade_response {
     my ($answer,@whichfoils)=&whichfoils($max,$randomize);      my ($answer,@whichfoils)=&whichfoils($max,$randomize);
     if ( !&Apache::response::submitted() ) { return; }      if ( !&Apache::response::submitted() ) { return; }
     my $response;      my $response;
     if ($ENV{'form.submitted'} eq 'scantron') {      if ($env{'form.submitted'} eq 'scantron') {
  $response=&Apache::response::getresponse();   $response=&Apache::response::getresponse();
     } else {      } else {
  $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1']};   $response = $env{'form.HWVAL_'.$Apache::inputtags::response['-1']};
     }      }
     if ( $response !~ /[0-9]+/) { return; }      if ( $response !~ /[0-9]+/) { return; }
     my $part=$Apache::inputtags::part;      my $part=$Apache::inputtags::part;
Line 231  sub displayallfoils { Line 234  sub displayallfoils {
     my ($direction)=@_;      my ($direction)=@_;
     my $result;      my $result;
     &Apache::lonxml::debug("survey style display");      &Apache::lonxml::debug("survey style display");
     my @names = @{ $Apache::response::foilgroup{'names'} };      my @names;
       if ( $Apache::response::foilgroup{'names'} ) {
    @names= @{ $Apache::response::foilgroup{'names'} };
       }
     my $temp=0;      my $temp=0;
     my $id=$Apache::inputtags::response['-1'];      my $id=$Apache::inputtags::response['-1'];
     my $part=$Apache::inputtags::part;      my $part=$Apache::inputtags::part;
Line 288  sub whichfoils { Line 294  sub whichfoils {
     my ($truecnt,$falsecnt) = &getfoilcounts();      my ($truecnt,$falsecnt) = &getfoilcounts();
     my $count=0;      my $count=0;
     # we will add in 1 of the true statements      # we will add in 1 of the true statements
     if (($falsecnt+1)>$max) { $count=$max } else { $count=$falsecnt+1; }      if ( $max>0 && ($falsecnt+1)>$max) { $count=$max } else { $count=$falsecnt+1; $max=$count; }
     my $answer=int(&Math::Random::random_uniform() * ($count));      my $answer=int(&Math::Random::random_uniform() * ($count));
     &Apache::lonxml::debug("Count is $count, $answer is $answer");      &Apache::lonxml::debug("Count is $count, $answer is $answer");
     my @names;      my @names;
Line 504  sub displayfoils { Line 510  sub displayfoils {
 }  }
   
 sub displayallanswers {  sub displayallanswers {
     my @names = @{ $Apache::response::foilgroup{'names'} };      my @names;
       if ( $Apache::response::foilgroup{'names'} ) {
    @names= @{ $Apache::response::foilgroup{'names'} };
       }
       
     my $result=&Apache::response::answer_header('radiobuttonresponse');      my $result=&Apache::response::answer_header('radiobuttonresponse');
     foreach my $name (@names) {      foreach my $name (@names) {
Line 519  sub displayanswers { Line 528  sub displayanswers {
     my ($max,$randomize)=@_;      my ($max,$randomize)=@_;
     my ($answer,@whichopt) = &whichfoils($max,$randomize);      my ($answer,@whichopt) = &whichfoils($max,$randomize);
     my $result=&Apache::response::answer_header('radiobuttonresponse');      my $result=&Apache::response::answer_header('radiobuttonresponse');
       if ($Apache::lonhomework::type eq 'exam') {
    my $correct = ('A'..'Z')[$answer];
    $result.=&Apache::response::answer_part('radiobuttonresponse',
    $correct);
       }
     foreach my $name (@whichopt) {      foreach my $name (@whichopt) {
  $result.=&Apache::response::answer_part('radiobuttonresponse',   $result.=&Apache::response::answer_part('radiobuttonresponse',
  $Apache::response::foilgroup{$name.'.value'})   $Apache::response::foilgroup{$name.'.value'});
  }      }
     $result.=&Apache::response::answer_footer('radiobuttonresponse');      $result.=&Apache::response::answer_footer('radiobuttonresponse');
     return $result;      return $result;
 }  }
Line 606  sub end_foil { Line 620  sub end_foil {
  my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);   my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
  if ($value ne 'unused') {   if ($value ne 'unused') {
     my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);      my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
     if (!$name) {      if ($name eq "") {
  &Apache::lonxml::error("Foils without names exist. This can cause problems to malfunction.");   &Apache::lonxml::warning("Foils without names exist. This can cause problems to malfunction.");
  $name=$Apache::lonxml::curdepth;   $name=$Apache::lonxml::curdepth;
     }      }
     if (defined($Apache::response::foilnames{$name})) {      if (defined($Apache::response::foilnames{$name})) {

Removed from v.1.99  
changed lines
  Added in v.1.106


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