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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 12 Dec 2003 19:41:11 -0000


albertel		Fri Dec 12 14:41:11 2003 EDT

  Modified files:              (Branch: version_1_1_X)
    /loncom/interface	lonparmset.pm 
  Log:
  - backport 1.144 1.145
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.139.2.1 loncom/interface/lonparmset.pm:1.139.2.2
--- loncom/interface/lonparmset.pm:1.139.2.1	Tue Dec  9 17:40:46 2003
+++ loncom/interface/lonparmset.pm	Fri Dec 12 14:41:11 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.139.2.1 2003/12/09 22:40:46 albertel Exp $
+# $Id: lonparmset.pm,v 1.139.2.2 2003/12/12 19:41:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1759,8 +1759,25 @@
 	}
     }
 # Store
-    &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs);
-    &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs);
+    my $delentries=$#deldata+1;
+    my @newdatakeys=keys %newdata;
+    my $putentries=$#newdatakeys+1;
+    if ($delentries) {
+	if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
+	    $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
+	} else {
+	    $r->print('<h2><font color="red">'.
+		      &mt('Error deleting parameters').'</font></h2>');
+	}
+    }
+    if ($putentries) {
+	if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
+	    $r->print('<h2>'.&mt('Stored [_1] parameter(s)</h2>',$putentries));
+	} else {
+	    $r->print('<h2><font color="red">'.
+		      &mt('Error storing parameters').'</font></h2>');
+	}
+    }
 # Read and display
     my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
     my $oldsection='';
@@ -1768,6 +1785,7 @@
     my $oldpart='';
     my $pointer=0;
     $tableopen=0;
+    my $foundkeys=0;
     foreach my $thiskey (sort keys %resourcedata) {
 	if ($resourcedata{$thiskey.'.type'}) {
 	    my ($course,$middle,$part,$name)=
@@ -1805,6 +1823,7 @@
 	    $r->print(&tablestart().'<tr><td><b>'.$name.
 		      ':</b></td><td><input type="checkbox" name="del_'.
 		      $thiskey.'" /></td><td>');
+	    $foundkeys++;
 	    if ($resourcedata{$thiskey.'.type'}=~/^date/) {
 		my $jskey='key_'.$pointer;
 		$pointer++;
@@ -1823,8 +1842,8 @@
 	}
     }
     
-    $r->print(&tableend().
-	      '<p><input type="submit" value="'.&mt('Modify Parameters').'" /></p></form></body></html>');
+    $r->print(&tableend().'<p>'.
+	($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>');
 }
 
 ##################################################