[LON-CAPA-cvs] cvs: modules /gerd/geogebra transactivity.pl

www www at source.lon-capa.org
Sat Oct 29 10:44:03 EDT 2011


www		Sat Oct 29 14:44:03 2011 EDT

  Added files:                 
    /modules/gerd/geogebra	transactivity.pl 
  Log:
  Parse activity log for first viewing and part submissions
  
  

Index: modules/gerd/geogebra/transactivity.pl
+++ modules/gerd/geogebra/transactivity.pl
use strict;
use Date::Manip;
use HTML::TokeParser;
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 $part='';
           if ($inter{'action_values'}=~/submitted\%3d([^\&]+)/) {
              $part=$1;
           }
           $transactions{"$inter{'student'}:$inter{'resource'}:$part"}.=','.
              $inter{'unixtime'};
        }
# clear
         %inter=();
      } else {
         $inter{$entry}=$p->get_text('/'.$entry);
         if ($entry eq 'time') {
            $inter{'unixtime'}=UnixDate($inter{$entry},"%s");
         }
      }
   }
}
foreach my $key (sort(keys(%transactions))) {
   print $key.'='.$transactions{$key}."\n";
}


# -------------------------------------------------------- Escape Special Chars

sub escape {
    my $str=shift;
    $str =~ s/(\W)/"%".unpack('H2',$1)/eg;
    return $str;
}

# ----------------------------------------------------- Un-Escape Special Chars

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





More information about the LON-CAPA-cvs mailing list