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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 19 Nov 2002 19:20:50 -0000


matthew		Tue Nov 19 14:20:50 2002 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm lonspreadsheet.pm 
  Log:
  Fixes Bug 426 by implementing sorting the the student and course 
  spreadsheet views.  Students are sorted alphabetically by full name
  (lastname generation, firstname middlename).
  Resources are sorted by containing sequence or symb as required.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.76 loncom/interface/lonparmset.pm:1.77
--- loncom/interface/lonparmset.pm:1.76	Sun Nov  3 14:05:31 2002
+++ loncom/interface/lonparmset.pm	Tue Nov 19 14:20:50 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.76 2002/11/03 19:05:31 www Exp $
+# $Id: lonparmset.pm,v 1.77 2002/11/19 19:20:50 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1377,6 +1377,22 @@
                          $dom,$crs).
                     '<br>';
             }
+            if ($name =~ /^spreadsheet_default_(classcalc|
+                                                studentcalc|
+                                                assesscalc)$/x) {
+                my $sheettype = $1;
+                if ($sheettype eq 'classcalc') {
+                    # no need to do anything since viewing the sheet will
+                    # cause it to be updated.
+                } elsif ($sheettype eq 'studentcalc') {
+                    # expire all the student spreadsheets
+                    &Apache::lonnet::expirespread('','','studentcalc');
+                } else {
+                    # expire all the default assessment spreadsheets
+                    # ACK!  No way to do this currently!!!!! Bummer!
+                }
+            }
+
             if ($name) {
                 $setoutput.='Setting <tt>'.$name.'</tt> to <tt>'.
                     $value.'</tt>: '.
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.141 loncom/interface/lonspreadsheet.pm:1.142
--- loncom/interface/lonspreadsheet.pm:1.141	Fri Nov 15 13:59:28 2002
+++ loncom/interface/lonspreadsheet.pm	Tue Nov 19 14:20:50 2002
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.141 2002/11/15 18:59:28 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.142 2002/11/19 19:20:50 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1186,17 +1186,43 @@
 ########################################################################
 sub sort_indicies {
     my $sheet = shift;
-    #
-    # Sort the rows in some manner
-    #
-    my @sortby=();
     my @sortidx=();
-    # Skip row 0
-    for (my $row=1;$row<=$sheet->{'maxrow'};$row++) {
-        push (@sortby, $sheet->{'safe'}->reval('$f{"A'.$row.'"}'));
-        push (@sortidx, $row);
+    #
+    if ($sheet->{'sheettype'} eq 'classcalc') {
+        my @sortby=();
+        # Skip row 0
+        for (my $row=1;$row<=$sheet->{'maxrow'};$row++) {
+            my (undef,$sname,$sdom,$fullname,$section,$id) = 
+                split(':',$sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$row}});
+            push (@sortby, lc($fullname));
+            push (@sortidx, $row);
+        }
+        @sortidx = sort { $sortby[$a] cmp $sortby[$b]; } @sortidx;
+    } elsif ($sheet->{'sheettype'} eq 'studentcalc') {
+        my @sortby=();
+        # Skip row 0
+        &Apache::lonnet::logthis('starting sort for studentcalc');
+        for (my $row=1;$row<=$sheet->{'maxrow'};$row++) {
+            my (undef,$symb,$uname,$udom,$mapid,$resid,$title) = 
+                split(':',$sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$row}});
+            $symb = &Apache::lonnet::unescape($symb);
+            my ($sequence) = ($symb =~ /\/([^\/]*\.sequence)/);
+            if ($sequence eq '') {
+                $sequence = $symb;
+            }
+            push (@sortby, $sequence);
+            push (@sortidx, $row);
+        }
+        @sortidx = sort { $sortby[$a] cmp $sortby[$b]; } @sortidx;
+    } else {
+        my @sortby=();
+        # Skip row 0
+        for (my $row=1;$row<=$sheet->{'maxrow'};$row++) {
+            push (@sortby, $sheet->{'safe'}->reval('$f{"A'.$row.'"}'));
+            push (@sortidx, $row);
+        }
+        @sortidx = sort { $sortby[$a] cmp $sortby[$b]; } @sortidx;
     }
-    @sortidx=sort { lc($sortby[$a]) cmp lc($sortby[$b]); } @sortidx;
     return @sortidx;
 }