--- loncom/interface/lonhelper.pm	2004/04/22 14:43:16	1.74
+++ loncom/interface/lonhelper.pm	2004/09/24 19:49:12	1.87
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.74 2004/04/22 14:43:16 matthew Exp $
+# $Id: lonhelper.pm,v 1.87 2004/09/24 19:49:12 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -585,30 +585,6 @@ sub display {
 
     $result .= <<HEADER;
 <html>
-<script type="text/javascript" language="Javascript" >
-    var editbrowser;
-    function openbrowser(formname,elementname,only,omit) {
-        var url = '/res/?';
-        if (editbrowser == null) {
-            url += 'launch=1&';
-        }
-        url += 'catalogmode=interactive&';
-        url += 'mode=parmset&';
-        url += 'form=' + formname + '&';
-        if (only != null) {
-            url += 'only=' + only + '&';
-        } 
-        if (omit != null) {
-            url += 'omit=' + omit + '&';
-        }
-        url += 'element=' + elementname + '';
-        var title = 'Browser';
-        var options = 'scrollbars=1,resizable=1,menubar=0';
-        options += ',width=700,height=600';
-        editbrowser = open(url,title,options,'1');
-        editbrowser.focus();
-    }
-</script>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <title>$loncapaHelper: $helperTitle</title>
@@ -1198,6 +1174,13 @@ sub end_choice {
     return '';
 }
 
+{
+    # used to generate unique id attributes for <input> tags. 
+    # internal use only.
+    my $id = 0;
+    sub new_id { return $id++; }
+}
+
 sub render {
     my $self = shift;
     my $var = $self->{'variable'};
@@ -1280,6 +1263,7 @@ BUTTONS
     my $type = "radio";
     if ($self->{'multichoice'}) { $type = 'checkbox'; }
     foreach my $choice (@{$self->{CHOICES}}) {
+        my $id = &new_id();
         $result .= "<tr>\n<td width='20'>&nbsp;</td>\n";
         $result .= "<td valign='top'><input type='$type' name='$var.forminput'"
             . "' value='" . 
@@ -1288,6 +1272,7 @@ BUTTONS
         if ($checkedChoices{$choice->[1]}) {
             $result .= " checked ";
         }
+        $result .= qq{id="$id"};
         my $choiceLabel = $choice->[0];
         if ($choice->[4]) {  # if we need to evaluate this choice
             $choiceLabel = "sub { my $helper = shift; my $state = shift;" .
@@ -1295,8 +1280,8 @@ BUTTONS
             $choiceLabel = eval($choiceLabel);
             $choiceLabel = &$choiceLabel($helper, $self);
         }
-	&Apache::lonnet::logthis("TITLE TRANSLATION >$choiceLabel<");
-        $result .= "/></td><td> " . &mtn($choiceLabel) . "</td></tr>\n";
+        $result .= "/></td><td> ".qq{<label for="$id">}.
+            &mtn($choiceLabel). "</label></td></tr>\n";
     }
     $result .= "</table>\n\n\n";
     $result .= $buttons;
@@ -2114,7 +2099,9 @@ sub render {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
 	    comp = document.forms.helpform.elements.chksec.value;
             if (document.forms.helpform.elements[i].value.indexOf(':'+comp+':') != -1) {
-                document.forms.helpform.elements[i].checked=value;
+		if (document.forms.helpform.elements[i].value.indexOf(':Active') != -1) {
+		    document.forms.helpform.elements[i].checked=value;
+		}
             }
         }
     }
@@ -2122,7 +2109,14 @@ sub render {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
             if (document.forms.helpform.elements[i].value.indexOf(':Active') != -1) {
                 document.forms.helpform.elements[i].checked=true;
-            }
+            } 
+        }
+    }
+    function uncheckexpired() {
+	for (i=0; i<document.forms.helpform.elements.length; i++) {
+            if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) {
+                document.forms.helpform.elements[i].checked=false;
+            } 
         }
     }
 </script>
@@ -2130,16 +2124,18 @@ SCRIPT
 
         my %lt=&Apache::lonlocal::texthash(
                     'ocs'  => "Select Only Current Students",
+                    'ues'  => "Unselect Expired Students",
                     'sas'  => "Select All Students",
                     'uas'  => "Unselect All Students",
-                    'sfsg' => "Select for Section/Group",
+                    'sfsg' => "Select Current Students for Section/Group",
 		    'ufsg' => "Unselect for Section/Group");
  
         $buttons = <<BUTTONS;
 <br />
 <input type="button" onclick="checkactive()" value="$lt{'ocs'}" />
+<input type="button" onclick="uncheckexpired()" value="$lt{'ues'}" /><br />
 <input type="button" onclick="checkall(true, '$var')" value="$lt{'sas'}" />
-<input type="button" onclick="checkall(false, '$var')" value="$lt{'uas'}" />
+<input type="button" onclick="checkall(false, '$var')" value="$lt{'uas'}" /><br />
 <input type="button" onclick="checksec(true)" value="$lt{'sfsg'}">
 <input type="text" size="5" name="chksec">&nbsp;
 <input type="button" onclick="checksec(false)" value="$lt{'ufsg'}">
@@ -2202,7 +2198,6 @@ BUTTONS
     }
 
     my $name = $self->{'coursepersonnel'} ? &mt('Name') : &mt('Student Name');
-    &Apache::lonnet::logthis("THE NAME IS >$name<");
     my $type = 'radio';
     if ($self->{'multichoice'}) { $type = 'checkbox'; }
     $result .= "<table cellspacing='2' cellpadding='2' border='0'>\n";
