[LON-CAPA-cvs] cvs: modules /gerd/harvesting crypting.pl getdata.pl

www www@source.lon-capa.org
Wed, 15 Jun 2011 00:24:56 -0000


www		Wed Jun 15 00:24:56 2011 EDT

  Added files:                 
    /modules/gerd/harvesting	crypting.pl 

  Modified files:              
    /modules/gerd/harvesting	getdata.pl 
  Log:
  Updated harvesting routines
  
  
Index: modules/gerd/harvesting/getdata.pl
diff -u modules/gerd/harvesting/getdata.pl:1.1 modules/gerd/harvesting/getdata.pl:1.2
--- modules/gerd/harvesting/getdata.pl:1.1	Tue Jun 14 15:29:56 2011
+++ modules/gerd/harvesting/getdata.pl	Wed Jun 15 00:24:56 2011
@@ -5,41 +5,44 @@
 use lib '/home/httpd/lib/perl';
 use Apache::lonnet;
 my $count=0;
-#open(IN,"matrix/allcourses.dat");
-#print("Opened reading\n");
-#open(OUT,">matrix/allstudents.dat");
-#print("Opened writing\n");
-#while (my $line=<IN>) {
-   my $line='11617e003483fe4oucapa2:ohiou:mg287901:ohiou:1070328580:1062804127';
-
+open(IN,"matrix/allstudents.dat");
+print("Opened reading\n");
+open(OUT,">matrix/rawsubs.dat");
+print("Opened writing\n");
+while (my $line=<IN>) {
    my ($cnum,$cdom,$uname,$udom)=split(/\:/,$line);
    $count++;
    if ($count<$offset) { print "."; next;}
    my %data=&Apache::lonnet::dump($cdom.'_'.$cnum,$udom,$uname);
-   print "\n==== $count = $udom = $uname =$cnum = $cdom ====\n";
+   print "==== $count = $udom = $uname =$cnum = $cdom ====\n";
    foreach my $record (keys(%data)) {
-     
-       print $record.' :=  '.$data{$record}."\n";
-
       if ($record=~/^version\:(.+)$/) {
           my $symb=$1;
+          my ($folder,$num,$url)=split(/\_\_\_/,$symb);
+          my $instance=$folder.'___'.$num;
           my $version=$data{$record};
           my $keys=$data{$version.':keys:'.$symb};
-          print "=> Keys $keys\n";
           my @stored=split(/\:/,$keys);
           foreach my $item (@stored) {
               if ($item=~/^resource\.(.+)\.tries$/) {
                  my $part=$1;
-                 print "---> Part: $part\n";
+                 if ($data{"$version:$symb:resource.$part.regrader"}) {
+                    print "Regraded\n";
+                    next;
+                 }
                  my $tries=$data{"$version:$symb:resource.$part.tries"};
                  my $solved=$data{"$version:$symb:resource.$part.solved"};
-                 print "---> Tries/Solved: $tries/$solved\n";
+                 my $timestamp=$data{"$version:$symb:timestamp"};
+                 unless ($tries && $solved && $timestamp) {
+                    print "=========== ERROR: $count Symb: $symb $uname $udom $cnum $cdom =====================\n";
+                    print "==== Version $version Tries: $tries Solved: $solved Time: $timestamp Keys: $keys ==\n";
+                    next;
+                 }
+                 print OUT "$uname\t$udom\t$cnum\t$cdom\t$url\t$part\t$instance\t$tries\t$solved\t$timestamp\n";
               }
           } 
        }
-#      my @entries=split(/\:/,$classlist{$student});
-#      print OUT "$cnum:$cdom:$student:$entries[0]:$entries[1]\n";
    } 
-#}
-#close(OUT);
-#close(IN);
+}
+close(OUT);
+close(IN);

Index: modules/gerd/harvesting/crypting.pl
+++ modules/gerd/harvesting/crypting.pl
use strict;

my $inname=shift;
my $outname=$inname;
$outname=~s/raw/enc/;

my %clear=();
my %encry=();

open(IN,$inname);
open(OUT,'>'.$outname);
while (my $line=<IN>) {
   my @entries=split(/\t/,$line);
   $clear{$entries[0]}=1;
   $entries[0]=&fullcrypt($entries[0]);
   $encry{$entries[0]}=1;
   print OUT join("\t",@entries);
}
close(OUT);
close(IN);
my @c=keys(%clear);
my @e=keys(%encry);
print $#c.' '.$#e."\n";


sub fullcrypt {
   my $name=shift;
   my $first=substr($name,0,8);
   my $last=substr($name,8,16);
   return crypt($first,42).crypt($last,17);
}