[LON-CAPA-cvs] cvs: loncom /homework grades.pm inputtags.pm structuretags.pm /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 29 Apr 2004 07:57:47 -0000


albertel		Thu Apr 29 03:57:47 2004 EDT

  Modified files:              
    /loncom/homework	grades.pm structuretags.pm inputtags.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - can now grade an Anonymous exam
     - CODE is noticed by rndseed in either the student record
       (Apache::lonhomework::history) or %ENV and used
     - analyze mode now needs student data loaded and does so
     - CODE is stored into student data
     
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.192 loncom/homework/grades.pm:1.193
--- loncom/homework/grades.pm:1.192	Thu Apr 29 03:21:16 2004
+++ loncom/homework/grades.pm	Thu Apr 29 03:57:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.192 2004/04/29 07:21:16 albertel Exp $
+# $Id: grades.pm,v 1.193 2004/04/29 07:57:47 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4434,13 +4434,18 @@
 	my $i=0;
 	foreach my $resource (@resources) {
 	    $i++;
-	    my $result=&Apache::lonnet::ssi($resource->src(),
-				 ('submitted'     =>'scantron',
-				  'grade_target'  =>'grade',
-				  'grade_username'=>$uname,
-				  'grade_domain'  =>$udom,
-				  'grade_courseid'=>$ENV{'request.course.id'},
-				  'grade_symb'    =>$resource->symb()));
+	    my %form=('submitted'     =>'scantron',
+		      'grade_target'  =>'grade',
+		      'grade_username'=>$uname,
+		      'grade_domain'  =>$udom,
+		      'grade_courseid'=>$ENV{'request.course.id'},
+		      'grade_symb'    =>$resource->symb());
+	    if (exists($scan_record->{'scantron.CODE'}) &&
+		$scan_record->{'scantron.CODE'}) {
+		$form{'CODE'}=$scan_record->{'scantron.CODE'};
+	    }
+	    my $result=&Apache::lonnet::ssi($resource->src(),%form);
+
 	}
 	$completedstudents{$uname}={'line'=>$line};
     } continue {
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.245 loncom/homework/structuretags.pm:1.246
--- loncom/homework/structuretags.pm:1.245	Tue Mar  9 15:37:58 2004
+++ loncom/homework/structuretags.pm	Thu Apr 29 03:57:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.245 2004/03/09 20:37:58 albertel Exp $
+# $Id: structuretags.pm,v 1.246 2004/04/29 07:57:47 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -405,8 +405,8 @@
 	$Apache::lonhomework::scantronmode=1;
     }
 
+    &initialize_storage();
     if ($target ne 'analyze') {
-	&initialize_storage();
 	if ($target eq 'web') {
 	    &Apache::lonhomework::showhash(%Apache::lonhomework::history);
 	}
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.140 loncom/homework/inputtags.pm:1.141
--- loncom/homework/inputtags.pm:1.140	Tue Apr 27 09:52:45 2004
+++ loncom/homework/inputtags.pm	Thu Apr 29 03:57:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.140 2004/04/27 13:52:45 matthew Exp $
+# $Id: inputtags.pm,v 1.141 2004/04/29 07:57:47 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -485,6 +485,9 @@
 sub setgradedata {
     my ($award,$msg,$id,$previously_used) = @_;
     # if the student already has it correct, don't modify the status
+    if ($Apache::lonhomework::scantronmode && defined($ENV{'form.CODE'})) {
+	$Apache::lonhomework::results{"resource.CODE"}=$ENV{'form.CODE'};
+    }
     if (!$Apache::lonhomework::scantronmode &&
 	$Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
 	$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.490 loncom/lonnet/perl/lonnet.pm:1.491
--- loncom/lonnet/perl/lonnet.pm:1.490	Thu Apr 29 03:18:10 2004
+++ loncom/lonnet/perl/lonnet.pm	Thu Apr 29 03:57:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.490 2004/04/29 07:18:10 albertel Exp $
+# $Id: lonnet.pm,v 1.491 2004/04/29 07:57:47 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4448,6 +4448,15 @@
     return '64bit2';
 }
 
+sub getCODE {
+    if (defined($ENV{'form.CODE'})) { return $ENV{'form.CODE'}; }
+    if (defined($Apache::lonhomework::parsing_a_problem) &&
+	defined($Apache::lonhomework::history{'resource.CODE'})) {
+	return $Apache::lonhomework::history{'resource.CODE'};
+    }
+    return undef;
+}
+
 sub rndseed {
     my ($symb,$courseid,$domain,$username)=@_;
 
@@ -4459,8 +4468,7 @@
     if (!$domain) { $domain=$wdomain; }
     if (!$username) { $username=$wusername }
     my $which=$ENV{"course.$courseid.rndseed"};
-    my $CODE=$ENV{'form.CODE'};
-    if (defined($CODE)) {
+    if (defined(&getCODE())) {
 	return &rndseed_CODE_64bit($symb,$courseid,$domain,$username);
     } elsif ($which eq '64bit2') {
 	return &rndseed_64bit2($symb,$courseid,$domain,$username);
@@ -4535,8 +4543,8 @@
 	use integer;
 	my $symbchck=unpack("%32S*",$symb.' ') << 16;
 	my $symbseed=numval2($symb);
-	my $CODEchck=unpack("%32S*",$ENV{'form.CODE'}.' ') << 16;
-	my $CODEseed=numval($ENV{'form.CODE'});
+	my $CODEchck=unpack("%32S*",&getCODE().' ') << 16;
+	my $CODEseed=numval(&getCODE());
 	my $courseseed=unpack("%32S*",$courseid.' ');
 	my $num1=$symbseed+$CODEchck;
 	my $num2=$CODEseed+$courseseed+$symbchck;