--- loncom/interface/lonstatistics.pm 2002/05/19 15:44:40 1.20 +++ loncom/interface/lonstatistics.pm 2002/05/30 13:36:18 1.24 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstatistics.pm,v 1.20 2002/05/19 15:44:40 minaeibi Exp $ +# $Id: lonstatistics.pm,v 1.24 2002/05/30 13:36:18 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,7 @@ # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei # YEAR=2002 # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei -# 5/12,5/14,5/15,5/19 Behrouz Minaei +# 5/12,5/14,5/15,5/19,5/26 Behrouz Minaei # ### @@ -86,6 +86,51 @@ my %Header = (0,"Homework Sets Order",1, 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd"); my %Answer = (); + +sub unescape { + my $str=shift; + $str =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; + return $str; +} + +sub Activity { + my $file="/home/minaeibi/minaei"; + my $userid='billskat'; + $r->print("Using $file"); + $r->rflush(); + open(FILEID, "<$file"); + my $line; + my @allaccess; + while ($line=) { + my ($time,$machine,$what)=split(':',$line); + #$r->print("time=$time machine=$machine:-> $what\n"); + #$r->rflush(); + $what=&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; } + push (@allaccess,unescape($access)); + #print $machine; + } + } + @allaccess=sort(@allaccess); + my $Count=0; + foreach my $access (@allaccess) { + my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); + $Count++; +# $r->print("$Count ".localtime($date)." $who $resource\n"); + $r->print("$Count) $date: $who --> $resource"); + $r->rflush(); + if ($post) { + $r->print("Sent data ".join(':',unescape(@posts)).''); + } + } +} + + + sub InitAnalysis { my ($rid, $student)=@_; my ($uname,$udom)=split(/\:/,$student); @@ -279,7 +324,7 @@ sub AnalyzeProblem { my $OpSel=''; my $CurInt = $ENV{'form.interval'}; if ($CurInt eq '') {$CurMap = '1';} - my $Ptr = 'Select number of intervals'."\n". + my $Ptr = 'Select number of intervals'."\n". ''."\n"; for (my $n=1;$n<=7;$n++) { $Ptr .= ''. "\n".' # '. "\n".' Problem Title '. - "\n".' Resouse '. + "\n".' Resource '. "\n".' Address '. "\n".''; @@ -478,7 +523,7 @@ sub StudentReport { "\n".' Tries '. "\n".''; my ($temp)=keys(%result); - unless ($temp=~/^error\:/) { + unless ($temp=~/^(con_lost|error|no_such_host)/i) { foreach my $CurCol (@cols) { if (!$CurCol){ my $Set=&Apache::lonnet::declutter($hash{'map_id_'.$1}); @@ -639,8 +684,8 @@ sub PreStatTable { $Ptr .= ''. ' #Stdnts: Total Number of Students opened the problem.'. ' Tries : Total Number of Tries for solving the problem.'. - ' Max : Maximunm Number of Tries for solving the problem.'. - ' Avg. : Average Number of the tries. [ Tries / #Stdnts ]'. + ' Mod : Maximunm Number of Tries for solving the problem.'. + ' Mean : Average Number of the tries. [ Tries / #Stdnts ]'. ' #YES : Number of students solved the problem correctly.'. ' #yes : Number of students solved the problem by override.'. ' %Wrng : Percentage of students tried to solve the problem but'. @@ -648,10 +693,10 @@ sub PreStatTable { # ' DoDiff : Degree of Difficulty of the problem. [ Tries/(#YES+#yes+0.1) ]'. Kashy formula ' DoDiff : Degree of Difficulty of the problem. [ 1 - ((#YES+#yes) / Tries) ]'. #Gerd formula ' S.D. : Standard Deviation of the tries.'. - '[ sqrt(sum((Xi - Avg.)^2)) / (#Stdnts-1)'. + '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)'. ' where Xi denotes every student\'s tries ]'. ' Skew. : Skewness of the students tries.'. - ' [ (sqrt( sum((Xi - Avg.)^3) / #Stdnts)) / (S.D.^3) ]'. + ' [ (sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3) ]'. ' Dis.F. : Discrimination Factor: A Standard for '. 'evaluating the problem according to a Criterion'. ' [Applied Criterion in %27 Upper Students - '. @@ -704,15 +749,18 @@ sub usection { my ($udom,$unam,$courseid,$ActiveFlag)=@_; $courseid=~s/\_/\//g; $courseid=~s/^(\w)/\/$1/; - foreach (split(/\&/,&Apache::lonnet::reply('dump:'. - $udom.':'.$unam.':roles', - &Apache::lonnet::homeserver($unam,$udom)))){ - my ($key,$value)=split(/\=/,$_); - $key=&Apache::lonnet::unescape($key); + + my %result=&Apache::lonnet::dump('roles',$udom,$unam); + my ($checkForResult)=keys(%result); + if ($checkForResult=~/^(con_lost|error|no_such_host)/i) { + return -1; + } + foreach my $key (keys (%result)) { + my $value=$result{$key}; if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) { my $section=$1; if ($key eq $courseid.'_st') { $section=''; } - my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value)); + my ($dummy,$end,$start)=split(/\_/,$value); if ( $ActiveFlag ne 'Any' ) { my $now=time; my $notactive=0; @@ -759,7 +807,7 @@ sub ExtractStudentData { my $SecLimit; my $MapLimit; my ($temp)=keys(%result); - unless ($temp=~/^error\:/) { + unless ($temp=~/^(con_lost|error|no_such_host)/i) { foreach my $CurCol(@cols) { ($PrOrd,$ResId)=split(/\:/,$CurCol); if ( !$CurCol ) { next; } @@ -882,6 +930,7 @@ sub ExtractStudentData { } + # ------------------------------------------------------------ Build page table sub tracetable { my ($rid,$beenhere)=@_; @@ -1355,7 +1404,6 @@ sub ClassList { &GetStatus(); $cid=$ENV{'request.course.id'}; - my $chome=$ENV{'course.'.$cid.'.home'}; my ($cdom,$cnum)=split(/\_/,$cid); # ----------------------- Get first and last resource, see if there is anything $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}}; @@ -1372,26 +1420,27 @@ sub ClassList { # foreach my $KeyPoint(sort keys(%students)) { - my $classlst=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.':classlist',$chome); - my $StudNo = 0; my $now=time; - unless ($classlst=~/^error\:/) { - foreach my $KeyPoint(sort split(/\&/,$classlst)) { - my ($name,$value)=split(/\=/,$KeyPoint); - my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value)); + + my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum); + + my ($checkForError)=keys(%classlist); + if($checkForError=~/^(con_lost|error|no_such_host)/i) { + $r->print('Could not access course data'); + } else { + foreach my $name (keys (%classlist)) { + my $value=$classlist{$name}; + my ($end,$start)=split(/\:/,$value); my $active=1; my $Status=$ENV{'form.status'}; $Status = ($Status) ? $Status : 'Active'; if ( ( ($end) && $now > $end ) && - ( ($Status eq 'Active') ) ) { $active=0; } - + ( ($Status eq 'Active') ) ) { $active=0; } if ( ($Status eq 'Expired') && - ($end == 0 || $now < $end) ) { $active=0; } - + ($end == 0 || $now < $end) ) { $active=0; } if ($active) { my $thisindex=$#students+1; - $name=&Apache::lonnet::unescape($name); $students[$thisindex]=$name; my ($sname,$sdom)=split(/\:/,$name); my $ssec=&usection($sdom,$sname,$cid,$Status); @@ -1404,12 +1453,10 @@ sub ClassList { $StuBox{$sname}=$sdom; } $StudNo++; - } + } } } - else { - $r->print('Could not access course data'); - } + $r->print("Total number of students : ".($#students+1)); $r->rflush(); # --------------- Find all assessments and put them into some linear-like order @@ -1460,6 +1507,8 @@ sub CreateForm { $Ptr .= ''; $Ptr .= ''; $Ptr .= ''; + #$Ptr .= ''; + #$Ptr .= ''; $r->print( $Ptr ); } else { @@ -1488,7 +1537,10 @@ sub Menu { # $Apache::lonxml::debug=0; &Title(); my $InpStr = $ENV{'form.sort'}; - if ($InpStr=~/^Analyze\_/) { + if ($InpStr eq 'Activity Log') { + &Activity(); + } + elsif ($InpStr=~/^Analyze\_/) { &ClassList(); &ShowOpGraph($InpStr,$ENV{'form.interval'}); } @@ -1505,6 +1557,7 @@ sub Menu { $r->rflush(); } + sub StudentOptions { my $OpSel5=''; $CurStu = $ENV{'form.student'};
'. ' #Stdnts: Total Number of Students opened the problem.'. ' Tries : Total Number of Tries for solving the problem.'. - ' Max : Maximunm Number of Tries for solving the problem.'. - ' Avg. : Average Number of the tries. [ Tries / #Stdnts ]'. + ' Mod : Maximunm Number of Tries for solving the problem.'. + ' Mean : Average Number of the tries. [ Tries / #Stdnts ]'. ' #YES : Number of students solved the problem correctly.'. ' #yes : Number of students solved the problem by override.'. ' %Wrng : Percentage of students tried to solve the problem but'. @@ -648,10 +693,10 @@ sub PreStatTable { # ' DoDiff : Degree of Difficulty of the problem. [ Tries/(#YES+#yes+0.1) ]'. Kashy formula ' DoDiff : Degree of Difficulty of the problem. [ 1 - ((#YES+#yes) / Tries) ]'. #Gerd formula ' S.D. : Standard Deviation of the tries.'. - '[ sqrt(sum((Xi - Avg.)^2)) / (#Stdnts-1)'. + '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)'. ' where Xi denotes every student\'s tries ]'. ' Skew. : Skewness of the students tries.'. - ' [ (sqrt( sum((Xi - Avg.)^3) / #Stdnts)) / (S.D.^3) ]'. + ' [ (sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3) ]'. ' Dis.F. : Discrimination Factor: A Standard for '. 'evaluating the problem according to a Criterion'. ' [Applied Criterion in %27 Upper Students - '. @@ -704,15 +749,18 @@ sub usection { my ($udom,$unam,$courseid,$ActiveFlag)=@_; $courseid=~s/\_/\//g; $courseid=~s/^(\w)/\/$1/; - foreach (split(/\&/,&Apache::lonnet::reply('dump:'. - $udom.':'.$unam.':roles', - &Apache::lonnet::homeserver($unam,$udom)))){ - my ($key,$value)=split(/\=/,$_); - $key=&Apache::lonnet::unescape($key); + + my %result=&Apache::lonnet::dump('roles',$udom,$unam); + my ($checkForResult)=keys(%result); + if ($checkForResult=~/^(con_lost|error|no_such_host)/i) { + return -1; + } + foreach my $key (keys (%result)) { + my $value=$result{$key}; if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) { my $section=$1; if ($key eq $courseid.'_st') { $section=''; } - my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value)); + my ($dummy,$end,$start)=split(/\_/,$value); if ( $ActiveFlag ne 'Any' ) { my $now=time; my $notactive=0; @@ -759,7 +807,7 @@ sub ExtractStudentData { my $SecLimit; my $MapLimit; my ($temp)=keys(%result); - unless ($temp=~/^error\:/) { + unless ($temp=~/^(con_lost|error|no_such_host)/i) { foreach my $CurCol(@cols) { ($PrOrd,$ResId)=split(/\:/,$CurCol); if ( !$CurCol ) { next; } @@ -882,6 +930,7 @@ sub ExtractStudentData { } + # ------------------------------------------------------------ Build page table sub tracetable { my ($rid,$beenhere)=@_; @@ -1355,7 +1404,6 @@ sub ClassList { &GetStatus(); $cid=$ENV{'request.course.id'}; - my $chome=$ENV{'course.'.$cid.'.home'}; my ($cdom,$cnum)=split(/\_/,$cid); # ----------------------- Get first and last resource, see if there is anything $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}}; @@ -1372,26 +1420,27 @@ sub ClassList { # foreach my $KeyPoint(sort keys(%students)) { - my $classlst=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.':classlist',$chome); - my $StudNo = 0; my $now=time; - unless ($classlst=~/^error\:/) { - foreach my $KeyPoint(sort split(/\&/,$classlst)) { - my ($name,$value)=split(/\=/,$KeyPoint); - my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value)); + + my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum); + + my ($checkForError)=keys(%classlist); + if($checkForError=~/^(con_lost|error|no_such_host)/i) { + $r->print('Could not access course data'); + } else { + foreach my $name (keys (%classlist)) { + my $value=$classlist{$name}; + my ($end,$start)=split(/\:/,$value); my $active=1; my $Status=$ENV{'form.status'}; $Status = ($Status) ? $Status : 'Active'; if ( ( ($end) && $now > $end ) && - ( ($Status eq 'Active') ) ) { $active=0; } - + ( ($Status eq 'Active') ) ) { $active=0; } if ( ($Status eq 'Expired') && - ($end == 0 || $now < $end) ) { $active=0; } - + ($end == 0 || $now < $end) ) { $active=0; } if ($active) { my $thisindex=$#students+1; - $name=&Apache::lonnet::unescape($name); $students[$thisindex]=$name; my ($sname,$sdom)=split(/\:/,$name); my $ssec=&usection($sdom,$sname,$cid,$Status); @@ -1404,12 +1453,10 @@ sub ClassList { $StuBox{$sname}=$sdom; } $StudNo++; - } + } } } - else { - $r->print('Could not access course data'); - } + $r->print("Total number of students : ".($#students+1)); $r->rflush(); # --------------- Find all assessments and put them into some linear-like order @@ -1460,6 +1507,8 @@ sub CreateForm { $Ptr .= ''; $Ptr .= ''; $Ptr .= ''; + #$Ptr .= ''; + #$Ptr .= ''; $r->print( $Ptr ); } else { @@ -1488,7 +1537,10 @@ sub Menu { # $Apache::lonxml::debug=0; &Title(); my $InpStr = $ENV{'form.sort'}; - if ($InpStr=~/^Analyze\_/) { + if ($InpStr eq 'Activity Log') { + &Activity(); + } + elsif ($InpStr=~/^Analyze\_/) { &ClassList(); &ShowOpGraph($InpStr,$ENV{'form.interval'}); } @@ -1505,6 +1557,7 @@ sub Menu { $r->rflush(); } + sub StudentOptions { my $OpSel5=''; $CurStu = $ENV{'form.student'};