--- loncom/homework/structuretags.pm 2000/10/05 19:26:16 1.8 +++ loncom/homework/structuretags.pm 2000/10/11 21:03:27 1.9 @@ -6,7 +6,21 @@ use strict; use Apache::lonnet; sub BEGIN { - &Apache::lonxml::register('Apache::structuretags',('block','while','randomlist')); + &Apache::lonxml::register('Apache::structuretags',('block','while','randomlist','problem')); +} + +sub start_problem { + my ($target,$token,$parstack,$parser,$safeeval)=@_; + my $args =''; + if ( $#$parstack > -1 ) { + $args=$$parstack[$#$parstack]; + } + my $name = &Apache::run::run("{$args;".'return $name}',$safeeval); + return "$name\n\n" +} + +sub end_problem { + return "\n"; } sub start_block { @@ -19,7 +33,7 @@ sub start_block { 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]); + my $skip=&Apache::lonxml::get_all_text("/block",$$parser[$#$parser]); # print "skipped $skip"; } return ""; @@ -64,7 +78,7 @@ sub end_while { # sub start_randomlist { my ($target,$token,$parstack,$parser,$safeeval)=@_; - my $body= &Apache::lonxml::get_all_text("randomlist",$$parser[$#$parser]); + my $body= &Apache::lonxml::get_all_text("/randomlist",$$parser[$#$parser]); my $b_parser= HTML::TokeParser->new(\$body); my $b_tok; my @randomlist; @@ -75,7 +89,7 @@ sub start_randomlist { # get content of the tag until matching end tag # get all text upto the matching tag # and push the content into @randomlist - $list_item = &Apache::lonxml::get_all_text($b_tok->[1],$b_parser); + $list_item = &Apache::lonxml::get_all_text('/'.$b_tok->[1],$b_parser); $list_item = "$b_tok->[4]"."$list_item"."[1]>"; push(@randomlist,$list_item); # print "
START-TAG $b_tok->[1], $b_tok->[4], $list_item";