--- loncom/interface/spreadsheet/lonspreadsheet.pm 2009/04/22 17:19:14 1.53
+++ loncom/interface/spreadsheet/lonspreadsheet.pm 2011/09/26 12:15:39 1.59
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.53 2009/04/22 17:19:14 bisitz Exp $
+# $Id: lonspreadsheet.pm,v 1.59 2011/09/26 12:15:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -64,6 +64,7 @@ use Apache::lonnet;
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::loncoursedata();
+use Apache::lonquickgrades();
use HTML::Entities();
##
@@ -86,7 +87,7 @@ sub selectbox {
my $selout="\n
$title: ".'';
foreach (sort keys(%options)) {
$selout.=''.&mt($options{$_}).' ';
}
return $selout.' ';
@@ -146,7 +147,7 @@ sub file_dialogs {
$truefilename.'" />'.
'';
my $makedefault_dialog = ' ';
+ 'value="'.&mt('Save as & Make This Sheet the Default').'"/>';
#
my $link = '".&mt('Select Spreadsheet File')." ";
@@ -165,17 +166,18 @@ END
foreach my $sheetfilename ($spreadsheet->othersheets()) {
$load_dialog .= ' \n";
}
$load_dialog .= "\n \n\n";
#
+ my $headline = &mt('File Dialogs');
$result .=<
- File Dialogs
+ $headline
-->
@@ -199,16 +201,6 @@ END
sub handler {
my $r=shift;
#
- # Overload checking
- #
- # Check this server
- my $loaderror=&Apache::lonnet::overloaderror($r);
- if ($loaderror) { return $loaderror; }
- # Check the course homeserver
- $loaderror= &Apache::lonnet::overloaderror($r,
- $env{'course.'.$env{'request.course.id'}.'.home'});
-# if ($loaderror) { return $loaderror; }
- #
# HTML Header
#
if ($r->header_only) {
@@ -226,15 +218,39 @@ sub handler {
$r->uri.":opa:0:0:Cannot modify spreadsheet";
return HTTP_NOT_ACCEPTABLE;
}
+ my ($sheettype) = ($r->uri=~/\/(\w+)$/);
my $courseid = $env{'request.course.id'};
+
+ ##
+ ## Check permissions
+ my $allowed_to_edit = &Apache::lonnet::allowed('mgr',
+ $env{'request.course.id'});
+ # Only those instructors/tas/whatevers with complete access
+ # (not section restricted) are able to modify spreadsheets.
+ my $allowed_to_view = &Apache::lonnet::allowed('vgr',
+ $env{'request.course.id'});
+ if (! $allowed_to_view) {
+ $allowed_to_view = &Apache::lonnet::allowed('vgr',
+ $env{'request.course.id'}.'/'.$env{'request.course.sec'});
+ # Those who are restricted by section are allowed to view.
+ # The routines in lonstatistics which decide which students'
+ # will be shown take care of the restriction by section.
+ }
+
#
- # Do not allow students to continue if standard or external grading is in
- # effect.
+ # Do not allow users without vgr or mgr priv to continue unless
+ # grading type is set to spreadsheet.
#
- if ($env{'request.role'} =~ /^st\./) {
- if ($env{'course.'.$courseid.'.grading'} eq 'standard' ||
- $env{'course.'.$courseid.'.grading'} eq 'external' ) {
- return HTTP_NOT_ACCEPTABLE;
+
+ if ((!$allowed_to_view) && (!$allowed_to_edit)) {
+ if ($env{'course.'.$courseid.'.grading'} eq 'spreadsheet') {
+ if ($sheettype ne 'studentcalc') {
+ $r->internal_redirect('/adm/studentcalc');
+ return OK;
+ }
+ } else {
+ $r->internal_redirect('/adm/quickgrades');
+ return OK;
}
}
#
@@ -252,7 +268,6 @@ sub handler {
}
#
# Determine basic information about the spreadsheet
- my ($sheettype) = ($r->uri=~/\/(\w+)$/);
#
my $symb = undef;
$symb = $env{'form.usymb'} if (exists($env{'form.usymb'}));
@@ -275,29 +290,13 @@ sub handler {
$env{'request.course.id'});
}
- ##
- ## Check permissions
- my $allowed_to_edit = &Apache::lonnet::allowed('mgr',
- $env{'request.course.id'});
- # Only those instructors/tas/whatevers with complete access
- # (not section restricted) are able to modify spreadsheets.
- my $allowed_to_view = &Apache::lonnet::allowed('vgr',
- $env{'request.course.id'});
- if (! $allowed_to_view) {
- $allowed_to_view = &Apache::lonnet::allowed('vgr',
- $env{'request.course.id'}.'/'.$env{'request.course.sec'});
- # Those who are restricted by section are allowed to view.
- # The routines in lonstatistics which decide which students'
- # will be shown take care of the restriction by section.
- }
#
# Only those able to view others grades will be allowed to continue
# if they are not requesting their own.
if ($sheettype eq 'classcalc') {
- if (! $allowed_to_view) {
- $env{'user.error.msg'}=
- $r->uri.":vgr:0:0:Access Permission Denied";
- return HTTP_NOT_ACCEPTABLE;
+ if (!$allowed_to_view) {
+ $r->internal_redirect('/adm/studentcalc');
+ return OK;
}
}
if ((($name ne $env{'user.name'} ) ||
@@ -404,8 +403,17 @@ ENDSCRIPT
bug => 'Spreadsheet'});
$r->print(&Apache::loncommon::start_page('Grades Spreadsheet',$js).
&Apache::lonhtmlcommon::breadcrumbs('Spreadsheet',
- 'Spreadsheet_About').
- ''.&Apache::loncommon::end_page());
+ $r->print('');
+ &Apache::lonquickgrades::endGradeScreen($r);
+ $r->print(&Apache::loncommon::end_page());
$spreadsheet->clear_package();
return OK;
}