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

1.1       albertel    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 {
1.4       tsai       10:   &Apache::lonxml::register('Apache::structuretags',('block','while'));
1.1       albertel   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;';
1.3       albertel   19: #  print "<br>$code<br>";
1.1       albertel   20:   my $result = &Apache::run::run($code,$safeeval);
                     21:   if ( ! $result ) { 
1.3       albertel   22: #    my $skip=$$parser[$#$parser]->get_text("/block");
                     23:     my $skip=&Apache::lonxml::get_all_text("block",$$parser[$#$parser]);
                     24: #    print "skipped $skip";
1.1       albertel   25:   }
                     26:   return "";
                     27: }
                     28: 
                     29: sub end_block {
1.4       tsai       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: 
1.5     ! tsai       39:   push( @Apache::structuretags::whileconds, $code); 
1.4       tsai       40:   my $result = &Apache::run::run($code,$safeeval);
                     41:   my $bodytext=$$parser[$#$parser]->get_text("/while");
1.5     ! tsai       42:   push( @Apache::structuretags::whilebody, $bodytext);
        !            43:   if ( $result ) { 
1.4       tsai       44:      my $tempparser=HTML::TokeParser->new(\$bodytext);
                     45:      push (@$parser,$tempparser);
                     46:   }
1.5     ! tsai       47: 
1.4       tsai       48:   return "";
                     49: }
                     50: 
                     51: sub end_while {
1.5     ! tsai       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 "";
1.1       albertel   61: }
                     62: 
                     63: 1;
                     64: __END__

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