Diff for /loncom/homework/imageresponse.pm between versions 1.36 and 1.37

version 1.36, 2003/09/24 19:20:58 version 1.37, 2003/10/27 19:27:09
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 # July,August 2003 H. K. Ng  
 #  
 #FIXME LATER assumes multiple possible submissions but only one is possible   #FIXME LATER assumes multiple possible submissions but only one is possible 
 #currently  #currently
   
Line 49  sub start_imageresponse { Line 47  sub start_imageresponse {
     my $id = &Apache::response::start_response($parstack,$safeeval);      my $id = &Apache::response::start_response($parstack,$safeeval);
     if ($target eq 'meta') {      if ($target eq 'meta') {
  $result=&Apache::response::meta_package_write('imageresponse');   $result=&Apache::response::meta_package_write('imageresponse');
       } elsif ($target eq 'analyze') {
    my $part_id="$Apache::inputtags::part.$id";
    push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
     }      }
     return $result;      return $result;
 }  }
Line 183  sub end_foilgroup { Line 184  sub end_foilgroup {
     $result=&displayfoils($target,@whichopt);      $result=&displayfoils($target,@whichopt);
  } elsif ($target eq 'grade') {   } elsif ($target eq 'grade') {
     if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); }      if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); }
  }    } elsif ( $target eq 'analyze') {
       &Apache::response::analyze_store_foilgroup(\@whichopt,
         ['text','image','area']);
    }
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result=&Apache::edit::end_table();   $result=&Apache::edit::end_table();
     }      }
Line 200  sub end_conceptgroup { Line 204  sub end_conceptgroup {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     $Apache::imageresponse::conceptgroup=0;      $Apache::imageresponse::conceptgroup=0;
     my $result;      my $result;
     if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' ||
  if (defined(@{ $Apache::response::conceptgroup{'names'} })) {   $target eq 'analyze') {
     my @names = @{ $Apache::response::conceptgroup{'names'} };   &Apache::response::pick_foil_for_concept($target,
     my $pick=int(&Math::Random::random_uniform() * ($#names+1));   ['area','text','image'],
     my $name=$names[$pick];   \%Apache::hint::image,
     if (defined(@{ $Apache::response::conceptgroup{"$name.area"} })) {   $parstack,$safeeval);
  push @{ $Apache::response::foilgroup{'names'} }, $name;  
  $Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"};  
  $Apache::response::foilgroup{"$name.image"} = $Apache::response::conceptgroup{"$name.image"};  
  push(@{ $Apache::response::foilgroup{"$name.area"} }, @{ $Apache::response::conceptgroup{"$name.area"} });  
  my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);  
  $Apache::response::foilgroup{"$name.concept"} = $concept;  
  &Apache::lonxml::debug("Selecting $name in $concept");  
     }  
  }  
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result=&Apache::edit::end_table();   $result=&Apache::edit::end_table();
     }      }
Line 234  sub insert_foil { Line 229  sub insert_foil {
 $Apache::imageresponse::curname='';  $Apache::imageresponse::curname='';
 sub start_foil {  sub start_foil {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' ||
    $target eq 'analyze') {
  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
Line 260  sub end_foil { Line 256  sub end_foil {
 sub start_text {  sub start_text {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';      my $result='';
     if ($target eq 'web' || $target eq 'tex') {       if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { 
  &Apache::lonxml::startredirection;    &Apache::lonxml::startredirection; 
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  my $descr=&Apache::lonxml::get_all_text('/text',$parser);   my $descr=&Apache::lonxml::get_all_text('/text',$parser);
Line 278  sub start_text { Line 274  sub start_text {
 sub end_text {  sub end_text {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;      my $result;
     if ($target eq 'web' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  my $name = $Apache::imageresponse::curname;   my $name = $Apache::imageresponse::curname;
  if ( $Apache::imageresponse::conceptgroup   if ( $Apache::imageresponse::conceptgroup
      && !&Apache::response::showallfoils() ) {       && !&Apache::response::showallfoils() ) {
Line 295  sub end_text { Line 291  sub end_text {
 sub start_image {  sub start_image {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';      my $result='';
     if ($target eq 'web' || $target eq 'tex') {       if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { 
  &Apache::lonxml::startredirection;    &Apache::lonxml::startredirection; 
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);   my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);
Line 355  sub end_image { Line 351  sub end_image {
  if ( $Apache::imageresponse::conceptgroup   if ( $Apache::imageresponse::conceptgroup
      && !&Apache::response::showallfoils()) {       && !&Apache::response::showallfoils()) {
     $Apache::response::conceptgroup{"$name.image"} = $image;      $Apache::response::conceptgroup{"$name.image"} = $image;
    } else {
       $Apache::response::foilgroup{"$name.image"} = $image;
    }
       } elsif ($target eq 'analyze') {
    my $image = &Apache::lonxml::endredirection;
    if ( $Apache::imageresponse::conceptgroup
        && !&Apache::response::showallfoils()) {
       $Apache::response::conceptgroup{"$name.image"} = $image;
  } else {   } else {
     $Apache::response::foilgroup{"$name.image"} = $image;      $Apache::response::foilgroup{"$name.image"} = $image;
  }   }

Removed from v.1.36  
changed lines
  Added in v.1.37


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