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

www lon-capa-cvs@mail.lon-capa.org
Wed, 01 Jun 2005 02:02:43 -0000


This is a MIME encoded message

--www1117591363
Content-Type: text/plain

www		Tue May 31 22:02:43 2005 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm lonparmset.pm 
  Log:
  Well, it does use navmaps now ... but still a long way to go to actually
  clean it up.
  
  
--www1117591363
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20050531220243.txt"

Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.327 loncom/interface/lonnavmaps.pm:1.328
--- loncom/interface/lonnavmaps.pm:1.327	Sat Apr 16 11:33:14 2005
+++ loncom/interface/lonnavmaps.pm	Tue May 31 22:02:41 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.327 2005/04/16 15:33:14 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.328 2005/06/01 02:02:41 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3500,6 +3500,15 @@
     if ($self->encrypted()) {return &Apache::lonenc::encrypted($self->symb());}
     return $self->symb();
 }
+sub id {
+    my $self=shift;
+    return $self->{ID};
+}
+sub enclosing_map_src {
+    my $self=shift;
+    (my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/;
+    return $self->navHash('map_id_'.$first);
+}
 sub symb {
     my $self=shift;
     (my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/;
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.195 loncom/interface/lonparmset.pm:1.196
--- loncom/interface/lonparmset.pm:1.195	Mon May 30 13:58:51 2005
+++ loncom/interface/lonparmset.pm	Tue May 31 22:02:41 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.195 2005/05/30 17:58:51 albertel Exp $
+# $Id: lonparmset.pm,v 1.196 2005/06/01 02:02:41 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -72,7 +72,7 @@
 my %mapp;
 my %typep;
 my %keyp;
-
+my %uris;
 my %maptitles;
 
 ##################################################
@@ -675,7 +675,6 @@
 =cut
 
 sub extractResourceInformation {
-    my $bighash = shift;
     my $ids = shift;
     my $typep = shift;
     my $keyp = shift;
@@ -688,63 +687,62 @@
     my $mapp = shift;
     my $symbp = shift;
     my $maptitles=shift;
+    my $uris=shift;
+
 
-    foreach (keys %$bighash) {
-	if ($_=~/^src\_(\d+)\.(\d+)$/) {
-	    # there are no resources in the 0 level
-	    if ($1 eq '0') { next; }
-	    my $mapid=$1;
-	    my $resid=$2;
-	    my $id=$mapid.'.'.$resid;
-	    my $srcf=$$bighash{$_};
-	    if (1) {
-		$srcf=~/\.(\w+)$/;
-		$$ids[$#$ids+1]=$id;
-		$$typep{$id}=$1;
-		$$keyp{$id}='';
-		foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
-		  if ($_=~/^parameter\_(.*)/) {
-                    my $key=$_;
-                    my $allkey=$1;
-                    $allkey=~s/\_/\./g;
-		    if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 
-			'parm') {
-			next; #hide hidden things
-		    }
-                    my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
-                    my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
-                    my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
-                    my $parmdis = $display;
-                    $parmdis =~ s|(\[Part.*)$||g;
-                    my $partkey = $part;
-                    $partkey =~ tr|_|.|;
-                    $$allparms{$name} = $parmdis;
-                    $$allparts{$part} = "[Part $part]";
-                    $$allkeys{$allkey}=$display;
-                    if ($allkey eq $fcat) {
-		        $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
-		    }
-		    if ($$keyp{$id}) {
-		        $$keyp{$id}.=','.$key;
-		    } else {
-		        $$keyp{$id}=$key;
-		    }
-		  }
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
+    foreach my $resource (@allres) {
+	my $id=$resource->id();
+        my ($mapid,$resid)=split(/\./,$id);
+	if ($mapid eq '0') { next; }
+	$$ids[$#$ids+1]=$id;
+	my $srcf=$resource->src();
+	$srcf=~/\.(\w+)$/;
+	$$typep{$id}=$1;
+	$$keyp{$id}='';
+        $$uris{$id}=$srcf;
+	foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
+	    if ($_=~/^parameter\_(.*)/) {
+		my $key=$_;
+		my $allkey=$1;
+		$allkey=~s/\_/\./g;
+		if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 
+		    'parm') {
+		    next; #hide hidden things
 		}
-		$$mapp{$id}=
-		    &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid});
-                $$mapp{$mapid}=$$mapp{$id};
-		$$allmaps{$mapid}=$$mapp{$id};
-		if ($mapid eq '1') {
-		    $$maptitles{$mapid}='Main Course Documents';
+		my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
+		my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+		my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+		my $parmdis = $display;
+		$parmdis =~ s|(\[Part.*)$||g;
+		my $partkey = $part;
+		$partkey =~ tr|_|.|;
+		$$allparms{$name} = $parmdis;
+		$$allparts{$part} = "[Part $part]";
+		$$allkeys{$allkey}=$display;
+		if ($allkey eq $fcat) {
+		    $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
+		}
+		if ($$keyp{$id}) {
+		    $$keyp{$id}.=','.$key;
 		} else {
-		    $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
+		    $$keyp{$id}=$key;
 		}
-		$$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
-		$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
-                $$symbp{$mapid}=$$mapp{$id}.'___(all)';
 	    }
 	}
+	$$mapp{$id}=
+	    &Apache::lonnet::declutter($resource->enclosing_map_src());
+	$$mapp{$mapid}=$$mapp{$id};
+	$$allmaps{$mapid}=$$mapp{$id};
+	if ($mapid eq '1') {
+	    $$maptitles{$mapid}='Main Course Documents';
+	} else {
+	    $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
+	}
+	$$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
+	$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
+	$$symbp{$mapid}=$$mapp{$id}.'___(all)';
     }
 }
 
@@ -803,7 +801,6 @@
     my %defp;
     %courseopt=();
     %useropt=();
-    my %bighash=();
 
     @ids=();
     %symbp=();
@@ -906,11 +903,7 @@
     unless ($fcat) { $fcat=''; }
 
 # ------------------------------------------------------------------- Tie hashs
-    if (!(tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
-	      &GDBM_READER(),0640))) {
-	$r->print("Unable to access course data. (File $env{'request.course.fn'}.db not tieable)");
-	return ;
-    }
+
     if (!(tie(%parmhash,'GDBM_File',
 	      $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
 	$r->print("Unable to access parameter data. (File $env{'request.course.fn'}_parms.db not tieable)");
@@ -918,7 +911,7 @@
     }
 
 # --------------------------------------------------------- Get all assessments
-    &extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles);
+    &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
 
     $mapp{'0.0'} = '';
     $symbp{'0.0'} = '';
@@ -972,7 +965,6 @@
     &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
 
     if (!$have_assesments) {
-	untie(%bighash);
 	untie(%parmhash);
 	return '';
     }
@@ -1238,7 +1230,7 @@
                     my %display=();
                     my %type=   ();
                     my %default=();
-                    my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+                    my $uri=&Apache::lonnet::declutter($uris{$rid});
 
                     foreach (split(/\,/,$keyp{$rid})) {
                         my $tempkeyp = $_;
@@ -1337,7 +1329,7 @@
 #                  $r->print("$mapid:$map:   $rid <br /> \n");
 
                   if ($map eq $mapid) {
-                    my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+                    my $uri=&Apache::lonnet::declutter($uris{$rid});
 #                    $r->print("Keys: $keyp{$rid} <br />\n");
 
 #--------------------------------------------------------------------
@@ -1425,7 +1417,7 @@
             foreach (@ids) {
                 my $rid = $_;
         
-                my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+                my $uri=&Apache::lonnet::declutter($uris{$rid});
 
 #--------------------------------------------------------------------
 # @catmarker contains list of all possible parameters including part #s
@@ -1485,7 +1477,6 @@
         } # end of $parmlev eq general
     }
     $r->print('</form></body></html>');
-    untie(%bighash);
     untie(%parmhash);
 } # end sub assessparms
 

--www1117591363--