[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Fri, 02 May 2003 19:20:51 -0000
bowersj2 Fri May 2 15:20:51 2003 EDT
Modified files:
/loncom/interface lonhelper.pm
Log:
Resource panels have new options "toponly" to avoid recursion.
Enhanced documentation for creating helpers by code.
Fixed some features with the preprocessing that was supposed to work;
states are supposed to have the opportunity to bypass themselves. The
page format element does this (if the user did not select one col, it
skips itself). For a variety of reasons this was not working.
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.16 loncom/interface/lonhelper.pm:1.17
--- loncom/interface/lonhelper.pm:1.16 Wed Apr 30 15:23:48 2003
+++ loncom/interface/lonhelper.pm Fri May 2 15:20:51 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.16 2003/04/30 19:23:48 bowersj2 Exp $
+# $Id: lonhelper.pm,v 1.17 2003/05/02 19:20:51 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -149,7 +149,11 @@
and -maintain code.
It is possible to do some of the work with an XML fragment parsed by
-lonxml; again, see lonprintout.pm for an example.
+lonxml; again, see lonprintout.pm for an example. In that case it is
+imperative that you call B<Apache::lonhelper::registerHelperTags()>
+before parsing XML fragments and B<Apache::lonhelper::unregisterHelperTags()>
+when you are done. See lonprintout.pm for examples of this usage in the
+printHelper subroutine.
=cut
@@ -462,7 +466,7 @@
# Phase 2: Preprocess current state
my $startState = $self->{STATE};
- my $state = $self->{STATES}{$startState};
+ my $state = $self->{STATES}->{$startState};
# For debugging, print something here to determine if you're going
# to an undefined state.
@@ -473,10 +477,11 @@
# Phase 3: While the current state is different from the previous state,
# keep processing.
- while ( $startState ne $self->{STATE} )
+ while ( $startState ne $self->{STATE} &&
+ defined($self->{STATES}->{$self->{STATE}}) )
{
$startState = $self->{STATE};
- $state = $self->{STATES}{$startState};
+ $state = $self->{STATES}->{$startState};
$state->preprocess();
}
@@ -495,6 +500,11 @@
my $result = "";
+ if (!defined($state)) {
+ $result = "<font color='#ff0000'>Error: state '$state' not defined!</font>";
+ return $result;
+ }
+
# Phase 4: Display.
my $stateTitle = $state->title();
my $bodytag = &Apache::loncommon::bodytag("$self->{TITLE}",'','');
@@ -1295,7 +1305,10 @@
<resource> takes the standard variable attribute to control what helper
variable stores the results. It also takes a "multichoice" attribute,
-which controls whether the user can select more then one resource.
+which controls whether the user can select more then one resource. The
+"toponly" attribute controls whether the resource display shows just the
+resources in that sequence, or recurses into all sub-sequences, defaulting
+to false.
B<SUB-TAGS>
@@ -1356,6 +1369,7 @@
$paramHash->{'variable'} = $token->[2]{'variable'};
$helper->declareVar($paramHash->{'variable'});
$paramHash->{'multichoice'} = $token->[2]{'multichoice'};
+ $paramHash->{'toponly'} = $token->[2]{'toponly'};
return '';
}
@@ -1516,7 +1530,7 @@
}
};
- $ENV{'form.condition'} = 1;
+ $ENV{'form.condition'} = !$self->{'toponly'};
$result .=
&Apache::lonnavmaps::render( { 'cols' => [$renderColFunc,
Apache::lonnavmaps::resource()],