@@ -2390,6 +2385,13 @@ sub start_filefilter {
 
 sub end_filefilter { return ''; }
 
+{ 
+    # used to generate unique id attributes for <input> tags. 
+    # internal use only.
+    my $id=0;
+    sub new_id { return $id++;}
+}
+
 sub render {
     my $self = shift;
     my $result = '';
@@ -2476,7 +2478,7 @@ BUTTONS
     }
 
     # Sort the fileList into order
-    @fileList = sort @fileList;
+    @fileList = sort {lc($a) cmp lc($b)} @fileList;
 
     $result .= $buttons;
 
@@ -2528,14 +2530,16 @@ BUTTONS
             if ($status eq 'Published' && $helper->{VARS}->{'construction'}) {
                 $onclick = 'onclick="a=1" ';
             }
+            my $id = &new_id();
             $result .= '<tr><td align="right"' . " bgcolor='$color'>" .
                 "<input $onclick type='$type' name='" . $var
-            . ".forminput' value='" . HTML::Entities::encode($fileName,'<>&"').
+            . ".forminput' ".qq{id="$id"}." value='" . HTML::Entities::encode($fileName,'<>&"').
                 "'";
             if (!$self->{'multichoice'} && $choices == 0) {
                 $result .= ' checked';
             }
-            $result .= "/></td><td bgcolor='$color'>" . $file . "</td>" .
+            $result .= "/></td><td bgcolor='$color'>".
+                qq{<label for="$id">}. $file . "</label></td>" .
                 "<td bgcolor='$color'>$title</td>" .
                 "<td bgcolor='$color'>$status</td>" . "</tr>\n";
             $choices++;
@@ -2563,10 +2567,14 @@ 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'});
+    }
     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 =~ s/^\/home\/$uname\/public_html//;
+    my $resdir = $docroot . '/res/' . $udom . '/' . $uname .
         $subdirpart;
 
     my @constructionSpaceFileStat = stat($constructionSpaceDir . '/' . $file);
@@ -2695,6 +2703,7 @@ string honors the validation function, i
 no strict;
 @ISA = ("Apache::lonhelper::element");
 use strict;
+use Apache::lonlocal;
 
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::string',
@@ -2813,6 +2822,8 @@ be able to call methods on it.
 
 =cut
 
+use Apache::lonlocal;
+
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::general',
                                  'exec', 'condition', 'clause',
@@ -3126,7 +3137,7 @@ sub render {
 
     # Print the granularity, depending on the action
     if ($vars->{GRANULARITY} eq 'whole_course') {
-        $resourceString .= '<li>'.&mt('for').' <b>'.&mt('all resources in the course').'</b></li>';
+        $resourceString .= '<li>'.&mt('for <b>all resources in the course</b>').'</li>';
         $level = 9; # general course, see lonparmset.pm perldoc
         $affectedResourceId = "0.0";
         $symb = 'a';
@@ -3137,7 +3148,7 @@ sub render {
         my $title = $res->compTitle();
         $symb = $res->symb();
         $navmap->untieHashes();
-        $resourceString .= "<li>for the map named <b>$title</b></li>";
+        $resourceString .= '<li>'.&mt('for the map named [_1]',"<b>$title</b>").'</li>';
         $level = 8;
         $affectedResourceId = $vars->{RESOURCE_ID};
         $paramlevel = 'map';
@@ -3147,7 +3158,7 @@ sub render {
         $symb = $res->symb();
         my $title = $res->compTitle();
         $navmap->untieHashes();
-        $resourceString .= "<li>for the resource named <b>$title</b></li>";
+        $resourceString .= '<li>'.&mt('for the resource named [_1]',"<b>$title</b>").'</li>';
         $level = 7;
         $affectedResourceId = $vars->{RESOURCE_ID};
         $paramlevel = 'full';
@@ -3200,10 +3211,10 @@ sub render {
     
     # Print targets
     if ($vars->{TARGETS} eq 'course') {
-        $result .= '<li>'.&mt('for').' <b>'.&mt('all students in course').'</b></li>';
+        $result .= '<li>'.&mt('for <b>all students in course</b>').'</li>';
     } elsif ($vars->{TARGETS} eq 'section') {
         my $section = $vars->{SECTION_NAME};
-        $result .= "<li>".&mt('for section')." <b>$section</b></li>";
+        $result .= '<li>'.&mt('for section [_1]',"<b>$section</b>").'</li>';
         $level -= 3;
         $result .= "<input type='hidden' name='csec' value='" .
             HTML::Entities::encode($section,'<>&"') . "' />\n";
@@ -3214,7 +3225,7 @@ sub render {
         # Chop off everything after the last colon (section)
         $username = substr($username, 0, rindex($username, ':'));
         my $name = $classlist->{$username}->[6];
-        $result .= "<li>".&mt('for')." <b>$name</b></li>";
+        $result .= '<li>'.&mt('for [_1]',"<b>$name</b>").'</li>';
         $level -= 6;
         my ($uname, $udom) = split /:/, $vars->{USER_NAME};
         $result .= "<input type='hidden' name='uname' value='".
@@ -3225,9 +3236,7 @@ sub render {
 
     # Print value
     if ($vars->{ACTION_TYPE} ne 'tries' && $vars->{ACTION_TYPE} ne 'weight') {
-	$result .= "<li>".&mt('to')." <b>" . ctime($vars->{PARM_DATE}) . "</b> (" .
-	    Apache::lonnavmaps::timeToHumanString($vars->{PARM_DATE}) 
-	    . ")</li>\n";
+	$result .= '<li>'.&mt('to [_1] ([_2])',"<b>".ctime($vars->{PARM_DATE})."</b>",Apache::lonnavmaps::timeToHumanString($vars->{PARM_DATE}))."</li>\n";
     }
  
     # print pres_marker