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, 9 months ago) by tsai
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

    1: # The LearningOnline Network with CAPA
    2: # <script> definiton
    3: 
    4: package Apache::structuretags; 
    5: 
    6: use strict;
    7: use Apache::lonnet;
    8: 
    9: sub BEGIN {
   10:   &Apache::lonxml::register('Apache::structuretags',('block','while'));
   11: }
   12: 
   13: sub start_block {
   14:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   15: 
   16:   my $code = @$parstack[$#$parstack];
   17:   $code =~ s/\"//g;
   18:   $code .=';return $condition;';
   19: #  print "<br>$code<br>";
   20:   my $result = &Apache::run::run($code,$safeeval);
   21:   if ( ! $result ) { 
   22: #    my $skip=$$parser[$#$parser]->get_text("/block");
   23:     my $skip=&Apache::lonxml::get_all_text("block",$$parser[$#$parser]);
   24: #    print "skipped $skip";
   25:   }
   26:   return "";
   27: }
   28: 
   29: sub end_block {
   30: }
   31: 
   32: sub start_while {
   33:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   34: 
   35:   my $code = @$parstack[$#$parstack];
   36:   $code =~ s/\"//g;
   37:   $code .=';return $condition;';
   38: 
   39:   push( @Apache::structuretags::whileconds, $code); 
   40:   my $result = &Apache::run::run($code,$safeeval);
   41:   my $bodytext=$$parser[$#$parser]->get_text("/while");
   42:   push( @Apache::structuretags::whilebody, $bodytext);
   43:   if ( $result ) { 
   44:      my $tempparser=HTML::TokeParser->new(\$bodytext);
   45:      push (@$parser,$tempparser);
   46:   }
   47: 
   48:   return "";
   49: }
   50: 
   51: sub end_while {
   52:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   53:   my $code = pop @Apache::structuretags::whileconds;
   54:   my $bodytext = pop @Apache::structuretags::whilebody;
   55:   my $result = &Apache::run::run($code,$safeeval);
   56:   if ( $result ) { 
   57:      my $tempparser=HTML::TokeParser->new(\$bodytext);
   58:      push (@$parser,$tempparser);
   59:   } 
   60:   return "";
   61: }
   62: 
   63: 1;
   64: __END__

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