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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 26 Apr 2004 14:06:00 -0000


matthew		Mon Apr 26 10:06:00 2004 EDT

  Modified files:              
    /loncom/interface/spreadsheet	lonspreadsheet.pm classcalc.pm 
  Log:
  Bug 2945: Give DCs links to expire spreadsheet caches.
  
  
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.36 loncom/interface/spreadsheet/lonspreadsheet.pm:1.37
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.36	Mon Mar  1 11:40:44 2004
+++ loncom/interface/spreadsheet/lonspreadsheet.pm	Mon Apr 26 10:06:00 2004
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.36 2004/03/01 16:40:44 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.37 2004/04/26 14:06:00 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -240,7 +240,8 @@
     # Get query string for limited number of parameters
     #
     &Apache::loncommon::get_unprocessed_cgi
-        ($ENV{'QUERY_STRING'},['sname','sdomain','usymb','filename','recalc']);
+        ($ENV{'QUERY_STRING'},['sname','sdomain','usymb','filename','recalc',
+                               'output_format','not_first_run']);
     #
     # Deal with restricted student permissions 
     #
@@ -399,23 +400,35 @@
             &Apache::loncoursedata::delete_caches($ENV{'requres.course.id'});
         }
         if ($ENV{'form.recalc'} eq 'ilovewastingtime') {
-            &Apache::lonnet::logthis('ilovewastingtime');
+            &Apache::lonnet::logthis('spreadsheet expired: entire course');
             # expire ALL spreadsheets
             &Apache::lonnet::expirespread('','','studentcalc');
             &Apache::lonnet::expirespread('','','assesscalc');
+            $r->print('<h3>'.
+                      &mt('Expired spreadsheet caches for all students').
+                      '</h3>');
         } 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::logthis('spreadsheet expired: symb = '.$symb);
             &Apache::lonnet::expirespread('','','assesscalc',$symb);
             &Apache::lonnet::expirespread('','','studentcalc');
+            $r->print('<h3>'.
+              &mt('Expired spreadsheet caches for all students for symb  [_1]',
+                  $symb).
+                      '</h3>');
         } 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);
+            &Apache::lonnet::logthis('spreadsheet expired: student = '.
+                                     $sname.'@'.$sdom);
             if (defined($sname) && defined($sdom)) {
                 &Apache::lonnet::expirespread($sname,$sdom,'assesscalc');
                 &Apache::lonnet::expirespread($sname,$sdom,'studentcalc');
+                $r->print('<h3>'.
+                          &mt('Expired spreadsheet caches for student [_1]',
+                              $sname.'@'.$sdom).
+                          '</h3>');
             }
         }
     }
Index: loncom/interface/spreadsheet/classcalc.pm
diff -u loncom/interface/spreadsheet/classcalc.pm:1.18 loncom/interface/spreadsheet/classcalc.pm:1.19
--- loncom/interface/spreadsheet/classcalc.pm:1.18	Wed Jan 14 11:48:51 2004
+++ loncom/interface/spreadsheet/classcalc.pm	Mon Apr 26 10:06:00 2004
@@ -1,5 +1,5 @@
 #
-# $Id: classcalc.pm,v 1.18 2004/01/14 16:48:51 matthew Exp $
+# $Id: classcalc.pm,v 1.19 2004/04/26 14:06:00 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -299,6 +299,18 @@
     my $self = shift;
     my ($r) = @_;
     #
+    # Determine if we should output expire caches links...
+    my $show_expire_link = 0;
+    if (exists($ENV{'user.role.dc./'.$ENV{'request.role.domain'}.'/'})){
+        $show_expire_link = 1;
+    }
+    #
+    if ($show_expire_link) {
+        $r->print('<a href="/adm/classcalc?output_format=htmlclasslist&'.
+                  'recalc=ilovewastingtime&not_first_run=1">'.
+                  &mt('Expire all student spreadsheets').'</a>'.$/);
+    }
+    #
     $r->print('<h3>'.
               &mt('Click on a student to be taken to their spreadsheet').
               '</h3>');
@@ -322,8 +334,11 @@
   <th>$header{'domain'}</th>
   <th>$header{'section'}</th>
   <th>$header{'status'}</th>
-</tr>
 END
+    if ($show_expire_link) {
+        $tableheader.= '<th>&nbsp;</th>';
+    }
+    $tableheader.= "</tr>\n";
     #
     my $num_output = 0;
     foreach my $student (@Students) {
@@ -339,8 +354,15 @@
 		  '<td>'.$link.$student->{'username'}.'</a></td>'.
 		  '<td>'.$student->{'domain'}  .'</td>'.
 		  '<td>'.$student->{'section'} .'</td>'.
-		  '<td>'.$student->{'status'}  .'</td>'.
-                  "</tr>\n");
+		  '<td>'.$student->{'status'}  .'</td>');
+        if ($show_expire_link) {
+            $r->print('<td>'.
+                      '<a href="/adm/classcalc?recalc=student:'.
+                      $student->{'username'}.':'.$student->{'domain'}.'&'.
+                      'output_format=htmlclasslist&'.
+                      'not_first_run=1'.'">Expire Record</a>'.$/);
+        }
+        $r->print("</tr>\n");
     }
     $r->print("</table></p>\n");
     return;