--- loncom/interface/lonparmset.pm 2005/05/30 17:58:51 1.195
+++ loncom/interface/lonparmset.pm 2005/06/01 02:02:41 1.196
@@ -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 %symbp;
my %mapp;
my %typep;
my %keyp;
-
+my %uris;
my %maptitles;
##################################################
@@ -675,7 +675,6 @@ Input: See list below:
=cut
sub extractResourceInformation {
- my $bighash = shift;
my $ids = shift;
my $typep = shift;
my $keyp = shift;
@@ -688,63 +687,62 @@ sub extractResourceInformation {
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 @@ sub assessparms {
my %defp;
%courseopt=();
%useropt=();
- my %bighash=();
@ids=();
%symbp=();
@@ -906,11 +903,7 @@ sub assessparms {
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 @@ sub assessparms {
}
# --------------------------------------------------------- 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 @@ sub assessparms {
&startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
if (!$have_assesments) {
- untie(%bighash);
untie(%parmhash);
return '';
}
@@ -1238,7 +1230,7 @@ ENDTABLEHEADFOUR
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 @@ ENDTABLEHEADFOUR
# $r->print("$mapid:$map: $rid
\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}
\n");
#--------------------------------------------------------------------
@@ -1425,7 +1417,7 @@ ENDMAPONE
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 @@ ENDMAPONE
} # end of $parmlev eq general
}
$r->print('