# The LearningOnline Network with CAPA # (Publication Handler # # $Id: lonclassifystudents.pm,v 1.1 2002/07/27 20:50:15 minaeibi Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # # (Navigate problems for statistical reports # # YEAR=2002 # 5/12,7/27 Behrouz Minaei # ### package Apache::lonclassifystudents; use strict; use Apache::lonnet(); use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; #---- Activity log ------------------------------------------------------- sub LoadDoDiffFile { my $file="/home/minaeibi/183d.txt"; open(FILEID, "<$file"); my $line=; my %DoDiff=(); my @Act=split('&',$line); # $r->print('
'.$#Act); for(my $n=0;$n<=$#Act;$n++){ my ($res,$Degree)=split('@',$Act[$n]); $DoDiff{$res}=$Degree; } return \%DoDiff; } sub LoadClassFile { my $file="/home/minaeibi/class.txt"; open(FILEID, "<$file"); my $line; my %Grade=(); while ($line=) { my ($id,$ex1,$ex2,$ex3,$ex4,$hw,$final,$grade)=split(' ',$line); $Grade{$id}=$grade; } return \%Grade; } #------- Classification sub Classify { my ($DiscFac, $students)=@_; my ($fileGrade) = &LoadClassFile(); my $Count=0; my @List=(); my @LS=(); my @LF=(); my @LM=(); my $cf=0; my $cs=0; my $cm=0; foreach (keys(%$DiscFac)){ my @l=split(/\:/,$_); if (!($students->{$l[1]})) {next;} my $Grade=$fileGrade->{$students->{$l[1]}}; if( $Grade > 3 ) { $cs++; push(@LS,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Successful")); } elsif ( $Grade > 2 ) { $cm++; push(@LM,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Average")); } else { $cf++; push(@LF,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Failed")); } } my $Str = ''; for(my $n=0;$n<$cs;$n++){$Str .= '
'.$LS[$n];} for(my $n=0;$n<$cm;$n++){$Str .= '
'.$LM[$n];} for(my $n=0;$n<$cf;$n++){$Str .= '
'.$LF[$n];} return $Str; } sub ProcAct { # return; my ($Act,$Submit)=@_; my @Act=split(/\@/,$Act); @Act = sort(@Act); ##$r->print('
'.$#Act); ##for(my $n=0;$n<=$#Act;$n++){ ## $r->print('
n='.$n.')'.$Act[$n]); ## } # my $Beg=$Act[0]; my $Dif=$Submit-$Act[0]; $Dif = ($Dif>0) ? ($Dif/3600) : 0; # $r->print('
Access Number = '.$#Act.'
Submit Time='.$Submit.'
First Access='.$Act[0].'
Last Access='.$Act[$#Act].'
Submit - First = '.$Dif.''); #time spent for solving the problem # $r->print('
Def'.($Act[$#Act-1]-$Act[0])); return $Dif; } sub LoadActivityLog { # my $CacheDB = "/home/minaeibi/act183.log.cache"; my $CacheDB = "/home/httpd/perl/tmp/act183.log.cache"; my %Activity; if (-e "$CacheDB") { if (tie(%Activity,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) { return; } else { # $r->print("Unable to tie log Cache hash to db file"); } } else { if (tie(%Activity,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) { foreach (keys %Activity) {delete $Activity{$_};} &Build_log(\%Activity); } else { # $r->print("Unable to tie log Build hash to db file"); } } return \%Activity; } sub Build_log { my ($Activity)=@_; my $file="/home/minaeibi/act183.log"; open(FILEID, "<$file"); my $line; my $count=0; while ($line=) { my ($time,$machine,$what)=split(':',$line); $what=&Apache::lonnet::unescape($what); my @accesses=split('&',$what); foreach my $access (@accesses) { $count++; my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); if (!$resource) { next; } my $res=&Apache::lonnet::unescape($resource); if (($res =~ /\.problem/)) { $Activity->{$who.':'.$res}.=$date.'@'; #$r->print('
'.$time.':'.$who.'---'.$res); &Update_PrgInit($count); } } } # my $c=1; # foreach (sort keys %Activity) { # $r->print('
'.$c.')'.$_.' ... '.$Activity{$_}); # $c++; # } } sub Activity { my $file="/home/minaeibi/activity.log"; my $userid='adamsde1'; # $r->print("
Using $file"); # $r->rflush(); open(FILEID, "<$file"); my $line; my @allaccess; my $Count=0; while ($line=) { my ($time,$machine,$what)=split(':',$line); $what=&Apache::lonnet::unescape($what); my @accesses=split('&',$what); foreach my $access (@accesses) { my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); #if ($who ne $userid) { next; } if (!$resource) { next; } my $res=&Apache::lonnet::unescape($resource); if (($res =~ /\.(sequence|problem|htm|html|page)/)) { $Count++; ###888 $r->print("
$Count) ".localtime($date).": $who --> $res"); # if ($post) { # $Count++; # $r->print("
$Count) Sent data ".join(':', # &Apache::lonnet::unescape(@posts)).''); # } ###888 $r->rflush(); } #push (@allaccess,unescape($access)); #print $machine; } } # @allaccess=sort(@allaccess); # $Count=0; # foreach my $access (@allaccess) { # my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); # $Count++; # $r->print("
$Count) $date: $who --> $resource"); # $r->rflush(); # if ($post) { # $r->print("
Sent data ".join(':',unescape(@posts)).''); # } # } } #---- END Activity log --------------------------------------------------- 1; __END__