Annotation of loncom/homework/structuretags.pm, revision 1.4

1.1       albertel    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 {
1.4     ! tsai       11:   &Apache::lonxml::register('Apache::structuretags',('block','while'));
1.1       albertel   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;';
1.3       albertel   20: #  print "<br>$code<br>";
1.1       albertel   21:   my $result = &Apache::run::run($code,$safeeval);
                     22:   if ( ! $result ) { 
1.3       albertel   23: #    my $skip=$$parser[$#$parser]->get_text("/block");
                     24:     my $skip=&Apache::lonxml::get_all_text("block",$$parser[$#$parser]);
                     25: #    print "skipped $skip";
1.1       albertel   26:   }
                     27:   return "";
                     28: }
                     29: 
                     30: sub end_block {
1.4     ! tsai       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: 
1.1       albertel   58: }
                     59: 
                     60: 1;
                     61: __END__

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