[LON-CAPA-cvs] cvs: loncom /debugging_tools activity_log_counting.pl

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 27 Feb 2007 06:29:38 -0000


albertel		Tue Feb 27 01:29:38 2007 EDT

  Added files:                 
    /loncom/debugging_tools	activity_log_counting.pl 
  Log:
  - helper script to count who accessed what how often
  
  

Index: loncom/debugging_tools/activity_log_counting.pl
+++ loncom/debugging_tools/activity_log_counting.pl
use strict;
use XML::Simple;
my $ref = XMLin('activity.log.xml');
my %what;
my %who;
print("Parsed\n");
foreach my $key1 (keys(%$ref)) {
    foreach my $element (@{$ref->{$key1}}) {
	if (ref($element) eq 'HASH') {
	    my $res = (split(m{(?:/|%2f)},$element->{'resource'}))[-1];
	    $res = &unescape($res);
	    $what{$element->{'student'}}{$res}++;
	    $who{$res}{$element->{'student'}}++;
	}
    }
}

use Data::Dumper;
$Data::Dumper::Sortkeys=1;
print(&Dumper(\%who));

sub unescape {
    my $str=shift;
    $str =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
    return $str;
}