Diff for /loncom/homework/radiobuttonresponse.pm between versions 1.83 and 1.88

version 1.83, 2004/03/05 22:59:48 version 1.88, 2004/05/07 17:18:45
Line 29 Line 29
 package Apache::radiobuttonresponse;  package Apache::radiobuttonresponse;
 use strict;  use strict;
 use HTML::Entities();  use HTML::Entities();
   use Apache::lonlocal;
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));      &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));
Line 42  sub start_radiobuttonresponse { Line 43  sub start_radiobuttonresponse {
     push (@Apache::lonxml::namespace,'radiobuttonresponse');      push (@Apache::lonxml::namespace,'radiobuttonresponse');
     my $id = &Apache::response::start_response($parstack,$safeeval);      my $id = &Apache::response::start_response($parstack,$safeeval);
     %Apache::hint::radiobutton=();      %Apache::hint::radiobutton=();
       undef(%Apache::response::foilnames);
     if ($target eq 'meta') {      if ($target eq 'meta') {
  $result=&Apache::response::meta_package_write('radiobuttonresponse');   $result=&Apache::response::meta_package_write('radiobuttonresponse');
     } elsif ($target eq 'edit' ) {      } elsif ($target eq 'edit' ) {
Line 75  sub start_radiobuttonresponse { Line 77  sub start_radiobuttonresponse {
     $result .= ' \renewcommand{\labelenumi}{\alph{enumi}.}';      $result .= ' \renewcommand{\labelenumi}{\alph{enumi}.}';
  } elsif ($type eq 'i') {   } elsif ($type eq 'i') {
     $result .= ' \renewcommand{\labelenumi}{\roman{enumi}.}';      $result .= ' \renewcommand{\labelenumi}{\roman{enumi}.}';
    } else {
       $result .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}';
  }   }
  $result .= '\begin{enumerate}';   $result .= '\begin{enumerate}';
     } elsif ($target eq 'analyze') {      } elsif ($target eq 'analyze') {
Line 92  sub end_radiobuttonresponse { Line 96  sub end_radiobuttonresponse {
     &Apache::response::end_response;      &Apache::response::end_response;
     pop @Apache::lonxml::namespace;      pop @Apache::lonxml::namespace;
     &Apache::lonxml::deregister('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup'));      &Apache::lonxml::deregister('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup'));
       undef(%Apache::response::foilnames);
     return $result;      return $result;
 }  }
   
Line 227  sub displayallfoils { Line 232  sub displayallfoils {
     if (&Apache::response::show_answer() ) {      if (&Apache::response::show_answer() ) {
  foreach my $name (@names) {   foreach my $name (@names) {
     if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') {      if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') {
  $result.="<br />".$Apache::response::foilgroup{$name.'.value'};   $result.="<br />";
  if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {   if (defined($lastresponse{$name})) {
     $result.='<b>';      $result.='<b>';
  }   }
  $result .= $Apache::response::foilgroup{$name.'.text'};   $result .= $Apache::response::foilgroup{$name.'.text'};
  if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {   if (defined($lastresponse{$name})) {
     $result.='</b>';      $result.='</b>';
  }   }
     }      }
Line 280  sub whichfoils { Line 285  sub whichfoils {
  push (@whichfalse,$name);   push (@whichfalse,$name);
     } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'unused') {      } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'unused') {
     } else {      } else {
  &Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in <foilgroup>"));   &Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in <foilgroup>",'<>&"'));
     }      }
  }   }
     } else {      } else {
Line 306  sub whichfoils { Line 311  sub whichfoils {
  }   }
     } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'unused') {      } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'unused') {
     } else {      } else {
  &Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in <foilgroup>"));   &Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in <foilgroup>",'<>&"'));
     }      }
  }   }
  #pick a true statement   #pick a true statement
Line 535  sub end_foil { Line 540  sub end_foil {
     if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {      if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  $text=&Apache::lonxml::endredirection;   $text=&Apache::lonxml::endredirection;
     }      }
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'  || $target eq 'tex' || $target eq 'analyze') {      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'
    || $target eq 'tex' || $target eq 'analyze') {
  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);
     my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);  
     if (!$name) { $name=$Apache::lonxml::curdepth; }      if (!$name) { $name=$Apache::lonxml::curdepth; }
       if (defined($Apache::response::foilnames{$name})) {
    &Apache::lonxml::error(&mt("Foil name <b><tt>[_1]</tt></b> appears more than once. Foil names need to be unique.",$name));
       }
       $Apache::response::foilnames{$name}++;
       my $location =&Apache::lonxml::get_param('location',$parstack,
        $safeeval);
     if ( $Apache::radiobuttonresponse::conceptgroup      if ( $Apache::radiobuttonresponse::conceptgroup
  && !&Apache::response::showallfoils() ) {   && !&Apache::response::showallfoils() ) {
  push @{ $Apache::response::conceptgroup{'names'} }, $name;   push @{ $Apache::response::conceptgroup{'names'} }, $name;

Removed from v.1.83  
changed lines
  Added in v.1.88


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