[LON-CAPA-cvs] cvs: modules /minaeibi makedata.pl

minaeibi lon-capa-cvs@mail.lon-capa.org
Tue, 15 Oct 2002 12:47:59 -0000


minaeibi		Tue Oct 15 08:47:59 2002 EDT

  Modified files:              
    /modules/minaeibi	makedata.pl 
  Log:
  
  Five students' features is exrtacted from activity log via this script
  
   ----------------------------------------------------------------------
  
  
Index: modules/minaeibi/makedata.pl
diff -u modules/minaeibi/makedata.pl:1.2 modules/minaeibi/makedata.pl:1.3
--- modules/minaeibi/makedata.pl:1.2	Sun Oct 13 20:03:57 2002
+++ modules/minaeibi/makedata.pl	Tue Oct 15 08:47:59 2002
@@ -10,9 +10,10 @@
     open(RESID, "<$file.res");
     open(STDID, "<$file.grds");
     my $line;
+    my $resCount=0;
     my @allaccess;
-    my %resource;
-    my %student;
+    my %resource=();
+    my %student=();
 
 # Fetch the students' grades into hash
     while ($line=<STDID>) {
@@ -23,13 +24,10 @@
 # Fetch the resources' resources into hash
     while ($line=<RESID>) {
 	my ($resid,$res_name)=split(':',$line);
-	#$resource{$resid}=$res_name;
 	if (($res_name=~/\.(problem)$/) && ($resid=~/^RES\_(\w+)$/)) {
-#		print "$resid = $res_name";
+		$resCount++;
 		$resource{$resid}=$res_name;
 	}
-
-	#print "Resouse: $resid  name= $res_name\n";
     }
 
     while ($line=<LOGID>) {
@@ -44,37 +42,57 @@
 #	if ($res=~/^RES\_(\w+)$/) {
 	if ($resource{$res}) {
 		$student{$who} .= '&'.$time.':'.$res.':'.$post.':'.$stat;
-#		$n++;
 #		print("$n / $count) ".localtime($time)." $who ->  $res : $post : $stat");
    	}
     }
 
     foreach my $key (keys %student) {
 	my %fhash=();
+	my %shash=();
+	my %submit=();
 	my $tries=0;
 	my $solved=0;
 	my $first=0;
 	my @s_data = split(/\&/,$student{$key});
 	my $count=scalar @s_data-1;
-    	for(my $n=1; $n<$count; $n++) {
-		my ($time,$res,$post,$stat)=split(':',$s_data[$n]);
-		$stat=substr($stat,0,length($stat)-1);
-		#rint( length($stat)."             : $stat");                              
-		if ($post eq 'CSTORE') {
-		    $fhash{$res} += 1;
-		    if ( $stat eq 'SOLVED' ) {
-			if(($fhash{$res}) == 1 ) {
-			    $first++;
-			}
-			$solved++;
-			$tries++;
-		    } else {
-			$tries++;
-        	    }
-		}
-		#print( length($stat)."$res : $post : $stat");
+    	for (my $n=1; $n<$count; $n++) {
+	    my ($time,$res,$post,$stat)=split(':',$s_data[$n]);
+	    $stat=substr($stat,0,length($stat)-1);                                                     #if ($stat eq 'SUBMIT') {
+	#	$submit{"$res"} .= "$time:";
+	 #   }
+
+            if ($post eq 'POST') {                                                       
+               $submit{"$res"} .= "$time:";                                                
+            }        
+	  
+	    if ($post eq 'CSTORE') {
+		$fhash{$res} += 1;
+		if ( $stat eq 'SOLVED' ) {
+		    if(($fhash{$res}) == 1 ) {
+			$first++;
+		    }
+		    $shash{$res}=1;
+		    $solved++;
+		    $tries++;
+		} else {
+		    $tries++;
+        	}
+	    }
         }
-	print "Student ( $key ) tries = $tries  solved = $solved  first = $first  Grade = $s_data[0]";
+	my $spent=0;
+	my $tillS=0;
+        foreach my $tres (keys %submit) {
+	    my @rtime = split(/\:/,$submit{$tres});
+	    my $tcount=scalar @rtime - 1;
+	    my $diff=$rtime[$tcount]-$rtime[0];
+	    $spent += $diff;
+	    if ($shash{$tres}==1) {
+		$tillS += $diff;
+	    }
+	}
+	$spent = sprintf( "%.2f", $spent/(3600 * $resCount) );
+        $tillS = sprintf( "%.2f", $tillS/(3600 * $resCount) );
+	print "Student ( $key ) tries = $tries  solved = $solved  first = $first  tillSlvd = $tillS  spent = $spent  Grade = $s_data[0]";
     }
 }