) {
+ 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 {
+# $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("
Using $file");
@@ -75,11 +261,11 @@ sub Activity {
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("
$Count) ".localtime($date).": $who --> $res");
# if ($post) {
# $Count++;
@@ -88,7 +274,7 @@ sub Activity {
# }
$r->rflush();
}
- ## push (@allaccess,unescape($access));
+ #push (@allaccess,unescape($access));
#print $machine;
}
}
@@ -105,29 +291,25 @@ sub Activity {
# }
}
-#---- 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{$_}.'
');
-# }
-
my $parts='';
foreach my $elm (@{$Answer{"parts"}}) {
$parts.="$elm,";
@@ -150,32 +332,34 @@ sub InitAnalysis {
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 @@ sub ShowOpGraph {
$title =~ s/\ /"_"/eg;
$r->print('
'.$uri.'');
$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('
');
- 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 @@ sub ShowOpGraph {
$r->print("
Here you can see the Problem:
$Answ");
}
+
sub DrawTable {
my $k=shift;
my $Max=0;
@@ -266,38 +451,35 @@ sub DrawTable {
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('');
}
@@ -312,7 +494,6 @@ sub Decide {
$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 @@ sub OpStatus {
}
}
+
#---- END Analyze Web Page ----------------------------------------------
#---- Problem Statistics Web Page ---------------------------------------
@@ -398,6 +580,7 @@ sub ProcessDiscriminant {
}
+
#------- Creating Discimination factor
sub Discriminant {
my ($discriminantFactor)=@_;
@@ -430,10 +613,12 @@ sub Discriminant {
return (\%DisUp, \%DisLow);
}
+
sub NumericSort {
$a <=> $b;
}
+
sub CreateProblemStatisticsTableHeading {
my ($displayFormat,$sequenceSource,$sequenceTitle,$headings)=@_;
if($displayFormat eq 'Display CSV Format') {
@@ -465,15 +650,26 @@ sub CloseTable {
$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 @@ sub ExtractStudentData {
my $tries=0;
my $time=0;
my $awarded=0;
+ $Discussed=0;
my $code='U';
$awarded = $cache->{$name.
@@ -571,6 +768,11 @@ sub ExtractStudentData {
$ptr .= "*(part $_)";
$Dis .= '&';
}
+
+ my ($pr_no,$dod)=split('&',$ptr);
+ my $DoDiff=$DoDiff{$dod};
+# $r->print('
'.$name.'---'.$ptr.'==='.$DoDiff);
+
my $Fac = ($partData{$_.':Tries'}) ?
($partData{$_.':awarded'}/$partData{$_.':tries'}) : 0;
my $DisF;
@@ -579,24 +781,60 @@ sub ExtractStudentData {
} 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('
'.$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 @@ sub MySort {
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('');
+## &LoadDoDiffFile();
+ &LoadDiscussion();
my $p_count = 0;
my $nIndex = 0;
@@ -628,11 +879,16 @@ sub BuildStatisticsTable {
$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 @@ sub BuildStatisticsTable {
my $Incorrect = 0;
my $Override = 0;
my $StdNo = 0;
+ my $DiscNo=0;
my @StdLst;
while ( $PrOrd == $lpr[$i] )
{
@@ -652,7 +909,7 @@ sub BuildStatisticsTable {
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 @@ sub BuildStatisticsTable {
$TotalTries.'&'.$MxTries.'&'.$Avg.'&'.
$YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'.
$SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'.
- $Prob;
+ $DiscNo.'&'.$Prob;
$CachData{($p_count-1)}=$join;
+#6666666
+# $r->print('
'.$out.'&'.$DoD);
+# print (OUT $out.'@'.$DoD.'&');
+#6666666
+
$urlres=~/^(\w+)\/(\w+)/;
if ($StdNo) {
&Apache::lonnet::put('resevaldata',\%storestats,$1,$2);
@@ -745,6 +1007,9 @@ sub BuildStatisticsTable {
&CloseTable($cache);
}
&Close_PrgWin();
+#666666
+# close( OUT );
+#666666
}
=pod
@@ -797,12 +1062,15 @@ sub Cache_Statistics {
&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".'
'.
"\n".'"'.($RealIdx+1).'",'.
@@ -819,9 +1087,12 @@ sub TableRow {
"\n".'"'.$SD.'",'.
"\n".'"'.$Sk.'",'.
"\n".'"'.$_D1.'",'.
- "\n".'"'.$_D2.'"';
+ "\n".'"'.$_D2.'"'.
+ "\n".'"'.$DiscNo.'"';
+
$r->print("\n".$Ptr);
- } else {
+ }
+ else{
my $Ptr = "\n".''.
"\n".''.($RealIdx+1).' | '.
# "\n".''.$PrOrd.$Temp.' | '.
@@ -837,12 +1108,12 @@ sub TableRow {
"\n".' '.$SD.' | '.
"\n".' '.$Sk.' | '.
"\n".' '.$_D1.' | '.
- "\n".' '.$_D2.' | ';
+ "\n".' '.$_D2.' | '.
+ "\n".' '.$DiscNo.' | ';
$r->print("\n".$Ptr.'
' );
}
$GraphDat{$RealIdx}=$DoD.':'.$Wrng;
}
-
sub StatusOptions {
my ($cache)=@_;
@@ -965,6 +1236,9 @@ sub ProblemStatisticsLegend {
$Ptr .= 'Sum of Partial Credit Awarded / Total Number of Tries
';
$Ptr .= '2nd Criterion for Sorting the Students: ';
$Ptr .= 'Total number of Correct Answers / Total Number of Tries';
+ $Ptr .= '';
+ $Ptr .= 'Disc. | ';
+ $Ptr .= 'Number of Students had at least one discussion.';
$Ptr .= ' | ';
return $Ptr;
@@ -974,55 +1248,50 @@ sub ProblemStatisticsLegend {
#---- 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 @@ sub initial {
undef %CachData;
undef %GraphDat;
undef %ConceptData;
- undef $Pos;
undef $GData;
}
@@ -1613,16 +1881,18 @@ sub BuildProblemStatisticsPage {
$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('');