--- loncom/homework/grades.pm 2011/02/07 19:16:28 1.645 +++ loncom/homework/grades.pm 2011/03/31 17:58:25 1.646 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.645 2011/02/07 19:16:28 www Exp $ +# $Id: grades.pm,v 1.646 2011/03/31 17:58:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,7 @@ use Apache::lonhomework; use Apache::lonpickcode; use Apache::loncoursedata; use Apache::lonmsg(); -use Apache::Constants qw(:common); +use Apache::Constants qw(:common :http); use Apache::lonlocal; use Apache::lonenc; use Apache::lonstathelpers; @@ -9217,15 +9217,25 @@ sub select_problem { sub handler { my $request=$_[0]; &reset_caches(); - if ($env{'browser.mathml'}) { - &Apache::loncommon::content_type($request,'text/xml'); - } else { - &Apache::loncommon::content_type($request,'text/html'); + if ($request->header_only) { + &Apache::loncommon::content_type($request,'text/html'); + $request->send_http_header; + return OK; } - $request->send_http_header; - return '' if $request->header_only; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); + &init_perm(); + if (!$env{'request.course.id'}) { + # Not in a course. + $env{'user.error.msg'}="/adm/grades::vgr:0:0:Cannot display grades page outside course context"; + return HTTP_NOT_ACCEPTABLE; + } elsif (!%perm) { + $request->internal_redirect('/adm/quickgrades'); + } + &Apache::loncommon::content_type($request,'text/html'); + $request->send_http_header; + + # see what command we need to execute my @commands=&Apache::loncommon::get_env_multiple('form.command'); @@ -9242,7 +9252,7 @@ sub handler { (my $url=$env{'form.url'}) =~ s-^https*://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; $symb=&Apache::lonnet::symbread($url); } - &Apache::lonenc::check_decrypt(\$symb); + &Apache::lonenc::check_decrypt(\$symb); $ssi_error = 0; if (($symb eq '' || $command eq '') && ($env{'request.course.id'})) { @@ -9252,7 +9262,6 @@ sub handler { &startpage($request,undef,[],1,1); &select_problem($request); } else { - &init_perm(); if ($command eq 'submission' && $perm{'vgr'}) { &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}]); ($env{'form.student'} eq '' ? &listStudents($request,$symb) : &submission($request,0,0,$symb)); @@ -9396,7 +9405,7 @@ sub handler { &Apache::lonquickgrades::endGradeScreen($request); $request->print(&Apache::loncommon::end_page()); &reset_caches(); - return ''; + return OK; } 1;