[LON-CAPA-cvs] cvs: modules /gerd EvalActivityXML.pl
www
www@source.lon-capa.org
Wed, 29 Jul 2009 00:54:13 -0000
www Wed Jul 29 00:54:13 2009 EDT
Added files:
/modules/gerd EvalActivityXML.pl
Log:
Prorgam to analyze XML activity logs
Index: modules/gerd/EvalActivityXML.pl
+++ modules/gerd/EvalActivityXML.pl
use strict;
use Date::Manip;
use HTML::TokeParser;
my %gender=();
open(IN,'gender.csv');
while (my $line=<IN>) {
my ($id,$ge)=(split(/\,/,$line));
$gender{$id.':msu'}=$ge;
}
close(IN);
print "Read Gender File\n";
my $p=HTML::TokeParser->new("activity.log.xml");
my %inter=();
my %transactions=();
while (my $token=$p->get_token) {
if ($token->[0] eq 'S') {
my $entry=$token->[1];
if ($entry eq 'row') {
# process
if ($inter{'student'}) {
my $ge=$gender{$inter{'student'}};
unless (($ge eq 'f') || ($ge eq 'm')) {
print "Unknown user $inter{'student'}\n";
}
$transactions{"$ge:$inter{'student'}:$inter{'resource'}"}.=','.
$inter{'unixtime'}.','.$inter{'action'};
}
# clear
%inter=();
} else {
$inter{$entry}=$p->get_text('/'.$entry);
if ($entry eq 'time') {
$inter{'unixtime'}=UnixDate($inter{$entry},"%s");
}
}
}
}
print "Read Activity File\n";
open(OUT,">alltransactions.dat");
foreach my $key (keys(%transactions)) {
print OUT "$key:$transactions{$key}\n";
}
close(OUT);