--- loncom/interface/lonhelper.pm	2004/04/22 16:47:26	1.75
+++ loncom/interface/lonhelper.pm	2005/02/22 22:56:08	1.99
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.75 2004/04/22 16:47:26 albertel Exp $
+# $Id: lonhelper.pm,v 1.99 2005/02/22 22:56:08 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -575,6 +575,7 @@ sub display {
     }
 
     # Phase 4: Display.
+    my $html=&Apache::lonxml::xmlbegin();
     my $stateTitle=&mt($state->title());
     my $helperTitle = &mt($self->{TITLE});
     my $bodytag = &Apache::loncommon::bodytag($helperTitle,'','');
@@ -584,9 +585,8 @@ sub display {
     my $loncapaHelper = &mt("LON-CAPA Helper:");
 
     $result .= <<HEADER;
-<html>
+$html
     <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <title>$loncapaHelper: $helperTitle</title>
     </head>
     $bodytag
@@ -1165,7 +1165,7 @@ sub start_choice {
                                               $parser));
     my $nextstate = $token->[2]{'nextstate'};
     my $evalFlag = $token->[2]{'eval'};
-    push @{$paramHash->{CHOICES}}, [$human, $computer, $nextstate, 
+    push @{$paramHash->{CHOICES}}, [&mtn($human), $computer, $nextstate, 
                                     $evalFlag];
     return '';
 }
@@ -1174,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'};
@@ -1256,14 +1263,16 @@ 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='" . 
-            HTML::Entities::encode($choice->[1],'<>&"') 
+            HTML::Entities::encode($choice->[1],"<>&\"'") 
             . "'";
         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;" .
@@ -1271,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">}.
+            $choiceLabel. "</label></td></tr>\n";
     }
     $result .= "</table>\n\n\n";
     $result .= $buttons;
