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

minaeibi lon-capa-cvs@mail.lon-capa.org
Tue, 26 Mar 2002 18:11:32 -0000


minaeibi		Tue Mar 26 13:11:32 2002 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
  Log:
  Fixed warining that Matthew reported
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.13 loncom/interface/lonstatistics.pm:1.14
--- loncom/interface/lonstatistics.pm:1.13	Fri Mar 22 18:06:30 2002
+++ loncom/interface/lonstatistics.pm	Tue Mar 26 13:11:32 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstatistics.pm,v 1.13 2002/03/22 23:06:30 minaeibi Exp $
+# $Id: lonstatistics.pm,v 1.14 2002/03/26 18:11:32 minaeibi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -28,9 +28,10 @@
 # (Navigate problems for statistical reports
 # YEAR=2001
 # 5/05,7/09,7/25/01,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
-# 11/1, 11/4, 11/16, 12/14, 12/16, 12/18,12/20,12/31 Behrouz Minaei
+# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
 # YEAR=2002
-# 1/22, 2/1, 2/6, 2/25, 3/2, 3/6, 3/17, 3/21, 3/22 Behrouz Minaei
+# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26 Behrouz Minaei
+#
 ###
 
 package Apache::lonstatistics; 
@@ -158,17 +159,13 @@
 
 # ------ Create different Student Report 
 sub StudentReport {
-
     my ($sname,$sdom)=@_;
-
     if ( $sname eq 'All Students' ) {
 	$r->print( '<h3><font color=blue>WARNING: 
                     Please select a student</font></h3>' );
 	return;
     }
-    my $shome=&Apache::lonnet::homeserver($sname,$sdom);          
-    my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.':'.$cid,$shome );
-    my %result = ();
+    my %result = &Apache::lonnet::dump($cid,$sdom,$sname);
     my $ResId;
     my $PrOrd;
     my $Code;
@@ -189,11 +186,8 @@
 	      "\n".'<th> Results </th>'.
 	      "\n".'<th> Tries </th>'.
 	      "\n".'</tr>';
-    unless ($reply=~/^error\:/) {
-        foreach (split(/\&/,$reply)){
-            my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
-            $result{$name}=$value;
-        }
+    my ($temp)=keys(%result);
+    unless ($temp=~/^error\:/) {
         foreach my $CurCol (@cols) {
 	    if (!$CurCol){
 		my $Set=&Apache::lonnet::declutter($hash{'map_id_'.$1});
@@ -231,7 +225,6 @@
 			$PartNo++;
 		    }
 		}
-		#if ($_=~/^parameter\_(\w+)\_package$/) {
             }
 
             my $Prob = $Map.'___'.$2.'___'.
@@ -362,10 +355,10 @@
 	'evaluating the problem according to a Criterion<br>'.
 	'<b>           [Applied Criterion in %27 Upper Students - '.
 	'Applied the same Criterion in %27 Lower Students]</b><br>'.
-    '<b>           1st </b>Criterion for Sorting the Students: '.
-	'Sum of Partial Credit Awarded / Total Number of Tries<br>'.
-    '<b>           2nd </b>Criterion for Sorting the Students: '.
-	'Total number of Correct Answers / Total Number of Tries'.	
+    '<b>           1st Criterion</b> for Sorting the Students: '.
+	'<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>'.
+    '<b>           2nd Criterion</b> for Sorting the Students: '.
+	'<b>Total number of Correct Answers / Total Number of Tries</b>'.	
             '</pre>';
 
     $r->print($Ptr);
@@ -456,11 +449,9 @@
 # ------ Dump the Student's DB file and handling the data for statistics table 
 
 sub ExtractStudentData {
-    my ($student,$coid)=@_;
+    my $student=shift;
     my ($sname,$sdom) = split( /\:/, $student );
-    my $shome=&Apache::lonnet::homeserver( $sname,$sdom );          
-    my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.':'.$coid,$shome );
-    my %result = ();
+    my %result = &Apache::lonnet::dump($cid,$sdom,$sname);
     my $ResId;
     my $PrOrd;
     my $Dis = '';
@@ -479,11 +470,8 @@
     my $LatestVersion;
     my $SecLimit;
     my $MapLimit;
-    unless ($reply=~/^error\:/) {
-        foreach (split(/\&/,$reply)) {
-            my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
-            $result{$name}=$value;
-        }
+    my ($temp)=keys(%result);
+    unless ($temp=~/^error\:/) {
         foreach my $CurCol(@cols) {
 	    ($PrOrd,$ResId)=split(/\:/,$CurCol);
 	    if ( !$CurCol ) { next; }
@@ -510,13 +498,12 @@
 			$TempHash{"$Part.PrOrd"} = $PrOrd+$PartNo;
 			$PartNo++;
 		    }
-                    my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
+                    #my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
 		}
             }
 
             my $Prob = $Map.'___'.$PrbId.'___'.
                        &Apache::lonnet::declutter( $hash{'src_'.$ResId} );
-	    $OpResp{$PrOrd}=$Prob;
             $Code='U';
             $Tries = 0;
 	    $ParCr = 0;
@@ -524,16 +511,26 @@
   	    $LatestVersion = $result{"version:$Prob"};       
 
 	    if ( $LatestVersion ) {
-#333333333
-#my $userview=&Apache::lonnet::ssi($hash{'src_'.$ResId});
-#$r->print('<br>'.$userview); 
-#$r->print('<br>'.$Prob.$sname.$sdom.$coid.'<br>'.&get_student_answers($Prob,$sname,$sdom,$coid)); 
-
 		for ( my $Version=1; $Version<=$LatestVersion; $Version++ ) {
 		    my $vkeys = $result{"$Version:keys:$Prob"};
 		    my @keys = split(/\:/,$vkeys);		
-  
+
 		    foreach my $Key (@keys) {		  
+#333333333
+#			if ($OpResp{$PrOrd}) {
+#			    if (($Key=~/\.(\w+)\.submission$/)) {
+#				my $Resp = $result{"$Version:$Prob:$Key"};
+#				$r->print('<br>'.$Prob.'<br>'.$sname.'<br>'.$PrOrd.'<br>'.$Key.'<br><b>'.$Resp.'</b>'); 
+#				$r->rflush();
+#
+#				my %submission=&Apache::lonnet::str2hash($Resp);
+#    my $cb=0;
+#    foreach (sort keys %submission) {
+#	$r->print('<br>'.$cb.')'.$_.' ... '.$submission{$_});
+#	$cb++;
+#    }
+#			    }	  
+#			}
 			if (($Key=~/\.(\w+)\.solved$/) && ($Key!~/^\d+\:/)) {
 			    my $Part = $1;
 			    $Tries = $result{"$Version:$Prob:resource.$Part.tries"};
@@ -644,25 +641,26 @@
       
 	       my $meta=$hash{'src_'.$frid};
 	       my $PartNo = 0;
+	       my $Part;
 	#       if ($IsMap==0){
                if ($meta) {
 		   if ($meta=~/\.(problem|exam|quiz|assess|survey|form)$/) {
 		       foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
 			   if ($_=~/^stores\_(\w+)\_tries$/) {
-			       &Apache::lonnet::metadata($meta,$_.'.part');
+			       $Part=&Apache::lonnet::metadata($meta,$_.'.part');
 			       $P_Order++;
 			       $mapsort{$HWN} .= '&'.$P_Order;
 			       $PartNo++;
 			       #$r->print('<br>'.$PartNo.'---'.$P_Order);
 			   }
+			   foreach my $K(split(/\,/,&Apache::lonnet::metadata($meta,'packages'))) {
+			       if ($K=~/^optionresponse\_($Part)\_(\w+)$/) {
+				   #$r->print('<br>'.$_.'...'.$P_Order.'---'.$Part);
+				   $OpResp{$P_Order+1}=$frid;
+			       } 
+		   
+			   }
 		       }
-#		       foreach (split(/\,/,&Apache::lonnet::metadata($meta,'packages'))) {
-#			   if ($_=~/^optionresponse\_(\w+)\_(\w+)$/) {
-#			       $r->print('<br>'.$_.&Apache::lonnet::metadata($meta,$_));
-#			       $r->print('<br>'.$_.'...'.$P_Order);
-#			       $OpResp{$P_Order+1}=$frid;
-#			   } 
-#		       }
 		   }
                }
 	   }
@@ -735,7 +733,7 @@
                   $students[$index].'";</script>');
         $r->rflush();
 
-        &ExtractStudentData($students[$index],$cid);
+        &ExtractStudentData($students[$index]);
     }
 
 # -------------------- sorting the Data