--- loncom/interface/lonstatistics.pm 2002/02/05 12:24:45 1.2
+++ loncom/interface/lonstatistics.pm 2002/05/13 16:41:46 1.17
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonstatistics.pm,v 1.2 2002/02/05 12:24:45 minaeibi Exp $
+# $Id: lonstatistics.pm,v 1.17 2002/05/13 16:41:46 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,33 +27,36 @@
#
# (Navigate problems for statistical reports
# YEAR=2001
-# 5/05/01, 7/09/01, 7/25/01, 8/11/01,9/13/01, 9/26/01 Behrouz Minaei
-# 10/5/01, 10/9/01, 10/22/01, 10/26/01 Behrouz Minaei
-# 11/1/01, 11/4/01, 11/16/01 Behrouz Minaei
-# 12/14/01, 12/16/01, 12/18/01,12/20/01,12/31/01 Behrouz Minaei
+# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
+# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
# YEAR=2002
-# 1/22/02,2/1/02
+# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6,5/12 Behrouz Minaei
+#
###
-package Apache::lonstatistics;
+package Apache::lonstatistics;
-use strict;
+use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet();
use Apache::lonhomework;
+use Apache::loncommon;
use HTML::TokeParser;
use GDBM_File;
-use Benchmark;
# -------------------------------------------------------------- Module Globals
my %hash;
my %CachData;
my %GraphDat;
+my %OpResp;
my %maps;
-my @mapsort;
+my %mapsort;
my %section;
my %StuBox;
my %DiscFac;
+my %DisUp;
+my %DisLow;
+my $UpCnt;
my $CurMap;
my $CurSec;
my $CurStu;
@@ -65,192 +68,341 @@ my $Pos;
my $r;
my $OpSel1;
my $OpSel2;
-my $OpSelDis1;
-my $OpSelDis2;
-my $CurDis=0;
my $OpSel3;
my $OpSel4;
my $GData;
my $cid;
my $firstres;
my $lastres;
-my $DiscFlag=0;
-my $HWN=0;
+my $DiscFlag;
+my $HWN;
+my $P_Order;
+my %foil_to_concept;
+my @Concepts;
+my %ConceptData;
+my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod",
+ 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff",
+ 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd");
+my @shown;
+
+sub InitAnalysis {
+ my ($rid, $student)=@_;
+ my ($uname,$udom)=split(/\:/,$student);
+ $rid=~/(\d+)\.(\d+)/;
+ my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.
+ &Apache::lonnet::declutter($hash{'src_'.$rid});
+ my $URI = $hash{'src_'.$rid};
+ my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze',
+ 'grade_username' => $uname,
+ 'grade_domain' => $udom,
+ 'grade_courseid' => $cid,
+ 'grade_symb' => $symb));
+# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze'));
+
+ (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
+ my %Answer=();
+ %Answer=&Apache::lonnet::str2hash($Answ);
+
+ my $parts='';
+ foreach my $elm (@{$Answer{"parts"}}) {
+ $parts.="$elm,";
+ }
+ chop($parts);
+ my $conc='';
+ foreach my $elm (@{$Answer{"$parts.concepts"}}) {
+ $conc.="$elm@";
+ }
+ chop($conc);
+
+ @Concepts=split(/\@/,$conc);
+ my $show='';
+ foreach my $elm (@{$Answer{"$parts.shown"}}) {
+ $show.="$elm@";
+ }
+ chop($show);
+ @shown=split(/\@/,$show);
+# $r->print(" shown:".$show);# $r->rflush();
+ foreach my $concept (@{$Answer{"$parts.concepts"}}) {
+ foreach my $foil (@{$Answer{"$parts.concept.$concept"}}) {
+ $foil_to_concept{$foil} = $concept;
+ $ConceptData{$foil} = $Answer{"$parts.foil.value.$foil"};
+ }
+ }
+ return $symb;
+}
-my %Header = (0,"Problem Title",1,"#Stdnts",2,"Tries",3,"Mod",
- 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"S.D.",
- 9,"Skew.",10,"DoDiff",11,"Map");
-# 9,"Skew.",10,"DoDiff",11,"Dis.F.",12,"Resourse URL");
-
-my %class = qw(
-);
-
-my @LS;
-my @LF;
-
-sub GetBin {
- my ($Index1,$Index2,$String,$C)=@_;
- my @step = 5;
- my @L=($C eq 'S') ? @LS : @LF;
- my $Count=$#L+1;
- $r->print(" zone $C ------ $String ");
- for(my $n=0;$n<$Count;$n++){
- my @t=split(/\:/,$L[$n]);
- $r->print(" $t[$Index1] $t[$Index2]");
+
+sub Interval {
+ my ($rid,$part,$symb)=@_;
+ my $Int=$ConceptData{"Interval"};
+ my $due = &Apache::lonnet::EXT('resource.$part.duedate',$symb)+1;
+ my $opn = &Apache::lonnet::EXT('resource.$part.opendate',$symb);
+ my $add=int(($due-$opn)/$Int);
+#$r->print(" $opn, to $due add=$add int=$Int");#$r->rflush();
+ $ConceptData{"Int.0"}=$opn;
+ for (my $i=1;$i<$Int;$i++) {
+ $ConceptData{"Int.$i"}=$opn+$i*$add;
+ }
+ $ConceptData{"Int.$Int"}=$due;
+ for (my $i=0;$i<$Int;$i++) {
+ for (my $n=0; $n<=$#Concepts; $n++ ) {
+ my $tmp=$Concepts[$n];
+ $ConceptData{"$tmp.$i.true"}=0;
+ $ConceptData{"$tmp.$i.false"}=0;
+ }
}
}
-sub GetUniqe {
- my ($Index,$String,$C)=@_;
- my @step = 5;
- my @L=($C eq 'S') ? @LS : @LF;
- my $Count=$#L+1;
- my @List=();
- for(my $n=0;$n<$Count;$n++){
- my @t=split(/\:/,$L[$n]);
- push(@List,$t[$Index]);
- #$r->print(" $t[$Index]");
+
+sub ShowOpGraph {
+
+ my ($InpStr, $Int_No)=@_;
+
+ $r->print(<
+
+ function display(name) {
+ document.forms.displayform.elements.dis.value=name;
+ window.status=name;
+ }
+ function cleardisplay() {
+ document.forms.displayform.elements.dis.value='';
+ window.status='No Concept in particular';
}
- @List = sort NumSort(@List);
- $r->print(" zone $C ------ $String ");
- my $nIdx=0;
- my $nPrb=0;
- my %Proc;
- undef %Proc;
- while ( $nIdx < $Count ) {
- my $Focus=$List[$nIdx];
- my $Temp = $Focus;
- do {
- $nIdx++;
- $nPrb++;
- $Focus=$List[$nIdx];
- #$Proc{$name}=$Focus;
- } while ( $Focus == $Temp && $nIdx < $Count );
- $r->print(" $Temp --> $nPrb");
- $nPrb=0;
+
+ENDPOP
+
+ my ($rid,$part)=split(/\:/,substr($InpStr,8));
+ $ConceptData{"Interval"}=$Int_No;
+ my $symb=&InitAnalysis($rid,$students[0]);
+ &Interval($rid,$part,$symb);
+ my $URI = $hash{'src_'.$rid};
+ my $Src = $hash{'title_'.$rid};
+ $Src =~ s/\ /"_"/eg;
+ $r->print(' '.$URI.'');
+ for (my $n=1; $n<=$#Concepts+1; $n++ ) {
+ my $tmp=$Concepts[$n-1];
+ $tmp =~ s/" less than "/eg;
+ $r->print(" Concept $n:$tmp");
}
- return %Proc;
+ $r->rflush();
+
+ &Create_PrgWin();
+ &Update_PrgWin("Starting to analyze problem");
+ for (my $index=0;$index<=$#students;$index++) {
+ &Update_PrgWin($index);
+ &OpStatus($rid,$students[$index]);
+ }
+ &Close_PrgWin();
+
+ for (my $k=0; $k<$Int_No; $k++ ) {
+ my $data1='';
+ my $data2='';
+ &DrawGraph(&AdjustData($k).'+'.$Src.'+'.($k+1));
+ }
+#$Apache::lonxml::debug=1;
+#&Apache::lonhomework::showhash(%ConceptData);
+#$Apache::lonxml::debug=0;
+ my $Answ=&Apache::lonnet::ssi($URI);
+ $r->print(" Here you can see the Problem: $Answ");
+}
+
+sub AdjustData {
+ my $k=shift;
+ my $Max=0;
+ my @data1;
+ my @data2;
+ for (my $n=0; $n<=$#Concepts; $n++ ) {
+ my $tmp=$Concepts[$n];
+ $data1[$n]=$ConceptData{"$tmp.$k.true"};
+ $data2[$n]=$ConceptData{"$tmp.$k.false"};
+ my $Sum=$data1[$n]+$data2[$n];
+ if ( $Max<$Sum ) {$Max=$Sum;}
+ $ConceptData{"$tmp.true"}+=$data1[$n];
+ $ConceptData{"$tmp.false"}+=$data2[$n];
+ }
+ for (my $n=0; $n<=$#Concepts; $n++ ) {
+ if ($data1[$n]+$data2[$n]<$Max) {
+ $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
+ }
+ }
+ return join(',',@data1).'+'.
+ join(',',@data2).'+'.
+ $Max.'+'.($#data1+1);
}
-sub GetUniq {
- my ($Index,$String)=@_;
- my @step = 5;
- my $Count=0;
- my @List=();
- my @temp=();
- foreach (keys(%DiscFac)){
- $Count++;
- my @temp1=split(/\:/,$_);
- @temp=($temp1[$Index],@temp1);
- push(@List,join(':',@temp));
+
+sub DrawGraph {
+ my $data=shift;
+ my($data1,$data2,$Max,$P_No,$Src,$k)=split(/\+/,$data);
+
+ my $Str="\n".'
'.
+ "\n".'
'.
+ "\n".'
Correct Answers
'.
+ "\n".'
Wrong Answers
'.
+ "\n".'
From
'.
+ "\n".'
To
'.
+ "\n".'
'.
+ "\n"."
".
+ "\n"."
$data1
".
+ "\n"."
$data2
".
+ "\n"."
".localtime($ConceptData{'Int.'.($k-1)})."
".
+ "\n"."
".localtime($ConceptData{'Int.'.$k}-1)."
".
+ "\n"."
";
+ $r->print($Str);
+# $r->print(' Correct Answers: '.$data1.
+# ' Wrong Answers: '.$data2);
+# $r->print(' From: '.localtime($ConceptData{'Int.'.($k-1)}).
+# ' To: '.localtime($ConceptData{"Int.$k"}));
+
+# if ( $Max > 1 ) {
+# $Max += (10 - $Max % 10);
+# $Max = int($Max);
+# }
+# else { $Max = 1; }
+ my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.$k : $Src;
+ $GData=$Titr.'&'.'Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2;
+ if($ConceptData{'Interval'}>1){
+ $r->print(' ');
+ return;
}
- @List = sort NumericSort(@List);
+ $r->print(' Move your mouse over a bar to find out the concept');
+ my $ptr='';
+ $ptr.="\n".'';
+ $ptr.="\n".'
'.
+ "\n".'
';
+ $r->print(' '.$ptr.' ');
+}
- $r->print("
zone ($Index) ------ $String ----- / $temp[3]");
- my $nIdx=0;
- my $nPrb=0;
- my %Proc;
- undef %Proc;
- while ( $nIdx < $Count ) {
- my ($Focus,$Dummy,$name)=split(/\:/,$List[$nIdx]);
- my $Temp = $Focus;
- $Proc{$name}=$Focus;
- do {
- $nIdx++;
- $nPrb++;
- ($Focus,$Dummy,$name)=split(/\:/,$List[$nIdx]);
- $Proc{$name}=$Focus;
- } while ( $Focus == $Temp && $nIdx < $Count );
- $r->print(" $Temp --> $nPrb");
- $nPrb=0;
+
+sub AnalyzeProblem {
+# -------------------------------- Selecting the number of intervals
+ my $OpSel='';
+ my $CurInt = $ENV{'form.interval'};
+ if ($CurInt eq '') {$CurMap = '1';}
+ my $Ptr = 'Select number of intervals'."\n".
+ ''."\n";
+ $r->print( $Ptr );
+
+ $r->print(' Option Response Problems in this course:
');
+ my $Str = "\n".'
'.
+ "\n".'
'.
+ "\n".'
#
'.
+ "\n".'
Problem Title
'.
+ "\n".'
Resouse
'.
+ "\n".'
Address
'.
+ "\n".'
';
+
+ my $P_No=1;
+ foreach (sort keys %OpResp) {
+ my ($rid,$part)=split(/\:/,$OpResp{$_});
+ my $Temp = ''.$hash{'title_'.$rid}.'';
+ $Str .= "\n"."
".
+ "\n"."
$P_No
".
+ "\n"."
".$Temp."
".
+ "\n"."
".$hash{'src_'.$rid}."
".
+ "\n"."
".''.'
'.
+ "\n"."
";
+ $P_No++;
+ }
+ $Str .= "\n".'
';
+ $Str .= "\n".'';
+ $r->print($Str);
+ $r->rflush();
}
-sub NumericSort {
- $a <=> $b;
+
+sub Decide {
+ my ($type,$foil,$time)=@_;
+ my $k=0;
+ while ($time>$ConceptData{'Int.'.($k+1)} &&
+ $k<$ConceptData{'Interval'}) {$k++;}
+ $ConceptData{"$foil_to_concept{$foil}.$k.$type"}++;
}
-#------- Classification
-sub Classify {
- my $Count=0;
- my @List=();
-# foreach(keys %class){
-# $r->print(" $_ --> $class{$_}");
-# }
- # $DiscFac{($DisFactor.':'.$sname.':'.$ProbTot.':'.$TotalOpend.':'.
- # $TotalTries.':'.$ProbSolved.':'.$time)}=$Dis;
- @LS=();
- @LF=();
- my $cf=0;
- my $cs=0;
- foreach (keys(%DiscFac)){
- my @l=split(/\:/,$_);
- if ($class{$l[1]}){
- if( $class{$l[1]} == 4 ) {
- $cs++;
- push(@LS,('S:'.$l[6].':'.$l[0].':'.$l[5].':'.$l[4].':'.$l[3].':'.$class{$l[1]}));
- }
- elsif ( $class{$l[1]} < 3 ) {
- $cf++;
- push(@LF,('F:'.$l[6].':'.$l[0].':'.$l[5].':'.$l[4].':'.$l[3].':'.$class{$l[1]}));
+sub OpStatus {
+ my ($rid,$student)=@_;
+ my ($uname,$udom)=split(/\:/,$student);
+ my $code='U';
+ $rid=~/(\d+)\.(\d+)/;
+ my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.
+ &Apache::lonnet::declutter($hash{'src_'.$rid});
+ my %reshash=&Apache::lonnet::restore($symb,$cid,$udom,$uname);
+ my @True = ();
+ my @False = ();
+ my $flag=0;
+ @shown=();
+ if ($reshash{'version'}) {
+ for (my $version=1;$version<=$reshash{'version'};$version++) {
+ my $time=$reshash{"$version:timestamp"};
+ foreach (sort(split(/\:/,$reshash{$version.':keys'}))) {
+ if (($_=~/\.(\w+)\.(\w+)\.submission$/)) {
+ #my $Id1=$1; my $Id2=$2;
+ my $Resp = $reshash{$_};
+ my %submission=&Apache::lonnet::str2hash($Resp);
+ foreach (keys %submission) {
+ my $Ansr = $ConceptData{"$_"};
+ #my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"};
+ #$r->print(" shown: ".join(',',@shown)." size=$#shown");
+ if ($submission{$_}) {
+ #if($#shown==-1){
+ #my @str=split(/\&/,$Resp);
+ #my $garb;
+ #for(my $j=0;$j<=$#str;$j++){
+ # ($shown[$j],$garb)=split(/\=/,$str[$j]);
+ #}
+ ##$r->print(" shown: ".join(',',@shown)." size=$#shown");
+ #}
+ if ($submission{$_} eq $Ansr) {
+ &Decide("true",$_,$time );
+ }
+ else {&Decide("false",$_,$time );}
+ }
+ #else {
+ # if ($#shown==-1 && $flag==0) {
+ # $flag++;
+ # &InitAnalysis($rid,$student);
+ # }
+ # my @erl=split(/\:/,$_);
+ # for (my $i=0;$i<=$#shown; $i++){
+ # my $Ans=$Answer{"$Id1.$Id2.foil.value.$shown[$i]"};
+ # if ($erl[$i] eq $Ans) {
+ # &Decide("true",$shown[$i],$time);
+ # }
+ # else {&Decide("false",$shown[$i],$time);}
+ # }
+ #}
+ }
+ }
}
- }
- }
-
- $r->print(" zone successful");
- for(my $n=0;$n<$cs;$n++){
- $r->print(' '.$LS[$n]);
- }
-
- $r->print(" zone failed");
- for(my $n=0;$n<$cf;$n++){
- $r->print(' '.$LF[$n]);
+ }
}
-
-# my %Disc = &GetUniqe(@List,5,"Discrimination Factor");
-# my %Opnd = &GetUniq(@List,3,"Total Opened");
-# my %Trys = &GetUniq(@Lsit4,"Total Tries");
-# my %Slvd = &GetUniq(5,"Problems Solved");
-
- # my (@L, $Index,$String)=@_;
-
- my %Time = &GetUniqe(1,"Time",'S');
- &GetUniqe(1,"Time",'F');
- &GetUniqe(2,"Discrimination Factor",'S');
- &GetUniqe(2,"Discrimination Factor",'F');
- &GetUniqe(3,"Solved",'S');
- &GetUniqe(3,"Solved",'F');
- &GetUniqe(4,"Tries",'S');
- &GetUniqe(4,"Tries",'F');
-
- &GetBin(1,2, " Time ... Discriminat",'S');
- &GetBin(1,2, " Time ... Discriminat",'F');
- &GetBin(1,3, " Time ... Solved",'S');
- &GetBin(1,3, " Time ... Solved",'F');
- &GetBin(1,4, " Time ... Tries",'S');
- &GetBin(1,4, " Time ... Tries",'F');
- &GetBin(2,3, " Discriminant ... Solved",'S');
- &GetBin(2,3, " Discriminant ... Solved",'F');
- &GetBin(2,4, " Discriminant ... Tries",'S');
- &GetBin(2,4, " Discriminant ... Tries",'F');
- &GetBin(3,4, " Solved ... Tries",'S');
- &GetBin(3,4, " solved ... Tries",'F');
-# foreach (keys(%Disc)) {
-# $r->print(" : $Disc{$_} --> $Slvd{$_}");
- # }
- # $r->print(" ..........Discriminant ... Time................");
- ## foreach (keys(%Disc)) {
- # $r->print(" $Disc{$_} --> $Time{$_}");
- # }
- # $r->print(" ..........Time ... Solved.......................");
- # foreach (keys(%Disc)) {
- # $r->print(" $Disc{$_} --> $Slvd{$_}");
- # }
}
+
#------- Processing upperlist and lowerlist according to each problem
sub ProcessDisc {
my @List = @_;
@@ -260,7 +412,8 @@ sub ProcessDisc {
my @Dis;
my $Slvd=0;
my $tmp;
- my $Sum=0;
+ my $Sum1=0;
+ my $Sum2=0;
my $nIdx=0;
my $nStud=0;
my %Proc;
@@ -272,37 +425,29 @@ sub ProcessDisc {
do {
$nIdx++;
$nStud++;
- $Sum += $Dis[$CurDis];
+ $Sum1 += $Dis[0];
+ $Sum2 += $Dis[1];
($Prb,$tmp)=split(/\=/,$List[$nIdx]);
@Dis=split(/\+/,$tmp);
} while ( $Prb eq $Temp && $nIdx < $Count );
-# $Proc{$Temp}=$Sum.':'.$nStud;
- $Proc{$Temp}=($Sum/$nStud).':'.$nStud;
-# $r->print("$nIdx) $Temp --> ($nPrb) $Proc{$Temp} ");
- $Sum=0;
+# $Proc{$Temp}=($Sum1/$nStud).':'.$nStud;
+ $Proc{$Temp}=($Sum1/$nStud).':'.($Sum2/$nStud);
+# $r->print("$nIdx) $Temp --> ($nStud) $Proc{$Temp} ");
+ $Sum1=0;
+ $Sum2=0;
$nStud=0;
}
return %Proc;
}
-#------- Creating Discimination factor table
-sub DiscriminationTable {
+
+#------- Creating Discimination factor
+sub Discriminant {
my $Count=0;
foreach (keys(%DiscFac)){
$Count++;
}
- my $UpCnt = int(0.27*$Count);
- $r->print("
".
- "Current map: \"$CurMap\" ".
- "Current Section: \"$CurSec\" ".
- "Number of valid students: $Count".
- " The Upper 27% has $UpCnt records.".
- " The Lower 27% has $UpCnt records ".
- "The Criterion of sorting the students: ".
- "( Sum of Partial Credits Awarded / ".
- "Total Number of Tries )".
- "
");
- $r->rflush();
+ $UpCnt = int(0.27*$Count);
my $low=0;
my $up=$Count-$UpCnt;
my @UpList=();
@@ -310,12 +455,10 @@ sub DiscriminationTable {
$Count=0;
foreach my $key (sort(keys(%DiscFac))){
$Count++;
-# $r->print("$Count) $key ");
-
+ #$r->print(" $Count) $key = $DiscFac{$key}");
if ($low < $UpCnt || $Count > $up) {
$low++;
my $str=$DiscFac{$key};
-# $r->print("$Count) $str ");
foreach(split(/\:/,$str)){
if ($_) {
if ($low<$UpCnt){push(@LowList,$_);}
@@ -324,103 +467,14 @@ sub DiscriminationTable {
}
}
}
-
- my %Up=&ProcessDisc(@UpList);
- my %Low=&ProcessDisc(@LowList);
-
- my @list = ();
- my $Useful;
- my $UnUseful;
- $p_count = 0;
-
- foreach my $key( keys %CachData) {
- my @Temp=split(/\:/,$CachData{$key});
- ($UnUseful,$Useful)=split(/\>/,$Temp[0]);
- $list[$p_count]=$Useful.'&'.$CachData{$key};
- $p_count++;
- }
-
- @list = sort MySort (@list);
-
- my $Result = "\n".'
';
- $Result .= "\n".'
P#
';
- $Result .= "\n".'
'.$Header{0}.'
';
- $Result .= "\n".'
'.'Discrimination Factor'.'
';
- $Result .= "\n".'
'.'%Upper Award'.'
';
- $Result .= "\n".'
'.'%Lower Award'.'
';
- $Result .= "\n".'
'.'Upper Records'.'
';
- $Result .= "\n".'
'.'Lower Records'.'
';
- $Result .= "\n".'
'.'%Degree of Difficulty'.'
';
- $Result .= "\n".'
';
- $r->print( $Result );
-
- for ( my $nIdx = 0; $nIdx < $p_count; $nIdx++ ) {
- my( $Pre, $Post ) = split(/\&/,$list[$nIdx]);
- my ($Temp,$MxTries,$StdNo,$TotalTries,$YES,$Override,
- $Wrng,$Avg,$SD,$Sk,$DoD,$res,$Prob)=split(/\:/,$Post);
- my ($UpDis,$UpNo)=split(/\:/,$Up{$Prob});
- my ($LwDis,$LwNo)=split(/\:/,$Low{$Prob});
- $UpNo = ($UpNo) ? $UpNo : 0;
- $LwNo = ($LwNo) ? $LwNo : 0;
- my $U_Dis = sprintf("%.4f", $UpDis)*100;
- my $L_Dis = sprintf("%.4f", $LwDis)*100;
- my $DisFac = $UpDis - $LwDis;
- my $_Dis = sprintf("%.4f", $DisFac)*100;
- $r->print( "\n".'
'.
- "\n".'
'.($nIdx+1).'
'.
- "\n".'
'.$Temp.'
'.
- "\n".'
'.$_Dis.'
'.
- "\n".'
'.$U_Dis.'
'.
- "\n".'
'.$L_Dis.'
'.
- "\n".'
'.$UpNo.'
'.
- "\n".'
'.$LwNo.'
'.
- "\n".'
'.$DoD.'
'.
- "\n".'
' );
- }
- $r->print("\n".'
');
- $r->rflush();
+ %DisUp=&ProcessDisc(@UpList);
+ %DisLow=&ProcessDisc(@LowList);
}
-sub CreateDiscFac {
-
- my $CacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$cid\_statistics.db";
- my $CachDisFac = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$cid\_DiscFactor.db";
-
- my $ptr='';
-# $ptr .= ' Discrimination Criterion: '."\n".
-# ' '."\n";
- $ptr .= ' ';
- $r->print($ptr);
-
- if ((-e "$CacheDB")&&
- ($ENV{'form.sort'} ne 'Recalculate Discrimintion Factor')) {
- if (tie(%CachData,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) {
- tie(%DiscFac,'GDBM_File',$CachDisFac,&GDBM_READER,0640);
- #&DiscriminationTable();
- &Classify();
- }
- else {$r->print("Unable to tie hash to db file");}
- }
- else {
- if (tie(%CachData,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) {
- tie(%DiscFac,'GDBM_File',$CachDisFac,&GDBM_WRCREAT,0640);
- foreach (keys %CachData) {delete $CachData{$_};}
- foreach (keys %DiscFac) {delete $DiscFac{$_};}
- $DiscFlag=1;
- &Build_Statistics();
- $DiscFlag=0;
- &DiscriminationTable();
- }
- else {$r->print("Unable to tie hash to db file");}
- }
- untie(%CachData);
- untie(%DiscFac);
-}
-
+
+sub NumericSort {
+ $a <=> $b;
+}
# ------ Create different Student Report
sub StudentReport {
@@ -430,10 +484,9 @@ sub StudentReport {
Please select a student' );
return;
}
- my $shome=&Apache::lonnet::homeserver( $sname,$sdom );
- my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.':'.$cid,$shome );
- my %result = ();
+ my %result = &Apache::lonnet::dump($cid,$sdom,$sname);
my $ResId;
+ my $PrOrd;
my $Code;
my $Tries;
my $TotalTries = 0;
@@ -452,13 +505,10 @@ sub StudentReport {
"\n".'
Results
'.
"\n".'
Tries
'.
"\n".'';
- unless ($reply=~/^error\:/) {
- map {
- my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
- $result{$name}=$value;
- } split(/\&/,$reply);;
- foreach $ResId (@cols) {
- if ( !$ResId ) {
+ my ($temp)=keys(%result);
+ unless ($temp=~/^error\:/) {
+ foreach my $CurCol (@cols) {
+ if (!$CurCol){
my $Set=&Apache::lonnet::declutter($hash{'map_id_'.$1});
if ( $Set ) {
$SetNo++;
@@ -473,6 +523,7 @@ sub StudentReport {
$PtrCod='';
next;
}
+ ($PrOrd,$ResId)=split(/\:/,$CurCol);
$ResId=~/(\d+)\.(\d+)/;
my $Map = &Apache::lonnet::declutter( $hash{'map_id_'.$1} );
if ( $CurMap ne 'All Maps' ) {
@@ -482,25 +533,25 @@ sub StudentReport {
my $meta=$hash{'src_'.$ResId};
my $PartNo = 0;
undef %TempHash;
- map {
- if ($_=~/^stores\_(\d+)\_tries$/) {
+ foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))){
+ if ($_=~/^stores\_(\w+)\_tries$/) {
my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
if ( $TempHash{"$Part"} eq '' ) {
$TempHash{"$Part"} = $Part;
$TempHash{$PartNo}=$Part;
$TempHash{"$Part.Code"} = '-';
+ $TempHash{"$Part.PrOrd"} = $PrOrd+$PartNo;
$PartNo++;
}
}
- } split(/\,/,&Apache::lonnet::metadata($meta,'keys'));
+ }
my $Prob = $Map.'___'.$2.'___'.
&Apache::lonnet::declutter( $hash{'src_'.$ResId} );
$Code='U';
$Tries = 0;
$Wrongs = 0;
- $LatestVersion = $result{"version:$Prob"};
-
+ $LatestVersion = $result{"version:$Prob"};
if ( $LatestVersion ) {
for ( my $Version=1; $Version<=$LatestVersion; $Version++ ) {
my $vkeys = $result{"$Version:keys:$Prob"};
@@ -524,7 +575,7 @@ sub StudentReport {
$TempHash{"$Part.Wrongs"} = $Wrongs;
}
}
- }
+ }
for ( my $n = 0; $n < $PartNo; $n++ ) {
my $part = $TempHash{$n};
if ($PtrTry ne '') {$PtrTry .= ',';}
@@ -546,20 +597,54 @@ sub StudentReport {
$r->rflush();
}
+sub CreateTable {
+ my $ColNo=0;
+ foreach (keys(%Header)){
+ $ColNo++;
+ }
+ my ($Hd, $Hid)=@_;
+ if ( $Hd == 1 ) {
+ $r->print(' '.$hash{'title_'.$Hid}.'');
+ }
+ my $Result = "\n".'
';
+ $Result .= '
P#
'."\n";
+ for ( my $nIdx=0; $nIdx < $ColNo; $nIdx++ ) {
+ $Result .= '