@@ -1415,7 +1424,7 @@ sub render {
     $result .= "<select name='${var}.forminput'>\n";
     foreach my $choice (@{$self->{CHOICES}}) {
         $result .= "<option value='" . 
-            HTML::Entities::encode($choice->[1],'<>&"') 
+            HTML::Entities::encode($choice->[1],"<>&\"'") 
             . "'";
         if ($checkedChoices{$choice->[1]}) {
             $result .= " selected";
@@ -1706,7 +1715,9 @@ to false. The "suppressEmptySequences" a
 suppressEmptySequences argument to the render routine, which will cause
 folders that have all of their contained resources filtered out to also
 be filtered out. The 'addstatus' attribute, if true, will add the icon
-and long status display columns to the display.
+and long status display columns to the display. The 'addparts'
+attribute will add in a part selector beside problems that have more
+than 1 part.
 
 =head3 SUB-TAGS
 
@@ -1751,7 +1762,7 @@ BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::resource',
                               ('resource', 'filterfunc', 
                                'choicefunc', 'valuefunc',
-                               'mapurl'));
+                               'mapurl','option'));
 }
 
 sub new {
@@ -1773,6 +1784,10 @@ sub start_resource {
     $paramHash->{'suppressEmptySequences'} = $token->[2]{'suppressEmptySequences'};
     $paramHash->{'toponly'} = $token->[2]{'toponly'};
     $paramHash->{'addstatus'} = $token->[2]{'addstatus'};
+    $paramHash->{'addparts'} = $token->[2]{'addparts'};
+    if ($paramHash->{'addparts'}) {
+	$helper->declareVar($paramHash->{'variable'}.'_part');
+    }
     $paramHash->{'closeallpages'} = $token->[2]{'closeallpages'};
     return '';
 }
@@ -1856,6 +1871,42 @@ sub start_mapurl {
 
 sub end_mapurl { return ''; }
 
+
+sub start_option {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    if (!defined($paramHash->{OPTION_TEXTS})) {
+	$paramHash->{OPTION_TEXTS} = [ ];
+	$paramHash->{OPTION_VARS}  = [ ];
+
+    }
+    # OPTION_TEXTS is a list of the text attribute
+    #               values used to create column headings.
+    # OPTION_VARS is a list of the variable names, used to create the checkbox
+    #             inputs.
+    #  We're ok with empty elements. as place holders
+    # Although the 'variable' element should really exist.
+    #
+
+    my $option_texts  = $paramHash->{OPTION_TEXTS};
+    my $option_vars   = $paramHash->{OPTION_VARS};
+    push(@$option_texts,  $token->[2]{'text'});
+    push(@$option_vars,   $token->[2]{'variable'});
+
+    #  Need to create and declare the option variables as well to make them
+    # persistent.
+    #
+    my $varname = $token->[2]{'variable'};
+    $helper->declareVar($varname);
+
+
+    return '';
+}
+
+sub end_option {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    return '';
+}
+
 # A note, in case I don't get to this before I leave.
 # If someone complains about the "Back" button returning them
 # to the previous folder state, instead of returning them to
@@ -1907,10 +1958,14 @@ BUTTONS
 
     $result .= $buttons;
 
-    my $filterFunc = $self->{FILTER_FUNC};
-    my $choiceFunc = $self->{CHOICE_FUNC};
-    my $valueFunc = $self->{VALUE_FUNC};
-    my $multichoice = $self->{'multichoice'};
+    my $filterFunc     = $self->{FILTER_FUNC};
+    my $choiceFunc     = $self->{CHOICE_FUNC};
+    my $valueFunc      = $self->{VALUE_FUNC};
+    my $multichoice    = $self->{'multichoice'};
+    my $option_vars    = $self->{OPTION_VARS};
+    my $option_texts   = $self->{OPTION_TEXTS};
+    my $addparts       = $self->{'addparts'};
+    my $headings_done  = 0;
 
     # Evaluate the map url as needed
     my $mapUrl;
@@ -1922,21 +1977,54 @@ BUTTONS
 	$mapUrl = $self->{MAP_URL};
     }
 
+
     # Create the composite function that renders the column on the nav map
     # have to admit any language that lets me do this can't be all bad
     #  - Jeremy (Pythonista) ;-)
     my $checked = 0;
     my $renderColFunc = sub {
         my ($resource, $part, $params) = @_;
+	my $result = "";
+
+	if(!$headings_done) {
+	    if ($option_texts) {
+		foreach my $text (@$option_texts) {
+		    $result .= "<th>$text</th>";
+		}
+	    }
+	    $result .= "<th>Select</th>";
+	    $result .= "</tr><tr>"; # Close off the extra row and start a new one.
+	    $headings_done = 1;
+	}
 
         my $inputType;
         if ($multichoice) { $inputType = 'checkbox'; }
         else {$inputType = 'radio'; }
 
         if (!&$choiceFunc($resource)) {
-            return '<td>&nbsp;</td>';
+	    $result .= '<td>&nbsp;</td>';
+            return $result;
         } else {
-            my $col = "<td><input type='$inputType' name='${var}.forminput' ";
+	    my $col = "";
+	    my $raw_name = &$valueFunc($resource);
+	    my $resource_name =   
+                   HTML::Entities::encode($raw_name,"<>&\"'");
+	    if($option_vars) {
+		foreach my $option_var (@$option_vars) {
+		    my $var_value = "\|\|\|" . $helper->{VARS}->{$option_var} . 
+			"\|\|\|";
+		    my $checked ="";
+		    if($var_value =~ /\Q|||$raw_name|||\E/) {
+			$checked = "checked";
+		    }
+		    $col .= 
+                        "<td align='center'><input type='checkbox' name ='$option_var".
+			".forminput' value='".
+			$resource_name . "' $checked /> </td>";
+		}
+	    }
+
+            $col .= "<td align='center'><input type='$inputType' name='${var}.forminput' ";
             if (!$checked && !$multichoice) {
                 $col .= "checked ";
                 $checked = 1;
@@ -1945,15 +2033,52 @@ BUTTONS
 		$col .= "checked ";
 		$checked = 1;
 	    }
-            $col .= "value='" . 
-                HTML::Entities::encode(&$valueFunc($resource),'<>&"') 
-                . "' /></td>";
-            return $col;
+            $col .= "value='" . $resource_name  . "' /></td>";
+
+            return $result.$col;
         }
     };
+    my $renderPartsFunc = sub {
+        my ($resource, $part, $params) = @_;
+	my $col= "<td>";
+	my $id=$resource->{ID};
+	my $resource_name =   
+	    &HTML::Entities::encode(&$valueFunc($resource),"<>&\"'");
+	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 .= "<option value=\"$part\">All Parts</option>\n";
+	    foreach my $part (@{$resource->parts}) {
+		$col .= "<option value=\"$part\">Part: $part</option>\n";
+	    }
+	    $col .= "</select>";
+	}
+	$col .= "</td>";
+    };
+    $result.=(<<RADIO);
+<script type="text/javascript">
+    function updateRadio(form,name,value) {
+	var radiobutton=form[name];
+	for (var i=0; i<radiobutton.length; i++) {
+	    if (radiobutton[i].value == value) {
+		radiobutton[i].checked = true;
+		break;
+	    }
+	}
+    }
+    function updateHidden(form,id,name) {
+	var select=form['part_'+id+'.forminput'];
+	var hidden=form[name+'_part.forminput'];
+	var which=select.selectedIndex;
+	hidden.value=select.options[which].value;
+    }
+</script>
+<input type="hidden" name="${var}_part.forminput" />;
 
