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

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


minaeibi		Tue Oct 15 08:49:08 2002 EDT

  Added files:                 
    /modules/minaeibi	makeall.pl 
  Log:
  To extracty all the things from activity log
  
  
  

Index: modules/minaeibi/makeall.pl
+++ modules/minaeibi/makeall.pl
use strict;

sub main {
    my $file=$ARGV[0];
    my $me=$ARGV[1];

    print "Using $file.log\n";
    print "Using $me data logged data\n";
    open(LOGID, "<$file.log");
    open(RESID, "<$file.res");
    open(STDID, "<$file.grds");
    my $line;
    my $resCount=0;
    my @allaccess;
    my %resource=();
    my %student=();

# Fetch the students' grades into hash
    while ($line=<STDID>) {
	my ($stdid,$std_grade)=split(':',$line);
	$student{$stdid}=$std_grade;
    }

# Fetch the resources' resources into hash
    while ($line=<RESID>) {
	my ($resid,$res_name)=split(':',$line);
#	if (($res_name=~/\.(problem)$/) && ($resid=~/^RES\_(\w+)$/)) {
		$resCount++;
		$resource{$resid}=$res_name;
#	}
    }

    while ($line=<LOGID>) {
	push(@allaccess,$line);
    }
    @allaccess=sort(@allaccess);

    my $count=scalar @allaccess-1;

    for(my $n=0; $n<$count; $n++) {
	my ($time,$who,$res,$post,$stat)=split(':',$allaccess[$n]);
#	if ($res=~/^RES\_(\w+)$/) {
#	if ($resource{$res}) {
		$student{$who} .= '&'.$time.':'.$res.':'.$post.':'.$stat;
		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);                                                     #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++;
        	}
	    }
        }
	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]";
    }
}

main;