:
+
+=back
+
+=cut
+
+##################################################
+##################################################
+sub assessparms {
+
+ my $r=shift;
+# -------------------------------------------------------- Variable declaration
+ my %allkeys;
+ my %allmaps;
+ my %alllevs;
+
+ $alllevs{'Resource Level'}='full';
+# $alllevs{'Resource Level [BRIEF]'}='brief';
+ $alllevs{'Map Level'}='map';
+ $alllevs{'Course Level'}='general';
+
+ my %allparms;
+ my %allparts;
+
+ my %defp;
+ %courseopt=();
+ %useropt=();
+ my %bighash=();
+
+ @ids=();
+ %symbp=();
+ %typep=();
+
+ my $message='';
+
+ $csec=$ENV{'form.csec'};
+ $udom=$ENV{'form.udom'};
+ unless ($udom) { $udom=$r->dir_config('lonDefDomain'); }
+
+ my @pscat=&get_env_multiple('form.pscat');
+ my $pschp=$ENV{'form.pschp'};
+ my @psprt=&get_env_multiple('form.psprt');
+ my $showoptions=$ENV{'form.showoptions'};
+
+ my $pssymb='';
+ my $parmlev='';
+ my $prevvisit=$ENV{'form.prevvisit'};
+
+# unless ($parmlev==$ENV{'form.parmlev'}) {
+# $parmlev = 'full';
+# }
+
+ unless ($ENV{'form.parmlev'}) {
+ $parmlev = 'map';
+ } else {
+ $parmlev = $ENV{'form.parmlev'};
+ }
+
+# ----------------------------------------------- Was this started from grades?
+
+ if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
+ && (!$ENV{'form.dis'})) {
+ my $url=$ENV{'form.url'};
+ $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+ $pssymb=&Apache::lonnet::symbread($url);
+ @pscat='all';
+ $pschp='';
+ $parmlev = 'full';
+ } elsif ($ENV{'form.symb'}) {
+ $pssymb=$ENV{'form.symb'};
+ @pscat='all';
+ $pschp='';
+ $parmlev = 'full';
+ } else {
+ $ENV{'form.url'}='';
+ }
+
+ my $id=$ENV{'form.id'};
+ if (($id) && ($udom)) {
+ $uname=(&Apache::lonnet::idget($udom,$id))[1];
+ if ($uname) {
+ $id='';
+ } else {
+ $message=
+ "Unknown ID '$id' at domain '$udom'";
+ }
+ } else {
+ $uname=$ENV{'form.uname'};
+ }
+ unless ($udom) { $uname=''; }
+ $uhome='';
+ if ($uname) {
+ $uhome=&Apache::lonnet::homeserver($uname,$udom);
+ if ($uhome eq 'no_host') {
+ $message=
+ "Unknown user '$uname' at domain '$udom'";
+ $uname='';
+ } else {
+ $csec=&Apache::lonnet::usection($udom,$uname,
+ $ENV{'request.course.id'});
+ if ($csec eq '-1') {
+ $message="".
+ "User '$uname' at domain '$udom' not ".
+ "in this course";
+ $uname='';
+ $csec=$ENV{'form.csec'};
+ } else {
+ my %name=&Apache::lonnet::userenvironment($udom,$uname,
+ ('firstname','middlename','lastname','generation','id'));
+ $message="\n\nFull Name: ".
+ $name{'firstname'}.' '.$name{'middlename'}.' '
+ .$name{'lastname'}.' '.$name{'generation'}.
+ "
\nID: ".$name{'id'}.'
';
+ }
+ }
+ }
+
+ unless ($csec) { $csec=''; }
+
+ my $fcat=$ENV{'form.fcat'};
+ 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)");
+ return ;
+ }
+
# --------------------------------------------------------- Get all assessments
- map {
- if ($_=~/^src\_(\d+)\.(\d+)$/) {
- my $mapid=$1;
- my $resid=$2;
- if ($bighash{$_}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
- $typep[$#typep+1]=$1;
- $mapp[$#mapp+1]=$mapid;
- $resp[$#resp+1]=$resid;
- $srcp[$#srcp+1]=&Apache::lonnet::declutter($bighash{$_});
- $symbp[$#symbp+1]=
- &Apache::lonnet::declutter($bighash{'map_id_'.$mapid}).
- '___'.$resid.'___'.$srcp[$#srcp];
- }
- }
- } keys %bighash;
+ extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp);
+
+ $mapp{'0.0'} = '';
+ $symbp{'0.0'} = '';
+# ---------------------------------------------------------- Anything to store?
+ if ($ENV{'form.pres_marker'}) {
+ my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'});
+ $spnam=~s/\_([^\_]+)$/\.$1/;
+# ---------------------------------------------------------- Construct prefixes
+
+ my $symbparm=$symbp{$sresid}.'.'.$spnam;
+ my $mapparm=$mapp{$sresid}.'___(all).'.$spnam;
+
+ my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam;
+ my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
+ my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
+
+ my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
+ my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
+ my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
+
+ my $storeunder='';
+ if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; }
+ if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; }
+ if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
+ if ($snum==6) { $storeunder=$seclevel; }
+ if ($snum==5) { $storeunder=$seclevelm; }
+ if ($snum==4) { $storeunder=$seclevelr; }
+
+ my %storecontent = ($storeunder => $ENV{'form.pres_value'},
+ $storeunder.'.type' => $ENV{'form.pres_type'});
+ my $reply='';
+ if ($snum>3) {
+# ---------------------------------------------------------------- Store Course
+#
+# Expire sheets
+ &Apache::lonnet::expirespread('','','studentcalc');
+ if (($snum==7) || ($snum==4)) {
+ &Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid});
+ } elsif (($snum==8) || ($snum==5)) {
+ &Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid});
+ } else {
+ &Apache::lonnet::expirespread('','','assesscalc');
+ }
+# Store parameter
+ $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ } else {
+# ------------------------------------------------------------------ Store User
+#
+# Expire sheets
+ &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
+ if ($snum==1) {
+ &Apache::lonnet::expirespread
+ ($uname,$udom,'assesscalc',$symbp{$sresid});
+ } elsif ($snum==2) {
+ &Apache::lonnet::expirespread
+ ($uname,$udom,'assesscalc',$mapp{$sresid});
+ } else {
+ &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
+ }
+# Store parameter
+ $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$udom,$uname);
+ }
+
+ if ($reply=~/^error\:(.*)/) {
+ $message.="Write Error: $1";
+ }
+# ---------------------------------------------------------------- Done storing
+ }
+# -------------------------------------------------------------- Get coursedata
+ %courseopt = &Apache::lonnet::dump
+ ('resourcedata',
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+# --------------------------------------------------- Get userdata (if present)
+ if ($uname) {
+ %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
+ }
+
# ------------------------------------------------------------------- Sort this
+ @ids=sort {
+ if ($fcat eq '') {
+ $a<=>$b;
+ } else {
+ my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
+ my $aparm=$outpar[$result];
+ ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
+ my $bparm=$outpar[$result];
+ 1*$aparm<=>1*$bparm;
+ }
+ } @ids;
+#----------------------------------------------- if all selected, fill in array
+ if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
+ if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
# ------------------------------------------------------------------ Start page
- $r->content_type('text/html');
- $r->send_http_header;
- $r->print('
');
-
- $r->print('');
- untie(%bighash);
- untie(%parmhash);
- }
- } else {
+
+ &startpage($r,$id,$udom,$csec,$uname);
+# if ($ENV{'form.url'}) {
+# $r->print('');
+# }
+ $r->print('');
+
+ foreach ('tolerance','date_default','date_start','date_end',
+ 'date_interval','int','float','string') {
+ $r->print('');
+ }
+
+ $r->print(''.$message.'
');
+
+ my @temp_psprt;
+ foreach my $t (@psprt) {
+ push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
+ }
+
+ @psprt = @temp_psprt;
+
+ my @temp_pscat;
+ map {
+ my $cat = $_;
+ push(@temp_pscat, map { $_.'.'.$cat } @psprt);
+ } @pscat;
+
+ @pscat = @temp_pscat;
+
+ if (($prevvisit) || ($pschp) || ($pssymb)) {
+# ----------------------------------------------------------------- Start Table
+ my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
+ my $csuname=$ENV{'user.name'};
+ my $csudom=$ENV{'user.domain'};
+
+
+ if ($parmlev eq 'full' || $parmlev eq 'brief') {
+
+ my $coursespan=$csec?8:5;
+ $r->print('');
+ $r->print(' | ');
+ $r->print('Any User | ');
+ if ($uname) {
+ $r->print("");
+ $r->print("User $uname at Domain $udom | ");
+ }
+ $r->print(<Parameter in Effect
+Current Session Value ($csuname at $csudom) |
+
---|
| Resource Level |
+in Course |
+ENDTABLETWO
+ if ($csec) {
+ $r->print("in Section/Group $csec | ");
+ }
+ $r->print(<Assessment URL and Title | Type |
+Enclosing Map | Part No. | Parameter Name |
+default | from Enclosing Map |
+general | for Enclosing Map | for Resource |
+ENDTABLEHEADFOUR
+
+ if ($csec) {
+ $r->print('general | for Enclosing Map | for Resource | ');
+ }
+
+ if ($uname) {
+ $r->print('general | for Enclosing Map | for Resource | ');
+ }
+
+ $r->print('
');
+
+ my $defbgone='';
+ my $defbgtwo='';
+
+ foreach (@ids) {
+
+ my $rid=$_;
+ my ($inmapid)=($rid=~/\.(\d+)$/);
+
+ if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) ||
+ ($pssymb eq $symbp{$rid})) {
+# ------------------------------------------------------ Entry for one resource
+ if ($defbgone eq '"E0E099"') {
+ $defbgone='"E0E0DD"';
+ } else {
+ $defbgone='"E0E099"';
+ }
+ if ($defbgtwo eq '"FFFF99"') {
+ $defbgtwo='"FFFFDD"';
+ } else {
+ $defbgtwo='"FFFF99"';
+ }
+ my $thistitle='';
+ my %name= ();
+ undef %name;
+ my %part= ();
+ my %display=();
+ my %type= ();
+ my %default=();
+ my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+
+ foreach (split(/\,/,$keyp{$rid})) {
+ my $tempkeyp = $_;
+ if (grep $_ eq $tempkeyp, @catmarker) {
+ $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
+ $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
+ $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
+ unless ($display{$_}) { $display{$_}=''; }
+ $display{$_}.=' ('.$name{$_}.')';
+ $default{$_}=&Apache::lonnet::metadata($uri,$_);
+ $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
+ $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
+ }
+ }
+ my $totalparms=scalar keys %name;
+ if ($totalparms>0) {
+ my $firstrow=1;
+
+ $r->print(''.
+ join(' / ',split(/\//,$uri)).
+ ' '.
+ "$bighash{'title_'.$rid}");
+
+ if ($thistitle) {
+ $r->print(' ('.$thistitle.')');
+ }
+ $r->print(' | ');
+ $r->print(''.$typep{$rid}.
+ ' | ');
+
+ $r->print('');
+
+ $r->print(' / res / ');
+ $r->print(join(' / ', split(/\//,$mapp{$rid})));
+
+ $r->print(' | ');
+
+ foreach (sort keys %name) {
+ unless ($firstrow) {
+ $r->print('
');
+ } else {
+ undef $firstrow;
+ }
+
+ &print_row($r,$_,\%part,\%name,$rid,\%default,
+ \%type,\%display,$defbgone,$defbgtwo,
+ $parmlev);
+ }
+ }
+ }
+ } # end foreach ids
+# -------------------------------------------------- End entry for one resource
+ $r->print('
---|
');
+ } # end of brief/full
+#--------------------------------------------------- Entry for parm level map
+ if ($parmlev eq 'map') {
+ my $defbgone = '"E0E099"';
+ my $defbgtwo = '"FFFF99"';
+
+ my %maplist;
+
+ if ($pschp eq 'all') {
+ %maplist = %allmaps;
+ } else {
+ %maplist = ($pschp => $mapp{$pschp});
+ }
+
+#-------------------------------------------- for each map, gather information
+ my $mapid;
+ foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
+ my $maptitle = $maplist{$mapid};
+
+#----------------------- loop through ids and get all parameter types for map
+#----------------------------------------- and associated information
+ my %name = ();
+ my %part = ();
+ my %display = ();
+ my %type = ();
+ my %default = ();
+ my $map = 0;
+
+# $r->print("Catmarker: @catmarker
\n");
+
+ foreach (@ids) {
+ ($map)=(/([\d]*?)\./);
+ my $rid = $_;
+
+# $r->print("$mapid:$map: $rid
\n");
+
+ if ($map eq $mapid) {
+ my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+# $r->print("Keys: $keyp{$rid}
\n");
+
+#--------------------------------------------------------------------
+# @catmarker contains list of all possible parameters including part #s
+# $fullkeyp contains the full part/id # for the extraction of proper parameters
+# $tempkeyp contains part 0 only (no ids - ie, subparts)
+# When storing information, store as part 0
+# When requesting information, request from full part
+#-------------------------------------------------------------------
+ foreach (split(/\,/,$keyp{$rid})) {
+ my $tempkeyp = $_;
+ my $fullkeyp = $tempkeyp;
+ $tempkeyp =~ s/_[\d_]+_/_0_/;
+
+ if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
+ $part{$tempkeyp}="0";
+ $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
+ $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
+ unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
+ $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
+ $display{$tempkeyp} =~ s/_[\d_]+_/_0_/;
+ $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
+ $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
+ }
+ } # end loop through keys
+ }
+ } # end loop through ids
+
+#---------------------------------------------------- print header information
+ $r->print(<
+Set Defaults for All Resources in map
+$maptitle
+Specifically for
+ENDMAPONE
+ if ($uname) {
+ my %name=&Apache::lonnet::userenvironment($udom,$uname,
+ ('firstname','middlename','lastname','generation', 'id'));
+ my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
+ .$name{'lastname'}.' '.$name{'generation'};
+ $r->print("User $uname \($person\) in \n");
+ } else {
+ $r->print("all users in \n");
+ }
+
+ if ($csec) {$r->print("Section $csec of \n")};
+
+ $r->print("$coursename
");
+ $r->print("
\n");
+#---------------------------------------------------------------- print table
+ $r->print('');
+ $r->print('Parameter Name | ');
+ $r->print('Default Value | ');
+ $r->print('Parameter in Effect |
');
+
+ foreach (sort keys %name) {
+ &print_row($r,$_,\%part,\%name,$mapid,\%default,
+ \%type,\%display,$defbgone,$defbgtwo,
+ $parmlev);
+# $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid} |
\n");
+ }
+ $r->print("
");
+ } # end each map
+ } # end of $parmlev eq map
+#--------------------------------- Entry for parm level general (Course level)
+ if ($parmlev eq 'general') {
+ my $defbgone = '"E0E099"';
+ my $defbgtwo = '"FFFF99"';
+
+#-------------------------------------------- for each map, gather information
+ my $mapid="0.0";
+#----------------------- loop through ids and get all parameter types for map
+#----------------------------------------- and associated information
+ my %name = ();
+ my %part = ();
+ my %display = ();
+ my %type = ();
+ my %default = ();
+
+ foreach (@ids) {
+ my $rid = $_;
+
+ my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+
+#--------------------------------------------------------------------
+# @catmarker contains list of all possible parameters including part #s
+# $fullkeyp contains the full part/id # for the extraction of proper parameters
+# $tempkeyp contains part 0 only (no ids - ie, subparts)
+# When storing information, store as part 0
+# When requesting information, request from full part
+#-------------------------------------------------------------------
+ foreach (split(/\,/,$keyp{$rid})) {
+ my $tempkeyp = $_;
+ my $fullkeyp = $tempkeyp;
+ $tempkeyp =~ s/_[\d_]+_/_0_/;
+ if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
+ $part{$tempkeyp}="0";
+ $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
+ $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
+ unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
+ $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
+ $display{$tempkeyp} =~ s/_[\d_]+_/_0_/;
+ $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
+ $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
+ }
+ } # end loop through keys
+ } # end loop through ids
+
+#---------------------------------------------------- print header information
+ $r->print(<
+Set Defaults for All Resources in Course
+$coursename
+ENDMAPONE
+ if ($uname) {
+ my %name=&Apache::lonnet::userenvironment($udom,$uname,
+ ('firstname','middlename','lastname','generation', 'id'));
+ my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
+ .$name{'lastname'}.' '.$name{'generation'};
+ $r->print(" User $uname \($person\) \n");
+ } else {
+ $r->print("ALL USERS \n");
+ }
+
+ if ($csec) {$r->print("Section $csec\n")};
+ $r->print("
\n");
+#---------------------------------------------------------------- print table
+ $r->print('');
+ $r->print('Parameter Name | ');
+ $r->print('Default Value | ');
+ $r->print('Parameter in Effect |
');
+
+ foreach (sort keys %name) {
+ &print_row($r,$_,\%part,\%name,$mapid,\%default,
+ \%type,\%display,$defbgone,$defbgtwo,$parmlev);
+# $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid} |
\n");
+ }
+ $r->print("
");
+ } # end of $parmlev eq general
+ }
+ $r->print('