--- loncom/interface/lonstatistics.pm 2003/05/27 14:51:24 1.71 +++ loncom/interface/lonstatistics.pm 2003/10/03 15:40:47 1.78.2.2 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstatistics.pm,v 1.71 2003/05/27 14:51:24 matthew Exp $ +# $Id: lonstatistics.pm,v 1.78.2.2 2003/10/03 15:40:47 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -300,9 +300,10 @@ sub PrepareClasslist { @Students = @TmpStudents; # # Now deal with that current student thing.... - if (exists($ENV{'form.StudentAssessmentStudent'})) { + $curr_student = undef; + if (exists($ENV{'form.SelectedStudent'})) { my ($current_uname,$current_dom) = - split(':',$ENV{'form.StudentAssessmentStudent'}); + split(':',$ENV{'form.SelectedStudent'}); my $i; for ($i = 0; $i<=$#Students; $i++) { next if (($Students[$i]->{'username'} ne $current_uname) || @@ -310,15 +311,17 @@ sub PrepareClasslist { $curr_student = $Students[$i]; last; # If we get here, we have our student. } - if ($i == 0) { - $prev_student = 'none'; - } else { - $prev_student = $Students[$i-1]; - } - if ($i == $#Students) { - $next_student = 'none'; - } else { - $next_student = $Students[$i+1]; + if (defined($curr_student)) { + if ($i == 0) { + $prev_student = undef; + } else { + $prev_student = $Students[$i-1]; + } + if ($i == $#Students) { + $next_student = undef; + } else { + $next_student = $Students[$i+1]; + } } } # @@ -329,7 +332,7 @@ sub PrepareClasslist { @SelectedStudentData = ($ENV{'form.StudentData'}); } } else { - @SelectedStudentData = ('fullname'); + @SelectedStudentData = ('username'); } foreach (@SelectedStudentData) { if ($_ eq 'all') { @@ -377,11 +380,7 @@ selected student. ####################################################### ####################################################### sub current_student { - if (defined($curr_student)) { - return $curr_student; - } else { - return 'All Students'; - } + return $curr_student; } ####################################################### @@ -399,11 +398,7 @@ in the list of students. Or something. ####################################################### ####################################################### sub previous_student { - if (defined($prev_student)) { - return $prev_student; - } else { - return 'No Student Selected'; - } + return $prev_student; } ####################################################### @@ -421,11 +416,7 @@ to be viewed. ####################################################### ####################################################### sub next_student { - if (defined($next_student)) { - return $next_student; - } else { - return 'No Student Selected'; - } + return $next_student; } ####################################################### @@ -528,10 +519,8 @@ sub PrepareCourseData { my $name_length = length($seq->{'title'}); my $num_parts = $seq->{'num_assess_parts'}; # - # The number of columns needed for the summation text: - # " 1/5" = 1+3 columns, " 10/99" = 1+5 columns - my $sum_length = 1+1+2*(length($num_parts)); - my $num_col = $num_parts+$sum_length; + # Use 3 digits for each the sum and total, which means 7 total... + my $num_col = $num_parts+7; if ($num_col < $name_length) { $num_col = $name_length; } @@ -816,6 +805,46 @@ sub DisplayClasslist { my @Fields = ('fullname','username','domain','id','section'); # my $Str=''; + if (! @Students) { + if ($SelectedSections[0] eq 'all') { + if (lc($ENV{'form.Status'}) eq 'any') { + $Str .= '

There are no students in the course.

'; + } elsif (lc($ENV{'form.Status'}) eq 'active') { + $Str .= '

There are no currently enrolled students in '. + 'the course.

'; + } elsif (lc($ENV{'form.Status'}) eq 'expired') { + $Str .= '

There are no previously enrolled '. + 'students in the course.

'; + } + } else { + my $sections; + if (@SelectedSections == 1) { + $sections = 'section '.$SelectedSections[0]; + } elsif (@SelectedSections > 2) { + $sections = 'sections '.join(', ',@SelectedSections); + $sections =~ s/, ([^,])*$/, and $1/; + } else { + $sections = 'sections '.join(' and ',@SelectedSections); + } + if (lc($ENV{'form.Status'}) eq 'any') { + $Str .= '

There are no students in '.$sections.'.

'; + } elsif (lc($ENV{'form.Status'}) eq 'active') { + $Str .= '

There are no currently enrolled students '. + 'in '.$sections.'.

'; + } elsif (lc($ENV{'form.Status'}) eq 'expired') { + $Str .= '

There are no previously enrolled students '. + 'in '.$sections.'.

'; + } + } + $Str.= ''. + 'Return to the chart.'; + $r->print($Str); + $r->rflush(); + return; + } + + # "Click" is asinine but it is probably not my place to change the world. + $Str .= '

Click on a students name or username to view their chart

'; $Str .= '
'."\n"; $Str .= ''."\n"; foreach my $field (@Fields) { @@ -836,10 +865,11 @@ sub DisplayClasslist { # foreach my $field (@Fields) { $Str .= '
'; - if ($field eq 'fullname') { + if ($field eq 'fullname' || $field eq 'username') { $Str .= ''; $Str .= $student->{$field}.' '; $Str .= ''; @@ -865,32 +895,27 @@ sub CreateMainMenu { # my $Str = ''; # - $Str .= ''."\n"; - $Str .= ''."\n"; - $Str .= ''."\n"; - $Str .= ''."\n"; - $Str .= ''."\n"; - # - $Str .= '\n"; - $Str .= '\n"; - # - $Str .= ''."\n"; - # - $Str .= '
Select a Report
'. - ''. - "'. - ''. - "'; - $Str .= '
'."\n"; - $Str .= '
'."\n"; + $Str = ''; +# $Str .= ''."\n"; +# $Str .= ''."\n"; +# $Str .= ''."\n"; +# # +# $Str .= ''; +# $Str .= '\n"; +# $Str .= '
Report:'; +# $Str .= ''.(' 'x30).''. +# ''. +# "
'."\n"; +# $Str .= '
'."\n"; # return $Str; } @@ -901,6 +926,10 @@ sub handler { my $r=shift; my $c = $r->connection(); # + &Apache::loncoursedata::clear_internal_caches(); + # + &Apache::loncoursedata::clear_internal_caches(); + # # Check for overloading my $loaderror=&Apache::lonnet::overloaderror($r); if ($loaderror) { return $loaderror; } @@ -940,7 +969,7 @@ sub handler { # Extract form elements from query string &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['sort','reportSelected', - 'StudentAssessmentStudent']); + 'SelectedStudent']); if (! exists($ENV{'form.reportSelected'})) { $ENV{'form.reportSelected'} = 'student_assessment'; } @@ -982,8 +1011,8 @@ END my %reports = ('classlist' => 'Class list', 'problem_statistics' => 'Problem Statistics', 'student_assessment' => 'Problem Status Chart', - 'percentage' => 'Correct-problems Plot', - 'option_response' => 'Option Response Analysis', +# 'percentage' => 'Correct-problems Plot', +# 'option_response' => 'Option Response Analysis', # 'activitylog' => 'Activity Log', ); $r->print(&CreateMainMenu($ENV{'form.status'}, @@ -1001,8 +1030,6 @@ END &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c); } elsif($GoToPage eq 'DoDiffGraph' || $GoToPage eq 'PercentWrongGraph') { # &Apache::lonproblemstatistics::BuildGraphicChart($r,$c); - } elsif($GoToPage eq 'classlist') { - &DisplayClasslist($r); } elsif($GoToPage eq 'Correct-problems Plot') { # &Apache::lonpercentage::BuildPercentageGraph($r,$c); }