[LON-CAPA-cvs] cvs: loncom /interface lonwizard.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 13 Feb 2003 23:46:27 -0000


bowersj2		Thu Feb 13 18:46:27 2003 EDT

  Modified files:              
    /loncom/interface	lonwizard.pm 
  Log:
  Date now uses hours+meridian instead of seperate hours and meridian fields.
  
  Rendering fixed to work more smoothly with nav maps. Resource and 
  map selection should work, with some possibly user-confusing possibilities.
  Will research those in my next user meetings.
  
  
Index: loncom/interface/lonwizard.pm
diff -u loncom/interface/lonwizard.pm:1.7 loncom/interface/lonwizard.pm:1.8
--- loncom/interface/lonwizard.pm:1.7	Thu Feb 13 16:00:11 2003
+++ loncom/interface/lonwizard.pm	Thu Feb 13 18:46:27 2003
@@ -659,7 +659,7 @@
     foreach (@keys)
     {
 	$result .= "<option value=\"" . HTML::Entities::encode($choices->{$_}) 
-            . "\">" . HTML::Entities::encode($_) . "\n";
+            . "\">" . HTML::Entities::encode($_) . "</option>\n";
     }
     $result .= "</select>\n\n";
 
@@ -870,7 +870,7 @@
         } else {
             $result .= "<option value='$i'>";
         }
-        $result .= $months[$i] . "\n";
+        $result .= $months[$i] . "</option>\n";
     }
     $result .= "</select>\n";
 
@@ -882,7 +882,7 @@
         } else {
             $result .= '<option>';
         }
-        $result .= "$i\n";
+        $result .= "$i</option>\n";
     }
     $result .= "</select>,\n";
 
@@ -894,43 +894,50 @@
         } else {
             $result .= "<option>";
         }
-        $result .= "$i\n";
+        $result .= "$i</option>\n";
     }
     $result .= "</select>,\n";
 
     # Display Hours and Minutes if they are called for
     if (!$self->{DISPLAY_JUST_DATE}) {
+        # Build hour
         $result .= "<select name='$self->{VAR_NAME}hour'>\n";
-        if ($date->hour == 12) { $result .= "<option selected>12\n"; }
-        else { $result .= "<option>12\n" }
+        $result .= "<option " . ($date->hour == 0 ? 'selected ':'') .
+            " value='0'>midnight</option>\n";
         for ($i = 1; $i < 12; $i++) {
-            if (($date->hour) % 12 == $i % 12) {
-                $result .= "<option selected>";
+            if ($date->hour == $i) {
+                $result .= "<option selected value='$i'>$i a.m.</option>\n";
             } else {
-                $result .= "<option>";
+                $result .= "<option value='$i'>$i a.m</option>\n";
+            }
+        }
+        $result .= "<option " . ($date->hour == 12 ? 'selected ':'') .
+            " value='12'>noon</option>\n";
+        for ($i = 13; $i < 24; $i++) {
+            my $printedHour = $i - 12;
+            if ($date->hour == $i) {
+                $result .= "<option selected value='$i'>$printedHour p.m.</option>\n";
+            } else {
+                $result .= "<option value='$i'>$printedHour p.m.</option>\n";
             }
-            $result .= "$i\n";
         }
+
         $result .= "</select> :\n";
 
         $result .= "<select name='$self->{VAR_NAME}minute'>\n";
         for ($i = 0; $i < 60; $i++) {
+            my $printedMinute = $i;
+            if ($i < 10) {
+                $printedMinute = "0" . $printedMinute;
+            }
             if ($date->min == $i) {
                 $result .= "<option selected>";
             } else {
                 $result .= "<option>";
             }
-            $result .= "$i\n";
+            $result .= "$printedMinute</option>\n";
         }
         $result .= "</select>\n";
-
-        $result .= "<select name='$self->{VAR_NAME}meridian'>\n";
-        if ($date->hour < 12) {
-            $result .= "<option selected>A.M.\n<option>P.M.\n";
-        } else {
-            $result .= "<option>A.M.\n<option selected>P.M.\n";
-        }
-        $result .= "</select>";
     }
 
     if (defined ($self->{MESSAGE_AFTER})) {
@@ -1195,18 +1202,9 @@
         $result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />';
     }
 
-    $result .= $self->{MESSAGE_BEFORE} if (defined $self->{MESSAGE_BEFORE});
-
-    # Get the course nav map
-    my $navmap = Apache::lonnavmaps::navmap->new(
-                           $ENV{"request.course.fn"}.".db",
-                           $ENV{"request.course.fn"}."_parms.db", 0, 0);
-
-    if (!defined($navmap)) {
-        return "<font color='red' size='+1'>Something has gone wrong with the map selection feature. Please contact your administrator.</font>";
-    }
+    $result .= $self->{MESSAGE_BEFORE} . '<br /><br />'
+        if (defined $self->{MESSAGE_BEFORE});
 
-    my $iterator = $navmap->getIterator(undef, undef, undef, 0, 0);
     my $filterFunc = $self->{FILTER_FUNC};
     my $choiceFunc = $self->{CHOICE_FUNC};
 
@@ -1227,15 +1225,13 @@
     };
 
     $result .= 
-        &Apache::lonnavmaps::render( { "iterator" => $iterator,
-                                       'cols' => [$renderColFunc, 
+        &Apache::lonnavmaps::render( { 'cols' => [$renderColFunc, 
                                                   Apache::lonnavmaps::resource()],
                                        'showParts' => 0,
                                        'queryString' => $wizard->queryStringVars() . '&folderManip=1',
-                                       'url' => '/adm/wizard'} );
+                                       'url' => '/adm/wizard',
+                                       'filterFunc' => $filterFunc } );
                                                 
-    $navmap->untieHashes();
-
     $result .= $self->{MESSAGE_AFTER} if (defined $self->{MESSAGE_AFTER});
 
     return $result;