[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm
raeburn
raeburn at source.lon-capa.org
Fri Jun 26 12:41:00 EDT 2026
raeburn Fri Jun 26 16:41:00 2026 EDT
Modified files:
/loncom/interface lonhelper.pm
Log:
- Remove trailing whitespace. No code changes.
-------------- next part --------------
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.211 loncom/interface/lonhelper.pm:1.212
--- loncom/interface/lonhelper.pm:1.211 Fri Jun 19 13:19:46 2026
+++ loncom/interface/lonhelper.pm Fri Jun 26 16:41:00 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.211 2026/06/19 13:19:46 raeburn Exp $
+# $Id: lonhelper.pm,v 1.212 2026/06/26 16:41:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -382,7 +382,7 @@
$self->{TITLE} = shift;
$self->{REQUIRED_PRIV} = shift;
-
+
# If there is a state from the previous form, use that. If there is no
# state, use the start state parameter.
if (defined $env{"form.CURRENT_STATE"})
@@ -409,7 +409,7 @@
# Get the hash.
$self->{FILENAME} = $Apache::lonnet::tmpdir . md5_hex($self->{TOKEN}); # Note the token is not the literal file
-
+
my $file = Apache::File->new($self->{FILENAME});
my $contents = <$file>;
@@ -813,7 +813,7 @@
will form a subroutine that when called will provide a default value for
the element. How this value is interpreted by the element is specific to
the element itself, and possibly the settings the element has (such as
-multichoice vs. single choice for <choices> tags).
+multichoice vs. single choice for <choices> tags).
This is also intended for things like the course initialization helper, where the
user is setting various parameters. By correctly grabbing current settings
@@ -873,7 +873,7 @@
if ($target ne 'helper') {
return '';
}
-
+
$paramHash->{NEXTSTATE} = &Apache::lonxml::get_all_text('/nextstate',
$parser);
return '';
@@ -887,7 +887,7 @@
if ($target ne 'helper') {
return '';
}
-
+
$paramHash->{FINAL_CODE} = &Apache::lonxml::get_all_text('/finalcode',
$parser);
return '';
@@ -901,7 +901,7 @@
if ($target ne 'helper') {
return '';
}
-
+
$paramHash->{DEFAULT_VALUE} = &Apache::lonxml::get_all_text('/defaultvalue',
$parser);
$paramHash->{DEFAULT_VALUE} = 'sub { my $helper = shift; my $state = shift;' .
@@ -918,7 +918,7 @@
if ($target ne 'helper') {
return '';
}
-
+
$paramHash->{VALIDATOR} = &Apache::lonxml::get_all_text('/validator',
$parser);
$paramHash->{VALIDATOR} = 'sub { my $helper = shift; my $state = shift; my $element = shift; my $val = shift;' .
@@ -1380,7 +1380,7 @@
$parser));
my $nextstate = $token->[2]{'nextstate'};
my $evalFlag = $token->[2]{'eval'};
- my $relatedVar = $token->[2]{'relatedvalue'};
+ my $relatedVar = $token->[2]{'relatedvalue'};
my $relatedDefault = $token->[2]{'relateddefault'};
push @{$paramHash->{CHOICES}}, [&mtn($human), $computer, $nextstate,
$evalFlag, $relatedVar, $relatedDefault];
@@ -1544,7 +1544,7 @@
if (defined($self->{NEXTSTATE})) {
$helper->changeState($self->{NEXTSTATE});
}
-
+
foreach my $choice (@{$self->{CHOICES}}) {
if ($choice->[1] eq $chosenValue) {
if (defined($choice->[2])) {
@@ -2129,7 +2129,7 @@
element of the text box.
=item * text=header-text : provides column header text for the option.
-
+
=item * variable=helpervar : provides a helper variable to contain the
value of the input control for each resource. In general, the result
will be a set of values separated by ||| for the checkbox the value between
@@ -2143,7 +2143,7 @@
=over 4
-
+
=item * Preloading checkboxes : Set the helper variable to the value you
would have gotten from the control if it had been manually set as desired.
@@ -2169,7 +2169,7 @@
BEGIN {
&Apache::lonhelper::register('Apache::lonhelper::resource',
- ('resource', 'filterfunc',
+ ('resource', 'filterfunc',
'choicefunc', 'valuefunc',
'mapurl','option'));
}
@@ -2410,7 +2410,7 @@
# Evaluate the map url as needed
my $mapUrl;
if ($self->{EVAL_MAP_URL}) {
- my $mapUrlFunc = eval('sub { my $helper = shift; my $state = shift; ' .
+ my $mapUrlFunc = eval('sub { my $helper = shift; my $state = shift; ' .
$self->{MAP_URL} . '}');
$mapUrl = &$mapUrlFunc($helper, $self);
} else {
@@ -2420,7 +2420,7 @@
my %defaultSymbs;
if (defined($self->{DEFAULT_VALUE})) {
my $valueFunc = eval($self->{DEFAULT_VALUE});
- die 'Error in default value code for variable ' .
+ die 'Error in default value code for variable ' .
$self->{'variable'} . ', Perl said: ' . $@ if $@;
my @defaultSymbs = &$valueFunc($helper, $self);
if (!$multichoice && @defaultSymbs) { # only allowed 1
@@ -2477,13 +2477,13 @@
my $colnum = 0;
my $col = "";
my $raw_name = &$valueFunc($resource);
- my $resource_name =
+ my $resource_name =
HTML::Entities::encode($raw_name,"<>&\"'");
if($option_vars) {
foreach my $option_var (@$option_vars) {
my $option_type = $option_types->[$option_num];
$option_num++;
- my $var_value = "\|\|\|" . $helper->{VARS}->{$option_var} .
+ my $var_value = "\|\|\|" . $helper->{VARS}->{$option_var} .
"\|\|\|";
my $checked ="";
if($var_value =~ /\Q|||$raw_name|||\E/) {
@@ -2492,7 +2492,7 @@
if ($option_type eq 'text') {
#
# For text's the variable value is a ||| separated set of
- # resource_name=value
+ # resource_name=value
#
my @values = split(/\|\|\|/, $helper->{VARS}->{$option_var});
@@ -2518,13 +2518,13 @@
"_forminput' value='".$text_value."' size='5' ".
"aria-labelledby='row".$params->{counter}." col".$colnum."' /></td>";
} elsif ($option_type eq 'hidden') {
- $col .=
+ $col .=
"<td align='center'><input type='hidden' name ='$option_var".
"_forminput' value='".
$resource_name . "' /></td>";
} else {
$colnum ++;
- $col .=
+ $col .=
"<td align='center'><input type='$option_type' name ='$option_var".
"_forminput' value='".
$resource_name . "' $checked ".
@@ -2561,7 +2561,7 @@
my $colnum = 0;
my $col= "<td>";
my $id=$resource->{ID};
- my $resource_name =
+ my $resource_name =
&HTML::Entities::encode(&$valueFunc($resource),"<>&\"'");
if ($addparts && (scalar(@{$resource->parts}) > 1)) {
$colnum ++;
@@ -2610,7 +2610,7 @@
} elsif ($env{'request.noversionuri'} =~ m{^\Q/adm/helper/\E(.+)\.helper$}) {
$caller = $1;
}
- $result .=
+ $result .=
&Apache::lonnavmaps::render( { 'cols' => $cols,
'showParts' => 0,
'filterFunc' => $filterFunc,
@@ -2627,10 +2627,10 @@
);
$result .= $buttons;
-
+
return $result;
}
-
+
sub postprocess {
my $self = shift;
@@ -2692,20 +2692,20 @@
Student elements display a choice of students enrolled in the current
course. Currently it is primitive; this is expected to evolve later.
-Student elements take the following attributes:
+Student elements take the following attributes:
=over 4
-=item * B<variable>:
+=item * B<variable>:
Does what it usually does: declare which helper variable to put the
result in.
-=item * B<multichoice>:
+=item * B<multichoice>:
If true allows the user to select multiple students. Defaults to false.
-=item * B<coursepersonnel>:
+=item * B<coursepersonnel>:
If true adds the course personnel to the top of the student
selection. Defaults to false.
@@ -2762,8 +2762,8 @@
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
}
$paramHash->{'emptyallowed'} = $token->[2]{'emptyallowed'};
-
-}
+
+}
sub end_student {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
@@ -2788,7 +2788,7 @@
my %defaultUsers;
if (defined($self->{DEFAULT_VALUE})) {
my $valueFunc = eval($self->{DEFAULT_VALUE});
- die 'Error in default value code for variable ' .
+ die 'Error in default value code for variable ' .
$self->{'variable'} . ', Perl said: ' . $@ if $@;
my @defaultUsers = &$valueFunc($helper, $self);
if (!$self->{'multichoice'} && @defaultUsers) { # only allowed 1
@@ -2803,10 +2803,10 @@
$personnel_section = $env{'request.course.sec'};
}
- my ($course_personnel,
- $current_members,
- $expired_members,
- $future_members) =
+ my ($course_personnel,
+ $current_members,
+ $expired_members,
+ $future_members) =
&Apache::lonselstudent::get_people_in_class($env{'request.course.sec'},
$personnel_section);
@@ -2854,7 +2854,7 @@
# And future.
$result .= '<h3 class="LC_heading_3">'.$titles{'future'}.'</h3>';
-
+
$result .= &Apache::lonselstudent::render_student_list( $future_members,
"helpform",
"future",
@@ -2864,7 +2864,7 @@
0);
}
if (!$self->{'activeonly'} && ((scalar(@$expired_members)) > 0)) {
- # Past
+ # Past
$result .= '<h3 class="LC_heading_3">'.$titles{'expired'}.'</h3>';
$result .= &Apache::lonselstudent::render_student_list($expired_members,
@@ -2887,10 +2887,10 @@
my $result = $env{'form.' . $self->{'variable'} . '_forminput'};
if (!$result && !$self->{'emptyallowed'}) {
if ($self->{'coursepersonnel'}) {
- $self->{ERROR_MSG} =
+ $self->{ERROR_MSG} =
&mt('You must choose at least one user to continue.');
} else {
- $self->{ERROR_MSG} =
+ $self->{ERROR_MSG} =
&mt('You must choose at least one student to continue.');
}
return 0;
@@ -2913,7 +2913,7 @@
files allows the users to choose files from a given directory on the
server. It is always multichoice and stores the result as a triple-pipe
-delimited entry in the helper variables.
+delimited entry in the helper variables.
Since it is extremely unlikely that you can actually code a constant
representing the directory you wish to allow the user to search, <files>
@@ -2923,17 +2923,17 @@
files accepts the attribute "variable" to control where the files chosen
are put. It accepts the attribute "multichoice" as the other attribute,
defaulting to false, which if true will allow the user to select more
-then one choice.
+then one choice.
-<files> accepts three subtags:
+<files> accepts three subtags:
=over 4
-=item * B<nextstate>: works as it does with the other tags.
+=item * B<nextstate>: works as it does with the other tags.
=item * B<filechoice>: When the contents of this tag are surrounded by
"sub {" and "}", will return a string representing what directory
- on the server to allow the user to choose files from.
+ on the server to allow the user to choose files from.
=item * B<filefilter>: Should contain Perl code that when surrounded
by "sub { my $filename = shift; " and "}", returns a true value if
@@ -2951,7 +2951,7 @@
they should not be able to see, like the C</etc/> directory. However,
the security impact would be minimal, since it would only expose
the existence of files, there should be no way to parlay that into
-viewing the files.
+viewing the files.
=cut
@@ -2969,7 +2969,7 @@
sub not_old_version {
my $file = shift;
-
+
# Given a file name, return false if it is an "old version" of a
# file, or true if it is not.
@@ -2993,7 +2993,7 @@
$paramHash->{'variable'} = $token->[2]{'variable'};
$helper->declareVar($paramHash->{'variable'});
$paramHash->{'multichoice'} = $token->[2]{'multichoice'};
-}
+}
sub end_files {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
@@ -3005,7 +3005,7 @@
$paramHash->{FILTER_FUNC} = sub { return 1; };
}
Apache::lonhelper::files->new();
-}
+}
sub start_filechoice {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
@@ -3034,7 +3034,7 @@
sub end_filefilter { return ''; }
-{
+{
# used to generate unique id attributes for <input> tags.
# internal use only.
my $id=0;
@@ -3045,9 +3045,9 @@
my $self = shift;
my $result = '';
my $var = $self->{'variable'};
-
+
my $subdirFunc = eval('sub {' . $self->{'filechoice'} . '}');
- die 'Error in resource filter code for variable ' .
+ die 'Error in resource filter code for variable ' .
{'variable'} . ', Perl said:' . $@ if $@;
my $subdir = &$subdirFunc();
@@ -3118,14 +3118,14 @@
unless ($subdir=~m{^\Q$londocroot\E}) {
$subdir=$londocroot.$subdir;
}
- my ($user,$domain)=
+ my ($user,$domain)=
&Apache::lonnet::constructaccess($subdir);
$metadir='/res/'.$domain.'/'.$user.'/'.$innerpath;
($listref,$listerror) =
&Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/');
} else {
# local library server resource space
- ($listref,$listerror) =
+ ($listref,$listerror) =
&Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/');
}
@@ -3143,7 +3143,7 @@
$result .= '<table border="0" cellpadding="2" cellspacing="0">';
# Keeps track if there are no choices, prints appropriate error
- # if there are none.
+ # if there are none.
my $choices = 0;
# Print each legitimate file choice.
for my $file (@fileList) {
@@ -3179,7 +3179,7 @@
# couldn't figure out how to reach into the event handler's
# actual code to retreive a value), but it works well enough
# here.
-
+
my $onclick = '';
if ($status eq 'Published' && $helper->{VARS}->{'construction'}) {
$onclick = 'onclick="a=1" ';
@@ -3220,7 +3220,7 @@
sub fileState {
my $constructionSpaceDir = shift;
my $file = shift;
-
+
my ($uname,$udom)=($env{'user.name'},$env{'user.domain'});
if ($env{'request.role'}=~/^ca\./) {
(undef,$udom,$uname)=split(/\//,$env{'request.role'});
@@ -3239,7 +3239,7 @@
my $constructionSpaceFileModified = $constructionSpaceFileStat[9];
my $resourceSpaceFileModified = $resourceSpaceFileStat[9];
-
+
if ($constructionSpaceFileModified > $resourceSpaceFileModified) {
return ['Modified', '#FFFFCC'];
}
@@ -3330,9 +3330,9 @@
$choices{$section_name} = $section_name;
}
}
-
+
if (exists($choices{"No section assigned"})) {
- push(@{$paramHash->{CHOICES}},
+ push(@{$paramHash->{CHOICES}},
['No section assigned','No section assigned']);
delete($choices{"No section assigned"});
}
@@ -3356,15 +3356,15 @@
return '';
}
Apache::lonhelper::section->new();
-}
+}
1;
package Apache::lonhelper::group;
=pod
-
+
=head2 Element: groupX<group, helper element>
-
+
<group> allows the user to choose one or more groups from the current course.
It takes the standard attributes "variable", "multichoice",
@@ -3390,10 +3390,10 @@
my $ref = Apache::lonhelper::choices->new();
bless($ref);
}
-
+
sub start_group {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-
+
if ($target ne 'helper') {
return '';
}
@@ -3503,7 +3503,7 @@
$state->noproceed();
}
-
+
return '';
}
@@ -3532,7 +3532,7 @@
if (defined($self->{DEFAULT_VALUE})) {
my $valueFunc = eval($self->{DEFAULT_VALUE});
- die 'Error in default value code for variable ' .
+ die 'Error in default value code for variable ' .
$self->{'variable'} . ', Perl said: ' . $@ if $@;
$result .= ' value="' . &$valueFunc($helper, $self) . '"';
}
@@ -3654,7 +3654,7 @@
if ($target ne 'helper') {
return '';
}
-
+
my $clause = Apache::lonxml::get_all_text('/clause', $parser);
$clause = eval('sub { my $helper = shift; my $state = shift; '
. $clause . '}');
@@ -3675,7 +3675,7 @@
The <eval> tag will be evaluated as a subroutine call passed in the
current helper object and state hash as described in <condition> above,
but is expected to return a string to be printed directly to the
-screen. This is useful for dynamically generating messages.
+screen. This is useful for dynamically generating messages.
=cut
@@ -3689,7 +3689,7 @@
if ($target ne 'helper') {
return '';
}
-
+
my $program = Apache::lonxml::get_all_text('/eval', $parser);
$program = eval('sub { my $helper = shift; my $state = shift; '
. $program . '}');
@@ -3697,7 +3697,7 @@
$paramHash->{MESSAGE_TEXT} = &$program($helper, $paramHash);
}
-sub end_eval {
+sub end_eval {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target ne 'helper') {
@@ -3745,7 +3745,7 @@
bless($ref);
}
-sub start_final {
+sub start_final {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target ne 'helper') {
@@ -3754,7 +3754,7 @@
$paramHash->{'restartCourse'} = $token->[2]{'restartCourse'};
- return '';
+ return '';
}
sub end_final {
@@ -3765,7 +3765,7 @@
}
Apache::lonhelper::final->new();
-
+
return '';
}
@@ -3792,11 +3792,11 @@
# Collect all the results
for my $stateName (keys(%{$helper->{STATES}})) {
my $state = $helper->{STATES}->{$stateName};
-
+
for my $element (@{$state->{ELEMENTS}}) {
if (defined($element->{FINAL_CODE})) {
# Compile the code.
- my $code = 'sub { my $helper = shift; my $element = shift; '
+ my $code = 'sub { my $helper = shift; my $element = shift; '
. $element->{FINAL_CODE} . '}';
$code = eval($code);
die 'Error while executing final code for element with var ' .
@@ -3819,7 +3819,7 @@
}
if (!@results) {
- $result .= ' <li>' .
+ $result .= ' <li>' .
&mt('No changes were made to current settings.') . '</li>';
}
@@ -3848,7 +3848,7 @@
"<input type='button' onclick='history.go(-1)' value='$previous' />" .
"<input type='hidden' name='orgurl' value='$targetURL' />" .
"<input type='hidden' name='selectrole' value='1' />\n" .
- "<input type='hidden' name='" . $env{'request.role'} .
+ "<input type='hidden' name='" . $env{'request.role'} .
"' value='1' />\n<input type='submit' value='" . $finish . "' />\n" .
"</form></p>\n";
@@ -3919,14 +3919,14 @@
'answer_date' => "answerdate",
'tries' => 'maxtries',
'weight' => 'weight' );
-
+
my $affectedResourceId = "";
my $parm_name = $parmTypeHash{$vars->{ACTION_TYPE}};
my $level = "";
my $resourceString;
my $symb;
my $paramlevel;
-
+
# Print the granularity, depending on the action
if ($vars->{GRANULARITY} eq 'whole_course') {
$resourceString .= '<li>'.&mt('for [_1]all resources in the course[_2]','<b>','</b>').'</li>';
@@ -4028,7 +4028,7 @@
.&mt('Confirm that this information is correct, then click "Save" to complete setting the parameter.')
.'</p>'
.'<ul>';
-
+
# Print the type of manipulation:
my $extra;
if ($vars->{ACTION_TYPE} eq 'tries') {
@@ -4045,12 +4045,12 @@
$result .= &mt('Setting the [_1]',"<b>$what</b>");
}
$result .= "</li>\n";
- if ($vars->{ACTION_TYPE} eq 'due_date' ||
+ if ($vars->{ACTION_TYPE} eq 'due_date' ||
$vars->{ACTION_TYPE} eq 'answer_date') {
# for due dates, we default to "date end" type entries
$result .= "<input type='hidden' name='recent_date_end' " .
"value='" . $vars->{PARM_DATE} . "' />\n";
- $result .= "<input type='hidden' name='pres_value' " .
+ $result .= "<input type='hidden' name='pres_value' " .
"value='" . $vars->{PARM_DATE} . "' />\n";
$result .= "<input type='hidden' name='pres_type' " .
"value='date_end' />\n";
@@ -4072,7 +4072,7 @@
}
$result .= $resourceString;
-
+
# Print targets
if ($vars->{TARGETS} eq 'course') {
$result .= '<li>'.&mt('for [_1]all students in course[_2]','<b>','</b>').'</li>';
@@ -4118,7 +4118,7 @@
# print pres_marker
$result .= "\n<input type='hidden' name='pres_marker'" .
" value='$affectedResourceId&$parm_name&$level' />\n";
-
+
# Make the table appear
$result .= "\n<input type='hidden' value='true' name='prevvisit' />";
$result .= "\n<input type='hidden' value='$symb' name='pssymb' />";
@@ -4128,7 +4128,7 @@
return $result;
}
-
+
sub overrideForm {
return 1;
}
More information about the LON-CAPA-cvs
mailing list