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

minaeibi lon-capa-cvs@mail.lon-capa.org
Mon, 14 Oct 2002 00:03:57 -0000


minaeibi		Sun Oct 13 20:03:57 2002 EDT

  Modified files:              
    /modules/minaeibi	makedata.pl 
  Log:
  This version of this perl script extract 3 student features from activity log
  
  
Index: modules/minaeibi/makedata.pl
diff -u modules/minaeibi/makedata.pl:1.1 modules/minaeibi/makedata.pl:1.2
--- modules/minaeibi/makedata.pl:1.1	Mon Sep 23 12:56:17 2002
+++ modules/minaeibi/makedata.pl	Sun Oct 13 20:03:57 2002
@@ -23,8 +23,13 @@
 # Fetch the resources' resources into hash
     while ($line=<RESID>) {
 	my ($resid,$res_name)=split(':',$line);
-	$resource{$resid}=$res_name;
-#	print "Resouse: $resid  name= $res_name\n";
+	#$resource{$resid}=$res_name;
+	if (($res_name=~/\.(problem)$/) && ($resid=~/^RES\_(\w+)$/)) {
+#		print "$resid = $res_name";
+		$resource{$resid}=$res_name;
+	}
+
+	#print "Resouse: $resid  name= $res_name\n";
     }
 
     while ($line=<LOGID>) {
@@ -36,11 +41,40 @@
 
     for(my $n=0; $n<$count; $n++) {
 	my ($time,$who,$res,$post,$stat)=split(':',$allaccess[$n]);
-	if ($who eq $me ) {#&& $res=~/^RES\_(\w+)$/) {
-	    $n++;
-#   	    print("$n / $count) ".localtime($time)." $who ->  $res : $post : $stat");
-#   	    print(localtime($time)." $who ->  $resource{$res} : $post : $stat");
+#	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 $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");
+        }
+	print "Student ( $key ) tries = $tries  solved = $solved  first = $first  Grade = $s_data[0]";
     }
 }