\n";
+ }
+ ##
+ ## Editing code
+ $result .=&hiddenfield('cell','').
+ &hiddenfield('newformula','');
+ ##
+ ## Create the save and load dialogs
+ my $filename = $spreadsheet->filename();
+ $filename = 'Default' if ($filename =~ /^default\.$sheettype/i);
+ $filename =~ s/_$sheettype$//;
+ my $save_dialog = ''.
+ ' '.
+ ''.
+ '';
+ my $makedefault_dialog = '';
+ #
+ my $link = 'Select Spreadsheet File";
+ my $load_dialog = <
+
+
+
+ $link
+
+
+
\n\n";
+ #
+ $result .=<
+
+
+
$load_dialog
+
+
+
$save_dialog
+
$makedefault_dialog
+
+
+
+
+END
+ return $result;
+}
+
sub handler {
my $r=shift;
#
@@ -155,6 +250,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 +271,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) {
@@ -229,6 +329,7 @@ ENDSCRIPT
#
if (exists($ENV{'form.load'}) && exists($ENV{'form.loadfilename'})) {
$filename = $ENV{'form.loadfilename'};
+ $ENV{'form.workcopy'} = 'no';
}
}
##
@@ -250,87 +351,37 @@ ENDSCRIPT
# error error - run in circles, scream and shout
return;
}
+ $spreadsheet->initialize();
+ #
+ # 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('