+RADIO
     $ENV{'form.condition'} = !$self->{'toponly'};
-    my $cols = [$renderColFunc, Apache::lonnavmaps::resource()];
+    my $cols = [$renderColFunc];
+    if ($self->{'addparts'}) { push(@$cols, $renderPartsFunc); }
+    push(@$cols, Apache::lonnavmaps::resource());
     if ($self->{'addstatus'}) {
 	push @$cols, (Apache::lonnavmaps::part_status_summary());
 	
@@ -2053,7 +2178,7 @@ sub start_student {
     $helper->declareVar($paramHash->{'variable'});
     $paramHash->{'multichoice'} = $token->[2]{'multichoice'};
     $paramHash->{'coursepersonnel'} = $token->[2]{'coursepersonnel'};
-    $paramHash->{'sctiveonly'} = $token->[2]{'activeonly'};
+    $paramHash->{'activeonly'} = $token->[2]{'activeonly'};
     if (defined($token->[2]{'nextstate'})) {
         $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
     }
@@ -2090,7 +2215,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;
+		}
             }
         }
     }
@@ -2098,7 +2225,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>
@@ -2106,19 +2240,33 @@ 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="checkall(true, '$var')" value="$lt{'sas'}" />
-<input type="button" onclick="checkall(false, '$var')" value="$lt{'uas'}" />
-<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'}">
+<table>
+  <tr>
+  
+    <td><input type="button" onclick="checkactive()" value="$lt{'ocs'}" /></td>
+    <td><input type="button" onclick="uncheckexpired()" value="$lt{'ues'}" /><br /></td>
+  </tr>
+  <tr>
+     <td><input type="button" onclick="checkall(true, '$var')" value="$lt{'sas'}" /></td>
+     <td> <input type="button" onclick="checkall(false, '$var')" value="$lt{'uas'}" /><br /></td>
+  </tr>
+  <tr>
+      <td><input type="button" onclick="checksec(true)" value="$lt{'sfsg'}"></td>
+      <td><input type="text" size="5" name="chksec">&nbsp;</td>
+  </tr>
+  <tr>
+      <td><input type="button" onclick="checksec(false)" value="$lt{'ufsg'}"></td>
+      <td></td>
+  </tr>
+</table>
 <br />
 BUTTONS
     }
@@ -2178,7 +2326,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";
@@ -2198,7 +2345,10 @@ BUTTONS
             $checked = 1;
         }
         $result .=
-            " value='" . HTML::Entities::encode($choice->[0] . ':' . $choice->[2] . ':' . $choice->[1] . ':' . $choice->[3],'<>&"')
+            " value='" . HTML::Entities::encode($choice->[0] . ':' 
+						.$choice->[2] . ':' 
+						.$choice->[1] . ':' 
+						.$choice->[3], "<>&\"'")
             . "' /></td><td>"
             . HTML::Entities::encode($choice->[1],'<>&"')
             . "</td><td align='center'>" 
@@ -2366,6 +2516,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 = '';
@@ -2452,7 +2609,7 @@ BUTTONS
     }
 
     # Sort the fileList into order
-    @fileList = sort @fileList;
+    @fileList = sort {lc($a) cmp lc($b)} @fileList;
 
     $result .= $buttons;
 
