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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 12 Feb 2005 02:37:00 -0000


albertel		Fri Feb 11 21:37:00 2005 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - upload scores now accpets student IDs as well as usernames
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.242 loncom/homework/grades.pm:1.243
--- loncom/homework/grades.pm:1.242	Mon Feb  7 12:07:58 2005
+++ loncom/homework/grades.pm	Fri Feb 11 21:37:00 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.242 2005/02/07 17:07:58 albertel Exp $
+# $Id: grades.pm,v 1.243 2005/02/12 02:37:00 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2655,15 +2655,17 @@
   function verify(vf) {
     var foundsomething=0;
     var founduname=0;
+    var foundID=0;
     var founddomain=0;
     for (i=0;i<=vf.nfields.value;i++) {
       tw=eval('vf.f'+i+'.selectedIndex');
-      if (i==0 && tw!=0) { founduname=1; }
-      if (i==1 && tw!=0) { founddomain=1; }
-      if (i!=0 && i!=1 && tw!=0) { foundsomething=1; }
+      if (i==0 && tw!=0) { foundID=1; }
+      if (i==1 && tw!=0) { founduname=1; }
+      if (i==2 && tw!=0) { founddomain=1; }
+      if (i!=0 && i!=1 && i!=2 && tw!=0) { foundsomething=1; }
     }
-    if (founduname==0 || founddomain==0) {
-      alert('You need to specify at both the username and domain');
+    if ((founduname==0 && foundID==0) || founddomain==0) {
+      alert('You need to specify the domain and either the username or ID');
       return;
     }
     if (foundsomething==0) {
@@ -2693,15 +2695,17 @@
   function verify(vf) {
     var foundsomething=0;
     var founduname=0;
+    var foundID=0;
     var founddomain=0;
     for (i=0;i<=vf.nfields.value;i++) {
       tw=eval('vf.f'+i+'.selectedIndex');
-      if (tw==1) { founduname=1; }
-      if (tw==2) { founddomain=1; }
-      if (tw>2) { foundsomething=1; }
+      if (tw==1) { foundID=1; }
+      if (tw==2) { founduname=1; }
+      if (tw==3) { founddomain=1; }
+      if (tw>3) { foundsomething=1; }
     }
-    if (founduname==0 || founddomain==0) {
-      alert('You need to specify at both the username and domain');
+    if ((founduname==0 && foundID==0) || founddomain==0) {
+      alert('You need to specify the domain and either the username or ID');
       return;
     }
     if (foundsomething==0) {
@@ -2768,7 +2772,9 @@
 sub csvupload_fields {
     my ($url,$symb) = @_;
     my (@parts) = &getpartlist($url,$symb);
-    my @fields=(['username','Student Username'],['domain','Student Domain']);
+    my @fields=(['ID','Student ID'],
+		['username','Student Username'],
+		['domain','Student Domain']);
     foreach my $part (sort(@parts)) {
 	my @datum;
 	my $display=&Apache::lonnet::metadata($url,$part.'.display');
@@ -2899,10 +2905,15 @@
     my $countdone=0;
     foreach my $grade (@gradedata) {
 	my %entries=&Apache::loncommon::record_sep($grade);
-	my $username=$entries{$fields{'username'}};
-	$username=~s/\s//g;
 	my $domain=$entries{$fields{'domain'}};
 	$domain=~s/\s//g;
+	my $username=$entries{$fields{'username'}};
+	$username=~s/\s//g;
+	if (!$username) {
+	    my $id=$entries{$fields{'ID'}};
+	    my %ids=&Apache::lonnet::idget($domain,$id);
+	    $username=$ids{$id};
+	}
 	if (!exists($$classlist{"$username:$domain"})) {
 	    push(@skipped,"$username:$domain");
 	    next;