[LON-CAPA-cvs] cvs: modules /gerd/geogebra timeseval.pl
www
www at source.lon-capa.org
Sat Oct 29 21:08:40 EDT 2011
www Sun Oct 30 01:08:40 2011 EDT
Added files:
/modules/gerd/geogebra timeseval.pl
Log:
Get average times
Index: modules/gerd/geogebra/timeseval.pl
+++ modules/gerd/geogebra/timeseval.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);
# Time on task averages
my %tottime=();
# Time between transactions
my %tbw=();
# Read stuff
open(IN,"processed_times.dat");
while (my $line=<IN>) {
chomp($line);
my ($key,$value)=split(/\=/,$line);
my ($first,$last,$submissions)=split(/\:/,$value);
$submissions=~s/^\,//;
my @subs=split(/\,/,$submissions);
#
my $timeontask=$last-$first;
if ($timeontask) {
$tottime{$key}=$timeontask;
}
for (my $i=0; $i<$#subs; $i++) {
my $timebetween=$subs[$i+1]-$subs[$i];
if ($timebetween) {
$tbw{$key.':'.$i}=$timebetween;
}
}
}
close(IN);
print &avestd(%tottime);
print ",,\n";
print &avestd(%tbw);
# Average and standard deviation
sub avestd {
my (%data)=@_;
my %sum=();
my %num=();
my %ave=();
my %std=();
foreach my $key (keys(%data)) {
my @comps=split(/\:/,$key);
my $id=$comps[0].':'.$comps[1];
$sum{$id}+=$data{$key};
$num{$id}++;
}
foreach my $id (keys(%sum)) {
$ave{$id}=$sum{$id}/$num{$id};
}
foreach my $symb (@symborder) {
foreach my $id (sort(keys(%sum))) {
if ($id=~/^\Q$symb\E\:(.+)$/) {
print $symbtitle{$symb}.",".$1.",".$ave{$id}."\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