version 1.32, 2002/09/02 20:21:43
|
version 1.36, 2002/11/12 19:52:46
|
Line 30
|
Line 30
|
# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 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 |
# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei |
# YEAR=2002 |
# 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 |
# 1/22,2/1,2/6,2/25,3/2,3/26,4/7,5/6 Behrouz Minaei |
# 5/12,5/14,5/15,5/19,5/26,7/16,7/25,7/29,8/5 Behrouz Minaei |
# 5/12,5/26,7/16,7/29,8/5,10/31 Behrouz Minaei |
# |
# |
### |
### |
|
|
package Apache::lonproblemstatistics; |
package Apache::lonproblemstatistics; |
|
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet(); |
Line 43 use Apache::lonhtmlcommon;
|
Line 43 use Apache::lonhtmlcommon;
|
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use GDBM_File; |
use GDBM_File; |
|
|
my $jr; |
|
|
|
sub InitializeProblemStatistics { |
sub InitializeProblemStatistics { |
my ($cacheDB, $students, $courseID, $c, $r)=@_; |
my ($cacheDB, $students, $courseID, $c, $r)=@_; |
my %cache; |
my %cache; |
|
|
$jr = $r; |
|
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database1.'); |
$r->print('Unable to tie database1.'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
Line 84 sub InitializeProblemStatistics {
|
Line 81 sub InitializeProblemStatistics {
|
my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ? |
my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ? |
$cache{'StatisticsLastStatus'} : 'Nothing'; |
$cache{'StatisticsLastStatus'} : 'Nothing'; |
my $whichStudents = join(':::',sort(@$students)); |
my $whichStudents = join(':::',sort(@$students)); |
if(!defined($cache{'StatisticsCached'}) || |
if(!defined($cache{'StatisticsCached'}) || |
$lastStatus ne $cache{'Status'} || |
$lastStatus ne $cache{'Status'} || |
$whichStudents ne $cache{'StatisticsWhichStudents'}) { |
$whichStudents ne $cache{'StatisticsWhichStudents'}) { |
$isNotCached = 1; |
$isNotCached = 1; |
Line 109 sub InitializeProblemStatistics {
|
Line 106 sub InitializeProblemStatistics {
|
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, |
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, |
'true', |
'true', |
$cacheDB, |
$cacheDB, |
'true', |
'true', |
'true', |
'true', |
$courseID, |
$courseID, |
$r, $c); |
$r, $c); |
Line 147 sub InitializeProblemStatistics {
|
Line 144 sub InitializeProblemStatistics {
|
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
} |
|
|
my $orderedProblems = &SortProblems(\%cache, |
my $orderedProblems = &SortProblems(\%cache, |
$cache{'ProblemStatisticsSort'}, |
$cache{'ProblemStatisticsSort'}, |
$cache{'SortProblems'}, |
$cache{'SortProblems'}, |
$cache{'ProblemStatisticsAscend'}); |
$cache{'ProblemStatisticsAscend'}); |
Line 179 sub BuildProblemStatisticsPage {
|
Line 176 sub BuildProblemStatisticsPage {
|
$Ptr .= '<tr><td align="right"><b>Sorting Type:</b></td>'."\n"; |
$Ptr .= '<tr><td align="right"><b>Sorting Type:</b></td>'."\n"; |
$Ptr .= '<td align="left">'."\n"; |
$Ptr .= '<td align="left">'."\n"; |
$Ptr .= &Apache::lonhtmlcommon::AscendOrderOptions( |
$Ptr .= &Apache::lonhtmlcommon::AscendOrderOptions( |
$cache{'ProblemStatisticsAscend'}, |
$cache{'ProblemStatisticsAscend'}, |
'ProblemStatistics', |
'ProblemStatistics', |
'Statistics'); |
'Statistics'); |
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= '</td></tr>'."\n"; |
Line 192 sub BuildProblemStatisticsPage {
|
Line 189 sub BuildProblemStatisticsPage {
|
\@sectionsSelected, |
\@sectionsSelected, |
'Statistics'); |
'Statistics'); |
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'}, |
$Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'}, |
$cache{'DisplayLegend'}, |
$cache{'DisplayLegend'}, |
$cache{'SortProblems'}); |
$cache{'SortProblems'}); |
$Ptr .= '</table>'; |
$Ptr .= '</table>'; |
Line 213 sub BuildProblemStatisticsPage {
|
Line 210 sub BuildProblemStatisticsPage {
|
$r->print('Unable to tie database.6'); |
$r->print('Unable to tie database.6'); |
return; |
return; |
} |
} |
&BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, |
&BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, |
$cache{'SortProblems'}, $orderedProblems, |
$cache{'SortProblems'}, $orderedProblems, |
\@Header, $r, $color); |
\@Header, $r, $color); |
untie(%cache); |
untie(%cache); |
|
|
Line 224 sub BuildProblemStatisticsPage {
|
Line 221 sub BuildProblemStatisticsPage {
|
sub BuildGraphicChart { |
sub BuildGraphicChart { |
my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_; |
my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_; |
my %cache; |
my %cache; |
my $max = 0; |
my $max; |
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
|
return 'Unable to tie database.7'; |
|
} |
|
|
my ($result, undef) = |
my $title = ''; |
|
if($graph eq 'DoDiffGraph') { |
|
$title = 'Degree-of-Difficulty'; |
|
} else { |
|
$title = 'Wrong-Percentage'; |
|
} |
|
|
|
my $currentSequence = -1; |
|
my $sortProblems = 'Sort Within Sequence'; |
|
|
|
my ($result, $orderedProblems) = |
&InitializeProblemStatistics($cacheDB, $students, $courseID, $c, $r); |
&InitializeProblemStatistics($cacheDB, $students, $courseID, $c, $r); |
if($result ne 'OK') { |
if($result ne 'OK') { |
return; |
return; |
} |
} |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
|
return 'Unable to tie database.7'; |
|
} |
|
|
|
my @problems = split(':::', $cache{'problemList'}); |
|
my @values = (); |
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 != -1) { |
|
&DrawGraph(\@values,$courseDescription,$title,$max,$r); |
|
} |
|
if($sortProblems eq 'Sort Within Sequence') { |
|
$r->print('<br><b>'.$cache{$sequence.':title'}.'</b>'."\n"); |
|
} |
|
|
|
$currentSequence = $sequence; |
|
@values = (); |
|
$max=0; |
|
} |
my $data = 0; |
my $data = 0; |
if($graph eq 'DoDiffGraph') { |
if($graph eq 'DoDiffGraph') { |
$data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}), |
$data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}), |
Line 252 sub BuildGraphicChart {
|
Line 278 sub BuildGraphicChart {
|
} |
} |
untie(%cache); |
untie(%cache); |
|
|
my $sendValues = join(',', @values); |
&DrawGraph(\@values,$courseDescription,$title,$max,$r); |
my $sendCount = scalar(@values); |
|
|
|
my $title = ''; |
return; |
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"); |
|
|
|
return; |
sub DrawGraph { |
|
my ($values,$courseDescription,$title,$Max,$r)=@_; |
|
my $sendValues = join(',', @$values); |
|
my $sendCount = scalar(@$values); |
|
$r->print("<br>The Maximum Value is: $Max"); |
|
if ( $Max > 1 ) { |
|
if ($Max % 10) { |
|
if ( int($Max) < $Max ) { |
|
$Max++; |
|
$Max = int($Max); |
|
} |
|
} |
|
#(10 - $Max % 10); |
|
} else { $Max = 1; } |
|
|
|
# my @GData = ($courseDescription, 'Problem_number', |
|
# $title, $Max, $sendCount, $sendValues); |
|
my @GData = ('','Problem_number',$title,$Max,$sendCount,$sendValues); |
|
|
|
# $r->print('</form>'."\n"); |
|
$r->print('<br>'."\n"); |
|
$r->print('<IMG src="/cgi-bin/graph.gif?'. |
|
(join('&', @GData)).'" border="1" />'); |
|
# $r->print('<form>'."\n"); |
|
$r->print('<br>'."\n"); |
} |
} |
|
|
#---- Problem Statistics Web Page --------------------------------------- |
#---- Problem Statistics Web Page --------------------------------------- |
Line 287 sub CreateProblemStatisticsTableHeading
|
Line 326 sub CreateProblemStatisticsTableHeading
|
$Str .= '&ProblemStatisticsSort='; |
$Str .= '&ProblemStatisticsSort='; |
$Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n"; |
$Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n"; |
} |
} |
$Str .= "\n".'</tr>'."\n"; |
$Str .= "\n".'</tr>'."\n"; |
|
|
return $Str; |
return $Str; |
} |
} |
Line 305 sub BuildStatisticsTable {
|
Line 344 sub BuildStatisticsTable {
|
next; |
next; |
} |
} |
|
|
if($currentSequence == -1 || |
if($currentSequence == -1 || |
($sortProblems eq 'Sort Within Sequence' && |
($sortProblems eq 'Sort Within Sequence' && |
$currentSequence != $sequence)) { |
$currentSequence != $sequence)) { |
if($displayFormat ne 'Display CSV Format') { |
if($displayFormat ne 'Display CSV Format') { |
if($currentSequence ne -1) { |
if($currentSequence ne -1) { |
Line 435 sub ProblemStatisticsButtons {
|
Line 474 sub ProblemStatisticsButtons {
|
|
|
my $Ptr = '<tr><td></td><td align="left">'; |
my $Ptr = '<tr><td></td><td align="left">'; |
$Ptr .= '<input type="submit" name="DoDiffGraph" '; |
$Ptr .= '<input type="submit" name="DoDiffGraph" '; |
$Ptr .= 'value="Degree of Difficulty" />'."\n"; |
$Ptr .= 'value="Plot Degree of Difficulty" />'."\n"; |
$Ptr .= '</td><td align="left">'; |
$Ptr .= '</td><td align="left">'; |
$Ptr .= '<input type="submit" name="PercentWrongGraph" '; |
$Ptr .= '<input type="submit" name="PercentWrongGraph" '; |
$Ptr .= 'value="Percent Wrong" />'."\n"; |
$Ptr .= 'value="Plot Percent Wrong" />'."\n"; |
$Ptr .= '</td></tr><tr><td></td><td>'."\n"; |
$Ptr .= '</td></tr><tr><td></td><td>'."\n"; |
$Ptr .= '<input type="submit" name="SortProblems" '; |
$Ptr .= '<input type="submit" name="SortProblems" '; |
if($sortProblems eq 'Sort All Problems') { |
if($sortProblems eq 'Sort All Problems') { |
Line 571 sub ExtractStudentData {
|
Line 610 sub ExtractStudentData {
|
} |
} |
|
|
my $studentTriesJoined = join(':::', @studentTries); |
my $studentTriesJoined = join(':::', @studentTries); |
$problemData{$id.':sequenceTitle'} = |
$problemData{$id.':sequenceTitle'} = |
$cache->{$sequence.':title'}; |
$cache->{$sequence.':title'}; |
$problemData{$id.':studentCount'} = $studentCount; |
$problemData{$id.':studentCount'} = $studentCount; |
$problemData{$id.':totalTries'} = $totalTries; |
$problemData{$id.':totalTries'} = $totalTries; |
Line 623 sub SortDivideByTries {
|
Line 662 sub SortDivideByTries {
|
my @orderedData = sort { ($data->{$a.':totalTries'}) ? |
my @orderedData = sort { ($data->{$a.':totalTries'}) ? |
($data->{$a.$sortOn}/$data->{$a.':totalTries'}):0 |
($data->{$a.$sortOn}/$data->{$a.':totalTries'}):0 |
<=> |
<=> |
($data->{$b.':totalTries'}) ? |
($data->{$b.':totalTries'}) ? |
($data->{$b.$sortOn}/$data->{$b.':totalTries'}):0 |
($data->{$b.$sortOn}/$data->{$b.':totalTries'}):0 |
} @$toSort; |
} @$toSort; |
|
|