From:['.localtime($ConceptData{'Int.'.$k}).
+ '] To: ['.localtime($ConceptData{'Int.'.($k+1)}-1).
+ "]
$Correct
$Wrong
";
+
+ $Str .= "\n".'
';
+
+ $r->print($Str);
+#$Apache::lonxml::debug=1;
+#&Apache::lonhomework::showhash(%ConceptData);
+#$Apache::lonxml::debug=0;
+}
+
+
+sub DrawGraph {
+ my ($k,$Src)=@_;
+ my $Max=0;
+ my @data1;
+ my @data2;
+
+ # Adjust Data and find the Max
+ 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;}
+ }
+ for (my $n=0; $n<=$#Concepts; $n++ ) {
+ if ($data1[$n]+$data2[$n]<$Max) {
+ $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
+ }
+ }
+ my $P_No = $#data1+1;
+
+ if ( $Max > 1 ) {
+ $Max += (10 - $Max % 10);
+ $Max = int($Max);
+ } else { $Max = 1; }
+
- $r->print(" zone successful");
- for(my $n=0;$n<$cs;$n++){
- $r->print(' '.$LS[$n]);
+ my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src;
+# $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2;
+ $GData="$Titr&Concepts&Answers&$Max&$P_No&".
+ (join(',',@data1)).'&'.(join(',',@data2));
+
+ $r->print('');
+}
+
+
+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 );
+
+ #the table of option response problems
+ $r->print(' Option Response Problems in this course:
');
+ my $Str = "\n".'
'.
+ "\n".'
'.
+ "\n".'
#
'.
+ "\n".'
Problem Title
'.
+ "\n".'
Resource
'.
+ "\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 Decide {
+ #deciding the true or false answer belongs to each interval
+ my ($type,$foil,$time)=@_;
+ my $k=0;
+ while ($time>$ConceptData{'Int.'.($k+1)} &&
+ $k<$ConceptData{'Interval'}) {$k++;}
+ $ConceptData{"$foil_to_concept{$foil}.$k.$type"}++;
+}
+
- $r->print(" zone failed");
- for(my $n=0;$n<$cf;$n++){
- $r->print(' '.$LF[$n]);
+#restore the student submissions and finding the result
+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;
+ if ($reshash{'version'}) {
+ my $tries=0;
+ &Apache::lonhomework::showhash(%Answer);
+ for (my $version=1;$version<=$reshash{'version'};$version++) {
+ my $time=$reshash{"$version:timestamp"};
+
+ foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) {
+ if (($key=~/\.(\w+)\.(\w+)\.submission$/)) {
+ my $Id1 = $1; my $Id2 = $2;
+ #check if this is a repeat submission, if so skip it
+ if ($reshash{"$version:resource.$Id1.previous"}) { next; }
+ #if no solved this wasn't a real submission, ignore it
+ if (!defined($reshash{"$version:resource.$Id1.solved"})) {
+ &Apache::lonxml::debug("skipping ");
+ next;
+ }
+ my $Resp = $reshash{"$version:$key"};
+ my %submission=&Apache::lonnet::str2hash($Resp);
+ foreach (keys %submission) {
+ my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"};
+ if ($submission{$_}) {
+ if ($submission{$_} eq $Ansr) {
+ &Decide("true",$_,$time );
+ }
+ else {&Decide("false",$_,$time );}
+ }
+ }
+ }
+ }
+ }
}
-
-# 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 = @_;
@@ -257,7 +429,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;
@@ -269,37 +442,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=();
@@ -307,12 +472,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,$_);}
@@ -321,103 +484,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 {
@@ -427,10 +501,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;
@@ -449,13 +522,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++;
@@ -470,6 +540,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' ) {
@@ -479,25 +550,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"};
@@ -521,7 +592,7 @@ sub StudentReport {
$TempHash{"$Part.Wrongs"} = $Wrongs;
}
}
- }
+ }
for ( my $n = 0; $n < $PartNo; $n++ ) {
my $part = $TempHash{$n};
if ($PtrTry ne '') {$PtrTry .= ',';}
@@ -543,20 +614,64 @@ sub StudentReport {
$r->rflush();
}
+sub CreateTable {
+ my ($Hd, $Hid)=@_;
+ if ($ENV{'form.showcsv'}) {
+ if ( $Hd == 1 ) {
+ $r->print(' "'.$hash{'title_'.$Hid}.'","'.$hash{'src_'.$Hid}.'"');
+ }
+ return;
+ }
+ my $ColNo=0;
+ foreach (keys(%Header)){
+ $ColNo++;
+ }
+ if ( $Hd == 1 ) {
+ $r->print(' '.$hash{'title_'.$Hid}.'');
+ }
+ my $Result = "\n".'
';
+ $Result .= '
P#
'."\n";
+ for ( my $nIdx=0; $nIdx < $ColNo; $nIdx++ ) {
+ $Result .= '