[LON-CAPA-cvs] cvs: loncom /interface/statistics lonproblemstatistics.pm
minaeibi
lon-capa-cvs@mail.lon-capa.org
Wed, 30 Oct 2002 18:37:01 -0000
This is a MIME encoded message
--minaeibi1036003021
Content-Type: text/plain
minaeibi Wed Oct 30 13:37:01 2002 EDT
Modified files:
/loncom/interface/statistics lonproblemstatistics.pm
Log:
Worked on build chart graph to fix bug #899
It needs more work.
--minaeibi1036003021
Content-Type: text/plain
Content-Disposition: attachment; filename="minaeibi-20021030133701.txt"
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.33 loncom/interface/statistics/lonproblemstatistics.pm:1.34
--- loncom/interface/statistics/lonproblemstatistics.pm:1.33 Sun Sep 22 13:08:32 2002
+++ loncom/interface/statistics/lonproblemstatistics.pm Wed Oct 30 13:37:00 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemstatistics.pm,v 1.33 2002/09/22 17:08:32 minaeibi Exp $
+# $Id: lonproblemstatistics.pm,v 1.34 2002/10/30 18:37:00 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,7 +84,7 @@
my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?
$cache{'StatisticsLastStatus'} : 'Nothing';
my $whichStudents = join(':::',sort(@$students));
- if(!defined($cache{'StatisticsCached'}) ||
+ if(!defined($cache{'StatisticsCached'}) ||
$lastStatus ne $cache{'Status'} ||
$whichStudents ne $cache{'StatisticsWhichStudents'}) {
$isNotCached = 1;
@@ -109,7 +109,7 @@
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
'true',
$cacheDB,
- 'true',
+ 'true',
'true',
$courseID,
$r, $c);
@@ -147,7 +147,7 @@
return ('ERROR', undef);
}
- my $orderedProblems = &SortProblems(\%cache,
+ my $orderedProblems = &SortProblems(\%cache,
$cache{'ProblemStatisticsSort'},
$cache{'SortProblems'},
$cache{'ProblemStatisticsAscend'});
@@ -179,7 +179,7 @@
$Ptr .= '<tr><td align="right"><b>Sorting Type:</b></td>'."\n";
$Ptr .= '<td align="left">'."\n";
$Ptr .= &Apache::lonhtmlcommon::AscendOrderOptions(
- $cache{'ProblemStatisticsAscend'},
+ $cache{'ProblemStatisticsAscend'},
'ProblemStatistics',
'Statistics');
$Ptr .= '</td></tr>'."\n";
@@ -192,7 +192,7 @@
\@sectionsSelected,
'Statistics');
$Ptr .= '</td></tr>'."\n";
- $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'},
+ $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'},
$cache{'DisplayLegend'},
$cache{'SortProblems'});
$Ptr .= '</table>';
@@ -213,8 +213,8 @@
$r->print('Unable to tie database.6');
return;
}
- &BuildStatisticsTable(\%cache, $cache{'DisplayFormat'},
- $cache{'SortProblems'}, $orderedProblems,
+ &BuildStatisticsTable(\%cache, $cache{'DisplayFormat'},
+ $cache{'SortProblems'}, $orderedProblems,
\@Header, $r, $color);
untie(%cache);
@@ -225,20 +225,76 @@
my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_;
my %cache;
my $max = 0;
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+ return 'Unable to tie database.7';
+ }
+
+# my @problems = split(':::', $cache{'problemList'});
+
+ my $title = '';
+ if($graph eq 'DoDiffGraph') {
+ $title = 'Degree-of-Difficulty';
+ } else {
+ $title = 'Wrong-Percentage';
+ }
- my ($result, undef) =
+
+ # foreach (@problems) {
+ # my $data = 0;
+ # if($graph eq 'DoDiffGraph') {
+ # $data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
+ # } else {
+ # $data = sprintf("%.1f", $cache{$_.':percentWrong'}),
+ # }
+ # if($max < $data) {
+ # $max = $data;
+ # }
+ # push(@values, $data);
+ # }
+
+
+ my $count = 1;
+ my $currentSequence = -1;
+ my $sortProblems = 'Sort Within Sequence';
+
+ my ($result, $orderedProblems) =
&InitializeProblemStatistics($cacheDB, $students, $courseID, $c, $r);
if($result ne 'OK') {
return;
}
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- return 'Unable to tie database.7';
- }
-
- my @problems = split(':::', $cache{'problemList'});
my @values = ();
- foreach (@problems) {
+
+ foreach(@$orderedProblems) {
+ my ($sequence,$problem,$part)=split(':', $_);
+ if($cache{'StatisticsMaps'} ne 'All Maps' &&
+ $cache{'StatisticsMaps'} ne $cache{$sequence.':title'}) {
+ next;
+ }
+
+ if($currentSequence == -1 ||
+ ($sortProblems eq 'Sort Within Sequence' &&
+ $currentSequence != $sequence)) {
+ if($currentSequence ne -1) {
+ #$r->print('<br>finish a graph<br>');
+ }
+ if($sortProblems eq 'Sort Within Sequence') {
+ $r->print('<b>'.$cache{$sequence.':title'}.'</b>');
+ }
+
+ my $sendValues = join(',', @values);
+ my $sendCount = scalar(@values);
+
+ my @GData = ($courseDescription, 'Problems',
+ $title, $max, $sendCount, $sendValues);
+ $r->print('</form>'."\n");
+ $r->print('<IMG src="/cgi-bin/graph.gif?'.
+ (join('&', @GData)).'" border="1" />');
+ $r->print('<form>'."\n");
+ $currentSequence = $sequence;
+ @values = ();
+
+ }
my $data = 0;
if($graph eq 'DoDiffGraph') {
$data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
@@ -249,29 +305,17 @@
$max = $data;
}
push(@values, $data);
- }
- untie(%cache);
-
- my $sendValues = join(',', @values);
- my $sendCount = scalar(@values);
- my $title = '';
- if($graph eq 'DoDiffGraph') {
- $title = 'Degree-of-Difficulty';
- } else {
- $title = 'Wrong-Percentage';
}
- my @GData = ($courseDescription, 'Problems', $title, $max, $sendCount,
- $sendValues);
- $r->print('</form>'."\n");
- $r->print('<IMG src="/cgi-bin/graph.gif?'.(join('&', @GData)).
- '" border="1" />');
- $r->print('<form>'."\n");
+#$r->print('<br>');
+
+ untie(%cache);
return;
}
+
#---- Problem Statistics Web Page ---------------------------------------
sub CreateProblemStatisticsTableHeading {
@@ -287,7 +331,7 @@
$Str .= '&ProblemStatisticsSort=';
$Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n";
}
- $Str .= "\n".'</tr>'."\n";
+ $Str .= "\n".'</tr>'."\n";
return $Str;
}
@@ -305,8 +349,8 @@
next;
}
- if($currentSequence == -1 ||
- ($sortProblems eq 'Sort Within Sequence' &&
+ if($currentSequence == -1 ||
+ ($sortProblems eq 'Sort Within Sequence' &&
$currentSequence != $sequence)) {
if($displayFormat ne 'Display CSV Format') {
if($currentSequence ne -1) {
@@ -571,7 +615,7 @@
}
my $studentTriesJoined = join(':::', @studentTries);
- $problemData{$id.':sequenceTitle'} =
+ $problemData{$id.':sequenceTitle'} =
$cache->{$sequence.':title'};
$problemData{$id.':studentCount'} = $studentCount;
$problemData{$id.':totalTries'} = $totalTries;
@@ -623,7 +667,7 @@
my @orderedData = sort { ($data->{$a.':totalTries'}) ?
($data->{$a.$sortOn}/$data->{$a.':totalTries'}):0
<=>
- ($data->{$b.':totalTries'}) ?
+ ($data->{$b.':totalTries'}) ?
($data->{$b.$sortOn}/$data->{$b.':totalTries'}):0
} @$toSort;
--minaeibi1036003021--