[LON-CAPA-cvs] cvs: loncom /homework grades.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 08 May 2002 18:59:37 -0000


www		Wed May  8 14:59:37 2002 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  Can verify receipts now, bug 268
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.22 loncom/homework/grades.pm:1.23
--- loncom/homework/grades.pm:1.22	Fri May  3 18:34:25 2002
+++ loncom/homework/grades.pm	Wed May  8 14:59:37 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.22 2002/05/03 22:34:25 albertel Exp $
+# $Id: grades.pm,v 1.23 2002/05/08 18:59:37 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,14 +59,63 @@
   return '';
 }
 
+sub verifyreceipt {
+    my $request=shift;
+    my $courseid=$ENV{'request.course.id'};
+    my $chome=$ENV{"course.$courseid.home"};
+    my $cdom=$ENV{"course.$courseid.domain"};
+    my $cnum=$ENV{"course.$courseid.num"};
+    my $receipt=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).'-'.
+                $ENV{'form.receipt'};
+    $receipt=~s/[^\-\d]//g;
+    my $symb=$ENV{'form.symb'};
+    unless ($symb) {
+	$symb=&Apache::lonnet::symbread($ENV{'form.url'});
+    }
+    if ((&Apache::lonnet::allowed('mgr',$courseid)) && ($symb)) {
+        $request->print('<h1>Verifying Submission Receipt '.$receipt.'</h1>');
+        my $matches=0;
+        my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');
+        foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
+            my ($uname,$udom)=split(/\:/,$student);
+            if ($receipt eq 
+             &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) {
+               $request->print('Matching '.$student.'<br>');
+               $matches++;
+	   }
+        }
+        $request->print('<p>'.$matches.' match(es)</p>');
+    }
+    return '';
+}
 
 sub listStudents {
   my ($request) = shift;
-  my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
   my $chome=$ENV{"course.$ENV{'request.course.id'}.home"};
-  $request->print ('<h1>Show Student Submissions on Assessment</h1>'.
- '<table border="1"><tr><th>Username</th><th>Domain</th><th>Name</th><th>&nbsp;</th></tr>'
- );
+  my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
+  my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
+  my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
+  $request->print(<<ENDHEADER);
+<h1>Verify a Submission Receipt Issued by this Server</h1>
+<form action="/adm/grades" method="post">
+<tt>$hostver-<input type="text" name="receipt" size="4"></tt>
+<input type="submit" name="submit" value="Verify">
+<input type="hidden" name="command" value="verify">
+ENDHEADER
+	  if ($ENV{'form.url'}) {
+	    $request->print(
+    '<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />');
+	  }
+	  if ($ENV{'form.symb'}) {
+	    $request->print(
+    '<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />');
+	  }
+  $request->print(<<ENDTABLEST);
+</form>
+<h1>Show Student Submissions on Assessment</h1>
+<table border="1">
+<tr><th>Username</th><th>Domain</th><th>Name</th><th>&nbsp;</th></tr>
+ENDTABLEST
   my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');
   foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
       my ($sname,$sdom) = split(/:/,$student);
@@ -428,8 +477,10 @@
       $request->print(&viewgrades($request));
     } elsif ($command eq 'editgrades') {
       $request->print(&editgrades($request));
+    } elsif ($command eq 'verify') {
+      $request->print(&verifyreceipt($request));
     } else {
-      $request->print("Unknown action:$command:");
+      $request->print("Unknown action: $command:");
     }
   }
   &send_footer($request);