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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Fri, 02 Nov 2007 23:29:49 -0000


albertel		Fri Nov  2 19:29:49 2007 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  - eliminate some copy and paste
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.383 loncom/interface/lonparmset.pm:1.384
--- loncom/interface/lonparmset.pm:1.383	Tue Oct 16 20:27:44 2007
+++ loncom/interface/lonparmset.pm	Fri Nov  2 19:29:49 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.383 2007/10/17 00:27:44 albertel Exp $
+# $Id: lonparmset.pm,v 1.384 2007/11/02 23:29:49 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2503,16 +2503,24 @@
             if ($tuname) {
 		$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
 	    }
-	    if ($cmd eq 'set') {
-		my $data=$env{$_};
-                my $typeof=$env{'form.typeof_'.$thiskey};
- 		if ($$olddata{$thiskey} ne $data) { 
+	    if ($cmd eq 'set' || $cmd eq 'datepointer') {
+		my ($data, $typeof, $text);
+		if ($cmd eq 'set') {
+		    $data=$env{$_};
+		    $typeof=$env{'form.typeof_'.$thiskey};
+		    $text = &mt('Saved modified parameter for');
+		} elsif ($cmd eq 'datepointer') {
+		    $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
+		    $typeof=$env{'form.typeof_'.$thiskey};
+		    $text = &mt('Saved modified date for');
+		}
+		if (defined($data) and $$olddata{$thiskey} ne $data) { 
 		    if ($tuname) {
 			if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
 								 $tkey.'.type' => $typeof},
 						 $tudom,$tuname) eq 'ok') {
 			    &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
-			    $r->print('<br />'.&mt('Saved modified parameter for').' '.
+			    $r->print('<br />'.$text.' '.
 				      &Apache::loncommon::plainname($tuname,$tudom));
 			} else {
 			    $r->print('<div class="LC_error">'.
@@ -2537,26 +2545,6 @@
 		} else {
 		    push (@deldata,$thiskey,$thiskey.'.type');
 		}
-	    } elsif ($cmd eq 'datepointer') {
-		my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
-                my $typeof=$env{'form.typeof_'.$thiskey};
-		if (defined($data) and $$olddata{$thiskey} ne $data) { 
-		    if ($tuname) {
-			if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
-								 $tkey.'.type' => $typeof},
-						 $tudom,$tuname) eq 'ok') {
-			    &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
-			    $r->print('<br />'.&mt('Saved modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
-			} else {
-			    $r->print('<div class="LC_error">'.
-				      &mt('Error saving parameters').'</div>');
-			}
-			&Apache::lonnet::devalidateuserresdata($tuname,$tudom);
-		    } else {
-			$newdata{$thiskey}=$data;
-			$newdata{$thiskey.'.type'}=$typeof; 
-		    }
-		}
 	    }
 	}
     }