[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm lonquickgrades.pm

www www@source.lon-capa.org
Fri, 03 Dec 2010 15:19:10 -0000


www		Fri Dec  3 15:19:10 2010 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm lonquickgrades.pm 
  Log:
  Saving my work: initializing navmaps for somebody else
  SEEMS TO WORK MOSTLY. NOT SURE ABOUT SIDE EFFECTS. NOT FOR RELEASE.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.452 loncom/interface/lonnavmaps.pm:1.453
--- loncom/interface/lonnavmaps.pm:1.452	Thu Dec  2 15:40:02 2010
+++ loncom/interface/lonnavmaps.pm	Fri Dec  3 15:19:09 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.452 2010/12/02 15:40:02 bisitz Exp $
+# $Id: lonnavmaps.pm,v 1.453 2010/12/03 15:19:09 www Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1931,6 +1931,9 @@
     my $class = ref($proto) || $proto;
     my $self = {};
 
+    $self->{USERNAME} = shift || $env{'user.name'};
+    $self->{DOMAIN}   = shift || $env{'user.domain'};
+
     # Resource cache stores navmap resources as we reference them. We generate
     # them on-demand so we don't pay for creating resources unless we use them.
     $self->{RESOURCE_CACHE} = {};
@@ -1969,8 +1972,9 @@
     my $self = shift;
     if ($self->{COURSE_USER_OPT_GENERATED}) { return; }
 
-    my $uname=$env{'user.name'};
-    my $udom=$env{'user.domain'};
+    my $uname=$self->{USERNAME};
+    my $udom=$self->{DOMAIN};
+
     my $cid=$env{'request.course.id'};
     my $cdom=$env{'course.'.$cid.'.domain'};
     my $cnum=$env{'course.'.$cid.'.num'};
@@ -2021,7 +2025,7 @@
     my %discussiontime = &Apache::lonnet::dump('discussiontimes', 
 					       $cdom, $cnum);
     my %lastread = &Apache::lonnet::dump('nohist_'.$cid.'_discuss',
-                                        $env{'user.domain'},$env{'user.name'},'lastread');
+                                        $self->{DOMAIN},$self->{USERNAME},'lastread');
     my %lastreadtime = ();
     foreach my $key (keys %lastread) {
         my $shortkey = $key;
@@ -2031,8 +2035,8 @@
 
     my %feedback=();
     my %error=();
-    my @keys = &Apache::lonnet::getkeys('nohist_email',$env{'user.domain'},
-					$env{'user.name'});
+    my @keys = &Apache::lonnet::getkeys('nohist_email',$self->{DOMAIN},
+					$self->{USERNAME});
     
     foreach my $msgid (@keys) {
 	if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) {
@@ -2080,8 +2084,8 @@
 
     # Retrieve performance data on problems
     my %student_data = Apache::lonnet::currentdump($env{'request.course.id'},
-						   $env{'user.domain'},
-						   $env{'user.name'});
+						   $self->{DOMAIN},
+						   $self->{USERNAME});
     $self->{STUDENT_DATA} = \%student_data;
 
     $self->{RETRIEVED_USER_DATA} = 1;
@@ -2432,8 +2436,8 @@
         @cgrps = sort(@cgrps);
         $cgroup = $cgrps[0];
     } 
-    my $uname=$env{'user.name'};
-    my $udom=$env{'user.domain'};
+    my $uname=$self->{USERNAME};
+    my $udom=$self->{DOMAIN};
 
     unless ($symb) { return ['']; }
     my $result='';
@@ -4101,8 +4105,8 @@
     my $self = shift; my $part = shift;
     if (!defined($part)) { $part = '0'; }
     my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
-                                $self->symb(), $env{'user.domain'},
-                                $env{'user.name'},
+                                $self->symb(), $self->{DOMAIN},
+                                $self->{USERNAME},
                                 $env{'request.course.sec'});
     return $weight;
 }
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.52 loncom/interface/lonquickgrades.pm:1.53
--- loncom/interface/lonquickgrades.pm:1.52	Thu Dec  2 00:53:37 2010
+++ loncom/interface/lonquickgrades.pm	Fri Dec  3 15:19:09 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.52 2010/12/02 00:53:37 www Exp $
+# $Id: lonquickgrades.pm,v 1.53 2010/12/03 15:19:09 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -93,19 +93,32 @@
     $r->print('<p class="LC_info">'.&mt('This may take a few moments to display.').'</p>');
 
     $r->rflush();
-    my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=&getData($showPoints);
-    &outputTable($r,$showPoints,$notshowTotals,
+
+    my $uname='korte';
+    my $udom='gerd';
+
+    my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=
+       &getData($showPoints,$uname,$udom);
+
+    if ($showCategories) {
+       &outputCategories($r,$showPoints,$notshowTotals,
+                 $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
+    } else {
+       &outputTable($r,$showPoints,$notshowTotals,
                  $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
+    }
     return OK;
 
 }
 
 sub getData {
 
-    my ($showPoints)=@_;
+    my ($showPoints,$uname,$udom)=@_;
+
+    &Apache::lonnet::logthis("About to call with $uname $udom");
 
     # Create the nav map
-    my $navmap = Apache::lonnavmaps::navmap->new();
+    my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom);
 
     my $res = $navmap->firstResource(); # temp resource to access constants
 
@@ -334,6 +347,16 @@
 
 }
 
+#
+# Outputting category-based grades.
+#
+
+sub outputCategories {
+
+    my ($r,$showPoints,$notshowTotals,
+           $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_;
+}
+
 # Pass this two refs to arrays for the start and end color, and a number
 # from 0 to 1 for how much of the latter you want to mix in. It will
 # return a string ready to show ("#FFC309");