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

stredwic lon-capa-cvs@mail.lon-capa.org
Wed, 17 Jul 2002 12:38:25 -0000


stredwic		Wed Jul 17 08:38:25 2002 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  Gather some extra data about the resource tree in ProcessTopLevelMap.  The
  problem title and option response information are needed in lonstatistics.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.1 loncom/interface/loncoursedata.pm:1.2
--- loncom/interface/loncoursedata.pm:1.1	Tue Jul  9 11:43:49 2002
+++ loncom/interface/loncoursedata.pm	Wed Jul 17 08:38:25 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: loncoursedata.pm,v 1.1 2002/07/09 15:43:49 stredwic Exp $
+# $Id: loncoursedata.pm,v 1.2 2002/07/17 12:38:25 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -309,8 +309,13 @@
 		    ':'.$currentResourceID;
 	    }
 
-            # Get Parts for problem
 	    my $meta=$hash{'src_'.$currentResourceID};
+#            $cache->{$currentResourceID.':title'}=
+#                &Apache::lonnet::metdata($meta,'title');
+            $cache->{$currentResourceID.':title'}=
+                $hash{'title_'.$currentResourceID};
+
+            # Get Parts for problem
 	    foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
 		if($_=~/^stores\_(\d+)\_tries$/) {
 		    my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
@@ -322,7 +327,23 @@
                         $cache->{$currentSequence.':'.$currentResourceID.
                                    ':parts'}.=':'.$Part;
                     }
-		}
+                    foreach (split(/\,/,
+                             &Apache::lonnet::metadata($meta,'packages'))) {
+                        if($_=~/^optionresponse\_($Part)\_(\w+)$/) {
+                            if(defined($cache->{'OptionResponses'})) {
+                                $cache->{'OptionResponses'}.= ':::'.
+                                    $hash{'src_'.$currentResourceID}.'::'.
+                                    $hash{'title_'.$currentResourceID}.'::'.
+                                    $Part.'::'.$Problem;
+                            } else {
+                                $cache->{'OptionResponses'}=
+                                    $hash{'src_'.$currentResourceID}.'::'.
+                                    $hash{'title_'.$currentResourceID}.'::'.
+                                    $Part.'::'.$Problem;
+                            }
+                        }
+                    }
+                }
 	    }
 	}
 
@@ -336,6 +357,8 @@
 		# Capture sequence information here
 		$cache->{$currentSequence.':title'}=
 		    $hash{'title_'.$currentResourceID};
+                $cache->{$currentSequence.':source'}=
+                    $hash{'src_'.$currentResourceID};
 
                 my $totalProblems=0;
                 foreach my $currentProblem (split(/\:/,
@@ -442,40 +465,41 @@
 	    if($key eq $courseid.'_st') {
 		$section='';
 	    }
+
 	    my ($dummy,$end,$start)=split(/\_/,$value);
 	    my $now=time;
-	    my $notactive=0;
-	    if ($start) {
-		if($now<$start) {
-		    $notactive=1;
-		}
-	    }
-	    if($end) {
-		if ($now>$end) {
-		    $notactive=1;
-		}
-	    }
-	    if($notactive == 0) {
-		$status='Active';
-		$cursection=$section;
-		last;
-	    }
-	    if($notactive == 1) {
-		$oldsection=$section;
-	    }
+            my $notactive=0;
+            if ($start) {
+                if($now<$start) {
+                    $notactive=1;
+                }
+            }
+            if($end) {
+                if ($now>$end) {
+                    $notactive=1;
+                }
+            }
+            if($notactive == 0) {
+                $status='Active';
+                $cursection=$section;
+                last;
+            }
+            if($notactive == 1) {
+                $oldsection=$section;
+            }
 	}
     }
     if($status eq $ActiveFlag) {
-	if($cursection eq '-1') {
-	    return $oldsection;
-	}
-	return $cursection;
+        if($cursection eq '-1') {
+            return $oldsection;
+        }
+        return $cursection;
     }
     if($ActiveFlag eq 'Any') {
-	if($cursection eq '-1') {
-	    return $oldsection;
-	}
-	return $cursection;
+        if($cursection eq '-1') {
+            return $oldsection;
+        }
+        return $cursection;
     }
     return '-1';
 }
@@ -539,12 +563,11 @@
 	$cache->{$name.':id'}=$studentInformation->{'id'};
     }
 
-    # Get student's section number
     my $sec=&ProcessSection($section, $courseID, $status);
     if($sec != -1) {
-	$cache->{$name.':section'}=$sec;
+        $cache->{$name.':section'}=$sec;
     } else {
-	$cache->{$name.':section'}='';
+        $cache->{$name.':section'}='';
     }
 
     return;
@@ -791,6 +814,35 @@
 
     return $isCached;
 }
+
+#sub CheckStatus {
+#    my ($name, $data, $status)=@_;
+
+#    if($status eq 'Any') {
+#        my $section = ' ';
+#        foreach (split(':',$data->{$name.':Sections'})) {
+#            if($data->{$name.':'.$_.'Status'} eq 'Active') {
+#                return $_;
+#            }
+#            $section = $_;
+#        }
+#        return $_;
+#    }
+
+#    foreach (split(':',$data->{$name.':Sections'})) {
+#        if($data->{$name.':'.$_.'Status'} eq $status) {
+#            return $_;
+#        }
+#    }
+
+#    foreach (split(':',$data->{$name.':Sections'})) {
+#        if($data->{$name.':'.$_.'Status'} eq 'Any') {
+#            return $_;
+#        }
+#    }
+
+#    return 'not found';
+#}
 
 # ----- END HELPER FUNCTIONS --------------------------------------------