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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 06 Apr 2006 20:24:14 -0000


This is a MIME encoded message

--raeburn1144355054
Content-Type: text/plain

raeburn		Thu Apr  6 16:24:14 2006 EDT

  Modified files:              
    /loncom/interface/spreadsheet	assesscalc.pm classcalc.pm 
                                 	lonspreadsheet.pm Spreadsheet.pm 
                                 	studentcalc.pm 
  Log:
  Making group-based parameters apply in spreadsheet, using same cascading precedence scheme as used for parmset.
  
  
--raeburn1144355054
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060406162414.txt"

Index: loncom/interface/spreadsheet/assesscalc.pm
diff -u loncom/interface/spreadsheet/assesscalc.pm:1.51 loncom/interface/spreadsheet/assesscalc.pm:1.52
--- loncom/interface/spreadsheet/assesscalc.pm:1.51	Wed Oct 12 17:29:49 2005
+++ loncom/interface/spreadsheet/assesscalc.pm	Thu Apr  6 16:24:13 2006
@@ -1,5 +1,5 @@
 #
-# $Id: assesscalc.pm,v 1.51 2005/10/12 21:29:49 albertel Exp $
+# $Id: assesscalc.pm,v 1.52 2006/04/06 20:24:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -290,7 +290,8 @@
 
 This function cascades through the possible levels searching for a value for
 a parameter.  The levels are checked in the following order:
-user, course (at section level and course level), map, and lonnet::metadata.
+user, course (at group, section level and course level), map, and 
+lonnet::metadata.
 This function uses %parmhash, which must be tied prior to calling it.
 This function also requires %courseopt and %useropt to be initialized for
 this user and course.
@@ -301,11 +302,12 @@
 ##################################################
 sub parmval {
     my $self = shift;
-    my ($what,$symb,$uname,$udom,$csec,$recurse,$mapname,$id,$fn)=@_;
-    $uname = $self->{'name'}    if (! defined($uname));
-    $udom  = $self->{'domain'}  if (! defined($udom));
-    $csec  = $self->{'section'} if (! defined($csec));
-    $symb  = $self->{'symb'}    if (! defined($symb));
+    my ($what,$symb,$uname,$udom,$csec,$recurse,$mapname,$id,$fn,$cgroup)=@_;
+    $uname  = $self->{'name'}    if (! defined($uname));
+    $udom   = $self->{'domain'}  if (! defined($udom));
+    $csec   = $self->{'section'} if (! defined($csec));
+    $cgroup = $self->{'group'}   if (! defined($cgroup)); 
+    $symb   = $self->{'symb'}    if (! defined($symb));
     #
     my $result='';
     #
@@ -323,6 +325,10 @@
     my $courseprefix = $self->{'cid'};
     my $usercourseprefix = $uname.'_'.$udom.'_'.$self->{'cid'};
     #
+    my $grplevel=$courseprefix.'.['.$cgroup.'].'.$what;
+    my $grplevelr=$courseprefix.'.['.$cgroup.'].'.$symbparm;
+    my $grplevelm=$courseprefix.'.['.$cgroup.'].'.$mapparm;
+    #
     my $seclevel  = $courseprefix.'.['.$csec.'].'.$what;
     my $seclevelr = $courseprefix.'.['.$csec.'].'.$symbparm;
     my $seclevelm = $courseprefix.'.['.$csec.'].'.$mapparm;
@@ -334,12 +340,18 @@
     my $ucourselevel  = $usercourseprefix.'.'.$what;
     my $ucourselevelr = $usercourseprefix.'.'.$symbparm;
     my $ucourselevelm = $usercourseprefix.'.'.$mapparm;
-   # check user
+    # check user
     if (defined($uname)) {
         return $useropt{$ucourselevelr} if (defined($useropt{$ucourselevelr}));
         return $useropt{$ucourselevelm} if (defined($useropt{$ucourselevelm}));
         return $useropt{$ucourselevel}  if (defined($useropt{$ucourselevel}));
     }
+    # check group
+    if (defined($cgroup)) {
+        return $courseopt{$grplevelr} if (defined($courseopt{$grplevelr}));
+        return $courseopt{$grplevelm} if (defined($courseopt{$grplevelm}));
+        return $courseopt{$grplevel}  if (defined($courseopt{$grplevel}));
+    }
     # check section
     if (defined($csec)) {
         return $courseopt{$seclevelr} if (defined($courseopt{$seclevelr}));
Index: loncom/interface/spreadsheet/classcalc.pm
diff -u loncom/interface/spreadsheet/classcalc.pm:1.25 loncom/interface/spreadsheet/classcalc.pm:1.26
--- loncom/interface/spreadsheet/classcalc.pm:1.25	Thu Apr  6 12:43:49 2006
+++ loncom/interface/spreadsheet/classcalc.pm	Thu Apr  6 16:24:13 2006
@@ -1,5 +1,5 @@
 #
-# $Id: classcalc.pm,v 1.25 2006/04/06 16:43:49 albertel Exp $
+# $Id: classcalc.pm,v 1.26 2006/04/06 20:24:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -407,7 +407,7 @@
         my $sname = $student->{'username'}.':'.$student->{'domain'};
 	my $studentsheet = Apache::studentcalc->new
 	    ($student->{'username'},$student->{'domain'},undef,undef,
-	     $student->{'section'} );
+	     $student->{'section'},$student->{'group'} );
         if ($connection->aborted()) { $self->cleanup(); return; }
 	my @exportdata = $studentsheet->export_data($r);
         if ($studentsheet->badcalc()) {
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.43 loncom/interface/spreadsheet/lonspreadsheet.pm:1.44
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.43	Thu Apr  6 12:43:49 2006
+++ loncom/interface/spreadsheet/lonspreadsheet.pm	Thu Apr  6 16:24:13 2006
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.43 2006/04/06 16:43:49 albertel Exp $
+# $Id: lonspreadsheet.pm,v 1.44 2006/04/06 20:24:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -266,6 +266,24 @@
     $env{'form.sdomain'} = $domain;
     my $section = &Apache::lonnet::getsection($domain,$name,
 					      $env{'request.course.id'});
+    my $group;
+    my @groups = ();
+    if (($env{'user.name'} eq $name) && ($env{'user.domain'} eq $domain)) {
+        @groups=&Apache::lonnet::sort_course_groups(
+                                                 $env{'request.course.groups'},
+                                                 $env{'request.course.id'});
+    } else {
+        my $grouplist = &Apache::lonnet::get_users_groups($domain,$name,
+                                                    $env{'request.course.id'});
+        if ($grouplist) {
+            @groups=&Apache::lonnet::sort_course_groups($grouplist,
+                                                    $env{'request.course.id'});
+        }
+    }
+    if (@groups > 0) {
+        $group = $groups[0];
+    }
+
     ##
     ## Check permissions
     my $allowed_to_edit = &Apache::lonnet::allowed('mgr',
@@ -441,15 +459,15 @@
     my $spreadsheet = undef;
     if ($sheettype eq 'classcalc') {
         $spreadsheet = Apache::classcalc->new($name,$domain,$filename,undef,
-					      $section);
+					      $section,$group);
     } elsif ($sheettype eq 'studentcalc') {
         $spreadsheet = Apache::studentcalc->new($name,$domain,$filename,undef,
-						$section);
+						$section,$group);
     } elsif ($sheettype eq 'assesscalc' && 
              defined($symb) && 
              $allowed_to_edit) {
         $spreadsheet = Apache::assesscalc->new($name,$domain,$filename,$symb,
-					       $section);
+					       $section,$group);
     } else {
         return HTTP_NOT_ACCEPTABLE;
     }
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.66 loncom/interface/spreadsheet/Spreadsheet.pm:1.67
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.66	Thu Apr  6 12:43:49 2006
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Thu Apr  6 16:24:13 2006
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.66 2006/04/06 16:43:49 albertel Exp $
+# $Id: Spreadsheet.pm,v 1.67 2006/04/06 20:24:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -85,7 +85,7 @@
     my $class = ref($this) || $this;
     my ($stype) = ($class =~ /Apache::(.*)$/);
     #
