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

www lon-capa-cvs@mail.lon-capa.org
Sat, 18 Jun 2005 18:51:54 -0000


www		Sat Jun 18 14:51:54 2005 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm lonparmset.pm 
  Log:
  Brings up default values in overview mode.
  
  Still missing: auto-setting in overview mode.
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.109 loncom/interface/lonhtmlcommon.pm:1.110
--- loncom/interface/lonhtmlcommon.pm:1.109	Sat Jun 18 13:23:25 2005
+++ loncom/interface/lonhtmlcommon.pm	Sat Jun 18 14:51:50 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.109 2005/06/18 17:23:25 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.110 2005/06/18 18:51:50 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -266,12 +266,15 @@
     if (! defined($no_hh_mm_ss)) {
         $no_hh_mm_ss = 0;
     }
-    if (! defined($currentvalue) || $currentvalue eq 'now') {
-	unless ($includeempty) {
-	    $currentvalue = time;
-	    $wasdefined=0;
-	} else {
+    if ($currentvalue eq 'now') {
+	$currentvalue=time;
+    }
+    if ((!defined($currentvalue)) || ($currentvalue eq '')) {
+	$wasdefined=0;
+	if ($includeempty) {
 	    $currentvalue = 0;
+	} else {
+	    $currentvalue = time;
 	}
     }
     # other potentially useful values:     wkday,yrday,is_daylight_savings
@@ -282,9 +285,18 @@
 	$year += 1900;
     }
     unless ($wasdefined) {
-	$sec=($defsec?$defsec:0);
-	$min=($defmin?$defmin:0);
-        $hour=($defhour?$defhour:0);
+	if (($defhour) || ($defmin) || ($defsec)) {
+	    ($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = 
+		localtime(time);
+	    $year += 1900;
+	    $sec=($defsec?$defsec:0);
+	    $min=($defmin?$defmin:0);
+	    $hour=($defhour?$defhour:0);
+	} elsif (!$includeempty) {
+	    $sec=0;
+	    $min=0;
+	    $hour=0;
+	}
     }
     my $result = "\n<!-- $dname date setting form -->\n";
     $result .= <<ENDJS;
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.229 loncom/interface/lonparmset.pm:1.230
--- loncom/interface/lonparmset.pm:1.229	Sat Jun 18 13:23:25 2005
+++ loncom/interface/lonparmset.pm	Sat Jun 18 14:51:50 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.229 2005/06/18 17:23:25 www Exp $
+# $Id: lonparmset.pm,v 1.230 2005/06/18 18:51:50 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -525,7 +525,6 @@
         }
     }
     my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
-    &Apache::lonnet::logthis($marker.'-'.$parmname);
     my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
     unless (defined($winvalue)) { $winvalue=$val; }
     return 
@@ -2223,6 +2222,15 @@
 		$oldpart=$part;
 	    }
 #
+# Preset defaults?
+#
+            my ($hour,$min,$sec,$val)=('','','','');
+	    unless ($$resourcedata{$thiskey}) {
+		my ($parmname)=($thiskey=~/\.(\w+)$/);
+		($hour,$min,$sec,$val)=&preset_defaults($parmname);
+	    }
+
+#
 # Ready to print
 #
 	    $r->print(&tablestart().'<tr><td><b>'.$name.
@@ -2236,25 +2244,37 @@
 			  &Apache::lonhtmlcommon::date_setter('overviewform',
 							      $jskey,
 						      $$resourcedata{$thiskey},
-							      '',1).
+							      '',1,'','',$hour,$min,$sec).
 '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
 			  );
 	    } elsif ($thistype eq 'string_yesno') {
+		my $showval;
+		if (defined($$resourcedata{$thiskey})) {
+		    $showval=$$resourcedata{$thiskey};
+		} else {
+		    $showval=$val;
+		}
 		$r->print('<label><input type="radio" name="set_'.$thiskey.
 			  '" value="yes"');
-		if ($$resourcedata{$thiskey} eq 'yes') {
+		if ($showval eq 'yes') {
 		    $r->print(' checked="checked"');
 		}
                 $r->print(' />'.&mt('Yes').'</label> ');
 		$r->print('<label><input type="radio" name="set_'.$thiskey.
 			  '" value="no"');
-		if ($$resourcedata{$thiskey} eq 'no') {
+		if ($showval eq 'no') {
 		    $r->print(' checked="checked"');
 		}
                 $r->print(' />'.&mt('No').'</label>');
 	    } else {
+		my $showval;
+		if (defined($$resourcedata{$thiskey})) {
+		    $showval=$$resourcedata{$thiskey};
+		} else {
+		    $showval=$val;
+		}
 		$r->print('<input type="text" name="set_'.$thiskey.'" value="'.
-			  $$resourcedata{$thiskey}.'">');
+			  $showval.'">');
 	    }
 	    $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
 		      $thistype.'">');
@@ -2278,7 +2298,7 @@
 </head>
 $bodytag
 $breadcrumbs
-<form method="post" action="/adm/parmset?action=newoverview" name="parmform">
+<form method="post" action="/adm/parmset?action=newoverview" name="overviewform">
 ENDOVER
     my @ids=();
     my %typep=();