[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm
minaeibi
lon-capa-cvs@mail.lon-capa.org
Fri, 19 Jul 2002 18:17:34 -0000
This is a MIME encoded message
--minaeibi1027102654
Content-Type: text/plain
minaeibi Fri Jul 19 14:17:34 2002 EDT
Modified files:
/loncom/interface lonstatistics.pm
Log:
dded Discussion field to the stats table.
This version include the classification and load activity.log functions (It needs more work)
--minaeibi1027102654
Content-Type: text/plain
Content-Disposition: attachment; filename="minaeibi-20020719141734.txt"
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.27 loncom/interface/lonstatistics.pm:1.28
--- loncom/interface/lonstatistics.pm:1.27 Wed Jul 17 08:53:00 2002
+++ loncom/interface/lonstatistics.pm Fri Jul 19 14:17:34 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonstatistics.pm,v 1.27 2002/07/17 12:53:00 stredwic Exp $
+# $Id: lonstatistics.pm,v 1.28 2002/07/19 18:17:34 minaeibi 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,5/26 Behrouz Minaei
+# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei
#
###
@@ -42,7 +42,6 @@
use Apache::lonnet();
use Apache::lonhomework;
use Apache::loncommon;
-use Apache::loncoursedata;
use HTML::TokeParser;
use GDBM_File;
@@ -50,17 +49,204 @@
my %hash;
my %CachData;
my %GraphDat;
-my %mapsort;
-my $Pos;
my $r;
my $GData;
my %color;
my %foil_to_concept;
my @Concepts;
my %ConceptData;
-my %Answer = ();
+my %Answer=();
+my %mapsort;
+
+my %Activity=();
+my %Grade=();
+my %DoDiff=();
+my %Discuss=();
+my $TotalDiscuss=0;
+my $TotalDiscuss_=0;
+
+
+sub LoadDiscussion {
+# my $symb=shift;
+# $r->print('<br>$cid ... '.$symb);
+# my %contrib=&Apache::lonnet::dump('msu_2964385f9033c63msul1','msu','2964385f9033c63msul1');
+ my $cid=$ENV{'request.course.id'};
+ my %contrib=&Apache::lonnet::dump(
+ $ENV{'request.course.id'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ foreach my $temp(keys %contrib) {
+ if ($temp=~/^version/) {
+ my $ver=$contrib{$temp};
+ my ($dummy,$prb)=split(':',$temp);
+ for (my $idx=1; $idx<=$ver; $idx++ ) {
+ my $name=$contrib{"$idx:$prb:sendername"};
+ $Discuss{"$name:$prb"}=$idx;
+ }
+ }
+ }
+# $r->print('<br>cid='.$cid);
+# my %contrib=&Apache::lonnet::restore($symb,$cid,
+# $ENV{$cid.'.domain'},
+# $ENV{'course.'.$cid.'.num'});
+
+# $Apache::lonxml::debug=1;
+# &Apache::lonhomework::showhash(%Discuss);
+# $Apache::lonxml::debug=0;
+}
+
+sub LoadDoDiffFile {
+ my $file="/home/minaeibi/183d.txt";
+ open(FILEID, "<$file");
+ my $line=<FILEID>;
+ %DoDiff=();
+ my @Act=split('&',$line);
+
+# $r->print('<br>'.$#Act);
+ for(my $n=0;$n<=$#Act;$n++){
+ my ($res,$Degree)=split('@',$Act[$n]);
+ $DoDiff{$res}=$Degree;
+ }
+}
+
+
+sub LoadClassFile {
+ my $file="/home/minaeibi/class.txt";
+ open(FILEID, "<$file");
+ my $line;
+ %Grade=();
+ while ($line=<FILEID>) {
+ my ($id,$ex1,$ex2,$ex3,$ex4,$hw,$final,$grade)=split(' ',$line);
+ $Grade{$id}=$grade;
+ }
+}
+
+
+#------- Classification
+sub Classify {
+ my ($DiscFac, $students)=@_;
+ &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=$Grade{$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"));
+ }
+ }
+ for(my $n=0;$n<$cs;$n++){$r->print('<br>'.$LS[$n]);}
+ for(my $n=0;$n<$cm;$n++){$r->print('<br>'.$LM[$n]);}
+ for(my $n=0;$n<$cf;$n++){$r->print('<br>'.$LF[$n]);}
+}
+
+
+sub ProcAct {
+ # return;
+ my ($Act,$Submit)=@_;
+ my @Act=split(/\@/,$Act);
+ @Act = sort(@Act);
+
+ ##$r->print('<br>'.$#Act);
+ ##for(my $n=0;$n<=$#Act;$n++){
+## $r->print('<br>n='.$n.')'.$Act[$n]);
+## }
+
+# my $Beg=$Act[0];
+ my $Dif=$Submit-$Act[0];
+ $Dif = ($Dif>0) ? ($Dif/3600) : 0;
+
+# $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>');
+
+
+#time spent for solving the problem
+# $r->print('<br>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";
+
+ 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();
+ }
+ else {
+ $r->print("Unable to tie log Build hash to db file");
+ }
+ }
+}
+
+sub Build_log {
+ my $file="/home/minaeibi/act183.log";
+ open(FILEID, "<$file");
+ my $line;
+ my $count=0;
+ while ($line=<FILEID>) {
+ 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('<br>'.$time.':'.$who.'---'.$res);
+ &Update_PrgInit($count);
+
+ }
+ }
+ }
+
+# my $c=1;
+# foreach (sort keys %Activity) {
+# $r->print('<br>'.$c.')'.$_.' ... '.$Activity{$_});
+# $c++;
+# }
+
+}
sub Activity {
+# $rid=~/(\d+)\.(\d+)/;
+# my $MapId=$1;
+# my $PrbId=$2;
+# my $MapOrg = $hash{'map_id_'.$MapId};
+# my $Map = &Apache::lonnet::declutter($MapOrg);
+# my $URI = $hash{'src_'.$rid};
+# my $Symb = $Map.'___'.$PrbId.'___'.&Apache::lonnet::declutter($URI);
my $file="/home/minaeibi/activity.log";
my $userid='adamsde1';
$r->print("<br>Using $file");
@@ -75,11 +261,11 @@
my @accesses=split('&',$what);
foreach my $access (@accesses) {
my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);
- if ($who ne $userid) { next; }
+ #if ($who ne $userid) { next; }
if (!$resource) { next; }
my $res=&Apache::lonnet::unescape($resource);
- if (($res =~ /\.(problem|htm|html)/)) {
- $Count++;
+ if (($res =~ /\.(sequence|problem|htm|html|page)/)) {
+ $Count++;
$r->print("<br>$Count) ".localtime($date).": $who --> $res");
# if ($post) {
# $Count++;
@@ -88,7 +274,7 @@
# }
$r->rflush();
}
- ## push (@allaccess,unescape($access));
+ #push (@allaccess,unescape($access));
#print $machine;
}
}
@@ -105,29 +291,25 @@
# }
}
-#---- Analyze Web Page ---------------------------------------------------
sub InitAnalysis {
my ($uri,$part,$problem,$student,$courseID)=@_;
- my ($username,$userdomain)=split(/\:/,$student);
+ my ($uname,$udom)=split(/\:/,$student);
+
# Render the student's view of the problem. $Answ is the problem
# Stringafied
- my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze',
- 'grade_username' => $username,
- 'grade_domain' => $userdomain,
- 'grade_courseid' => $courseID,
- 'grade_symb' => $problem));
-# my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze'));
+ my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze',
+ 'grade_username' => $uname,
+ 'grade_domain' => $udom,
+ 'grade_courseid' => $courseID,
+ 'grade_symb' => $problem));
+# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze'));
-# (undef,$Answ)=split(/_HASH_REF__/,$Answ,2);
+# (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
%Answer=();
%Answer=&Apache::lonnet::str2hash($Answ);
-# foreach (sort(keys(%Answer))) {
-# $r->print($_.' '.$Answer{$_}.'<br>');
-# }
-
my $parts='';
foreach my $elm (@{$Answer{"parts"}}) {
$parts.="$elm,";
@@ -150,32 +332,34 @@
return;
}
+
sub Interval {
my ($part,$symb)=@_;
- my $interval=$ConceptData{"Interval"};
- my $due = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb)+1;
- my $open = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
- my $add=int(($due-$open)/$interval);
- $ConceptData{'Interval.0'}=$open;
- for (my $i=1;$i<$interval;$i++) {
- $ConceptData{'Interval.'.$i}=$open+$i*$add;
+ 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);
+ $ConceptData{"Int.0"}=$opn;
+ for (my $i=1;$i<$Int;$i++) {
+ $ConceptData{"Int.$i"}=$opn+$i*$add;
}
- $ConceptData{'Interval.'.$interval}=$due;
- for (my $i=0;$i<$interval;$i++) {
+ $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;
+ $ConceptData{"$tmp.$i.true"}=0;
+ $ConceptData{"$tmp.$i.false"}=0;
}
}
}
+
sub ShowOpGraph {
my ($cache, $students, $courseID)=@_;
my $uri = $cache->{'AnalyzeURI'};
my $part = $cache->{'AnalyzePart'};
my $problem = $cache->{'AnalyzeProblem'};
- my $title = $cache->{'AnalyzeProblem'};
+ my $title = $cache->{'AnalyzeTitle'};
my $interval = $cache->{'Interval'};
$ConceptData{"Interval"} = $interval;
@@ -188,21 +372,21 @@
$title =~ s/\ /"_"/eg;
$r->print('<br><b>'.$uri.'</b>');
$r->rflush();
-
+
#Java script Progress window
&Create_PrgWin();
- &Update_PrgWin("Starting to analyze problem",0,0,'');
- for(my $index=0; $index<(scalar @$students); $index++) {
- &Update_PrgWin(scalar @$students, $index+1, $students->[$index]);
- &OpStatus($problem, $students->[$index], $courseID);
+ &Update_PrgWin("Starting-to-analyze-problem");
+ for (my $index=0;$index<(scalar @$students);$index++) {
+ &Update_PrgWin($index);
+ &OpStatus($problem,$students->[$index],$courseID);
}
&Close_PrgWin();
$r->print('<br>');
- for(my $k=0; $k<$interval; $k++ ) {
+ for (my $k=0; $k<$interval; $k++ ) {
&DrawGraph($k,$title);
}
- for(my $k=0; $k<$interval; $k++ ) {
+ for (my $k=0; $k<$interval; $k++ ) {
&DrawTable($k);
}
#$Apache::lonxml::debug=1;
@@ -212,6 +396,7 @@
$r->print("<br><b>Here you can see the Problem:</b><br>$Answ");
}
+
sub DrawTable {
my $k=shift;
my $Max=0;
@@ -266,38 +451,35 @@
sub DrawGraph {
- my ($currentInterval,$title)=@_;
+ my ($k,$Src)=@_;
my $Max=0;
my @data1;
my @data2;
# Adjust Data and find the Max
- for(my $n=0; $n<=$#Concepts; $n++ ) {
+ for (my $n=0; $n<=$#Concepts; $n++ ) {
my $tmp=$Concepts[$n];
- $data1[$n]=$ConceptData{$tmp.'.'.$currentInterval.'.true'};
- $data2[$n]=$ConceptData{$tmp.'.'.$currentInterval.'.false'};
+ $data1[$n]=$ConceptData{"$tmp.$k.true"};
+ $data2[$n]=$ConceptData{"$tmp.$k.false"};
my $Sum=$data1[$n]+$data2[$n];
- if($Max < $Sum) { $Max = $Sum; }
+ if ( $Max<$Sum ) {$Max=$Sum;}
}
- for(my $n=0; $n<=$#Concepts; $n++) {
- if($data1[$n]+$data2[$n]<$Max) {
+ for (my $n=0; $n<=$#Concepts; $n++ ) {
+ if ($data1[$n]+$data2[$n]<$Max) {
$data2[$n]+=$Max-($data1[$n]+$data2[$n]);
}
}
- my $P_No = scalar @data1;
+ my $P_No = $#data1+1;
- if($Max > 1) {
+ if ( $Max > 1 ) {
$Max += (10 - $Max % 10);
$Max = int($Max);
- } else {
- $Max = 1;
- }
+ } else { $Max = 1; }
- my $Titr=($ConceptData{'Interval'}>1) ?
- $title.'_interval_'.($currentInterval+1) : $title;
+ 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.'&';
- $GData .= (join(',',@data1)).'&'.(join(',',@data2));
+ $GData="$Titr&Concepts&Answers&$Max&$P_No&".
+ (join(',',@data1)).'&'.(join(',',@data2));
$r->print('<IMG src="/cgi-bin/graph.gif?'.$GData.'" border=1/>');
}
@@ -312,7 +494,6 @@
$ConceptData{"$foil_to_concept{$foil}.$k.$type"}++;
}
-
#restore the student submissions and finding the result
sub OpStatus {
my ($problem, $student, $courseID)=@_;
@@ -356,6 +537,7 @@
}
}
+
#---- END Analyze Web Page ----------------------------------------------
#---- Problem Statistics Web Page ---------------------------------------
@@ -398,6 +580,7 @@
}
+
#------- Creating Discimination factor
sub Discriminant {
my ($discriminantFactor)=@_;
@@ -430,10 +613,12 @@
return (\%DisUp, \%DisLow);
}
+
sub NumericSort {
$a <=> $b;
}
+
sub CreateProblemStatisticsTableHeading {
my ($displayFormat,$sequenceSource,$sequenceTitle,$headings)=@_;
if($displayFormat eq 'Display CSV Format') {
@@ -465,15 +650,26 @@
$r->rflush();
}
+
+
# ------ Dump the Student's DB file and handling the data for statistics table
sub ExtractStudentData {
- my ($cache,$name)=@_;
+ my ($cache,$name,$list)=@_;
my %discriminantFactor;
- my @list=();
my $totalTries = 0;
my $totalAwarded = 0;
my $tempProblemOrder=0;
+ my $spent=0;
+ my $spent_yes=0;
+ my $TotDiscuss=0;
+ my $TotalOpend = 0;
+ my $ProbSolved = 0;
+ my $ProbTot = 0;
+ my $TotFirst = 0;
+ my $TimeTot = 0;
+ my $Discussed=0;
+
foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
if($cache->{'ProblemStatisticsMap'} ne 'All Maps' &&
$cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) {
@@ -525,6 +721,7 @@
my $tries=0;
my $time=0;
my $awarded=0;
+ $Discussed=0;
my $code='U';
$awarded = $cache->{$name.
@@ -571,6 +768,11 @@
$ptr .= "*(part $_)";
$Dis .= '&';
}
+
+ my ($pr_no,$dod)=split('&',$ptr);
+ my $DoDiff=$DoDiff{$dod};
+# $r->print('<br>'.$name.'---'.$ptr.'==='.$DoDiff);
+
my $Fac = ($partData{$_.':Tries'}) ?
($partData{$_.':awarded'}/$partData{$_.':tries'}) : 0;
my $DisF;
@@ -579,24 +781,60 @@
} else {
$DisF = $Fac;
}
+
+ if ($Discuss{"$name:$problem"}) {
+ $TotDiscuss++;
+ $Discussed=1;
+ }
+ my $time = $cache->{"$name:$LatestVersion:$problem:timestamp"};
$Dis .= $tempProblemOrder.'='.$DisF.'+'.$Yes;
$ptr .= '&'.$partData{$_.'.Tries'}.
'&'.$partData{$_.'.Wrongs'}.
'&'.$partData{$_.'.Code'};
- push (@list, $ptr);
+ push (@$list, $ptr."&$Discussed");
+
+#### if ($DoDiff>0.85) {
+
+ $TimeTot += $time;
+
+ if ($Yes==1 && $partData{$_.'.Tries'}==1) {
+ $TotFirst++;
+ }
+ my $Acts= $Activity{$name.':'.$problem};
+ if ($Acts) {
+ my $Pt=&ProcAct( $Acts, $time );
+ #my ($spe,$beg) = split(/\+/,$Pt);
+ my $spe= $Pt;
+ if ($Yes==1) {$spent_yes += $spe;}
+ $spent += $spe;
+ #$Beg += $beg;
+# $r->print('<br>'.$name.'---'.$problem.'---'.$spe);
+ }
+ $TotalOpend++;
+ $ProbTot++;
+
$tempProblemOrder++;
}
}
+ my $pstr;
if($totalTries) {
my $DisFac = ($totalAwarded/$totalTries);
my $DisFactor = sprintf( "%.4f", $DisFac );
- $discriminantFactor{$DisFactor}=$Dis;
+ my $TS = sprintf( "%.2f", $spent );
+ my $TS_yes = sprintf( "%.2f", $spent_yes );
+ # $DiscFac{$DisFactor}=$Dis;
+ $pstr=$DisFactor.':'.$name.':'.$ProbTot.':'.$TotalOpend.':'.
+ $totalTries.':'.$ProbSolved.':'.$TotFirst.':'.
+ $TS_yes.':'.$TS.':'.$TotDiscuss;
+ $discriminantFactor{$pstr}=$Dis;
}
}
- return (\%discriminantFactor, \@list);
+ return (\%discriminantFactor);
}
+
+=pod
sub MySort {
if ( $Pos > 0 ) {
if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;}
@@ -607,9 +845,22 @@
else { $a cmp $b; }
}
}
+=cut
sub BuildStatisticsTable {
- my ($cache,$discriminantFactor,$list,$headings)=@_;
+ my ($cache,$discriminantFactor,$list,$headings,$students)=@_;
+
+#6666666
+# my $file="/home/httpd/perl/tmp/183d.txt";
+# open(OUT, ">$file");
+#6666666
+ &Create_PrgWin();
+##777777
+## &LoadActivityLog();
+## $r->print('<script>popwin.document.popremain.remaining.value="'.
+## 'Loading Discussion...";</script>');
+## &LoadDoDiffFile();
+ &LoadDiscussion();
my $p_count = 0;
my $nIndex = 0;
@@ -628,11 +879,16 @@
$cache->{$sequence.':source'},
$cache->{$sequence.':title'},
$headings);
+
+##777777
+## &Classify($discriminantFactor, $students);
+
+
my ($Hid,$pr)=split(/\:/,$mapsort{$_});
my @lpr=split(/\&/,$pr);
for (my $i=1; $i<=$#lpr; $i++) {
my %storestats=();
- my ($PrOrd,$Prob,$Tries,$Wrongs,$Code)=split(/\&/,$list->[$nIndex]);
+ my ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]);
my $Temp = $Prob;
my $MxTries = 0;
my $TotalTries = 0;
@@ -640,6 +896,7 @@
my $Incorrect = 0;
my $Override = 0;
my $StdNo = 0;
+ my $DiscNo=0;
my @StdLst;
while ( $PrOrd == $lpr[$i] )
{
@@ -652,7 +909,7 @@
elsif( $Code eq 'I' ) { $Incorrect++; }
elsif( $Code eq 'O' ) { $Override++; }
elsif( $Code eq 'U' ) { $StdNo--; }
- ($PrOrd,$Prob,$Tries,$Wrongs,$Code)=split(/\&/,$list->[$nIndex]);
+ ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]);
}
$p_count++;
@@ -732,9 +989,14 @@
$TotalTries.'&'.$MxTries.'&'.$Avg.'&'.
$YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'.
$SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'.
- $Prob;
+ $DiscNo.'&'.$Prob;
$CachData{($p_count-1)}=$join;
+#6666666
+# $r->print('<br>'.$out.'&'.$DoD);
+# print (OUT $out.'@'.$DoD.'&');
+#6666666
+
$urlres=~/^(\w+)\/(\w+)/;
if ($StdNo) {
&Apache::lonnet::put('resevaldata',\%storestats,$1,$2);
@@ -745,6 +1007,9 @@
&CloseTable($cache);
}
&Close_PrgWin();
+#666666
+# close( OUT );
+#666666
}
=pod
@@ -797,12 +1062,15 @@
&CloseTable($cache);
}
}
-=cut
+=cut
+
+
+
sub TableRow {
- my ($cache,$Str,$Idx,$RealIdx)=@_;
+ my ($Str,$Idx,$RealIdx)=@_;
my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
- $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$Prob)=split(/\&/,$Str);
- if($cache->{'DisplayFormat'} eq 'Display CSV Format') {
+ $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str);
+ if ($ENV{'form.showcsv'}) {
my ($ResId,$Dummy)=split(/\*/,$Prob);
my $Ptr = "\n".'<br>'.
"\n".'"'.($RealIdx+1).'",'.
@@ -819,9 +1087,12 @@
"\n".'"'.$SD.'",'.
"\n".'"'.$Sk.'",'.
"\n".'"'.$_D1.'",'.
- "\n".'"'.$_D2.'"';
+ "\n".'"'.$_D2.'"'.
+ "\n".'"'.$DiscNo.'"';
+
$r->print("\n".$Ptr);
- } else {
+ }
+ else{
my $Ptr = "\n".'<tr>'.
"\n".'<td>'.($RealIdx+1).'</td>'.
# "\n".'<td>'.$PrOrd.$Temp.'</td>'.
@@ -837,12 +1108,12 @@
"\n".'<td bgcolor='.$color{"green"}.'> '.$SD.'</td>'.
"\n".'<td bgcolor='.$color{"green"}.'> '.$Sk.'</td>'.
"\n".'<td bgcolor='.$color{"purple"}.'> '.$_D1.'</td>'.
- "\n".'<td bgcolor='.$color{"purple"}.'> '.$_D2.'</td>';
+ "\n".'<td bgcolor='.$color{"purple"}.'> '.$_D2.'</td>'.
+ "\n".'<td bgcolor='.$color{"yellow"}.'> '.$DiscNo.'</td>';
$r->print("\n".$Ptr.'</tr>' );
}
$GraphDat{$RealIdx}=$DoD.':'.$Wrng;
}
-
sub StatusOptions {
my ($cache)=@_;
@@ -965,6 +1236,9 @@
$Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>';
$Ptr .= '<b>2nd Criterion</b> for Sorting the Students: ';
$Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>';
+ $Ptr .= '</td>';
+ $Ptr .= '<td><b>Disc.</b></td>';
+ $Ptr .= '<td>Number of Students had at least one discussion.';
$Ptr .= '</td></tr></table>';
return $Ptr;
@@ -974,55 +1248,50 @@
#---- Problem Statistics Graph Web Page --------------------------------------
+# ------------------------------------------- Prepare data for Graphical chart
+
sub GetGraphData {
- my ($whichGraph, $courseID)=@_;
- my $Col=0;
- my $graphTitle='';
+ my $ylab = shift;
+ my $Col;
my $data='';
my $count = 0;
my $Max = 0;
- my $graphData='Graph data does not exist.';
+ my $cid=$ENV{'request.course.id'};
my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$courseID\_graph.db";
- if(-e $GraphDB) {
- if(tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {
- if($whichGraph eq 'DiffGraph') {
- $graphTitle = 'Degree-of-Difficulty';
+ "_$ENV{'user.domain'}_$cid\_graph.db";
+ foreach (keys %GraphDat) {delete $GraphDat{$_};}
+ if (-e "$GraphDB") {
+ if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {
+ if ( $ylab eq 'DoDiff Graph' ) {
+ $ylab = 'Degree-of-Difficulty';
$Col = 0;
- } else {
- $graphTitle = 'Wrong-Percentage';
+ }
+ else {
+ $ylab = 'Wrong-Percentage';
$Col = 1;
}
foreach (sort NumericSort keys %GraphDat) {
my @Temp=split(/\:/,$GraphDat{$_});
my $inf = $Temp[$Col];
- if($Max < $inf) {
- $Max = $inf;
- }
+ if ( $Max < $inf ) {$Max = $inf;}
$data .= $inf.',';
$count++;
}
- if($Max > 1) {
+ if ( $Max > 1 ) {
$Max += (10 - $Max % 10);
$Max = int($Max);
- } else {
- $Max = 1;
- }
+ }
+ else { $Max = 1; }
untie(%GraphDat);
- my $Course = $ENV{'course.'.$courseID.'.description'};
+ my $Course = $ENV{'course.'.$cid.'.description'};
$Course =~ s/\ /"_"/eg;
- $graphData = $Course.'&'.'Problems'.'&'.$graphTitle.'&'.$Max.'&';
- $graphData .= $count.'&'.$data;
- } else {
- $graphData = "Unable to tie hash to db file";
+ $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.$Max.'&'.$count.'&'.$data;
+ }
+ else {
+ $r->print("Unable to tie hash to db file");
}
}
-
- return $graphData;
}
-
-#---- END Problem Statistics Graph Web Page ----------------------------------
-
#---- Problem Analysis Web Page ----------------------------------------------
sub IntervalOptions {
@@ -1581,7 +1850,6 @@
undef %CachData;
undef %GraphDat;
undef %ConceptData;
- undef $Pos;
undef $GData;
}
@@ -1613,16 +1881,18 @@
$r->print(&ProblemStatisticsLegend());
# my $discriminantFactor;
-# my $list;
+# my @list=();
# foreach (@$students) {
-# ($discriminantFactor, $list) = &ExtractStudentData($_);
+# ($discriminantFactor, $list) = &ExtractStudentData(\%cache, $_,
+# \@list);
# }
# my ($upper, $lower) = &Discriminant($discriminantFactor);
# 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");
-# &BuildStatisticsTable(\%cache, $discriminantFactor, $list, \%Header);
+# 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc.");
+# &BuildStatisticsTable(\%cache, $discriminantFactor, \@list, \%Header,
+# $students);
$r->print('</form>');
--minaeibi1027102654--