--- loncom/interface/lonhelper.pm	2005/07/07 04:16:01	1.106
+++ loncom/interface/lonhelper.pm	2005/07/12 16:03:12	1.111
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.106 2005/07/07 04:16:01 albertel Exp $
+# $Id: lonhelper.pm,v 1.111 2005/07/12 16:03:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1265,13 +1265,13 @@ BUTTONS
         my $id = &new_id();
         $result .= "<tr>\n<td width='20'>&nbsp;</td>\n";
         $result .= "<td valign='top'><input type='$type' name='$var.forminput'"
-            . "' value='" . 
+            . " value='" . 
             HTML::Entities::encode($choice->[1],"<>&\"'") 
             . "'";
         if ($checkedChoices{$choice->[1]}) {
-            $result .= " checked ";
+            $result .= " checked='checked' ";
         }
-        $result .= qq{id="$id"};
+        $result .= qq{id="id$id"};
         my $choiceLabel = $choice->[0];
         if ($choice->[4]) {  # if we need to evaluate this choice
             $choiceLabel = "sub { my $helper = shift; my $state = shift;" .
@@ -1279,7 +1279,7 @@ BUTTONS
             $choiceLabel = eval($choiceLabel);
             $choiceLabel = &$choiceLabel($helper, $self);
         }
-        $result .= "/></td><td> ".qq{<label for="$id">}.
+        $result .= "/></td><td> ".qq{<label for="id$id">}.
             $choiceLabel. "</label></td></tr>\n";
     }
     $result .= "</table>\n\n\n";
