[LON-CAPA-cvs] cvs: loncom /interface loncoursedata.pm lonstatistics.pm /interface/statistics lonstudentassessment.pm

stredwic lon-capa-cvs@mail.lon-capa.org
Sun, 01 Sep 2002 06:23:19 -0000


This is a MIME encoded message

--stredwic1030861399
Content-Type: text/plain

stredwic		Sun Sep  1 02:23:19 2002 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm lonstatistics.pm 
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  First, fixed a typo in lonstudentassessment.  Also, fixed the updating of
  the statistics information if the resource tree changes.  Note, in
  student assessment it will show up as a blank space unless an attempt
  was made for that problem.
  
  
--stredwic1030861399
Content-Type: text/plain
Content-Disposition: attachment; filename="stredwic-20020901022319.txt"

Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.27 loncom/interface/loncoursedata.pm:1.28
--- loncom/interface/loncoursedata.pm:1.27	Sat Aug 31 14:31:15 2002
+++ loncom/interface/loncoursedata.pm	Sun Sep  1 02:23:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: loncoursedata.pm,v 1.27 2002/08/31 18:31:15 stredwic Exp $
+# $Id: loncoursedata.pm,v 1.28 2002/09/01 06:23:19 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -309,6 +309,15 @@
         return 'Can not open Coursemap.';
     }
 
+    my $oldkeys;
+    if(defined($cache->{'ResourceKeys'})) {
+        $oldkeys = $cache->{'ResourceKeys'};
+        foreach (split(':::', $cache->{'ResourceKeys'})) {
+            delete $cache->{$_};
+        }
+        delete $cache->{'ResourceKeys'};
+    }
+
     # Initialize state machine.  Set information pointing to top level map.
     my (@sequences, @currentResource, @finishResource);
     my ($currentSequence, $currentResourceID, $lastResourceID);
@@ -320,6 +329,7 @@
     my $topLevelSequenceNumber = $currentSequence;
 
     my %sequenceRecord;
+    my %allkeys;
     while(1) {
         if($c->aborted()) {
             last;
@@ -344,6 +354,7 @@
             } else {
                 $cache->{'orderedSequences'}.=':'.$currentSequence;
             }
+            $allkeys{'orderedSequences'}++;
 
 	    $lastResourceID=$hash{'map_finish_'.
 				  $hash{'src_'.$currentResourceID}};
@@ -378,20 +389,24 @@
 							 $currentResourceID}));
 
 	    $cache->{$currentResourceID.':problem'}=$Problem;
+            $allkeys{$currentResourceID.':problem'}++;
 	    if(!defined($cache->{$currentSequence.':problems'})) {
 		$cache->{$currentSequence.':problems'}=$currentResourceID;
 	    } else {
 		$cache->{$currentSequence.':problems'}.=
 		    ':'.$currentResourceID;
 	    }
+            $allkeys{$currentSequence.':problems'}++;
 
 	    my $meta=$hash{'src_'.$currentResourceID};
 #            $cache->{$currentResourceID.':title'}=
 #                &Apache::lonnet::metdata($meta,'title');
             $cache->{$currentResourceID.':title'}=
                 $hash{'title_'.$currentResourceID};
+            $allkeys{$currentResourceID.':title'}++;
             $cache->{$currentResourceID.':source'}=
                 $hash{'src_'.$currentResourceID};
+            $allkeys{$currentResourceID.':source'}++;
 
             # Get Parts for problem
             my %beenHere;
@@ -408,6 +423,8 @@
                             $cache->{$currentSequence.':'.$currentResourceID.
                                      ':parts'}.=':'.$partId;
                         }
+                        $allkeys{$currentSequence.':'.$currentResourceID.
+                                  ':parts'}++;
                     }
                     if($beenHere{'r:'.$partId.':'.$responseId} == 0) {
                         $beenHere{'r:'.$partId.':'.$responseId}++;
@@ -421,6 +438,8 @@
                                      ':'.$partId.':responseIDs'}.=':'.
                                                                   $responseId;
                         }
+                        $allkeys{$currentSequence.':'.$currentResourceID.':'.
+                                     $partId.':responseIDs'}++;
                     }
                     if(/^optionresponse/ && 
                        $beenHere{'o:'.$partId.':'.$currentResourceID} == 0) {
@@ -434,6 +453,7 @@
                                 $currentResourceID.':'.
                                 $partId.':'.$responseId;
                         }
+                        $allkeys{'OptionResponses'}++;
                     }
                 }
             }
@@ -449,8 +469,10 @@
 		# Capture sequence information here
 		$cache->{$currentSequence.':title'}=
 		    $hash{'title_'.$currentResourceID};
+                $allkeys{$currentSequence.':title'}++;
                 $cache->{$currentSequence.':source'}=
                     $hash{'src_'.$currentResourceID};
+                $allkeys{$currentSequence.':source'}++;
 
                 my $totalProblems=0;
                 foreach my $currentProblem (split(/\:/,
@@ -474,6 +496,7 @@
 		    $cache->{$currentSequence.':columnWidth'}=
                         (scalar @titleLength);
 		}
+                $allkeys{$currentSequence.':columnWidth'}++;
 	    } else {
                 # Remove sequence from list, if it contains no problems to
                 # display.
@@ -510,6 +533,15 @@
 	$currentResourceID=pop(@currentResource);
     }
 
+    my @theKeys = keys(%allkeys);
+    my $newkeys = join(':::', @theKeys);
+    $cache->{'ResourceKeys'} = join(':::', $newkeys);
+    if($newkeys ne $oldkeys) {
+        $cache->{'ResourceUpdated'} = 'true';
+    } else {
+        $cache->{'ResourceUpdated'} = 'false';
+    }
+
     unless (untie(%hash)) {
         &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                                  "Could not untie coursemap $fn (browse)".
@@ -693,10 +725,13 @@
         return;
     }
 
