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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 06 Aug 2003 19:54:36 -0000


matthew		Wed Aug  6 15:54:36 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	lonspreadsheet.pm 
  Log:
  Added help links. (not all links are valid at this time)
  Added intentionally undocumented feature to expire spreadsheets.  Thus if 
  someone REALLY needs to expire all their spreadsheets they can ask us 
  first and we can tell them how to do so.  Also allow expiration of a 
  single student or a single symb if you know the secret words.
  
  
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.18 loncom/interface/spreadsheet/lonspreadsheet.pm:1.19
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.18	Fri Aug  1 09:31:41 2003
+++ loncom/interface/spreadsheet/lonspreadsheet.pm	Wed Aug  6 15:54:36 2003
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.18 2003/08/01 13:31:41 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.19 2003/08/06 19:54:36 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -226,7 +226,7 @@
     # Get query string for limited number of parameters
     #
     &Apache::loncommon::get_unprocessed_cgi
-        ($ENV{'QUERY_STRING'},['sname','sdomain','usymb','filename']);
+        ($ENV{'QUERY_STRING'},['sname','sdomain','usymb','filename','recalc']);
     #
     # Deal with restricted student permissions 
     #
@@ -363,6 +363,30 @@
         }
     }
     ##
+    ## Take care of "backdoor" spreadsheet expiration / recalc stuff
+    if ($allowed_to_edit && exists($ENV{'form.recalc'})) {
+        if ($ENV{'form.recalc'} eq 'ilovewastingtime') {
+            &Apache::lonnet::logthis('ilovewastingtime');
+            # expire ALL spreadsheets
+            &Apache::lonnet::expirespread('','','studentcalc');
+            &Apache::lonnet::expirespread('','','assesscalc');
+        } elsif ($ENV{'form.recalc'} =~ /^symb:/) {
+            # expire for all students on this symb
+            my ($symb) = ($ENV{'form.recalc'} =~ /^symb:(.*)$/);
+            &Apache::lonnet::logthis('symb = '.$symb);
+            &Apache::lonnet::expirespread('','','assesscalc',$symb);
+            &Apache::lonnet::expirespread('','','studentcalc');
+        } elsif ($ENV{'form.recalc'} =~ /^student:/) {
+            # expire all assessment spreadsheets for this user
+            my ($sname,$sdom) = ($ENV{'form.recalc'}=~/^student:(.*):(.*)$/);
+            &Apache::lonnet::logthis('student = '.$sname.':'.$sdom);
+            if (defined($sname) && defined($sdom)) {
+                &Apache::lonnet::expirespread($sname,$sdom,'assesscalc');
+                &Apache::lonnet::expirespread($sname,$sdom,'studentcalc');
+            }
+        }
+    }
+    ##
     ## Make the spreadsheet
     &Apache::Spreadsheet::initialize_spreadsheet_package();
     my $spreadsheet = undef;
@@ -422,9 +446,24 @@
     }
     $r->rflush();
     #
+    $r->print("<table><tr>");
     if ($sheettype eq 'classcalc') {
-        $r->print('<input type="submit" value="Generate Spreadsheet" /><br />');
+        $r->print('<td><input type="submit" value="Generate Spreadsheet" />'.
+                  '</td>');
+    }
+    if ($allowed_to_view) {
+        $r->print('<td>'.
+                  &Apache::loncommon::help_open_topic("Spreadsheet_About",
+                                                      'Spreadsheet Help').
+                  '</td>');
+    }
+    if ($allowed_to_edit) {
+        $r->print('<td>'.
+                  &Apache::loncommon::help_open_topic("Spreadsheet_Editing",
+                                                      'Editing Help').
+                  '</td>');
     }
+    $r->print('</tr></table>');
     #
     # Keep track of the filename
     $r->print(&hiddenfield('filename',$filename));