@@ -1427,7 +1427,7 @@ sub render {
             HTML::Entities::encode($choice->[1],"<>&\"'") 
             . "'";
         if ($checkedChoices{$choice->[1]}) {
-            $result .= " selected";
+            $result .= " selected='selected' ";
         }
         my $choiceLabel = $choice->[0];
         if ($choice->[4]) {  # if we need to evaluate this choice
@@ -1566,7 +1566,7 @@ sub render {
     $result .= "<select name='${var}month'>\n";
     for ($i = 0; $i < 12; $i++) {
         if ($i == $date->mon) {
-            $result .= "<option value='$i' selected>";
+            $result .= "<option value='$i' selected='selected'>";
         } else {
             $result .= "<option value='$i'>";
         }
@@ -1578,7 +1578,7 @@ sub render {
     $result .= "<select name='${var}day'>\n";
     for ($i = 1; $i < 32; $i++) {
         if ($i == $date->mday) {
-            $result .= '<option selected>';
+            $result .= '<option selected="selected">';
         } else {
             $result .= '<option>';
         }
@@ -1590,7 +1590,7 @@ sub render {
     $result .= "<select name='${var}year'>\n";
     for ($i = 2000; $i < 2030; $i++) { # update this after 64-bit dates
         if ($date->year + 1900 == $i) {
-            $result .= "<option selected>";
+            $result .= "<option selected='selected'>";
         } else {
             $result .= "<option>";
         }
@@ -1605,21 +1605,21 @@ sub render {
 	my $pm = &mt('p.m.');
         # Build hour
         $result .= "<select name='${var}hour'>\n";
-        $result .= "<option " . ($date->hour == 0 ? 'selected ':'') .
+        $result .= "<option " . ($date->hour == 0 ? 'selected="selected" ':'') .
             " value='0'>" . &mt('midnight') . "</option>\n";
         for ($i = 1; $i < 12; $i++) {
             if ($date->hour == $i) {
-                $result .= "<option selected value='$i'>$i $am</option>\n";
+                $result .= "<option selected='selected' value='$i'>$i $am</option>\n";
             } else {
                 $result .= "<option value='$i'>$i $am</option>\n";
             }
         }
-        $result .= "<option " . ($date->hour == 12 ? 'selected ':'') .
+        $result .= "<option " . ($date->hour == 12 ? 'selected="selected" ':'') .
             " value='12'>" . &mt('noon') . "</option>\n";
         for ($i = 13; $i < 24; $i++) {
             my $printedHour = $i - 12;
             if ($date->hour == $i) {
-                $result .= "<option selected value='$i'>$printedHour $pm</option>\n";
+                $result .= "<option selected='selected' value='$i'>$printedHour $pm</option>\n";
             } else {
                 $result .= "<option value='$i'>$printedHour $pm</option>\n";
             }
@@ -1634,7 +1634,7 @@ sub render {
                 $printedMinute = "0" . $printedMinute;
             }
             if ($date->min == $i) {
-                $result .= "<option selected>";
+                $result .= "<option selected='selected'>";
             } else {
                 $result .= "<option>";
             }
@@ -2016,7 +2016,7 @@ BUTTONS
 			"\|\|\|";
 		    my $checked ="";
 		    if($var_value =~ /\Q|||$raw_name|||\E/) {
-			$checked = "checked";
+			$checked = "checked='checked'";
 		    }
 		    $col .= 
                         "<td align='center'><input type='checkbox' name ='$option_var".
@@ -2027,11 +2027,11 @@ BUTTONS
 
             $col .= "<td align='center'><input type='$inputType' name='${var}.forminput' ";
             if (!$checked && !$multichoice) {
-                $col .= "checked ";
+                $col .= "checked='checked' ";
                 $checked = 1;
             }
 	    if ($multichoice) { # all resources start checked; see bug 1174
-		$col .= "checked ";
+		$col .= "checked='checked' ";
 		$checked = 1;
 	    }
             $col .= "value='" . $resource_name  . "' /></td>";
@@ -2342,7 +2342,7 @@ BUTTONS
             $self->{'variable'} . '.forminput' . "'";
             
         if (!$self->{'multichoice'} && !$checked) {
-            $result .= " checked ";
+            $result .= " checked='checked' ";
             $checked = 1;
         }
         $result .=
@@ -2594,14 +2594,16 @@ BUTTONS
     # If the subdirectory is in local CSTR space
     my $metadir;
     if ($subdir =~ m|/home/([^/]+)/public_html/(.*)|) {
-        my $user = $1;
-        my $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
+	my ($user,$domain)= 
+	    &Apache::loncacc::constructaccess($subdir,
+				     $Apache::lonnet::perlvar{'lonDefDomain'});
 	$metadir='/res/'.$domain.'/'.$user.'/'.$2;
         @fileList = &Apache::lonnet::dirlist($subdir, $domain, $user, '');
     } elsif ($subdir =~ m|^~([^/]+)/(.*)$|) {
 	$subdir='/home/'.$1.'/public_html/'.$2;
-        my $user = $1;
-        my $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
+	my ($user,$domain)= 
+	    &Apache::loncacc::constructaccess($subdir,
+				     $Apache::lonnet::perlvar{'lonDefDomain'});
 	$metadir='/res/'.$domain.'/'.$user.'/'.$2;
         @fileList = &Apache::lonnet::dirlist($subdir, $domain, $user, '');
     } else {
@@ -2668,7 +2670,7 @@ BUTTONS
             . ".forminput' ".qq{id="$id"}." value='" . HTML::Entities::encode($fileName,"<>&\"'").
                 "'";
             if (!$self->{'multichoice'} && $choices == 0) {
-                $result .= ' checked';
+                $result .= ' checked="checked"';
             }
             $result .= "/></td><td bgcolor='$color'>".
                 qq{<label for="$id">}. $file . "</label></td>" .
@@ -3268,6 +3270,11 @@ sub render {
                         'answer_date' => "0_answerdate",
 			'tries' => '0_maxtries',
 			'weight' => '0_weight' );
+    my %realParmName = ('open_date' => "opendate",
+                        'due_date' => "duedate",
+                        'answer_date' => "answerdate",
+			'tries' => 'maxtries',
+			'weight' => 'weight' );
     
     my $affectedResourceId = "";
     my $parm_name = $parmTypeHash{$vars->{ACTION_TYPE}};
@@ -3326,15 +3333,14 @@ sub render {
     my $result = "<form name='helpform' method='POST' action='/adm/parmset#$affectedResourceId&$parm_name&$level'>\n";
     $result .= "<input type='hidden' name='action' value='settable' />\n";
     $result .= "<input type='hidden' name='dis' value='helper' />\n";
-    if ($vars->{ACTION_TYPE} eq 'tries') {
-	$result .= "<input type='hidden' name='pscat' value='maxtries' />\n";
-    } else {
-	$result .= "<input type='hidden' name='pscat' value='".
-	    HTML::Entities::encode($vars->{ACTION_TYPE},"'<>&\"") . "' />\n";
-    }
+    $result .= "<input type='hidden' name='pscat' value='".
+	$realParmName{$vars->{ACTION_TYPE}}."' />\n";
     if ($vars->{GRANULARITY} eq 'resource') {
 	$result .= "<input type='hidden' name='symb' value='".
 	    HTML::Entities::encode($symb,"'<>&\"") . "' />\n";
+    } elsif ($vars->{GRANULARITY} eq 'map') {
+	$result .= "<input type='hidden' name='pschp' value='".
+	    $affectedResourceId."' />\n";
     }
     my $part = $vars->{RESOURCE_ID_part};
     if ($part eq 'All Parts' || !$part) { $part=0; }
@@ -3398,12 +3404,9 @@ sub render {
     } else {
         # FIXME: This is probably wasteful! Store the name!
         my $classlist = Apache::loncoursedata::get_classlist();
-        my $username = $vars->{USER_NAME};
-        # Chop off everything after the last colon (section)
-	my ($uname,$udom)=split(':',$username);
+	my ($uname,$udom)=split(':',$vars->{USER_NAME});
         my $name = $classlist->{$uname.':'.$udom}->[6];
         $result .= '<li>'.&mt('for [_1]',"<b>$name</b>").'</li>';
-	my ($uname, $udom) = split /:/, $vars->{USER_NAME};
         $result .= "<input type='hidden' name='uname' value='".
             HTML::Entities::encode($uname,"'<>&\"") . "' />\n";
         $result .= "<input type='hidden' name='udom' value='".
@@ -3421,7 +3424,6 @@ sub render {
     
     # Make the table appear
     $result .= "\n<input type='hidden' value='true' name='prevvisit' />";
-    $result .= "\n<input type='hidden' value='all' name='pschp' />";
     $result .= "\n<input type='hidden' value='$symb' name='pssymb' />";
     $result .= "\n<input type='hidden' value='$paramlevel' name='parmlev' />";