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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Wed, 25 Jun 2003 18:27:19 -0000


bowersj2		Wed Jun 25 14:27:19 2003 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Correctly reflect "awarded" status in the resource object.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.210 loncom/interface/lonnavmaps.pm:1.211
--- loncom/interface/lonnavmaps.pm:1.210	Wed Jun 25 12:45:54 2003
+++ loncom/interface/lonnavmaps.pm	Wed Jun 25 14:27:18 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.210 2003/06/25 16:45:54 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.211 2003/06/25 18:27:18 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1566,7 +1566,7 @@
 =over 4
 
 =item * B<new>(navHashFile, parmHashFile, genCourseAndUserOptions,
-  genMailDiscussStatus):
+  genMailDiscussStatus, getUserData):
 
 Binds a new navmap object to the compiled nav map hash and parm hash
 given as filenames. genCourseAndUserOptions is a flag saying whether
@@ -1577,7 +1577,8 @@
 information about the email and discussion status of
 resources. Returns the navmap object if this is successful, or
 B<undef> if not. You must check for undef; errors will occur when you
-try to use the other methods otherwise.
+try to use the other methods otherwise. getUserData, if true, will 
+retreive the user's performance data for various problems.
 
 =item * B<getIterator>(first, finish, filter, condition):
 
@@ -1598,6 +1599,7 @@
     $self->{PARM_HASH_FILE} = shift;
     $self->{GENERATE_COURSE_USER_OPT} = shift;
     $self->{GENERATE_EMAIL_DISCUSS_STATUS} = shift;
+    $self->{GET_USER_DATA} = shift;
 
     # 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.
@@ -1735,7 +1737,15 @@
         $self->{DISCUSSION_TIME} = \%discussiontime;
         $self->{EMAIL_STATUS} = \%emailstatus;
         
-    }    
+    }
+
+    if ($self->{GET_USER_DATA}) {
+	# Retreive performance data on problems
+	my %student_data = Apache::lonnet::currentdump($ENV{'request.course.id'},
+						       $ENV{'user.domain'},
+						       $ENV{'user.name'});
+	$self->{STUDENT_DATA} = \%student_data;
+    }
 
     $self->{PARM_CACHE} = {};
     $self->{INITED} = 1;
@@ -3088,6 +3098,11 @@
 
 Get the answer-reveal date for the problem.
 
+=item * B<awarded>: 
+
+Gets the awarded value for the problem part. Requires genUserData set to
+true when the navmap object was created.
+
 =item * B<duedate>:
 
 Get the due date for the problem.
@@ -3141,7 +3156,11 @@
     }
     return $self->parmval("answerdate", $part);
 }
-sub awarded { my $self = shift; return $self->queryRestoreHash('awarded', shift); }
+sub awarded { 
+    my $self = shift; my $part = shift;
+    if (!defined($part)) { $part = '0'; }
+    return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'};
+}
 sub duedate {
     (my $self, my $part) = @_;
     return $self->parmval("duedate", $part);
@@ -3182,7 +3201,12 @@
 }
 sub weight { 
     my $self = shift; my $part = shift;
-    return $self->parmval("weight", $part);
+    if (!defined($part)) { $part = '0'; }
+    return &Apache::lonnet::EXT('resource.'.$part.'.weight',
+				$self->symb(), $ENV{'user.domain'},
+				$ENV{'user.name'}, 
+				$ENV{'request.course.sec'});
+
 }
 
 # Multiple things need this