Annotation of loncom/interface/statistics/lonclassifystudents.pm, revision 1.1

1.1     ! minaeibi    1: # The LearningOnline Network with CAPA
        !             2: # (Publication Handler
        !             3: #
        !             4: # $Id: lonproblemstatistics.pm,v 1.2 2002/07/25 19:29:23 minaeibi Exp $
        !             5: #
        !             6: # Copyright Michigan State University Board of Trustees
        !             7: #
        !             8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !             9: #
        !            10: # LON-CAPA is free software; you can redistribute it and/or modify
        !            11: # it under the terms of the GNU General Public License as published by
        !            12: # the Free Software Foundation; either version 2 of the License, or
        !            13: # (at your option) any later version.
        !            14: #
        !            15: # LON-CAPA is distributed in the hope that it will be useful,
        !            16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            18: # GNU General Public License for more details.
        !            19: #
        !            20: # You should have received a copy of the GNU General Public License
        !            21: # along with LON-CAPA; if not, write to the Free Software
        !            22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            23: #
        !            24: # /home/httpd/html/adm/gpl.txt
        !            25: #
        !            26: # http://www.lon-capa.org/
        !            27: #
        !            28: # (Navigate problems for statistical reports
        !            29: #
        !            30: # YEAR=2002
        !            31: # 5/12,7/27  Behrouz Minaei
        !            32: #
        !            33: ###
        !            34: 
        !            35: package Apache::lonclassifystudents; 
        !            36: 
        !            37: use strict;
        !            38: use Apache::lonnet();
        !            39: use Apache::lonhtmlcommon;
        !            40: use Apache::loncoursedata;
        !            41: use GDBM_File;
        !            42: 
        !            43: 
        !            44: #---- Activity log -------------------------------------------------------
        !            45: 
        !            46: sub LoadDoDiffFile {
        !            47:     my $file="/home/minaeibi/183d.txt";
        !            48:     open(FILEID, "<$file");
        !            49:     my $line=<FILEID>;
        !            50:     my %DoDiff=();
        !            51:     my @Act=split('&',$line);
        !            52:     
        !            53: #    $r->print('<br>'.$#Act);
        !            54:     for(my $n=0;$n<=$#Act;$n++){
        !            55:        my ($res,$Degree)=split('@',$Act[$n]);
        !            56:       $DoDiff{$res}=$Degree;
        !            57:     }
        !            58: 
        !            59:     return \%DoDiff;
        !            60: }
        !            61: 
        !            62: sub LoadClassFile {
        !            63:     my $file="/home/minaeibi/class.txt";
        !            64:     open(FILEID, "<$file");
        !            65:     my $line;
        !            66:     my %Grade=();
        !            67:     while ($line=<FILEID>) {
        !            68:         my ($id,$ex1,$ex2,$ex3,$ex4,$hw,$final,$grade)=split(' ',$line);
        !            69:         $Grade{$id}=$grade;
        !            70:     }
        !            71:     return \%Grade;
        !            72: }
        !            73: 
        !            74: #------- Classification  
        !            75: sub Classify {
        !            76:     my ($DiscFac, $students)=@_;
        !            77:     my ($fileGrade) = &LoadClassFile();
        !            78:     my $Count=0;
        !            79:     my @List=();
        !            80:     my @LS=();
        !            81:     my @LF=();
        !            82:     my @LM=();
        !            83:     my $cf=0;
        !            84:     my $cs=0;
        !            85:     my $cm=0;
        !            86:     foreach (keys(%$DiscFac)){  
        !            87: 	my @l=split(/\:/,$_);
        !            88: 	if (!($students->{$l[1]})) {next;}
        !            89: 	my $Grade=$fileGrade->{$students->{$l[1]}};
        !            90: 	if( $Grade > 3 ) {
        !            91: 	    $cs++;
        !            92: 	    push(@LS,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Successful"));
        !            93: 	} elsif ( $Grade > 2 ) {
        !            94: 	    $cm++;
        !            95: 	    push(@LM,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Average"));
        !            96: 	} else {
        !            97: 	    $cf++;
        !            98: 	    push(@LF,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Failed"));
        !            99: 	}
        !           100:     }
        !           101:     my $Str = '';
        !           102:     for(my $n=0;$n<$cs;$n++){$Str .= '<br>'.$LS[$n];}
        !           103:     for(my $n=0;$n<$cm;$n++){$Str .= '<br>'.$LM[$n];}  
        !           104:     for(my $n=0;$n<$cf;$n++){$Str .= '<br>'.$LF[$n];}
        !           105: 
        !           106:     return $Str;
        !           107: } 
        !           108: 
        !           109: sub ProcAct {
        !           110:     # return;
        !           111:     my ($Act,$Submit)=@_;
        !           112:     my @Act=split(/\@/,$Act);
        !           113:     @Act = sort(@Act);
        !           114: 
        !           115:     ##$r->print('<br>'.$#Act);
        !           116:     ##for(my $n=0;$n<=$#Act;$n++){
        !           117: ##	$r->print('<br>n='.$n.')'.$Act[$n]);
        !           118: ##    }
        !           119: 
        !           120: #    my $Beg=$Act[0];
        !           121:     my $Dif=$Submit-$Act[0];
        !           122:     $Dif = ($Dif>0) ? ($Dif/3600) : 0; 
        !           123: 
        !           124: #    $r->print('<br>Access Number = '.$#Act.'<br>Submit Time='.$Submit.'<br>First Access='.$Act[0].'<br>Last Access='.$Act[$#Act].'<br> Submit - First = <b>'.$Dif.'</b>');
        !           125: 
        !           126: 
        !           127: #time spent for solving the problem           
        !           128: #    $r->print('<br>Def'.($Act[$#Act-1]-$Act[0]));
        !           129: 
        !           130:     return $Dif;
        !           131: }
        !           132: 
        !           133: sub LoadActivityLog {
        !           134: #    my $CacheDB = "/home/minaeibi/act183.log.cache";
        !           135:     my $CacheDB = "/home/httpd/perl/tmp/act183.log.cache";
        !           136: 
        !           137:     my %Activity;
        !           138:     if (-e "$CacheDB") {
        !           139: 	if (tie(%Activity,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) {
        !           140: 	    return;
        !           141:         }
        !           142:         else {
        !           143: #	    $r->print("Unable to tie log Cache hash to db file");
        !           144:         }
        !           145:     }
        !           146:     else {
        !           147: 	if (tie(%Activity,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) {
        !           148: 	    foreach (keys %Activity) {delete $Activity{$_};}
        !           149: 	    &Build_log(\%Activity); 
        !           150: 	}
        !           151:         else {
        !           152: #	    $r->print("Unable to tie log Build hash to db file");
        !           153:         }
        !           154:     }
        !           155:     return \%Activity;
        !           156: }
        !           157: 
        !           158: sub Build_log {
        !           159:     my ($Activity)=@_;
        !           160:     my $file="/home/minaeibi/act183.log";
        !           161:     open(FILEID, "<$file");
        !           162:     my $line;
        !           163:     my $count=0;
        !           164:     while ($line=<FILEID>) {
        !           165: 	my ($time,$machine,$what)=split(':',$line);
        !           166: 	$what=&Apache::lonnet::unescape($what);
        !           167: 	my @accesses=split('&',$what);
        !           168: 	           
        !           169: 	foreach my $access (@accesses) {
        !           170: 
        !           171: 	    $count++;
        !           172: 
        !           173: 	    my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);
        !           174: 	    if (!$resource) { next; }
        !           175: 	    my $res=&Apache::lonnet::unescape($resource);
        !           176: 	    if (($res =~ /\.problem/)) {
        !           177: 		$Activity->{$who.':'.$res}.=$date.'@';
        !           178:                 #$r->print('<br>'.$time.':'.$who.'---'.$res);
        !           179: 		&Update_PrgInit($count);
        !           180: 
        !           181: 	    }
        !           182: 	}
        !           183:     }
        !           184: 
        !           185: # my $c=1;
        !           186: # foreach (sort keys %Activity) {
        !           187: #     $r->print('<br>'.$c.')'.$_.' ... '.$Activity{$_});
        !           188: #     $c++;
        !           189: # }
        !           190: 
        !           191: }
        !           192: 
        !           193: sub Activity {
        !           194:     my $file="/home/minaeibi/activity.log";
        !           195:     my $userid='adamsde1';
        !           196: #    $r->print("<br>Using $file");
        !           197: #    $r->rflush();
        !           198:     open(FILEID, "<$file");
        !           199:     my $line;
        !           200:     my @allaccess;
        !           201:     my $Count=0;
        !           202:     while ($line=<FILEID>) {
        !           203: 	my ($time,$machine,$what)=split(':',$line);
        !           204: 	$what=&Apache::lonnet::unescape($what);
        !           205: 	my @accesses=split('&',$what);
        !           206: 	foreach my $access (@accesses) {
        !           207: 	    my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);
        !           208: 	    #if ($who ne $userid) { next; }
        !           209: 	    if (!$resource) { next; }
        !           210: 	    my $res=&Apache::lonnet::unescape($resource);
        !           211: 	    if (($res =~ /\.(sequence|problem|htm|html|page)/)) {
        !           212: 	    	$Count++;
        !           213: ###888		$r->print("<br>$Count) ".localtime($date).": $who --> $res");
        !           214: #	        if ($post) { 
        !           215: #		    $Count++;
        !           216: #		    $r->print("<br><b>$Count) Sent data ".join(':',
        !           217: #                              &Apache::lonnet::unescape(@posts)).'</b>');
        !           218: #		}
        !           219: ###888		$r->rflush();
        !           220: 	    }
        !           221: 	    #push (@allaccess,unescape($access));
        !           222: 	    #print $machine;
        !           223: 	}
        !           224:     }
        !           225: #    @allaccess=sort(@allaccess);
        !           226: #    $Count=0;
        !           227: #    foreach my $access (@allaccess) {
        !           228: #	my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);
        !           229: #	$Count++;
        !           230: #	$r->print("<br>$Count) $date: $who --> $resource");
        !           231: #	$r->rflush();
        !           232: #	if ($post) { 
        !           233: #	    $r->print("<br><b>Sent data ".join(':',unescape(@posts)).'</b>');
        !           234: #	}
        !           235: #    }
        !           236: }
        !           237: 
        !           238: #---- END Activity log ---------------------------------------------------
        !           239: 
        !           240: 1;
        !           241: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>