\n";
+ }
+ ##
+ ## Editing code
+ $result .=&hiddenfield('cell','').
+ &hiddenfield('newformula','');
+ ##
+ ## Create the save and load dialogs
+ my $filename = $spreadsheet->filename();
+ $filename = '' if ($filename =~ /^default\.$sheettype/i);
+ $filename =~ s/_$sheettype$//;
+ my $save_dialog = ''.
+ ' '.
+ ''.
+ '';
+ my $makedefault_dialog = '';
+ #
+ my $link = 'Browse";
+ my $load_dialog = <
+
+
+
+ $link
+
+
+
\n\n";
+ #
+ $result .=<
+
+
+
$load_dialog
+
+
+
$save_dialog
+
$makedefault_dialog
+
+
+
+
+END
+ return $result;
+}
+
sub handler {
my $r=shift;
#
@@ -99,7 +187,7 @@ sub handler {
# Check the course homeserver
$loaderror= &Apache::lonnet::overloaderror($r,
$ENV{'course.'.$ENV{'request.course.id'}.'.home'});
- if ($loaderror) { return $loaderror; }
+# if ($loaderror) { return $loaderror; }
#
# HTML Header
#
@@ -155,6 +243,7 @@ sub handler {
$ENV{'request.course.id'});
my $allowed_to_view = &Apache::lonnet::allowed('vgr',
$ENV{'request.course.id'});
+
#
# Only those able to view others grades will be allowed to continue
# if they are not requesting their own.
@@ -175,10 +264,14 @@ sub handler {
##
## Spit out the javascript required for editing
##
- if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
+ if ($allowed_to_edit) {
+ my $extra_javascript =
+ &Apache::loncommon::browser_and_searcher_javascript();
$r->print(<
+ $extra_javascript
+
var editwin;
function celledit(cellname,cellformula) {
@@ -250,84 +343,36 @@ ENDSCRIPT
# error error - run in circles, scream and shout
return;
}
+ #
+ # Output selector
+ $r->print(' ');
##
## Editing/loading/saving
if ($allowed_to_edit) {
- ##
- ## Deal with saving the spreadsheet
- if (exists($ENV{'form.save'}) &&
- exists($ENV{'form.savefilename'})) {
- $spreadsheet->filename($ENV{'form.savefilename'});
- my $save_status = $spreadsheet->save();
- if ($save_status ne 'ok') {
- $r->print("An error occurred while saving the spreadsheet".
- "There error is:".$save_status);
- } else {
- $r->print("Spreadsheet saved as ".$ENV{'form.savefilename'});
- }
- } elsif (exists($ENV{'form.newformula'}) &&
- exists($ENV{'form.cell'}) &&
- $ENV{'form.cell'} ne '' ) {
- ##
- ## Make any requested modifications to the spreadsheet
- $spreadsheet->modify_cell($ENV{'form.cell'},
- $ENV{'form.newformula'});
- $spreadsheet->save_tmp();
- # output that we are dealing with a temporary file
- $r->print(&hiddenfield('workcopy',$sheettype));
- $r->print('