--- loncom/interface/lonquickgrades.pm 2020/08/10 19:28:21 1.117 +++ loncom/interface/lonquickgrades.pm 2020/09/01 03:35:54 1.118 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.117 2020/08/10 19:28:21 raeburn Exp $ +# $Id: lonquickgrades.pm,v 1.118 2020/09/01 03:35:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -222,6 +222,10 @@ ENDCLOSE $r->print('

'.&mt("Unknown Student/Employee ID: [_1]",$stdid).'

'); $stdid=''; } + if (($uname eq '') && ($udom eq '')) { + $uname = $env{'user.name'}; + $udom = $env{'user.domain'}; + } $r->print('
'); my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. &Apache::loncommon::selectstudent_link('quickform','uname','udom'); @@ -237,9 +241,6 @@ ENDCLOSE } $r->rflush(); - my $notshowSPRSlink = - (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external') - || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals')); my $notshowTotals= $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'; my $showCategories= @@ -248,12 +249,19 @@ ENDCLOSE my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)= &getData($showPoints,$uname,$udom); - if ($showCategories) { - &outputCategories($r,$showPoints,$notshowTotals, - $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); + if (ref($navmap)) { + if ($showCategories) { + &outputCategories($r,$showPoints,$notshowTotals, + $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); + } else { + &outputTable($r,$showPoints,$notshowTotals, + $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); + } } else { - &outputTable($r,$showPoints,$notshowTotals, - $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); + if ($cangrade) { $r->print("\n
\n"); } + my $requrl = $r->uri; + $env{'user.error.msg'} = "$requrl:bre:0:0:Navmap initialization failed."; + return HTTP_NOT_ACCEPTABLE; } if ($cangrade) { $r->print("\n\n"); } &endGradeScreen($r); @@ -332,6 +340,8 @@ sub startGradeScreen { || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories')); my $notshowTotals= $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'; + my $showSPRSlink = + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet'; my $showCategories= $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'; @@ -353,6 +363,7 @@ sub startGradeScreen { push(@notes,&mt('Students do not see link to spreadsheet.')) if ($notshowSPRSlink); push(@notes,&mt('Students will see points based on problem weights.')) if ($showPoints); push(@notes,&mt('Students will see points based on categories.')) if ($showCategories); + push(@notes,&mt('Students will see link to spreadsheet.')) if ($showSPRSlink); push(@notes, &Apache::lonhtmlcommon::coursepreflink(&mt('Grade display settings'),'grading')); $r->print(&Apache::loncommon::head_subbox(join('  ',@notes))); } @@ -393,6 +404,7 @@ sub startGradeScreen { sub endGradeScreen { my ($r)=@_; $r->print(''.&Apache::loncommon::end_page()); + return; } # ----------- @@ -465,6 +477,10 @@ sub getData { # Create the nav map my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom); + if (!defined($navmap)) { + return (); + } + my $res = $navmap->firstResource(); # temp resource to access constants my $iterator = $navmap->getIterator(undef, undef, undef, 1); @@ -693,6 +709,7 @@ sub outputTable { } $r->print(&Apache::loncommon::end_data_table()); + return; } #