+    # This little delete thing, should not be here.  Move some other
+    # time though.
     if(defined($cache->{$name.':keys'})) {
 	foreach (split(':::', $cache->{$name.':keys'})) {
 	    delete $cache->{$name.':'.$_};
 	}
+        delete $cache->{$name.':keys'};
     }
 
     my %courseKeys;
@@ -764,11 +799,14 @@
         return;
     }
 
+    # This little delete thing, should not be here.  Move some other
+    # time though.
     my %allkeys;
     if(defined($output->{$name.':keys'})) {
 	foreach (split(':::', $output->{$name.':keys'})) {
 	    delete $output->{$name.':'.$_};
 	}
+        delete $output->{$name.':keys'};
     }
 
     my ($username,$domain)=split(':',$name);
@@ -1160,17 +1198,19 @@
         }
 
         my $downloadTime='Not downloaded';
+        my $needUpdate = 'false';
         if($checkDate eq 'true'  && 
            tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
             $downloadTime = $cache{$_.':lastDownloadTime'};
+            $needUpdate = $cache{'ResourceUpdated'};
             untie(%cache);
         }
 
         if($c->aborted()) { return 'Aborted'; }
 
-        #if($downloadTime ne 'Not downloaded') {
-	#    next;
-	#}
+        if($needUpdate eq 'true') {
+            $downloadTime = 'Not downloaded';
+	}
 	my $courseData = 
 	    &DownloadCourseInformation($_, $courseID, $downloadTime, 
 				       $WhatIWant);
@@ -1230,9 +1270,11 @@
 
         my %cache;
         my $downloadTime='Not downloaded';
+        my $needUpdate = 'false';
         if($checkDate eq 'true'  && 
            tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
             $downloadTime = $cache{$_.':lastDownloadTime'};
+            $needUpdate = $cache{'ResourceUpdated'};
             untie(%cache);
         }
 
@@ -1240,31 +1282,33 @@
             return 'Aborted';
         }
 
-        #if($downloadTime eq 'Not downloaded') {
-            my $error = 0;
-            my $courseData = 
-                &DownloadCourseInformation($_, $courseID, $downloadTime,
-                                           $WhatIWant);
-            my %downloadData;
-            unless(tie(%downloadData,'GDBM_File',$residualFile,
-                       &GDBM_WRCREAT(),0640)) {
-                return 'Failed to tie temporary download hash.';
-            }
-            foreach my $key (keys(%$courseData)) {
-                $downloadData{$key} = $courseData->{$key};
-                if($key =~ /^(con_lost|error|no_such_host)/i) {
-                    $error = 1;
-                    last;
-                }
+        if($needUpdate eq 'true') {
+            $downloadTime = 'Not downloaded';
+	}
+
+        my $error = 0;
+        my $courseData = 
+            &DownloadCourseInformation($_, $courseID, $downloadTime,
+                                       $WhatIWant);
+        my %downloadData;
+        unless(tie(%downloadData,'GDBM_File',$residualFile,
+                   &GDBM_WRCREAT(),0640)) {
+            return 'Failed to tie temporary download hash.';
+        }
+        foreach my $key (keys(%$courseData)) {
+            $downloadData{$key} = $courseData->{$key};
+            if($key =~ /^(con_lost|error|no_such_host)/i) {
+                $error = 1;
+                last;
             }
-            if($error) {
-                foreach my $deleteKey (keys(%$courseData)) {
-                    delete $downloadData{$deleteKey};
-                }
-                $downloadData{$_.':error'} = 'No course data for '.$_;
+        }
+        if($error) {
+            foreach my $deleteKey (keys(%$courseData)) {
+                delete $downloadData{$deleteKey};
             }
-            untie(%downloadData);
-        #}
+            $downloadData{$_.':error'} = 'No course data for '.$_;
+        }
+        untie(%downloadData);
     }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
 
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.49 loncom/interface/lonstatistics.pm:1.50
--- loncom/interface/lonstatistics.pm:1.49	Fri Aug 30 11:35:08 2002
+++ loncom/interface/lonstatistics.pm	Sun Sep  1 02:23:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstatistics.pm,v 1.49 2002/08/30 15:35:08 stredwic Exp $
+# $Id: lonstatistics.pm,v 1.50 2002/09/01 06:23:19 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -324,14 +324,14 @@
         return "Unable to tie hash to db file.";
     }
 
-    if(!$isCached) {
+#    if(!$isCached) {
         my $processTopResourceMapReturn=
-            &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c, $r);
+            &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c);
         if($processTopResourceMapReturn ne 'OK') {
             untie(%cache);
             return $processTopResourceMapReturn;
         }
-    }
+ #   }
 
     if($c->aborted()) {
         untie(%cache);
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.10 loncom/interface/statistics/lonstudentassessment.pm:1.11
--- loncom/interface/statistics/lonstudentassessment.pm:1.10	Sat Aug 31 15:25:39 2002
+++ loncom/interface/statistics/lonstudentassessment.pm	Sun Sep  1 02:23:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstudentassessment.pm,v 1.10 2002/08/31 19:25:39 stredwic Exp $
+# $Id: lonstudentassessment.pm,v 1.11 2002/09/01 06:23:19 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
 #    $jr = $r;
     my %cache;
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-[5~        $r->print('<html><body>Unable to tie database.</body></html>');
+        $r->print('<html><body>Unable to tie database.</body></html>');
         return;
     }
 

--stredwic1030861399--