[LON-CAPA-cvs] cvs: loncom /homework grades.pm
raeburn
raeburn@source.lon-capa.org
Thu, 31 Mar 2011 17:58:25 -0000
raeburn Thu Mar 31 17:58:25 2011 EDT
Modified files:
/loncom/homework grades.pm
Log:
- handler should return OK or HTTP_NOT_ACCEPTABLE;
- check if user is in course context and/or has priviliges to view page.
- internal redirect to /adm/quickgrades if lacking privileges.
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.645 loncom/homework/grades.pm:1.646
--- loncom/homework/grades.pm:1.645 Mon Feb 7 19:16:28 2011
+++ loncom/homework/grades.pm Thu Mar 31 17:58:25 2011
@@ -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::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 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 @@
(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 @@
&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 @@
&Apache::lonquickgrades::endGradeScreen($request);
$request->print(&Apache::loncommon::end_page());
&reset_caches();
- return '';
+ return OK;
}
1;