[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet lonspreadsheet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 18 Jun 2003 19:44:22 -0000


matthew		Wed Jun 18 15:44:22 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	lonspreadsheet.pm 
  Log:
  Interface changes:
  make default has been changed to 'save and make default' and this functionality
  has been implemented.
  The description of the action last taken is no longer displayed in the middle
  of the load/save table and instead appears below it.
  The description of the last action taken is clearer and more cleanly presented.
  
  
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.10 loncom/interface/spreadsheet/lonspreadsheet.pm:1.11
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.10	Wed Jun 18 11:32:37 2003
+++ loncom/interface/spreadsheet/lonspreadsheet.pm	Wed Jun 18 15:44:22 2003
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.10 2003/06/18 15:32:37 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.11 2003/06/18 19:44:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -93,18 +93,19 @@
     my $bgcolor = "#FFFFFF";
     my $sheettype = $spreadsheet->{'type'};
     my $result = '';
+    my $message = '';
     ##
     ## Deal with saving the spreadsheet
-    if (exists($ENV{'form.save'}) && 
+    if ((exists($ENV{'form.save'}) || exists($ENV{'form.makedefault'})) && 
         exists($ENV{'form.savefilename'})) {
         $spreadsheet->filename($ENV{'form.savefilename'});
         my $save_status = $spreadsheet->save();
         if ($save_status ne 'ok') {
-            $result .= "An error occurred while saving the spreadsheet".
+            $message .= "An error occurred while saving the spreadsheet".
                 "There error is:".$save_status;
             return $result;
         } else {
-            $result .= "Spreadsheet saved as ".$ENV{'form.savefilename'};
+            $message .= "Spreadsheet saved as ".$ENV{'form.savefilename'};
         }
     } elsif (exists($ENV{'form.newformula'}) && 
              exists($ENV{'form.cell'})       && 
@@ -116,8 +117,13 @@
         $spreadsheet->save_tmp();
         # output that we are dealing with a temporary file
         $result .=&hiddenfield('workcopy',$sheettype);
-        $result .='<pre>'.$ENV{'form.cell'}.' = '.
-                  $ENV{'form.newformula'}."</pre>\n";
+        if ($ENV{'form.newformula'} !~ /^\s*$/) {
+            $message .='<table><tr>'.
+              '<td valign="top"><pre>Cell '.$ENV{'form.cell'}.' = </pre></td>'.
+              '<td><pre>'.$ENV{'form.newformula'}."</pre></td></tr></table>\n";
+        } else {
+            $message .= 'Deleted contents of cell '.$ENV{'form.cell'}.'.';
+        }
     }
     ##
     ## Editing code
@@ -136,7 +142,7 @@
         $truefilename.'" />'.
         '</nobr>';
     my $makedefault_dialog = '<input type="submit" name="makedefault" '.
-        'value="Make This Sheet the Default"/>';
+        'value="Save as & Make This Sheet the Default"/>';
     #
     my $link = '<a href="javascript:openbrowser'.
         "('sheet','loadfilename','spreadsheet')\">Select Spreadsheet File</a>";
@@ -175,7 +181,7 @@
 </tr>
 </table>
 END
-    return $result;
+    return ($result,$message);
 }
 
 sub handler {
@@ -352,17 +358,38 @@
     ##
     ## Editing/loading/saving
     if ($allowed_to_edit) {
+        my ($html,$action_message) = &file_dialogs($spreadsheet);
         if ($ENV{'form.makedefault'}) {
             $spreadsheet->make_default();
+            if ($action_message) {
+                $action_message .= '<br />';
+            }
+            $action_message .= 'Made this spreadsheet the default';
+            if ($sheettype eq 'classcalc') {
+                $action_message .= ' for the course';
+            } elsif ($sheettype eq 'studentcalc') {
+                $action_message .= ' for all students';
+            } elsif ($sheettype eq 'assesscalc') {
+                $action_message .= ' for all assessments';
+            }
+            $action_message .= '.';
         }
         $r->print('<table><tr><td>'.$spreadsheet->html_header().'</td>'.
-                  '<td valign="bottom">'.
-                  &file_dialogs($spreadsheet)."</td></tr></table>\n");
+                  '<td valign="bottom">'.$html."</td></tr></table>\n");
+        $r->print(<<END);
+<table>
+<tr><td valign="top"><b>Last Action:</b></td>
+    <td>&nbsp;</td>
+    <td>$action_message</td>
+</tr>
+</table>
+END
         $r->rflush();
     } else {
         $r->print('<table><tr><td>'.$spreadsheet->html_header().
                   "</td></tr></table>\n");
     }
+    $r->rflush();
     #
     if (! exists($ENV{'form.not_first_run'}) && $sheettype eq 'classcalc') {
         $r->print('<input type="submit" value="Generate Spreadsheet" /><br />');