--- loncom/interface/lonhelper.pm 2006/05/16 20:45:26 1.150 +++ loncom/interface/lonhelper.pm 2006/06/25 21:50:25 1.155 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.150 2006/05/16 20:45:26 albertel Exp $ +# $Id: lonhelper.pm,v 1.155 2006/06/25 21:50:25 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -183,7 +183,9 @@ use Apache::File; use Apache::lonxml; use Apache::lonlocal; use Apache::lonnet; +use Apache::longroup; use Apache::lonselstudent; +use LONCAPA; # Register all the tags with the helper, so the helper can # push and pop them @@ -362,6 +364,7 @@ use Apache::loncommon; use Apache::File; use Apache::lonlocal; use Apache::lonnet; +use LONCAPA; sub new { my $proto = shift; @@ -467,9 +470,8 @@ sub _saveVars { sub _varsInFile { my $self = shift; my @vars = (); - for my $key (keys %{$self->{VARS}}) { - push @vars, &Apache::lonnet::escape($key) . '=' . - &Apache::lonnet::escape($self->{VARS}->{$key}); + for my $key (keys(%{$self->{VARS}})) { + push(@vars, &escape($key) . '=' . &escape($self->{VARS}->{$key})); } return join ('&', @vars); } @@ -1021,6 +1023,81 @@ sub postprocess { } 1; +package Apache::lonhelper::skip; + +=pod + +=head1 Elements + +=head2 Element: skipX + +The tag allows you define conditions under which the current state +should be skipped over and define what state to skip to. + + + + + #some code that decides whether to skip the state or not + + FINISH + + A possibly skipped state + + +=cut + +no strict; +@ISA = ("Apache::lonhelper::element"); +use strict; + +BEGIN { + &Apache::lonhelper::register('Apache::lonhelper::skip', + ('skip')); +} + +sub new { + my $ref = Apache::lonhelper::element->new(); + bless($ref); +} + +sub start_skip { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + + if ($target ne 'helper') { + return ''; + } + # let know what text to skip to + $paramHash->{SKIPTAG}='/skip'; + return ''; +} + +sub end_skip { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + + if ($target ne 'helper') { + return ''; + } + Apache::lonhelper::skip->new(); + return ''; +} + +sub render { + my $self = shift; + return ''; +} +# If a NEXTSTATE is set, switch to it +sub preprocess { + my ($self) = @_; + + if (defined($self->{NEXTSTATE})) { + $helper->changeState($self->{NEXTSTATE}); + } + + return 1; +} + +1; + package Apache::lonhelper::choices; =pod @@ -1608,8 +1685,6 @@ sub render { $date->min(0); } - &Apache::lonnet::logthis("date mode "); - if ($anytime) { $onclick = "onclick=\"javascript:updateCheck(this.form,'${var}anytime',false)\""; } @@ -2341,7 +2416,8 @@ sub render { my ($course_personnel, $current_members, $expired_members, - $future_members) = &Apache::lonselstudent::get_people_in_class(); + $future_members) = + &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'}); @@ -2848,7 +2924,7 @@ sub start_section { return if ($token->[2]{'onlysections'}); # add in groups to the end of the list - my %curr_groups = &Apache::loncommon::coursegroups(); + my %curr_groups = &Apache::longroup::coursegroups(); foreach my $group_name (sort(keys(%curr_groups))) { push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } @@ -2912,7 +2988,7 @@ sub start_group { # Populate the CHOICES element my %choices; - my %curr_groups = &Apache::loncommon::coursegroups(); + my %curr_groups = &Apache::longroup::coursegroups(); foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) { push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } @@ -3127,7 +3203,8 @@ sub start_clause { die 'Error in clause of condition, Perl said: ' . $@ if $@; if (!&$clause($helper, $paramHash)) { # Discard all text until the /condition. - &Apache::lonxml::get_all_text('/condition', $parser); + my $end_tag = $paramHash->{SKIPTAG} || '/condition'; + &Apache::lonxml::get_all_text($end_tag, $parser); } }