--- loncom/interface/lonquickgrades.pm 2021/03/04 14:02:14 1.49.6.6.2.2 +++ loncom/interface/lonquickgrades.pm 2011/03/25 22:06:34 1.79 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.49.6.6.2.2 2021/03/04 14:02:14 raeburn Exp $ +# $Id: lonquickgrades.pm,v 1.79 2011/03/25 22:06:34 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,13 +29,12 @@ package Apache::lonquickgrades; use strict; -use Apache::Constants qw(:common :http REDIRECT); +use Apache::Constants qw(:common :http); use POSIX; use Apache::loncommon; use Apache::lonlocal; use Apache::lonnet; use Apache::grades; -use Apache::lonuserstate; sub handler { my $r = shift; @@ -58,95 +57,30 @@ sub real_handler { return OK; } - my $cangrade=&Apache::lonnet::allowed('mgr'); + # Send header, don't cache this page + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $showPoints = $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard'; + 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= + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'; - my $reinitresult; - - if ($env{'request.course.id'}) { - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my ($blocked,$blocktext) = - &Apache::loncommon::blocking_status('grades',$cnum,$cdom); - if ($blocked) { - my $checkrole = "cm./$cdom/$cnum"; - if ($env{'request.course.sec'} ne '') { - $checkrole .= "/$env{'request.course.sec'}"; - } - unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && - ($env{'request.role'} !~ m{^st\./$cdom/$cnum})) { - &grades_blocked($r,$blocktext,$showPoints); - return OK; - } - } - } - unless ($cangrade) { - # Check for critical messages and redirect if present. - my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'grades'); - if ($redirect) { - &Apache::loncommon::content_type($r,'text/html'); - $r->header_out(Location => $url); - return REDIRECT; - } - - # Check if course needs to be re-initialized - my $loncaparev = $r->dir_config('lonVersion'); - ($reinitresult,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev); - - if ($reinitresult eq 'switch') { - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - $r->print(&Apache::loncommon::check_release_result(@reinit)); - return OK; - } elsif ($reinitresult eq 'update') { - my $cid = $env{'request.course.id'}; - my $cnum = $env{'course.'.$cid.'.num'}; - my $cdom = $env{'course.'.$cid.'.domain'}; - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - &startpage($r,$showPoints); - my $preamble = '
'.&mt("Unknown Student/Employee ID: [_1]",$stdid).'
'); $stdid=''; } - if (($uname eq '') && ($udom eq '')) { - $uname = $env{'user.name'}; - $udom = $env{'user.domain'}; - } $r->print('\n"); } - my $requrl = $r->uri; - $env{'user.error.msg'} = "$requrl:bre:0:0:Navmap initialization failed."; - return HTTP_NOT_ACCEPTABLE; + &outputTable($r,$showPoints,$notshowTotals, + $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); } if ($cangrade) { $r->print("\n\n"); } &endGradeScreen($r); return OK; + } -sub grades_blocked { - my ($r,$blocktext,$caller) = @_; - my $title = 'Points Display'; - if ($caller eq 'spreadsheet') { - $title = 'Spreadsheet'; - } elsif ($env{'course.'.$env{'request.course.id'}.'.grading'} ne 'standard') { - $title = 'Completed Problems Display'; - } - my $brcrum = [{href=>"/adm/quickgrades",text => $title}]; - &Apache::lonhtmlcommon::clear_breadcrumbs(); - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/quickgrades', - text=> $title}); - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs($title); - &Apache::loncommon::content_type($r,'text/html'); - &Apache::loncommon::no_cache($r); - $r->send_http_header; - $r->print(&Apache::loncommon::start_page($title). - $breadcrumbs. - $blocktext. - &Apache::loncommon::end_page()); - return; +sub startGradeScreen { + my ($r,$mode)=@_; + + my $showPoints = + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard'; + my $notshowSPRSlink = + (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external') + || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals') + || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories')); + my $notshowTotals= + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'; + my $showCategories= + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'; + + my $allowed_to_view = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); + my $allowed_to_edit = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); + + if ($allowed_to_view) { + my @notes; + push(@notes,&mt('Students do not see total points.')) if ($notshowTotals); + 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, &Apache::lonhtmlcommon::coursepreflink(&mt('Grade display settings'),'grading')); + $r->print(&Apache::loncommon::head_subbox(join(' ',@notes))); + } + + + $r->print("\n".'