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

www lon-capa-cvs@mail.lon-capa.org
Fri, 05 Sep 2003 03:47:47 -0000


www		Thu Sep  4 23:47:47 2003 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Bug #2110: Overview mode appears to be working.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.123 loncom/interface/lonparmset.pm:1.124
--- loncom/interface/lonparmset.pm:1.123	Thu Sep  4 18:36:47 2003
+++ loncom/interface/lonparmset.pm	Thu Sep  4 23:47:47 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.123 2003/09/04 22:36:47 www Exp $
+# $Id: lonparmset.pm,v 1.124 2003/09/05 03:47:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1666,6 +1666,26 @@
 }
 ##################################################
 
+my $tableopen;
+
+sub tablestart {
+    if ($tableopen) {
+	return '';
+    } else {
+	$tableopen=1;
+	return '<table border="2"><tr><th>Parameter</th><th>Delete</th><th>Set to ...</th></tr>';
+    }
+}
+
+sub tableend {
+    if ($tableopen) {
+	$tableopen=0;
+	return '</table>';
+    } else {
+	return'';
+    }
+}
+
 sub overview {
     my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag(
@@ -1681,12 +1701,37 @@
 <form method="post" action="/adm/parmset" name="overviewform">
 <input type="hidden" name="overview" value="1" />
 ENDOVER
+# Setting
+    my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
+    my %newdata=();
+    undef %newdata;
+    my @deldata=();
+    undef @deldata;
+    foreach (keys %ENV) {
+	if ($_=~/^form\.([a-z]+)\_(.+)$/) {
+	    my $cmd=$1;
+	    my $thiskey=$2;
+	    if ($cmd eq 'set') {
+		my $data=$ENV{$_};
+		if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
+	    } elsif ($cmd eq 'del') {
+		push (@deldata,$thiskey);
+	    } elsif ($cmd eq 'datepointer') {
+		my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_});
+		if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
+	    }
+	}
+    }
+# Store
+    &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs);
+    &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs);
 # Read and display
     my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
     my $oldsection='';
     my $oldrealm='';
     my $oldpart='';
     my $pointer=0;
+    $tableopen=0;
     foreach my $thiskey (sort keys %resourcedata) {
 	if ($resourcedata{$thiskey.'.type'}) {
 	    my ($course,$middle,$part,$name)=
@@ -1704,23 +1749,26 @@
 		$realm='<font color="orange">Resource: '.&Apache::lonnet::gettitle($middle).'</font>';
 	    }
 	    if ($section ne $oldsection) {
-		$r->print("\n<hr /><h1>$section</h1>");
+		$r->print(&tableend()."\n<hr /><h1>$section</h1>");
 		$oldsection=$section;
 		$oldrealm='';
 	    }
 	    if ($realm ne $oldrealm) {
-		$r->print("\n<h2>$realm</h2>");
+		$r->print(&tableend()."\n<h2>$realm</h2>");
 		$oldrealm=$realm;
 		$oldpart='';
 	    }
 	    if ($part ne $oldpart) {
-		$r->print("\n<h3><font color='blue'>Part: $part</font></h3>");
+		$r->print(&tableend().
+			  "\n<h3><font color='blue'>Part: $part</font></h3>");
 		$oldpart=$part;
 	    }
 #
 # Ready to print
 #
-	    $r->print('<br /><b>'.$name.':</b>');
+	    $r->print(&tablestart().'<tr><td><b>'.$name.
+		      ':</b></td><td><input type="checkbox" name="del_'.
+		      $thiskey.'" /></td><td>');
 	    if ($resourcedata{$thiskey.'.type'}=~/^date/) {
 		my $jskey='key_'.$pointer;
 		$pointer++;
@@ -1735,9 +1783,12 @@
 			  '<input type="text" name="set_'.$thiskey.'" value="'.
 			  $resourcedata{$thiskey}.'">');
 	    }
+	    $r->print('</td></tr>');
 	}
     }
-    $r->print('</form></body></html>');
+    
+    $r->print(&tableend().
+	      '<p><input type="submit" value="Modify Parameters" /></p></form></body></html>');
 }
 
 ##################################################