Diff for /loncom/interface/lonhelper.pm between versions 1.33 and 1.34

version 1.33, 2003/05/21 13:41:00 version 1.34, 2003/05/27 19:59:38
Line 1160  BUTTONS Line 1160  BUTTONS
     if (defined($self->{DEFAULT_VALUE})) {      if (defined($self->{DEFAULT_VALUE})) {
         $checkedChoicesFunc = eval ($self->{DEFAULT_VALUE});          $checkedChoicesFunc = eval ($self->{DEFAULT_VALUE});
         die 'Error in default value code for variable ' .           die 'Error in default value code for variable ' . 
             {'variable'} . ', Perl said:' . $@ if $@;              $self->{'variable'} . ', Perl said: ' . $@ if $@;
     } else {      } else {
         $checkedChoicesFunc = sub { return ''; };          $checkedChoicesFunc = sub { return ''; };
     }      }
Line 2250  sub end_section { Line 2250  sub end_section {
 }      }    
 1;  1;
   
   package Apache::lonhelper::string;
   
   =pod
   
   =head2 Element: string
   
   string elements provide a string entry field for the user. string elements
   take the usual 'variable' and 'nextstate' parameters. string elements
   also pass through 'maxlength' and 'size' attributes to the input tag.
   
   string honors the defaultvalue tag, if given.
   
   =cut
   
   no strict;
   @ISA = ("Apache::lonhelper::element");
   use strict;
   
   BEGIN {
       &Apache::lonhelper::register('Apache::lonhelper::string',
                                 ('string'));
   }
   
   sub new {
       my $ref = Apache::lonhelper::element->new();
       bless($ref);
   }
   
   # CONSTRUCTION: Construct the message element from the XML
   sub start_string {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   
       if ($target ne 'helper') {
           return '';
       }
   
       $paramHash->{'variable'} = $token->[2]{'variable'};
       $helper->declareVar($paramHash->{'variable'});
       $paramHash->{'nextstate'} = $token->[2]{'nextstate'};
       $paramHash->{'maxlength'} = $token->[2]{'maxlength'};
       $paramHash->{'size'} = $token->[2]{'size'};
   
       return '';
   }
   
   sub end_string {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   
       if ($target ne 'helper') {
           return '';
       }
       Apache::lonhelper::string->new();
       return '';
   }
   
   sub render {
       my $self = shift;
       my $result = '<input type="string" name="' . $self->{'variable'} . '.forminput"';
   
       if (defined($self->{'size'})) {
           $result .= ' size="' . $self->{'size'} . '"';
       }
       if (defined($self->{'maxlength'})) {
           $result .= ' maxlength="' . $self->{'maxlength'} . '"';
       }
   
       if (defined($self->{DEFAULT_VALUE})) {
           my $valueFunc = eval($self->{DEFAULT_VALUE});
           die 'Error in default value code for variable ' . 
               $self->{'variable'} . ', Perl said: ' . $@ if $@;
           $result .= ' value="' . &$valueFunc($helper, $self) . '"';
       }
   
       $result .= ' />';
   
       return $result;
   }
   
   # If a NEXTSTATE was given, switch to it
   sub postprocess {
       my $self = shift;
       if (defined($self->{NEXTSTATE})) {
           $helper->changeState($self->{NEXTSTATE});
       }
   
       return 1;
   }
   
   1;
   
 package Apache::lonhelper::general;  package Apache::lonhelper::general;
   
 =pod  =pod
Line 2394  tag. It goes through all the states and Line 2484  tag. It goes through all the states and
 snippets and collecting the results. Finally, it takes the user out of the  snippets and collecting the results. Finally, it takes the user out of the
 helper, going to a provided page.  helper, going to a provided page.
   
   If the parameter "restartCourse" is true, this will override the buttons and
   will make a "Finish Helper" button that will re-initialize the course for them,
   which is useful for the Course Initialization helper so the users never see
   the old values taking effect.
   
 =cut  =cut
   
 no strict;  no strict;
Line 2410  sub new { Line 2505  sub new {
     bless($ref);      bless($ref);
 }  }
   
 sub start_final { return ''; }  sub start_final { 
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   
       if ($target ne 'helper') {
           return '';
       }
   
       $paramHash->{'restartCourse'} = $token->[2]{'restartCourse'};
   
       return ''; 
   }
   
 sub end_final {  sub end_final {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
Line 2473  sub render { Line 2578  sub render {
     for my $re (@results) {      for my $re (@results) {
         $result .= '    <li>' . $re . "</li>\n";          $result .= '    <li>' . $re . "</li>\n";
     }      }
   
       if (!@results) {
           $result .= '    <li>No changes were made to current settings.</li>';
       }
   
       if ($self->{'restartCourse'}) {
           $result .= "<center>\n" .
               "<form action='/adm/roles' method='post' target='loncapaclient'>\n" .
               "<input type='button' onclick='history.go(-1)' value='&lt;- Previous' />" .
               "<input type='hidden' name='orgurl' value='/adm/navmaps' />" .
               "<input type='hidden' name='selectrole' value='1' />\n" .
               "<input type='hidden' name='" . $ENV{'request.role'} . 
               "' value='1' />\n<input type='submit' value='Finish Course Initialization' />\n" .
               "</form></center>";
       }
   
     return $result . '</ul>';      return $result . '</ul>';
 }  }
   
   sub overrideForm {
       my $self = shift;
       return $self->{'restartCourse'};
   }
   
 1;  1;
   
 package Apache::lonhelper::parmwizfinal;  package Apache::lonhelper::parmwizfinal;

Removed from v.1.33  
changed lines
  Added in v.1.34


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