version 1.27, 2002/08/14 20:42:49
|
version 1.35, 2002/11/01 22:09:39
|
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 |
# |
# |
### |
### |
|
|
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 database.'); |
$r->print('Unable to tie database1.'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
} |
|
|
Line 80 sub InitializeProblemStatistics {
|
Line 77 sub InitializeProblemStatistics {
|
} |
} |
} |
} |
|
|
|
my $isNotCached = 0; |
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'}) { |
if(defined($cache{'StatisticsCached'})) { |
$isNotCached = 1; |
untie(%cache); |
} |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
|
$r->print('Unable to tie database.'); |
untie(%cache); |
return ('ERROR', undef); |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
} |
$r->print('Unable to tie database.2'); |
my @statkeys = split(':::', $cache{'StatisticsKeys'}); |
return ('ERROR', undef); |
delete $cache{'StatisticsKeys'}; |
} |
delete $cache{'StatisticsCached'}; |
if($isNotCached && defined($cache{'StatisticsCached'})) { |
foreach(@statkeys) { |
my @statkeys = split(':::', $cache{'StatisticsKeys'}); |
delete $cache{$_}; |
delete $cache{'StatisticsKeys'}; |
} |
delete $cache{'StatisticsCached'}; |
|
foreach(@statkeys) { |
|
delete $cache{$_}; |
} |
} |
untie(%cache); |
} |
|
|
|
untie(%cache); |
|
if($isNotCached) { |
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, |
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, |
'true', |
'true', |
$cacheDB, |
$cacheDB, |
'true', |
'true', |
'true', |
'true', |
$courseID, |
$courseID, |
$r, $c); |
$r, $c); |
if($c->aborted()) { return ('ERROR', undef); } |
} |
|
if($c->aborted()) { return ('ERROR', undef); } |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.3'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
} |
my ($problemData) = &ExtractStudentData(\%cache, $students); |
my $problemData; |
&CalculateStatistics($problemData, \%cache); |
if($isNotCached) { |
untie(%cache); |
($problemData) = &ExtractStudentData(\%cache, $students); |
|
&CalculateStatistics($problemData, \%cache, $courseID); |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
} |
$r->print('Unable to tie database.'); |
untie(%cache); |
return ('ERROR', undef); |
|
} |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
|
$r->print('Unable to tie database.4'); |
|
return ('ERROR', undef); |
|
} |
|
if($isNotCached) { |
foreach(keys(%$problemData)) { |
foreach(keys(%$problemData)) { |
$cache{$_} = $problemData->{$_}; |
$cache{$_} = $problemData->{$_}; |
} |
} |
Line 128 sub InitializeProblemStatistics {
|
Line 136 sub InitializeProblemStatistics {
|
$cache{'StatisticsCached'} = 'true'; |
$cache{'StatisticsCached'} = 'true'; |
$cache{'StatisticsLastStatus'} = $cache{'Status'}; |
$cache{'StatisticsLastStatus'} = $cache{'Status'}; |
$cache{'StatisticsWhichStudents'} = $whichStudents; |
$cache{'StatisticsWhichStudents'} = $whichStudents; |
untie(%cache); |
} |
|
untie(%cache); |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.5'); |
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'}); |
|
untie(%cache); |
|
|
return ('OK', $orderedProblems); |
return ('OK', $orderedProblems); |
} |
} |
|
|
Line 153 sub BuildProblemStatisticsPage {
|
Line 163 sub BuildProblemStatisticsPage {
|
my %cache; |
my %cache; |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.6'); |
return; |
return; |
} |
} |
my $Ptr = ''; |
my $Ptr = ''; |
$Ptr .= '<table border="0" cellspacing="5"><tbody>'; |
$Ptr .= '<table border="0" cellspacing="5"><tbody>'; |
$Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n"; |
$Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n"; |
$Ptr .= '<td align="left">'; |
$Ptr .= '<td align="left">'; |
$Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics', |
$Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'Statistics', |
'Statistics'); |
'Statistics'); |
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= '</td></tr>'."\n"; |
$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"; |
$Ptr .= '<tr><td align="right"><b>Select Sections</b>'; |
$Ptr .= '<tr><td align="right"><b>Select Sections</b>'; |
$Ptr .= '</td>'."\n"; |
$Ptr .= '</td>'."\n"; |
Line 179 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 197 sub BuildProblemStatisticsPage {
|
Line 207 sub BuildProblemStatisticsPage {
|
} |
} |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$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 212 sub BuildGraphicChart {
|
Line 222 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 = 0; |
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
|
return 'Unable to tie database.7'; |
|
} |
|
|
|
my $title = ''; |
|
if($graph eq 'DoDiffGraph') { |
|
$title = 'Degree-of-Difficulty'; |
|
} else { |
|
$title = 'Wrong-Percentage'; |
|
} |
|
|
my ($result, undef) = |
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.'; |
|
} |
|
|
|
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('<b>'.$cache{$sequence.':title'}.'</b>'); |
|
} |
|
|
|
$currentSequence = $sequence; |
|
@values = (); |
|
} |
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 239 sub BuildGraphicChart {
|
Line 277 sub BuildGraphicChart {
|
} |
} |
untie(%cache); |
untie(%cache); |
|
|
my $sendValues = join(',', @values); |
&DrawGraph(\@values,$courseDescription,$title,$max,$r); |
my $sendCount = scalar(@values); |
|
|
return; |
|
} |
|
|
my $title = ''; |
|
if($graph eq 'DoDiffGraph') { |
|
$title = 'Degree-of-Difficulty'; |
|
} else { |
|
$title = 'Wrong-Percentage'; |
|
} |
|
my @GData = ($courseDescription, 'Problems', $title, $max, $sendCount, |
|
$sendValues); |
|
|
|
|
sub DrawGraph { |
|
my ($values,$courseDescription,$title,$Max,$r)=@_; |
|
my $sendValues = join(',', @$values); |
|
my $sendCount = scalar(@$values); |
|
|
|
if ( $Max > 1 ) { |
|
if ($Max % 10) { |
|
$Max++; |
|
} |
|
#(10 - $Max % 10); |
|
$Max = int($Max); |
|
} else { $Max = 1; } |
|
|
|
my @GData = ($courseDescription, 'Problem_number', |
|
$title, $Max, $sendCount, $sendValues); |
$r->print('</form>'."\n"); |
$r->print('</form>'."\n"); |
$r->print('<IMG src="/cgi-bin/graph.gif?'.(join('&', @GData)). |
$r->print('<IMG src="/cgi-bin/graph.gif?'. |
'" border="1" />'); |
(join('&', @GData)).'" border="1" />'); |
$r->print('<form>'."\n"); |
$r->print('<form>'."\n"); |
|
|
return; |
|
} |
} |
|
|
#---- Problem Statistics Web Page --------------------------------------- |
#---- Problem Statistics Web Page --------------------------------------- |
Line 274 sub CreateProblemStatisticsTableHeading
|
Line 319 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 286 sub BuildStatisticsTable {
|
Line 331 sub BuildStatisticsTable {
|
my $count = 1; |
my $count = 1; |
my $currentSequence = -1; |
my $currentSequence = -1; |
foreach(@$orderedProblems) { |
foreach(@$orderedProblems) { |
my ($sequence,$problem,$part)=split(':', $_); |
my ($sequence,$problem,$part)=split(':', $_); |
if($cache->{'StatisticsMaps'} ne 'All Maps' && |
if($cache->{'StatisticsMaps'} ne 'All Maps' && |
$cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) { |
$cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) { |
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 422 sub ProblemStatisticsButtons {
|
Line 467 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 494 sub ProblemStatisticsLegend {
|
Line 539 sub ProblemStatisticsLegend {
|
$Ptr .= '<b>Dis.F.</b></td>'; |
$Ptr .= '<b>Dis.F.</b></td>'; |
$Ptr .= '<td>Discrimination Factor: A Standard for evaluating the '; |
$Ptr .= '<td>Discrimination Factor: A Standard for evaluating the '; |
$Ptr .= 'problem according to a Criterion<br>'; |
$Ptr .= 'problem according to a Criterion<br>'; |
$Ptr .= '<b>[Applied Criterion in %27 Upper Students - '; |
$Ptr .= '<b>[Criterion to group students into %27 Upper Students - '; |
$Ptr .= 'Applied the same Criterion in %27 Lower Students]</b><br>'; |
$Ptr .= 'and %27 Lower Students]</b><br>'; |
$Ptr .= '<b>1st Criterion</b> for Sorting the Students: '; |
$Ptr .= '<b>1st Criterion</b> for Sorting the Students: '; |
$Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>'; |
$Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>'; |
$Ptr .= '<b>2nd Criterion</b> for Sorting the Students: '; |
$Ptr .= '<b>2nd Criterion</b> for Sorting the Students: '; |
Line 558 sub ExtractStudentData {
|
Line 603 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 610 sub SortDivideByTries {
|
Line 655 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; |
|
|
Line 686 sub SortProblems {
|
Line 731 sub SortProblems {
|
} |
} |
|
|
sub CalculateStatistics { |
sub CalculateStatistics { |
my ($data, $cache)=@_; |
my ($data, $cache, $courseID)=@_; |
|
|
my @problems = split(':::', $data->{'problemList'}); |
my @problems = split(':::', $data->{'problemList'}); |
foreach(@problems) { |
foreach(@problems) { |
Line 784 sub CalculateStatistics {
|
Line 829 sub CalculateStatistics {
|
|
|
my $df2 = $upper2Sum - $lower2Sum; |
my $df2 = $upper2Sum - $lower2Sum; |
$data->{$_.':discriminationFactor2'} = sprintf("%.2f", $df2); |
$data->{$_.':discriminationFactor2'} = sprintf("%.2f", $df2); |
|
|
|
my %storestats; |
|
my $Average = ($data->{$_.':studentCount'}) ? |
|
$data->{$_.':totalTries'}/$data->{$_.':studentCount'} : 0; |
|
$storestats{$courseID.'___'.$cache->{$sequence.':source'}. |
|
'___timestamp'}=time; |
|
$storestats{$courseID.'___'.$cache->{$sequence.':source'}. |
|
'___stdno'}=$data->{$_.':studentCount'}; |
|
$storestats{$courseID.'___'.$cache->{$sequence.':source'}. |
|
'___avetries'}=$Average; |
|
$storestats{$courseID.'___'.$cache->{$sequence.':source'}. |
|
'___difficulty'}=$data->{$_.':degreeOfDifficulty'}; |
|
$cache->{$sequence.':source'} =~ /^(\w+)\/(\w+)/; |
|
if($data->{$_.':studentCount'}) { |
|
&Apache::lonnet::put('nohist_resevaldata',\%storestats,$1,$2); |
|
} |
} |
} |
|
|
return; |
return; |