version 1.176, 2009/06/15 11:18:11
|
version 1.197, 2015/08/28 22:44:59
|
Line 64 messages, resource selections, or date q
|
Line 64 messages, resource selections, or date q
|
|
|
The helper tag is required to have one attribute, "title", which is the name |
The helper tag is required to have one attribute, "title", which is the name |
of the helper itself, such as "Parameter helper". The helper tag may optionally |
of the helper itself, such as "Parameter helper". The helper tag may optionally |
have a "requiredpriv" attribute, specifying the priviledge a user must have |
have a "requiredpriv" attribute, specifying the privilege a user must have |
to use the helper, or get denied access. See loncom/auth/rolesplain.tab for |
to use the helper, or get denied access. See loncom/auth/rolesplain.tab for |
useful privs. Default is full access, which is often wrong! |
useful privs. You may add the modifier &S at the end of the three letter priv |
|
if you want to grant access to users for whom the corresponding privilege is |
|
section-specific. The default is full access, which is often wrong! |
|
|
=head2 State tags |
=head2 State tags |
|
|
Line 261 sub real_handler {
|
Line 263 sub real_handler {
|
my $uri = shift; |
my $uri = shift; |
if (!defined($uri)) { $uri = $r->uri(); } |
if (!defined($uri)) { $uri = $r->uri(); } |
$env{'request.uri'} = $uri; |
$env{'request.uri'} = $uri; |
my $filename = '/home/httpd/html' . $uri; |
my $filename = $r->dir_config('lonDocRoot').$uri; |
my $fh = Apache::File->new($filename); |
my $fh = Apache::File->new($filename); |
my $file; |
my $file; |
read $fh, $file, 100000000; |
read $fh, $file, 100000000; |
Line 283 sub real_handler {
|
Line 285 sub real_handler {
|
|
|
my $allowed = $helper->allowedCheck(); |
my $allowed = $helper->allowedCheck(); |
if (!$allowed) { |
if (!$allowed) { |
$env{'user.error.msg'} = $env{'request.uri'}.':'.$helper->{REQUIRED_PRIV}. |
my ($priv,$modifier) = split(/\&/,$helper->{REQUIRED_PRIV}); |
|
$env{'user.error.msg'} = $env{'request.uri'}.':'.$priv. |
":0:0:Permission denied to access this helper."; |
":0:0:Permission denied to access this helper."; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
Line 508 sub allowedCheck {
|
Line 511 sub allowedCheck {
|
if (!defined($self->{REQUIRED_PRIV})) { |
if (!defined($self->{REQUIRED_PRIV})) { |
return 1; |
return 1; |
} |
} |
|
my ($priv,$modifier) = split(/\&/,$self->{REQUIRED_PRIV}); |
return Apache::lonnet::allowed($self->{REQUIRED_PRIV}, $env{'request.course.id'}); |
my $allowed = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); |
|
if ((!$allowed) && ($modifier eq 'S') && ($env{'request.course.sec'} ne '')) { |
|
$allowed = &Apache::lonnet::allowed($priv,$env{'request.course.id'}.'/'. |
|
$env{'request.course.sec'}); |
|
} |
|
return $allowed; |
} |
} |
|
|
sub changeState { |
sub changeState { |
Line 571 sub process {
|
Line 579 sub process {
|
# 4: Render the current state to the screen as an HTML page. |
# 4: Render the current state to the screen as an HTML page. |
sub display { |
sub display { |
my $self = shift; |
my $self = shift; |
|
my $footer = shift; |
my $state = $self->{STATES}{$self->{STATE}}; |
my $state = $self->{STATES}{$self->{STATE}}; |
|
|
my $result = ""; |
my $result = ""; |
Line 606 sub display {
|
Line 614 sub display {
|
# FIXME: This should be parameterized, not concatenated - Jeremy |
# FIXME: This should be parameterized, not concatenated - Jeremy |
|
|
|
|
if (!$state->overrideForm()) { $result.='<form name="helpform" method="post">'; } |
if (!$state->overrideForm()) { $result.='<form name="helpform" method="post" action="">'; } |
if ($stateHelp) { |
if ($stateHelp) { |
$stateHelp = &Apache::loncommon::help_open_topic($stateHelp); |
$stateHelp = &Apache::loncommon::help_open_topic($stateHelp); |
} |
} |
Line 651 sub display {
|
Line 659 sub display {
|
$result .= $buttons; |
$result .= $buttons; |
|
|
|
|
#foreach my $key (keys %{$self->{VARS}}) { |
#foreach my $key (keys(%{$self->{VARS}})) { |
# $result .= "|$key| -> " . $self->{VARS}->{$key} . "<br />"; |
# $result .= "|$key| -> " . $self->{VARS}->{$key} . "<br />"; |
#} |
#} |
|
|
Line 661 sub display {
|
Line 669 sub display {
|
</form> |
</form> |
FOOTER |
FOOTER |
|
|
$result .= &Apache::loncommon::end_page(); |
$result .= $footer.&Apache::loncommon::end_page(); |
# Handle writing out the vars to the file |
# Handle writing out the vars to the file |
my $file = Apache::File->new('>'.$self->{FILENAME}); |
my $file = Apache::File->new('>'.$self->{FILENAME}); |
print $file $self->_varsInFile(); |
print $file $self->_varsInFile(); |
Line 1476 BUTTONS
|
Line 1484 BUTTONS
|
HTML::Entities::encode($choice->[1],"<>&\"'") |
HTML::Entities::encode($choice->[1],"<>&\"'") |
. "'"; |
. "'"; |
if ($checkedChoices{$choice->[1]}) { |
if ($checkedChoices{$choice->[1]}) { |
$result .= " checked='checked' "; |
$result .= " checked='checked'"; |
} |
} |
$result .= qq{id="id$id"}; |
$result .= qq{ id="id$id"}; |
my $choiceLabel = $choice->[0]; |
my $choiceLabel = $choice->[0]; |
if ($choice->[3]) { # if we need to evaluate this choice |
if ($choice->[3]) { # if we need to evaluate this choice |
$choiceLabel = "sub { my $helper = shift; my $state = shift;" . |
$choiceLabel = "sub { my $helper = shift; my $state = shift;" . |
Line 1486 BUTTONS
|
Line 1494 BUTTONS
|
$choiceLabel = eval($choiceLabel); |
$choiceLabel = eval($choiceLabel); |
$choiceLabel = &$choiceLabel($helper, $self); |
$choiceLabel = &$choiceLabel($helper, $self); |
} |
} |
$result .= "/></td><td> ".qq{<label for="id$id">}. |
$result .= " /></td><td> ".qq{<label for="id$id">}. |
$choiceLabel. "</label></td>"; |
$choiceLabel. "</label></td>"; |
if ($choice->[4]) { |
if ($choice->[4]) { |
$result .='<td><input type="text" size="5" name="' |
$result .='<td><input type="text" size="5" name="' |
Line 1913 CHECK
|
Line 1921 CHECK
|
if ($anytime) { |
if ($anytime) { |
$result.=' checked="checked" ' |
$result.=' checked="checked" ' |
} |
} |
$result.="name='${var}anytime'/>".&mt('Any time').'</label>' |
my $anytimetext = &mt('Any time'); |
|
if (($var eq 'startreserve') || ($var eq 'endreserve')) { |
|
$anytimetext = &mt('Any time before slot starts'); |
|
} elsif (($var eq 'startunique') || ($var eq 'endunique')) { |
|
$anytimetext = &mt('No restriction on uniqueness'); |
|
} |
|
$result.="name='${var}anytime'/>".$anytimetext.'</label>' |
} |
} |
return $result; |
return $result; |
|
|
Line 2066 the toplevel default.sequence in the res
|
Line 2080 the toplevel default.sequence in the res
|
evaluated with "sub { my $helper = shift; my $state = shift;" and |
evaluated with "sub { my $helper = shift; my $state = shift;" and |
"}", with the return value used as the mapurl. |
"}", with the return value used as the mapurl. |
|
|
|
=item * <option />: Allows you to add optional elements to the |
|
resource chooser currently these can be a checkbox, or a text entry |
|
or hidden (see the 'type' attribute below). |
|
the following attributes are supported by this tag: |
|
|
|
=over 4 |
|
|
|
=item * type=control-type : determines the type of control displayed. |
|
This can be one of the following types: 'checkbox' provides a true/false |
|
checkbox. 'text' provides a text entry control. 'hidden' provides a |
|
hidden form element that returns the name of the resource for each |
|
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 |
|
the |||'s will either be empty, if the box is not checked, or the resource |
|
name if checked. For the text entry, the values will be the text in the |
|
text box. This could be empty. Hidden elements unconditionally provide |
|
the resource name for each row of the chooser and allow you to therefore |
|
correlate text entries to their resources. |
|
The helper variable can be initialized by the user code to pre-load values |
|
into the controls: |
|
|
|
=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. |
|
|
|
=item * Preloading text entries : Set the helper variable to triple pipe |
|
separated values where each value is of the form resource-name=value |
|
|
|
=item * Preloading hidden fields : These cannot be pre-loaded and will always |
|
be pipe separated resource names. |
|
|
|
=back |
|
|
|
|
|
=back |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 2195 sub start_option {
|
Line 2252 sub start_option {
|
if (!defined($paramHash->{OPTION_TEXTS})) { |
if (!defined($paramHash->{OPTION_TEXTS})) { |
$paramHash->{OPTION_TEXTS} = [ ]; |
$paramHash->{OPTION_TEXTS} = [ ]; |
$paramHash->{OPTION_VARS} = [ ]; |
$paramHash->{OPTION_VARS} = [ ]; |
|
$paramHash->{OPTION_TYPES} = [ ]; |
|
|
} |
} |
|
# We can have an attribute: type which can have the |
|
# values: "checkbox" or "text" which defaults to |
|
# checkbox allowing us to change the type of input |
|
# for the option: |
|
# |
|
my $input_widget_type = 'checkbox'; |
|
if(defined($token->[2]{'type'})) { |
|
my $widget_type = $token->[2]{'type'}; |
|
if ($widget_type eq 'text') { # only accept legal alternatives |
|
$input_widget_type = $widget_type; # Illegals are checks. |
|
} elsif ($widget_type eq 'hidden') { |
|
$input_widget_type = $widget_type; |
|
} |
|
} |
|
|
# OPTION_TEXTS is a list of the text attribute |
# OPTION_TEXTS is a list of the text attribute |
# values used to create column headings. |
# values used to create column headings. |
# OPTION_VARS is a list of the variable names, used to create the checkbox |
# OPTION_VARS is a list of the variable names, used to create the checkbox |
# inputs. |
# inputs. |
|
# OPTION_TYPES is a list of the option types: |
|
# |
# We're ok with empty elements. as place holders |
# We're ok with empty elements. as place holders |
# Although the 'variable' element should really exist. |
# Although the 'variable' element should really exist. |
# |
# |
|
|
|
|
my $option_texts = $paramHash->{OPTION_TEXTS}; |
my $option_texts = $paramHash->{OPTION_TEXTS}; |
my $option_vars = $paramHash->{OPTION_VARS}; |
my $option_vars = $paramHash->{OPTION_VARS}; |
|
my $option_types = $paramHash->{OPTION_TYPES}; |
push(@$option_texts, $token->[2]{'text'}); |
push(@$option_texts, $token->[2]{'text'}); |
push(@$option_vars, $token->[2]{'variable'}); |
push(@$option_vars, $token->[2]{'variable'}); |
|
push(@$option_types, $input_widget_type); |
|
|
|
|
# Need to create and declare the option variables as well to make them |
# Need to create and declare the option variables as well to make them |
# persistent. |
# persistent. |
Line 2284 BUTTONS
|
Line 2363 BUTTONS
|
my $multichoice = $self->{'multichoice'}; |
my $multichoice = $self->{'multichoice'}; |
my $option_vars = $self->{OPTION_VARS}; |
my $option_vars = $self->{OPTION_VARS}; |
my $option_texts = $self->{OPTION_TEXTS}; |
my $option_texts = $self->{OPTION_TEXTS}; |
|
my $option_types = $self->{OPTION_TYPES}; |
my $addparts = $self->{'addparts'}; |
my $addparts = $self->{'addparts'}; |
my $headings_done = 0; |
my $headings_done = 0; |
|
|
Line 2324 BUTTONS
|
Line 2404 BUTTONS
|
$result .= "<th>$text</th>"; |
$result .= "<th>$text</th>"; |
} |
} |
} |
} |
$result .= "<th>Select</th>"; |
$result .= '<th>'.&Apache::lonlocal::mt('Select').'</th>'; |
$result .= "</tr><tr>"; # Close off the extra row and start a new one. |
$result .= "</tr><tr>"; # Close off the extra row and start a new one. |
$headings_done = 1; |
$headings_done = 1; |
} |
} |
Line 2342 BUTTONS
|
Line 2422 BUTTONS
|
my $resource_name = |
my $resource_name = |
HTML::Entities::encode($raw_name,"<>&\"'"); |
HTML::Entities::encode($raw_name,"<>&\"'"); |
if($option_vars) { |
if($option_vars) { |
|
my $option_num = 0; |
foreach my $option_var (@$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 =""; |
my $checked =""; |
if($var_value =~ /\Q|||$raw_name|||\E/) { |
if($var_value =~ /\Q|||$raw_name|||\E/) { |
$checked = "checked='checked'"; |
$checked = "checked='checked'"; |
} |
} |
$col .= |
if ($option_type eq 'text') { |
"<td align='center'><input type='checkbox' name ='$option_var". |
# |
"_forminput' value='". |
# For text's the variable value is a ||| separated set of |
$resource_name . "' $checked /> </td>"; |
# resource_name=value |
|
# |
|
my @values = split(/\|\|\|/, $helper->{VARS}->{$option_var}); |
|
|
|
# Normal practice would be to toss this in a hash but |
|
# the only thing that saves is the compare in the loop |
|
# below and for all but one case we'll break out of the loop |
|
# before it completes. |
|
|
|
my $text_value = ''; # In case there's no match. |
|
foreach my $value (@values) { |
|
my ($res, $skip) = split(/=/, $value); |
|
if($res eq $resource_name) { |
|
$text_value = $skip; |
|
last; |
|
} |
|
} |
|
# TODO: add an attribute to <option> that allows the |
|
# programmer to set the width of the tex entry box. |
|
|
|
$col .= |
|
"<td align='center'><input type='text' name ='$option_var". |
|
"_forminput' value='".$text_value."' size='5' /> </td>"; |
|
} elsif ($option_type eq 'hidden') { |
|
$col .= "<td align='center'><input type='hidden' name ='$option_var". |
|
"_forminput' value='". |
|
$resource_name . "'/> </td>"; |
|
} else { |
|
$col .= |
|
"<td align='center'><input type=$option_type name ='$option_var". |
|
"_forminput' value='". |
|
$resource_name . "' $checked /> </td>"; |
|
} |
} |
} |
} |
} |
|
|
Line 2386 BUTTONS
|
Line 2501 BUTTONS
|
&HTML::Entities::encode(&$valueFunc($resource),"<>&\"'"); |
&HTML::Entities::encode(&$valueFunc($resource),"<>&\"'"); |
if ($addparts && (scalar(@{$resource->parts}) > 1)) { |
if ($addparts && (scalar(@{$resource->parts}) > 1)) { |
$col .= "<select onclick=\"javascript:updateRadio(this.form,'${var}_forminput','$resource_name');updateHidden(this.form,'$id','${var}');\" name='part_${id}_forminput'>\n"; |
$col .= "<select onclick=\"javascript:updateRadio(this.form,'${var}_forminput','$resource_name');updateHidden(this.form,'$id','${var}');\" name='part_${id}_forminput'>\n"; |
$col .= "<option value=\"$part\">All Parts</option>\n"; |
$col .= "<option value=\"$part\">".&Apache::lonlocal::mt('All Parts')."</option>\n"; |
foreach my $part (@{$resource->parts}) { |
foreach my $part (@{$resource->parts}) { |
$col .= "<option value=\"$part\">Part: $part</option>\n"; |
$col .= "<option value=\"$part\">".&Apache::lonlocal::mt('Part: [_1]',$part)."</option>\n"; |
} |
} |
$col .= "</select>"; |
$col .= "</select>"; |
} |
} |
Line 2433 RADIO
|
Line 2548 RADIO
|
'closeAllPages' => $self->{'closeallpages'}, |
'closeAllPages' => $self->{'closeallpages'}, |
'suppressEmptySequences' => $self->{'suppressEmptySequences'}, |
'suppressEmptySequences' => $self->{'suppressEmptySequences'}, |
'include_top_level_map' => $self->{'include_top_level_map'}, |
'include_top_level_map' => $self->{'include_top_level_map'}, |
'iterator_map' => $mapUrl } |
'iterator_map' => $mapUrl, |
|
'map_no_edit_link' => 1, } |
); |
); |
|
|
$result .= $buttons; |
$result .= $buttons; |
Line 2505 selection. Defaults to false.
|
Line 2621 selection. Defaults to false.
|
If true, only active students and course personnel will be |
If true, only active students and course personnel will be |
shown. Defaults to false. |
shown. Defaults to false. |
|
|
|
=item * B<sectiononly>: |
|
|
|
If true, and user's role is in a specific section, only course personnel |
|
will be shown if they also have a section-specific role in the same section. |
|
Defaults to false. |
|
|
=item * B<emptyallowed>: |
=item * B<emptyallowed>: |
|
|
If true, the selection of no users is allowed. Defaults to false. |
If true, the selection of no users is allowed. Defaults to false. |
Line 2540 sub start_student {
|
Line 2662 sub start_student {
|
$helper->declareVar($paramHash->{'variable'}); |
$helper->declareVar($paramHash->{'variable'}); |
$paramHash->{'multichoice'} = $token->[2]{'multichoice'}; |
$paramHash->{'multichoice'} = $token->[2]{'multichoice'}; |
$paramHash->{'coursepersonnel'} = $token->[2]{'coursepersonnel'}; |
$paramHash->{'coursepersonnel'} = $token->[2]{'coursepersonnel'}; |
|
$paramHash->{'sectiononly'} = $token->[2]{'sectiononly'}; |
$paramHash->{'activeonly'} = $token->[2]{'activeonly'}; |
$paramHash->{'activeonly'} = $token->[2]{'activeonly'}; |
if (defined($token->[2]{'nextstate'})) { |
if (defined($token->[2]{'nextstate'})) { |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
Line 2581 sub render {
|
Line 2704 sub render {
|
delete($defaultUsers{''}); |
delete($defaultUsers{''}); |
} |
} |
|
|
|
my $personnel_section; |
|
if ($self->{'sectiononly'}) { |
|
$personnel_section = $env{'request.course.sec'}; |
|
} |
|
|
my ($course_personnel, |
my ($course_personnel, |
$current_members, |
$current_members, |
$expired_members, |
$expired_members, |
$future_members) = |
$future_members) = |
&Apache::lonselstudent::get_people_in_class($env{'request.course.sec'}); |
&Apache::lonselstudent::get_people_in_class($env{'request.course.sec'}, |
|
$personnel_section); |
|
|
|
|
# Load up the non-students, if necessary |
# Load up the non-students, if necessary |
|
|
Line 2596 sub render {
|
Line 2722 sub render {
|
unshift @$current_members, (@$course_personnel); |
unshift @$current_members, (@$course_personnel); |
} |
} |
|
|
|
my %titles = &Apache::lonlocal::texthash( |
|
'active' => 'Select Currently Enrolled Students and Active Course Personnel', |
|
'future' => 'Select Future Enrolled Students', |
|
'expired' => 'Select Previously Enrolled Students', |
|
); |
|
|
|
if ($env{'request.course.sec'}) { |
|
if ($self->{'sectiononly'}) { |
|
$titles{'active'} = &mt('Select Currently Enrolled Students and Active Course Personnel in Section: [_1]', |
|
$env{'request.course.sec'}); |
|
} else { |
|
$titles{'active'} = &mt('Select Currently Enrolled Students in Section: [_1], and Active Course Personnel', |
|
$env{'request.course.sec'}); |
|
} |
|
$titles{'future'} = &mt('Select Future Enrolled Students in Section: [_1]', |
|
$env{'request.course.sec'}); |
|
$titles{'expired'} = &mt('Select Previously Enrolled Students in Section: [_1]', |
|
$env{'request.course.sec'}); |
|
} |
|
|
# Current personel |
# Current personnel |
|
|
$result .= '<h4>'.&mt('Select Currently Enrolled Students and Active Course Personnel').'</h4>'; |
$result .= '<h4>'.$titles{'active'}.'</h4>'; |
$result .= &Apache::lonselstudent::render_student_list( $current_members, |
$result .= &Apache::lonselstudent::render_student_list( $current_members, |
"helpform", |
"helpform", |
"current", |
"current", |
\%defaultUsers, |
\%defaultUsers, |
$self->{'multichoice'}, |
$self->{'multichoice'}, |
$self->{'variable'}, |
$self->{'variable'}, |
1); |
1); |
|
|
|
|
# If activeonly is not set then we can also give the expired students: |
# If activeonly is not set then we can also give the expired students: |
# |
# |
if (!$self->{'activeonly'} && ((scalar(@$future_members)) > 0)) { |
if (!$self->{'activeonly'} && ((scalar(@$future_members)) > 0)) { |
|
|
# And future. |
# And future. |
|
|
$result .= '<h4>'.&mt('Select Future Enrolled Students and Future Course Personnel').'</h4>'; |
$result .= '<h4>'.$titles{'future'}.'</h4>'; |
|
|
$result .= &Apache::lonselstudent::render_student_list( $future_members, |
$result .= &Apache::lonselstudent::render_student_list( $future_members, |
"helpform", |
"helpform", |
Line 2628 sub render {
|
Line 2772 sub render {
|
if (!$self->{'activeonly'} && ((scalar(@$expired_members)) > 0)) { |
if (!$self->{'activeonly'} && ((scalar(@$expired_members)) > 0)) { |
# Past |
# Past |
|
|
$result .= '<h4>'.&mt('Select Previously Enrolled Students and Inactive Course Personnel').'</h4>'; |
$result .= '<h4>'.$titles{'expired'}.'</h4>'; |
$result .= &Apache::lonselstudent::render_student_list($expired_members, |
$result .= &Apache::lonselstudent::render_student_list($expired_members, |
"helpform", |
"helpform", |
"past", |
"past", |
Line 2870 BUTTONS
|
Line 3014 BUTTONS
|
} |
} |
|
|
# Get the list of files in this directory. |
# Get the list of files in this directory. |
my @fileList; |
my (@fileList,$listref,$listerror); |
|
|
# If the subdirectory is in local CSTR space |
# If the subdirectory is in local CSTR space |
my $metadir; |
my $metadir; |
if ($subdir =~ m|/home/([^/]+)/public_html/(.*)|) { |
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my ($user,$domain)= |
if ($subdir =~ m{^(?:\Q$londocroot\E)*/priv/[^/]+/[^/]+/(.*)$}) { |
&Apache::loncacc::constructaccess($subdir, |
my $innerpath=$1; |
$Apache::lonnet::perlvar{'lonDefDomain'}); |
unless ($subdir=~m{^\Q$londocroot\E}) { |
$metadir='/res/'.$domain.'/'.$user.'/'.$2; |
$subdir=$londocroot.$subdir; |
@fileList = &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/'); |
} |
} elsif ($subdir =~ m|^~([^/]+)/(.*)$|) { |
|
$subdir='/home/'.$1.'/public_html/'.$2; |
|
my ($user,$domain)= |
my ($user,$domain)= |
&Apache::loncacc::constructaccess($subdir, |
&Apache::lonnet::constructaccess($subdir); |
$Apache::lonnet::perlvar{'lonDefDomain'}); |
$metadir='/res/'.$domain.'/'.$user.'/'.$innerpath; |
$metadir='/res/'.$domain.'/'.$user.'/'.$2; |
($listref,$listerror) = |
@fileList = &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/'); |
&Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/'); |
} else { |
} else { |
# local library server resource space |
# local library server resource space |
@fileList = &Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/'); |
($listref,$listerror) = |
|
&Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/'); |
} |
} |
|
|
# Sort the fileList into order |
# Sort the fileList into order |
@fileList = sort {lc($a) cmp lc($b)} @fileList; |
if (ref($listref) eq 'ARRAY') { |
|
@fileList = sort {lc($a) cmp lc($b)} @{$listref}; |
|
} |
|
|
$result .= $buttons; |
$result .= $buttons; |
|
|
Line 2988 sub fileState {
|
Line 3133 sub fileState {
|
} |
} |
my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $subdirpart = $constructionSpaceDir; |
my $subdirpart = $constructionSpaceDir; |
$subdirpart =~ s/^\/home\/$uname\/public_html//; |
$subdirpart =~ s{^\Q$docroot/priv/$udom/$uname\E}{}; |
my $resdir = $docroot . '/res/' . $udom . '/' . $uname . |
my $resdir = $docroot . '/res/' . $udom . '/' . $uname . |
$subdirpart; |
$subdirpart; |
|
|
Line 3038 It takes the standard attributes "variab
|
Line 3183 It takes the standard attributes "variab
|
"allowempty" and "nextstate", meaning what they do for most other |
"allowempty" and "nextstate", meaning what they do for most other |
elements. |
elements. |
|
|
also takes a boolean 'onlysections' whcih will restrict this to only |
also takes a boolean 'onlysections' which will restrict this to only |
have sections and not include groups |
have sections and not include groups |
|
|
=cut |
=cut |
Line 3076 sub start_section {
|
Line 3221 sub start_section {
|
|
|
# Populate the CHOICES element |
# Populate the CHOICES element |
my %choices; |
my %choices; |
|
my $usersec = $Apache::lonnet::env{'request.course.sec'}; |
|
|
my $section = Apache::loncoursedata::CL_SECTION(); |
if ($usersec ne '') { |
my $classlist = Apache::loncoursedata::get_classlist(); |
$choices{$usersec} = $usersec; |
foreach my $user (keys(%$classlist)) { |
} else { |
my $section_name = $classlist->{$user}[$section]; |
my $section = Apache::loncoursedata::CL_SECTION(); |
if (!$section_name) { |
my $classlist = Apache::loncoursedata::get_classlist(); |
$choices{"No section assigned"} = ""; |
foreach my $user (keys(%$classlist)) { |
} else { |
my $section_name = $classlist->{$user}[$section]; |
$choices{$section_name} = $section_name; |
if (!$section_name) { |
|
$choices{"No section assigned"} = ""; |
|
} else { |
|
$choices{$section_name} = $section_name; |
|
} |
|
} |
|
|
|
if (exists($choices{"No section assigned"})) { |
|
push(@{$paramHash->{CHOICES}}, |
|
['No section assigned','No section assigned']); |
|
delete($choices{"No section assigned"}); |
} |
} |
} |
|
|
|
if (exists($choices{"No section assigned"})) { |
|
push(@{$paramHash->{CHOICES}}, |
|
['No section assigned','No section assigned']); |
|
delete($choices{"No section assigned"}); |
|
} |
} |
for my $section_name (sort {lc($a) cmp lc($b) } (keys(%choices))) { |
for my $section_name (sort {lc($a) cmp lc($b) } (keys(%choices))) { |
push @{$paramHash->{CHOICES}}, [$section_name, $section_name]; |
push @{$paramHash->{CHOICES}}, [$section_name, $section_name]; |
Line 3127 It takes the standard attributes "variab
|
Line 3277 It takes the standard attributes "variab
|
"allowempty" and "nextstate", meaning what they do for most other |
"allowempty" and "nextstate", meaning what they do for most other |
elements. |
elements. |
|
|
|
also takes a boolean grouponly, which if true, will restrict choice to |
|
groups in which user is a member, unless user has the mdg priv in the course, |
|
in which case all groups will be possible choices. Defaults to false. |
|
|
=cut |
=cut |
|
|
no strict; |
no strict; |
Line 3156 sub start_group {
|
Line 3310 sub start_group {
|
$helper->declareVar($paramHash->{'variable'}); |
$helper->declareVar($paramHash->{'variable'}); |
$paramHash->{'multichoice'} = $token->[2]{'multichoice'}; |
$paramHash->{'multichoice'} = $token->[2]{'multichoice'}; |
$paramHash->{'allowempty'} = $token->[2]{'allowempty'}; |
$paramHash->{'allowempty'} = $token->[2]{'allowempty'}; |
|
$paramHash->{'grouponly'} = $token->[2]{'grouponly'}; |
if (defined($token->[2]{'nextstate'})) { |
if (defined($token->[2]{'nextstate'})) { |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
} |
} |
Line 3163 sub start_group {
|
Line 3318 sub start_group {
|
# Populate the CHOICES element |
# Populate the CHOICES element |
my %choices; |
my %choices; |
|
|
my %curr_groups = &Apache::longroup::coursegroups(); |
my %curr_groups; |
|
if ((!$paramHash->{'grouponly'}) || (&Apache::lonnet::allowed('mdg',$Apache::lonnet::env{'request.course.id'}))) { |
|
%curr_groups = &Apache::longroup::coursegroups(); |
|
} elsif ($Apache::lonnet::env{'request.course.groups'} ne '') { |
|
map { $curr_groups{$_} = 1; } split(/,/,$Apache::lonnet::env{'request.course.groups'}); |
|
} |
foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) { |
foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) { |
push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); |
push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); |
} |
} |
Line 3188 package Apache::lonhelper::string;
|
Line 3348 package Apache::lonhelper::string;
|
string elements provide a string entry field for the user. string elements |
string elements provide a string entry field for the user. string elements |
take the usual 'variable' and 'nextstate' parameters. string elements |
take the usual 'variable' and 'nextstate' parameters. string elements |
also pass through 'maxlength' and 'size' attributes to the input tag. |
also pass through 'maxlength' and 'size' attributes to the input tag. |
|
Since you could have multiple strings in a helper state, each with its own |
|
validator, all but the last string should have |
|
noproceed='1' so that _all_ validators are evaluated before the next |
|
state can be reached. |
|
|
string honors the defaultvalue tag, if given. |
string honors the defaultvalue tag, if given. |
|
|
Line 3207 BEGIN {
|
Line 3371 BEGIN {
|
|
|
sub new { |
sub new { |
my $ref = Apache::lonhelper::element->new(); |
my $ref = Apache::lonhelper::element->new(); |
|
$ref->{'PROCEED'} = 1; # By default postprocess goes to next state. |
bless($ref); |
bless($ref); |
} |
} |
|
|
Line 3223 sub start_string {
|
Line 3388 sub start_string {
|
$paramHash->{'nextstate'} = $token->[2]{'nextstate'}; |
$paramHash->{'nextstate'} = $token->[2]{'nextstate'}; |
$paramHash->{'maxlength'} = $token->[2]{'maxlength'}; |
$paramHash->{'maxlength'} = $token->[2]{'maxlength'}; |
$paramHash->{'size'} = $token->[2]{'size'}; |
$paramHash->{'size'} = $token->[2]{'size'}; |
|
|
return ''; |
return ''; |
} |
} |
|
|
sub end_string { |
sub end_string { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
|
|
if ($target ne 'helper') { |
if ($target ne 'helper') { |
return ''; |
return ''; |
} |
} |
Apache::lonhelper::string->new(); |
my $state = Apache::lonhelper::string->new(); |
|
|
|
|
|
if(&Apache::lonxml::get_param('noproceed', $parstack, $safeeval, undef, 1)) { |
|
$state->noproceed(); |
|
} |
|
|
|
|
|
|
return ''; |
return ''; |
} |
} |
|
|
|
sub noproceed() { |
|
my $self = shift; |
|
$self->{PROCEED} = 0; |
|
} |
|
|
sub render { |
sub render { |
my $self = shift; |
my $self = shift; |
my $result = ''; |
my $result = ''; |
Line 3245 sub render {
|
Line 3423 sub render {
|
$result .= '<p><font color="#FF0000">' . $self->{ERROR_MSG} . '</font></p>'; |
$result .= '<p><font color="#FF0000">' . $self->{ERROR_MSG} . '</font></p>'; |
} |
} |
|
|
$result .= '<input type="string" name="' . $self->{'variable'} . '_forminput"'; |
$result .= '<input type="text" name="' . $self->{'variable'} . '_forminput"'; |
|
|
if (defined($self->{'size'})) { |
if (defined($self->{'size'})) { |
$result .= ' size="' . $self->{'size'} . '"'; |
$result .= ' size="' . $self->{'size'} . '"'; |
Line 3280 sub postprocess {
|
Line 3458 sub postprocess {
|
} |
} |
} |
} |
|
|
if (defined($self->{'nextstate'})) { |
if (defined($self->{'nextstate'}) && $self->{PROCEED}) { |
$helper->changeState($self->{'nextstate'}); |
$helper->changeState($self->{'nextstate'}); |
} |
} |
|
|
Line 3507 sub render {
|
Line 3685 sub render {
|
my @results; |
my @results; |
|
|
# Collect all the results |
# Collect all the results |
for my $stateName (keys %{$helper->{STATES}}) { |
for my $stateName (keys(%{$helper->{STATES}})) { |
my $state = $helper->{STATES}->{$stateName}; |
my $state = $helper->{STATES}->{$stateName}; |
|
|
for my $element (@{$state->{ELEMENTS}}) { |
for my $element (@{$state->{ELEMENTS}}) { |
Line 3560 sub render {
|
Line 3738 sub render {
|
} |
} |
my $previous = HTML::Entities::encode(&mt("Back"), '<>&"'); |
my $previous = HTML::Entities::encode(&mt("Back"), '<>&"'); |
my $next = HTML::Entities::encode(&mt("Next"), '<>&"'); |
my $next = HTML::Entities::encode(&mt("Next"), '<>&"'); |
my $target = " target='loncapaclient'"; |
|
if ($env{'environment.remote'} eq 'off') { $target=''; } |
|
$result .= "<p>\n" . |
$result .= "<p>\n" . |
"<form action='".$actionURL."' method='post' $target>\n" . |
"<form action='".$actionURL."' method='post' >\n" . |
"<input type='button' onclick='history.go(-1)' value='$previous' />" . |
"<input type='button' onclick='history.go(-1)' value='$previous' />" . |
"<input type='hidden' name='orgurl' value='$targetURL' />" . |
"<input type='hidden' name='orgurl' value='$targetURL' />" . |
"<input type='hidden' name='selectrole' value='1' />\n" . |
"<input type='hidden' name='selectrole' value='1' />\n" . |