File:  [LON-CAPA] / loncom / homework / structuretags.pm
Revision 1.4: download - view: text, annotated - select for diffs
Tue Aug 22 16:19:26 2000 UTC (23 years, 8 months ago) by tsai
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

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

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