--- loncom/interface/lonhelper.pm 2003/05/02 19:20:51 1.17 +++ loncom/interface/lonhelper.pm 2003/05/07 19:24:07 1.23 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.17 2003/05/02 19:20:51 bowersj2 Exp $ +# $Id: lonhelper.pm,v 1.23 2003/05/07 19:24:07 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -997,17 +997,20 @@ sub render { if ($self->{'multichoice'}) { $result .= < - function checkall(value) { + function checkall(value, checkName) { for (i=0; i SCRIPT $buttons = < - - + +
  BUTTONS } @@ -1474,10 +1477,10 @@ sub render { if ($self->{'multichoice'}) { $result = < - function checkall(value) { + function checkall(value, checkName) { for (i=0; i   - - + +
  BUTTONS } @@ -1627,21 +1630,25 @@ sub render { my $self = shift; my $result = ''; my $buttons = ''; + my $var = $self->{'variable'}; if ($self->{'multichoice'}) { $result = < - function checkall(value) { + function checkall(value, checkName) { for (i=0; i SCRIPT $buttons = < - - + +
BUTTONS } @@ -1682,7 +1689,7 @@ BUTTONS $checked = 1; } $result .= - " value='" . HTML::Entities::encode($_) + " value='" . HTML::Entities::encode($_ . ':' . $choices->{$_}->[$section]) . "' />" . HTML::Entities::encode($choices->{$_}->[$fullname]) . "" @@ -1828,14 +1835,27 @@ sub render { my $filterFunc = $self->{FILTER_FUNC}; my $buttons = ''; + my $type = 'radio'; + if ($self->{'multichoice'}) { + $type = 'checkbox'; + } if ($self->{'multichoice'}) { $result = < - function checkall(value) { + function checkall(value, checkName) { for (i=0; i   - - + + +BUTTONS + + if ($helper->{VARS}->{'construction'}) { + $buttons .= < +
  BUTTONS + } } # Get the list of files in this directory. @@ -1869,15 +1896,11 @@ BUTTONS $result .= '
' . $self->{ERROR_MSG} . '

'; } - $result .= ''; + $result .= '
'; # Keeps track if there are no choices, prints appropriate error # if there are none. my $choices = 0; - my $type = 'radio'; - if ($self->{'multichoice'}) { - $type = 'checkbox'; - } # Print each legitimate file choice. for my $file (@fileList) { $file = (split(/&/, $file))[0]; @@ -1886,14 +1909,36 @@ BUTTONS } my $fileName = $subdir .'/'. $file; if (&$filterFunc($file)) { - $result .= '\n"; + $result .= "/>\n"; $choices++; } } @@ -1909,6 +1954,37 @@ BUTTONS return $result; } +# Determine the state of the file: Published, unpublished, modified. +# Return the color it should be in and a label as a two-element array +# reference. +# Logic lifted from lonpubdir.pm, even though I don't know that it's still +# the most right thing to do. + +sub fileState { + my $constructionSpaceDir = shift; + my $file = shift; + + my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; + my $subdirpart = $constructionSpaceDir; + $subdirpart =~ s/^\/home\/$ENV{'user.name'}\/public_html//; + my $resdir = $docroot . '/res/' . $ENV{'user.domain'} . '/' . $ENV{'user.name'} . + $subdirpart; + + my @constructionSpaceFileStat = stat($constructionSpaceDir . '/' . $file); + my @resourceSpaceFileStat = stat($resdir . '/' . $file); + if (!@resourceSpaceFileStat) { + return ['Unpublished', '#FFCCCC']; + } + + my $constructionSpaceFileModified = $constructionSpaceFileStat[9]; + my $resourceSpaceFileModified = $resourceSpaceFileStat[9]; + + if ($constructionSpaceFileModified > $resourceSpaceFileModified) { + return ['Modified', '#FFFFCC']; + } + return ['Published', '#CCFFCC']; +} + sub postprocess { my $self = shift; my $result = $ENV{'form.' . $self->{'variable'} . '.forminput'};
' . - "{VARS}->{'construction'}) { + $onclick = 'onclick="a=1" '; + } + $result .= '
" . + "{'multichoice'} && $choices == 0) { $result .= ' checked'; } - $result .= "/>" . $file . "
" . $file . + "$status