-    my ($name,$domain,$filename,$usymb,$section)=@_;
+    my ($name,$domain,$filename,$usymb,$section,$group)=@_;
     if (defined($usymb) && ref($usymb)) {
         $usymb = $usymb->symb;
     }
@@ -99,11 +99,21 @@
         $section = &Apache::lonnet::getsection($domain,$name,
 					       $env{'request.course.id'});
     }
+    if (! defined($group) || $group eq '') {
+        my $grouplist = &Apache::lonnet::get_users_groups($domain,$name,
+                                                    $env{'request.course.id'});
+        if ($grouplist) {
+            my @groups = &Apache::lonnet::sort_course_groups($grouplist,
+                                                    $env{'request.course.id'});
+            $group = $groups[0];
+        }
+    }
     #
     my $self = {
         name     => $name,
         domain   => $domain,
         section  => $section,
+        group    => $group,
         type     => $stype,
         symb     => $usymb,
         errorlog => '',
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.37 loncom/interface/spreadsheet/studentcalc.pm:1.38
--- loncom/interface/spreadsheet/studentcalc.pm:1.37	Thu Apr  6 12:43:49 2006
+++ loncom/interface/spreadsheet/studentcalc.pm	Thu Apr  6 16:24:13 2006
@@ -1,5 +1,5 @@
 #
-# $Id: studentcalc.pm,v 1.37 2006/04/06 16:43:49 albertel Exp $
+# $Id: studentcalc.pm,v 1.38 2006/04/06 20:24:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -571,7 +571,8 @@
                                                        $self->{'domain'},
                                                        $assess_filename,
                                                        $resource->symb,
-						       $self->{'section'});
+						       $self->{'section'},
+                                                       $self->{'group'});
             my @exportdata = $assessSheet->export_data($r);
             #
             if ($assessSheet->badcalc()) {

--raeburn1144355054--