@@ -2504,14 +2661,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++;
@@ -2539,10 +2698,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);
@@ -2671,6 +2834,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',
@@ -2714,7 +2878,7 @@ sub render {
     my $result = '';
 
     if (defined $self->{ERROR_MSG}) {
-        $result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />';
+        $result .= '<p><font color="#FF0000">' . $self->{ERROR_MSG} . '</font></p>';
     }
 
     $result .= '<input type="string" name="' . $self->{'variable'} . '.forminput"';
@@ -2789,6 +2953,8 @@ be able to call methods on it.
 
 =cut
 
+use Apache::lonlocal;
+
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::general',
                                  'exec', 'condition', 'clause',
@@ -2910,6 +3076,9 @@ will make a "Finish Helper" button that
 which is useful for the Course Initialization helper so the users never see
 the old values taking effect.
 
+If the parameter "restartCourse" is not true a 'Finish' Button will be
+presented that takes the user back to whatever was defined as <exitpage>
+
 =cut
 
 no strict;
@@ -3007,8 +3176,12 @@ sub render {
 	$result .= '</ul>';
     }
 
+    my $actionURL = $self->{EXIT_PAGE};
+    my $targetURL = '';
+    my $finish=&mt('Finish');
     if ($self->{'restartCourse'}) {
-	my $targetURL = '/adm/menu';
+	my $actionURL = '/adm/roles';
+	$targetURL = '/adm/menu';
 	if ($ENV{'course.'.$ENV{'request.course.id'}.'.url'}=~/^uploaded/) {
 	    $targetURL = '/adm/coursedocs';
 	} else {
@@ -3017,25 +3190,24 @@ sub render {
 	if ($ENV{'course.'.$ENV{'request.course.id'}.'.clonedfrom'}) {
 	    $targetURL = '/adm/parmset?overview=1';
 	}
-	my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"');
-	my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"');
-        $result .= "<center>\n" .
-            "<form action='/adm/roles' method='post' target='loncapaclient'>\n" .
-            "<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'} . 
-            "' value='1' />\n<input type='submit' value='" .
-	    &mt('Finish Course Initialization') . "' />\n" .
-            "</form></center>";
+	my $finish=&mt('Finish Course Initialization');
     }
+    my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"');
+    my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"');
+    $result .= "<center>\n" .
+	"<form action='".$actionURL."' method='post' target='loncapaclient'>\n" .
+	"<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'} . 
+	"' value='1' />\n<input type='submit' value='" . $finish . "' />\n" .
+	"</form></center>";
 
     return $result;
 }
 
 sub overrideForm {
-    my $self = shift;
-    return $self->{'restartCourse'};
+    return 1;
 }
 
 1;
@@ -3099,10 +3271,10 @@ sub render {
     my $resourceString;
     my $symb;
     my $paramlevel;
-
+    
     # 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';
@@ -3112,24 +3284,34 @@ sub render {
         my $res = $navmap->getByMapPc($vars->{RESOURCE_ID});
         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';
     } else {
         my $navmap = Apache::lonnavmaps::navmap->new();
         my $res = $navmap->getById($vars->{RESOURCE_ID});
+        my $part = $vars->{RESOURCE_ID_part};
+	if ($part ne 'All Parts' && $part) { $parm_name=~s/^0/$part/; } else { $part=&mt('All Parts'); }
         $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] part [_2]',"<b>$title</b>","<b>$part</b>").'</li>';
         $level = 7;
         $affectedResourceId = $vars->{RESOURCE_ID};
         $paramlevel = 'full';
     }
 
     my $result = "<form name='helpform' method='get' action='/adm/parmset#$affectedResourceId&$parm_name&$level'>\n";
+    if ($vars->{GRANULARITY} eq 'resource') {
+	$result .= "<input type='hidden' name='symb' value='".
+	    HTML::Entities::encode($symb,"'<>&\"") . "' />\n";
+	$result .= "<input type='hidden' name='pscat' value='".
+	    HTML::Entities::encode($vars->{ACTION_TYPE},"'<>&\"") . "' />\n";
+	my $part = $vars->{RESOURCE_ID_part};
+	if ($part eq 'All Parts' || !$part) { $part=0; }
+	$result .= "<input type='hidden' name='psprt' value='".
+	    HTML::Entities::encode($part,"'<>&\"") . "' />\n";
+    }
     $result .= '<p>'.&mt('Confirm that this information is correct, then click &quot;Finish Helper&quot; to complete setting the parameter.').'<ul>';
     
     # Print the type of manipulation:
@@ -3176,13 +3358,13 @@ 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";
+            HTML::Entities::encode($section,"'<>&\"") . "' />\n";
     } else {
         # FIXME: This is probably wasteful! Store the name!
         my $classlist = Apache::loncoursedata::get_classlist();
@@ -3190,20 +3372,18 @@ 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='".
-            HTML::Entities::encode($uname,'<>&"') . "' />\n";
+            HTML::Entities::encode($uname,"'<>&\"") . "' />\n";
         $result .= "<input type='hidden' name='udom' value='".
-            HTML::Entities::encode($udom,'<>&"') . "' />\n";
+            HTML::Entities::encode($udom,"'<>&\"") . "' />\n";
     }
 
     # 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