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

www lon-capa-cvs@mail.lon-capa.org
Thu, 01 May 2003 20:26:28 -0000


www		Thu May  1 16:26:28 2003 EDT

  Modified files:              
    /loncom/interface	lonmanagekeys.pm 
  Log:
  Continued work on listing access keys, annotate and csv output next.
  
  
Index: loncom/interface/lonmanagekeys.pm
diff -u loncom/interface/lonmanagekeys.pm:1.6 loncom/interface/lonmanagekeys.pm:1.7
--- loncom/interface/lonmanagekeys.pm:1.6	Wed Apr 30 22:12:43 2003
+++ loncom/interface/lonmanagekeys.pm	Thu May  1 16:26:28 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to manage course access keys 
 #
-# $Id: lonmanagekeys.pm,v 1.6 2003/05/01 02:12:43 www Exp $
+# $Id: lonmanagekeys.pm,v 1.7 2003/05/01 20:26:28 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -54,13 +54,27 @@
 
 # =================================================== Show student list to drop
 sub show_key_list {
-    my ($r,$comment,%cenv)=@_;
-
+    my ($r,$comment,$newonly,$checkonly,%cenv)=@_;
+    $comment=~s/\W/\./g;
     my %accesskeys=&Apache::lonnet::dump
 	('accesskeys',$cenv{'domain'},$cenv{'num'});
+    $r->print('<table border="2"><tr><th>Key</th><th>Checked Out</th><th>Comments/Remarks/Notes</th></tr>');
     foreach (keys %accesskeys) {
-	$r->print($_.' '.$accesskeys{$_}.'<br />');
+        if ($_=~/^error\:/) {
+	    $r->print('<tr><td>No keys have been generated yet.</td></tr>');
+        } elsif ($accesskeys{$_}=~/$comment/) {
+	    my ($checkout,$com)=split(/\s*\#\s*/,$accesskeys{$_});
+            unless ($checkout) {
+		if ($checkonly) { next; }
+            } else {
+		if ($newonly) { next; }
+            }
+	   $r->print("\n<tr><td><tt>".$_.'</tt></td><td>'.($checkout?
+                     $checkout:'-').'</td><td>'.
+                     join('<br />',split(/\s*\;\s*/,$com)).'</td></tr>');
+       }
     }
+    $r->print('</table>');
     return '';
 #
 # Junk below
@@ -212,7 +226,8 @@
                 $r->print($msg.'<br />');
 	    }
             if ($ENV{'form.listkeys'}) {
-		&show_key_list($r,$ENV{'form.listcom'},%cenv);
+		&show_key_list($r,$ENV{'form.listcom'},
+                          $ENV{'form.newonly'},$ENV{'form.checkonly'},%cenv);
             }
 # --- Menu
 	    $r->print('<h3>Key Access</h3>');
@@ -227,8 +242,10 @@
 Comments/Remarks/Notes: <input type="text" name="comments" size="30" /><br />
 <input type="submit" name="genkeys" value="Generate Keys" />
 <hr /><h3>List Keys</h3>
-Comments/Remarks/Notes/Batch Number:
+Comments/Remarks/Notes/User/Batch Number:
 <input type="text" name="listcom" size="30" value="$batchnumber" /><br />
+<input type="checkbox" name="newonly" /> Unused keys only<br />
+<input type="checkbox" name="checkonly" />Used keys only<br />
 <input type="submit" name="listkeys" value="List Keys" />
 ENDKEYMENU
 	    $r->print('</form></body></html>');