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

www www at source.lon-capa.org
Sat Oct 29 12:52:23 EDT 2011


www		Sat Oct 29 16:52:23 2011 EDT

  Added files:                 
    /modules/gerd/geogebra	transtimes.pl 
  Log:
  Find first viewing time, last transaction time, and store transaction
  times for items interested in
  
  

Index: modules/gerd/geogebra/transtimes.pl
+++ modules/gerd/geogebra/transtimes.pl
use strict;

my %symbtitle=();
my @symborder=();
open(IN,"symbs.dat");
while (my $line=<IN>) {
   chomp($line);
   my ($title,$symb)=($line=~/^(.+)\s+(uploaded.+)$/);
   $symbtitle{$symb}=$title;
   push(@symborder,$symb);
}
close(IN);

my %students=();
my %firstaccess=();
my %lastsub=();
my %subs=();

open(IN,"raw_transactions.dat");
while (my $line=<IN>) {
   chomp($line);
   my ($key,$value)=split(/\=/,$line);
   my @times=sort(split(/\,/,$value));
   my ($uname,$udom,$symb,$part)=split(/\:/,$key);
   if ($symbtitle{$symb}) {
      $students{$uname}=1;
      if (($times[1]<$firstaccess{$symb.':'.$uname}) || (!$firstaccess{$symb.':'.$uname})) {
         $firstaccess{$symb.':'.$uname}=$times[1];
      }
      if ($part) {
         $lastsub{$symb.':'.$part.':'.$uname}=$times[-1];
         $subs{$symb.':'.$part.':'.$uname}=join(',', at times);
      }
   }
}
close(IN);

foreach my $key (sort(keys(%subs))) {
    my ($symb,$part,$user) = split(/\:/,$key);
    print $key."=".$firstaccess{$symb.':'.$user}.':'.$lastsub{$key}.':'.$subs{$key}."\n";
}

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