File:  [LON-CAPA] / loncom / homework / structuretags.pm
Revision 1.5: download - view: text, annotated - select for diffs
Fri Aug 25 14:40:47 2000 UTC (23 years, 8 months ago) by tsai
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

# The LearningOnline Network with CAPA
# <script> definiton

package Apache::structuretags; 

use strict;
use Apache::lonnet;

sub BEGIN {
  &Apache::lonxml::register('Apache::structuretags',('block','while'));
}

sub start_block {
  my ($target,$token,$parstack,$parser,$safeeval)=@_;

  my $code = @$parstack[$#$parstack];
  $code =~ s/\"//g;
  $code .=';return $condition;';
#  print "<br>$code<br>";
  my $result = &Apache::run::run($code,$safeeval);
  if ( ! $result ) { 
#    my $skip=$$parser[$#$parser]->get_text("/block");
    my $skip=&Apache::lonxml::get_all_text("block",$$parser[$#$parser]);
#    print "skipped $skip";
  }
  return "";
}

sub end_block {
}

sub start_while {
  my ($target,$token,$parstack,$parser,$safeeval)=@_;

  my $code = @$parstack[$#$parstack];
  $code =~ s/\"//g;
  $code .=';return $condition;';

  push( @Apache::structuretags::whileconds, $code); 
  my $result = &Apache::run::run($code,$safeeval);
  my $bodytext=$$parser[$#$parser]->get_text("/while");
  push( @Apache::structuretags::whilebody, $bodytext);
  if ( $result ) { 
     my $tempparser=HTML::TokeParser->new(\$bodytext);
     push (@$parser,$tempparser);
  }

  return "";
}

sub end_while {
  my ($target,$token,$parstack,$parser,$safeeval)=@_;
  my $code = pop @Apache::structuretags::whileconds;
  my $bodytext = pop @Apache::structuretags::whilebody;
  my $result = &Apache::run::run($code,$safeeval);
  if ( $result ) { 
     my $tempparser=HTML::TokeParser->new(\$bodytext);
     push (@$parser,$tempparser);
  } 
  return "";
}

1;
__END__

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