--- loncom/interface/statistics/lonstudentassessment.pm 2003/01/03 23:54:05 1.24 +++ loncom/interface/statistics/lonstudentassessment.pm 2003/01/13 01:34:11 1.27 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstudentassessment.pm,v 1.24 2003/01/03 23:54:05 minaeibi Exp $ +# $Id: lonstudentassessment.pm,v 1.27 2003/01/13 01:34:11 minaeibi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,8 @@ # 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,7/16,12/24 Behrouz Minaei -# +# YEAR=2003 +# 1/11 Behrouz Minaei ### package Apache::lonstudentassessment; @@ -41,12 +42,10 @@ use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; -#my $jr; sub BuildStudentAssessmentPage { my ($cacheDB,$students,$courseID,$formName,$headings,$spacing, $studentInformation,$r,$c)=@_; -# $jr = $r; my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $r->print('Unable to tie database.'); @@ -135,11 +134,11 @@ sub BuildStudentAssessmentPage { } $Count++; my $out = ''; -# $out .= sprintf("%3d", $Count); + $out .= sprintf("%3d) ", $Count); if($Count % 2) { $out .= ''; } else { - $out .= ''; + $out .= ''; } my $displayString = $out.'DISPLAYDATA'.$spacing; $r->print(&Apache::lonhtmlcommon::FormatStudentInformation( @@ -173,24 +172,21 @@ sub BuildStudentAssessmentPage { untie(%cache); } } - - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { - $r->print(&StudentAverageTotal(\%cache, $students, $sequenceKeys)); - untie(%cache); - } - $r->print(''."\n"); + $r->print(''."\n"); if($selected == 0) { $Str .= '

WARNING: '; - $Str .= 'Please select a student

'; + $Str .= 'No Students enrolled OR Please select a student'; $r->print($Str); + } else { + if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $r->print(&StudentAverageTotal(\%cache, $students, $sequenceKeys)); + untie(%cache); + } } - return; } - - #---- Student Assessment Web Page -------------------------------------------- sub CreateInterface { @@ -250,14 +246,16 @@ sub CreateTableHeadings { # my $Str = '     '; my $Str = ''; $Str .= ''."\n"; - $Str .= ''."\n"; + $Str .= ''."\n"; $Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings, $sequenceKeys); $Str .= ''."\n"; $Str .= ''."\n"; - my $displayString = ''."\n"; $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache, @@ -425,9 +423,15 @@ sub StudentAverageTotal { $ProblemsSolved += $cache->{$name.':problemsSolved'}; $TotalProblems += $cache->{$name.':totalProblems'}; } - $ProblemsSolved /= $StudentCount; - $TotalProblems /= $StudentCount; - + if ($StudentCount) { + $ProblemsSolved = sprintf( "%.2f", + $ProblemsSolved/$StudentCount); + $TotalProblems /= $StudentCount; + } else { + $ProblemsSolved = 0; + $TotalProblems = 0; + } + $Str .= '
     
'."\n"; $Str .= ''."\n"; @@ -446,7 +450,12 @@ sub StudentAverageTotal { #my @problems=split(':', $cache->{$S.':problems'}); #my $pCount=scalar @problems; my $pCount=MaxSeqPr($cache,@$students[0],$S); - my $crr=sprintf( "%.2f", $Correct{$S}/$StudentCount ); + my $crr; + if ($StudentCount) { + $crr=sprintf( "%.2f", $Correct{$S}/$StudentCount ); + } else { + $crr="0.00"; + } $Str .= '
Students Count'. $StudentCount.'
'.$title. ''.$pCount. ''.$crr.