--- loncom/interface/lonquickgrades.pm 2024/01/05 19:10:30 1.127 +++ loncom/interface/lonquickgrades.pm 2024/12/10 04:52:30 1.128 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.127 2024/01/05 19:10:30 raeburn Exp $ +# $Id: lonquickgrades.pm,v 1.128 2024/12/10 04:52:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -261,8 +261,19 @@ ENDCLOSE my $showCategories= $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'; + my $usec; + if ($cangrade) { + if (($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) { + $usec = $env{'request.course.sec'}; + } else { + $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'}); + } + } else { + $usec = $env{'request.course.sec'}; + } + my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts, - $topLevelRight,$topLevelAttempted) = &getData($showPoints,$uname,$udom); + $topLevelRight,$topLevelAttempted) = &getData($showPoints,$uname,$udom,$usec); if (ref($navmap)) { if ($showCategories) { @@ -277,16 +288,6 @@ ENDCLOSE if ($hidetotals eq 'all') { $nostdtotals = 1; } elsif ($hidetotals ne '') { - my $usec; - if ($cangrade) { - if (($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) { - $usec = $env{'request.course.sec'}; - } else { - $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'}); - } - } else { - $usec = $env{'request.course.sec'}; - } if ($usec ne '') { my %secnototals; map { $secnototals{$_} = 1; } split(/,/,$hidetotals); @@ -336,9 +337,9 @@ sub grades_blocked { } sub getStudentCatGrade { - my ($uname,$udom,%categories)=@_; + my ($uname,$udom,$usec,%categories)=@_; my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)= - &getData(1,$uname,$udom); + &getData(1,$uname,$udom,$usec); return &output_category_table(undef,0,$navmap,0,%categories); } @@ -354,11 +355,13 @@ sub getAllStudentData { my $usernameidx = &Apache::loncoursedata::CL_SNAME(); my $domainidx = &Apache::loncoursedata::CL_SDOM(); my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME(); + my $sectionidx = &Apache::loncoursedata::CL_SECTION(); foreach my $key (keys(%{$classlist})) { my $student = $classlist->{$key}; my $perc=&getStudentCatGrade($classlist->{$student}->[$usernameidx], $classlist->{$student}->[$domainidx], + $classlist->{$student}->[$sectionidx], %categories); } } @@ -531,10 +534,10 @@ sub excel_finish { sub getData { - my ($showPoints,$uname,$udom)=@_; + my ($showPoints,$uname,$udom,$usec)=@_; # Create the nav map - my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom); + my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom,$usec); if (!defined($navmap)) { return ();