--- loncom/interface/lonhelper.pm 2006/03/06 23:32:31 1.132
+++ loncom/interface/lonhelper.pm 2008/12/19 20:51:35 1.169
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.132 2006/03/06 23:32:31 foxr Exp $
+# $Id: lonhelper.pm,v 1.169 2008/12/19 20:51:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -81,25 +81,28 @@ State tags are also required to have an
human name of the state, and will be displayed as the header on top of
the screen for the user.
+State tags may also optionally have an attribute "help" which should be
+the filename of a help file, this will add a blue ? to the title.
+
=head2 Example Helper Skeleton
An example of the tags so far:
-
+
-Of course this does nothing. In order for the wizard to do something, it is
-necessary to put actual elements into the wizard. Documentation for each
+Of course this does nothing. In order for the helper to do something, it is
+necessary to put actual elements into the helper. Documentation for each
of these elements follows.
=head1 Creating a Helper With Code, Not XML
-In some situations, such as the printing wizard (see lonprintout.pm),
+In some situations, such as the printing helper (see lonprintout.pm),
writing the helper in XML would be too complicated, because of scope
issues or the fact that the code actually outweighs the XML. It is
possible to create a helper via code, though it is a little odd.
@@ -183,6 +186,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
@@ -331,7 +337,8 @@ sub start_state {
}
Apache::lonhelper::state->new($token->[2]{'name'},
- $token->[2]{'title'});
+ $token->[2]{'title'},
+ $token->[2]{'help'});
return '';
}
@@ -361,6 +368,7 @@ use Apache::loncommon;
use Apache::File;
use Apache::lonlocal;
use Apache::lonnet;
+use LONCAPA;
sub new {
my $proto = shift;
@@ -466,9 +474,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);
}
@@ -483,7 +490,7 @@ sub declareVar {
$self->{VARS}->{$var} = '';
}
- my $envname = 'form.' . $var . '.forminput';
+ my $envname = 'form.' . $var . '_forminput';
if (defined($env{$envname})) {
if (ref($env{$envname})) {
$self->{VARS}->{$var} = join('|||', @{$env{$envname}});
@@ -573,30 +580,28 @@ sub display {
}
# Phase 4: Display.
- my $html=&Apache::lonxml::xmlbegin();
my $stateTitle=&mt($state->title());
- my $helperTitle = &mt($self->{TITLE});
- my $browser_searcher_js = &Apache::loncommon::browser_and_searcher_javascript();
- my $bodytag = &Apache::loncommon::bodytag($helperTitle,'','');
+ my $stateHelp= $state->help();
+ my $browser_searcher_js =
+ '';
+
+ $result .= &Apache::loncommon::start_page($self->{TITLE},
+ $browser_searcher_js);
+
my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"');
my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"');
# FIXME: This should be parameterized, not concatenated - Jeremy
- my $loncapaHelper = &mt("LON-CAPA Helper:");
- $result .= <
- $loncapaHelper: $helperTitle
-
-
- $bodytag
-HEADER
+
if (!$state->overrideForm()) { $result.="