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

minaeibi lon-capa-cvs@mail.lon-capa.org
Mon, 23 Sep 2002 16:56:17 -0000


minaeibi		Mon Sep 23 12:56:17 2002 EDT

  Added files:                 
    /modules/minaeibi	makedata.pl 
  Log:
  new file to extract data from activity log
  
  

Index: modules/minaeibi/makedata.pl
+++ modules/minaeibi/makedata.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 @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);
	$resource{$resid}=$res_name;
#	print "Resouse: $resid  name= $res_name\n";
    }

    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 ($who eq $me ) {#&& $res=~/^RES\_(\w+)$/) {
	    $n++;
#   	    print("$n / $count) ".localtime($time)." $who ->  $res : $post : $stat");
#   	    print(localtime($time)." $who ->  $resource{$res} : $post : $stat");
   	}
    }
}

main;