--- loncom/interface/lonhelper.pm 2003/05/16 17:20:51 1.31
+++ loncom/interface/lonhelper.pm 2003/06/12 13:52:06 1.37
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.31 2003/05/16 17:20:51 bowersj2 Exp $
+# $Id: lonhelper.pm,v 1.37 2003/06/12 13:52:06 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1160,7 +1160,7 @@ BUTTONS
if (defined($self->{DEFAULT_VALUE})) {
$checkedChoicesFunc = eval ($self->{DEFAULT_VALUE});
die 'Error in default value code for variable ' .
- {'variable'} . ', Perl said:' . $@ if $@;
+ $self->{'variable'} . ', Perl said: ' . $@ if $@;
} else {
$checkedChoicesFunc = sub { return ''; };
}
@@ -1694,6 +1694,10 @@ BUTTONS
$col .= "checked ";
$checked = 1;
}
+ if ($multichoice) { # all resources start checked; see bug 1174
+ $col .= "checked ";
+ $checked = 1;
+ }
$col .= "value='" .
HTML::Entities::encode(&$valueFunc($resource))
. "' />";
@@ -1922,6 +1926,8 @@ no strict;
@ISA = ("Apache::lonhelper::element");
use strict;
+use Apache::lonpubdir; # for getTitleString
+
BEGIN {
&Apache::lonhelper::register('Apache::lonhelper::files',
('files', 'filechoice', 'filefilter'));
@@ -2078,6 +2084,9 @@ BUTTONS
$color = '';
}
+ # Get the title
+ my $title = Apache::lonpubdir::getTitleString($fileName);
+
# Netscape 4 is stupid and there's nowhere to put the
# information on the input tag that the file is Published,
# Unpublished, etc. In *real* browsers we can just say
@@ -2104,8 +2113,9 @@ BUTTONS
if (!$self->{'multichoice'} && $choices == 0) {
$result .= ' checked';
}
- $result .= "/>
" . $file .
- "
$status
\n";
+ $result .= "/>
" . $file . "
" .
+ "
$title
" .
+ "
$status
" . "\n";
$choices++;
}
}
@@ -2244,6 +2254,96 @@ sub end_section {
}
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 = '{'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;
=pod
@@ -2388,6 +2488,11 @@ tag. It goes through all the states and
snippets and collecting the results. Finally, it takes the user out of the
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
no strict;
@@ -2404,7 +2509,17 @@ sub new {
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 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
@@ -2467,9 +2582,30 @@ sub render {
for my $re (@results) {
$result .= '