File:  [LON-CAPA] / loncom / interface / lonparmset.pm
Revision 1.268.2.5: download - view: text, annotated - select for diffs
Mon Jun 19 09:38:16 2006 UTC (17 years, 11 months ago) by albertel
Branches: version_2_1_X
- backport 1.313

    1: # The LearningOnline Network with CAPA
    2: # Handler to set parameters for assessments
    3: #
    4: # $Id: lonparmset.pm,v 1.268.2.5 2006/06/19 09:38:16 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###################################################################
   29: ###################################################################
   30: 
   31: =pod
   32: 
   33: =head1 NAME
   34: 
   35: lonparmset - Handler to set parameters for assessments and course
   36: 
   37: =head1 SYNOPSIS
   38: 
   39: lonparmset provides an interface to setting course parameters. 
   40: 
   41: =head1 DESCRIPTION
   42: 
   43: This module sets coursewide and assessment parameters.
   44: 
   45: =head1 INTERNAL SUBROUTINES
   46: 
   47: =over 4
   48: 
   49: =cut
   50: 
   51: ###################################################################
   52: ###################################################################
   53: 
   54: package Apache::lonparmset;
   55: 
   56: use strict;
   57: use Apache::lonnet;
   58: use Apache::Constants qw(:common :http REDIRECT);
   59: use Apache::lonhtmlcommon();
   60: use Apache::loncommon;
   61: use GDBM_File;
   62: use Apache::lonhomework;
   63: use Apache::lonxml;
   64: use Apache::lonlocal;
   65: use Apache::lonnavmaps;
   66: 
   67: # --- Caches local to lonparmset
   68: 
   69: my $parmhashid;
   70: my %parmhash;
   71: my $symbsid;
   72: my %symbs;
   73: my $rulesid;
   74: my %rules;
   75: 
   76: # --- end local caches
   77: 
   78: ##################################################
   79: ##################################################
   80: 
   81: =pod
   82: 
   83: =item parmval
   84: 
   85: Figure out a cascading parameter.
   86: 
   87: Inputs:  $what - a parameter spec (incluse part info and name I.E. 0.weight)
   88:          $id   - a bighash Id number
   89:          $def  - the resource's default value   'stupid emacs
   90: 
   91: Returns:  A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 11 possible levels
   92: 
   93: 11 - General Course
   94: 10 - Map or Folder level in course
   95: 9- resource default
   96: 8- map default
   97: 7 - resource level in course
   98: 6 - General for section
   99: 5 - Map or Folder level for section
  100: 4 - resource level in section
  101: 3 - General for specific student
  102: 2 - Map or Folder level for specific student
  103: 1 - resource level for specific student
  104: 
  105: =cut
  106: 
  107: ##################################################
  108: sub parmval {
  109:     my ($what,$id,$def,$uname,$udom,$csec)=@_;
  110:     return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec);
  111: }
  112: 
  113: sub parmval_by_symb {
  114:     my ($what,$symb,$def,$uname,$udom,$csec)=@_;
  115: # load caches
  116: 
  117:     &cacheparmhash();
  118: 
  119:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
  120:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  121:     my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
  122:     my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
  123: 
  124: 
  125:     my $result='';
  126:     my @outpar=();
  127: # ----------------------------------------------------- Cascading lookup scheme
  128:     my $map=(&Apache::lonnet::decode_symb($symb))[0];    
  129:     $map = &Apache::lonnet::deversion($map);
  130: 
  131:     my $symbparm=$symb.'.'.$what;
  132:     my $mapparm=$map.'___(all).'.$what;
  133: 
  134:     my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
  135:     my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
  136:     my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
  137: 
  138:     my $courselevel=$env{'request.course.id'}.'.'.$what;
  139:     my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
  140:     my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
  141: 
  142: 
  143: 
  144: # --------------------------------------------------------- first, check course
  145: 
  146:     if (defined($$courseopt{$courselevel})) {
  147: 	$outpar[11]=$$courseopt{$courselevel};
  148: 	$result=11;
  149:     }
  150: 
  151:     if (defined($$courseopt{$courselevelm})) {
  152: 	$outpar[10]=$$courseopt{$courselevelm};
  153: 	$result=10;
  154:     }
  155: 
  156: # ------------------------------------------------------- second, check default
  157: 
  158:     if (defined($def)) { $outpar[9]=$def; $result=9; }
  159: 
  160: # ------------------------------------------------------ third, check map parms
  161: 
  162:     my $thisparm=$parmhash{$symbparm};
  163:     if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }
  164: 
  165:     if (defined($$courseopt{$courselevelr})) {
  166: 	$outpar[7]=$$courseopt{$courselevelr};
  167: 	$result=7;
  168:     }
  169: 
  170: # ------------------------------------------------------ fourth, back to course
  171:     if (defined($csec)) {
  172:         if (defined($$courseopt{$seclevel})) {
  173: 	    $outpar[6]=$$courseopt{$seclevel};
  174: 	    $result=6;
  175: 	}
  176:         if (defined($$courseopt{$seclevelm})) {
  177: 	    $outpar[5]=$$courseopt{$seclevelm};
  178: 	    $result=5;
  179: 	}
  180: 
  181:         if (defined($$courseopt{$seclevelr})) {
  182: 	    $outpar[4]=$$courseopt{$seclevelr};
  183: 	    $result=4;
  184: 	}
  185:     }
  186: 
  187: # ---------------------------------------------------------- fifth, check user
  188: 
  189:     if (defined($uname)) {
  190: 	if (defined($$useropt{$courselevel})) {
  191: 	    $outpar[3]=$$useropt{$courselevel};
  192: 	    $result=3;
  193: 	}
  194: 
  195: 	if (defined($$useropt{$courselevelm})) {
  196: 	    $outpar[2]=$$useropt{$courselevelm};
  197: 	    $result=2;
  198: 	}
  199: 
  200: 	if (defined($$useropt{$courselevelr})) {
  201: 	    $outpar[1]=$$useropt{$courselevelr};
  202: 	    $result=1;
  203: 	}
  204:     }
  205:     return ($result,@outpar);
  206: }
  207: 
  208: sub resetparmhash {
  209:     $parmhashid='';
  210: }
  211: 
  212: sub cacheparmhash {
  213:     if ($parmhashid eq  $env{'request.course.fn'}) { return; }
  214:     my %parmhashfile;
  215:     if (tie(%parmhashfile,'GDBM_File',
  216: 	      $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
  217: 	%parmhash=%parmhashfile;
  218: 	untie %parmhashfile;
  219: 	$parmhashid=$env{'request.course.fn'};
  220:     }
  221: }
  222: 
  223: sub resetsymbcache {
  224:     $symbsid='';
  225: }
  226: 
  227: sub symbcache {
  228:     my $id=shift;
  229:     if ($symbsid ne $env{'request.course.id'}) {
  230: 	%symbs=();
  231:     }
  232:     unless ($symbs{$id}) {
  233: 	my $navmap = Apache::lonnavmaps::navmap->new();
  234: 	if ($id=~/\./) {
  235: 	    my $resource=$navmap->getById($id);
  236: 	    $symbs{$id}=$resource->symb();
  237: 	} else {
  238: 	    my $resource=$navmap->getByMapPc($id);
  239: 	    $symbs{$id}=&Apache::lonnet::declutter($resource->src());
  240: 	}
  241: 	$symbsid=$env{'request.course.id'};
  242:     }
  243:     return $symbs{$id};
  244: }
  245: 
  246: sub resetrulescache {
  247:     $rulesid='';
  248: }
  249: 
  250: sub rulescache {
  251:     my $id=shift;
  252:     if ($rulesid ne $env{'request.course.id'}) {
  253: 	%rules=();
  254:     }
  255:     unless (defined($rules{$id})) {
  256: 	my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  257: 	my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
  258: 	%rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
  259: 	$rulesid=$env{'request.course.id'};
  260:     }
  261:     return $rules{$id};
  262: }
  263: 
  264: sub preset_defaults {
  265:     my $type=shift;
  266:     if (&rulescache($type.'_action') eq 'default') {
  267: # yes, there is something
  268: 	return (&rulescache($type.'_hours'),
  269: 		&rulescache($type.'_min'),
  270: 		&rulescache($type.'_sec'),
  271: 		&rulescache($type.'_value'));
  272:     } else {
  273: # nothing there or something else
  274: 	return ('','','','','');
  275:     }
  276: }
  277: 
  278: ##################################################
  279: ##################################################
  280: #
  281: # Store a parameter by ID
  282: #
  283: # Takes
  284: # - resource id
  285: # - name of parameter
  286: # - level
  287: # - new value
  288: # - new type
  289: # - username
  290: # - userdomain
  291: 
  292: sub storeparm {
  293:     my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
  294:     &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
  295: }
  296: 
  297: #
  298: # Store a parameter by symb
  299: #
  300: # Takes
  301: # - symb
  302: # - name of parameter
  303: # - level
  304: # - new value
  305: # - new type
  306: # - username
  307: # - userdomain
  308: 
  309: my %recstack;
  310: sub storeparm_by_symb {
  311:     my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag)=@_;
  312:     unless ($recflag) {
  313: # first time call
  314: 	%recstack=();
  315: 	$recflag=1;
  316:     }
  317: # store parameter
  318:     &storeparm_by_symb_inner
  319: 	($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
  320: # don't do anything if parameter was reset
  321:     unless ($nval) { return; }
  322:     my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
  323: # remember that this was set
  324:     $recstack{$parm}=1;
  325: # what does this trigger?
  326:     foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
  327: # don't backfire
  328:        unless ((!$triggered) || ($recstack{$triggered})) {
  329: 	   my $action=&rulescache($triggered.'_action');
  330: 	   my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
  331: # set triggered parameter on same level
  332: 	   my $newspnam=$prefix.$triggered;
  333: 	   my $newvalue='';
  334: 	   my $active=1;
  335: 	   if ($action=~/^when\_setting/) {
  336: # are there restrictions?
  337: 	       if (&rulescache($triggered.'_triggervalue')=~/\w/) {
  338: 		   $active=0;
  339: 		   foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
  340: 		       if (lc($possiblevalue) eq lc($nval)) { $active=1; }
  341: 		   }
  342: 	       }
  343: 	       $newvalue=&rulescache($triggered.'_value');
  344: 	   } else {
  345: 	       my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
  346: 	       if ($action=~/^later\_than/) {
  347: 		   $newvalue=$nval+$totalsecs;
  348: 	       } else {
  349: 		   $newvalue=$nval-$totalsecs;
  350: 	       }
  351: 	   }
  352: 	   if ($active) {
  353: 	       &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
  354: 				   $uname,$udom,$csec,$recflag);
  355: 	   }
  356:        }
  357:     }
  358:     return '';
  359: }
  360: 
  361: sub storeparm_by_symb_inner {
  362: # ---------------------------------------------------------- Get symb, map, etc
  363:     my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
  364: # ---------------------------------------------------------- Construct prefixes
  365:     $spnam=~s/\_([^\_]+)$/\.$1/;
  366:     my $map=(&Apache::lonnet::decode_symb($symb))[0];    
  367:     $map = &Apache::lonnet::deversion($map);
  368: 
  369:     my $symbparm=$symb.'.'.$spnam;
  370:     my $mapparm=$map.'___(all).'.$spnam;
  371: 
  372:     my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
  373:     my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
  374:     my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
  375:     
  376:     my $courselevel=$env{'request.course.id'}.'.'.$spnam;
  377:     my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
  378:     my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
  379:     
  380:     my $storeunder='';
  381:     if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
  382:     if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; }
  383:     if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
  384:     if ($snum==6) { $storeunder=$seclevel; }
  385:     if ($snum==5) { $storeunder=$seclevelm; }
  386:     if ($snum==4) { $storeunder=$seclevelr; }
  387:     
  388:     my $delete;
  389:     if ($nval eq '') { $delete=1;}
  390:     my %storecontent = ($storeunder         => $nval,
  391: 			$storeunder.'.type' => $ntype);
  392:     my $reply='';
  393:     if ($snum>3) {
  394: # ---------------------------------------------------------------- Store Course
  395: #
  396: 	my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
  397: 	my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  398: # Expire sheets
  399: 	&Apache::lonnet::expirespread('','','studentcalc');
  400: 	if (($snum==7) || ($snum==4)) {
  401: 	    &Apache::lonnet::expirespread('','','assesscalc',$symb);
  402: 	} elsif (($snum==8) || ($snum==5)) {
  403: 	    &Apache::lonnet::expirespread('','','assesscalc',$map);
  404: 	} else {
  405: 	    &Apache::lonnet::expirespread('','','assesscalc');
  406: 	}
  407: # Store parameter
  408: 	if ($delete) {
  409: 	    $reply=&Apache::lonnet::del
  410: 		('resourcedata',[keys(%storecontent)],$cdom,$cnum);
  411: 	} else {
  412: 	    $reply=&Apache::lonnet::cput
  413: 		('resourcedata',\%storecontent,$cdom,$cnum);
  414: 	}
  415: 	&Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
  416:     } else {
  417: # ------------------------------------------------------------------ Store User
  418: #
  419: # Expire sheets
  420: 	&Apache::lonnet::expirespread($uname,$udom,'studentcalc');
  421: 	if ($snum==1) {
  422: 	    &Apache::lonnet::expirespread
  423: 		($uname,$udom,'assesscalc',$symb);
  424: 	} elsif ($snum==2) {
  425: 	    &Apache::lonnet::expirespread
  426: 		($uname,$udom,'assesscalc',$map);
  427: 	} else {
  428: 	    &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
  429: 	}
  430: # Store parameter
  431: 	if ($delete) {
  432: 	    $reply=&Apache::lonnet::del
  433: 		('resourcedata',[keys(%storecontent)],$udom,$uname);
  434: 	} else {
  435: 	    $reply=&Apache::lonnet::cput
  436: 		('resourcedata',\%storecontent,$udom,$uname);
  437: 	}
  438: 	&Apache::lonnet::devalidateuserresdata($uname,$udom);
  439:     }
  440:     
  441:     if ($reply=~/^error\:(.*)/) {
  442: 	return "<font color=red>Write Error: $1</font>";
  443:     }
  444:     return '';
  445: }
  446: 
  447: ##################################################
  448: ##################################################
  449: 
  450: =pod
  451: 
  452: =item valout
  453: 
  454: Format a value for output.
  455: 
  456: Inputs:  $value, $type
  457: 
  458: Returns: $value, formatted for output.  If $type indicates it is a date,
  459: localtime($value) is returned.
  460: 
  461: =cut
  462: 
  463: ##################################################
  464: ##################################################
  465: sub valout {
  466:     my ($value,$type)=@_;
  467:     my $result = '';
  468:     # Values of zero are valid.
  469:     if (! $value && $value ne '0') {
  470: 	$result = '&nbsp;&nbsp;';
  471:     } else {
  472:         if ($type eq 'date_interval') {
  473:             my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
  474:             $year=$year-70;
  475:             $mday--;
  476:             if ($year) {
  477: 		$result.=$year.' yrs ';
  478:             }
  479:             if ($mon) {
  480: 		$result.=$mon.' mths ';
  481:             }
  482:             if ($mday) {
  483: 		$result.=$mday.' days ';
  484:             }
  485:             if ($hour) {
  486: 		$result.=$hour.' hrs ';
  487:             }
  488:             if ($min) {
  489: 		$result.=$min.' mins ';
  490:             }
  491:             if ($sec) {
  492: 		$result.=$sec.' secs ';
  493:             }
  494:             $result=~s/\s+$//;
  495:         } elsif (&isdateparm($type)) {
  496:             $result = localtime($value);
  497:         } else {
  498:             $result = $value;
  499:         }
  500:     }
  501:     return $result;
  502: }
  503: 
  504: ##################################################
  505: ##################################################
  506: 
  507: =pod
  508: 
  509: =item plink
  510: 
  511: Produces a link anchor.
  512: 
  513: Inputs: $type,$dis,$value,$marker,$return,$call
  514: 
  515: Returns: scalar with html code for a link which will envoke the 
  516: javascript function 'pjump'.
  517: 
  518: =cut
  519: 
  520: ##################################################
  521: ##################################################
  522: sub plink {
  523:     my ($type,$dis,$value,$marker,$return,$call)=@_;
  524:     my $winvalue=$value;
  525:     unless ($winvalue) {
  526: 	if (&isdateparm($type)) {
  527:             $winvalue=$env{'form.recent_'.$type};
  528:         } else {
  529:             $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
  530:         }
  531:     }
  532:     my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
  533:     my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
  534:     unless (defined($winvalue)) { $winvalue=$val; }
  535:     return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.
  536: 	'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
  537: 	    .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
  538: 		&valout($value,$type).'</a></td></tr></table>';
  539: }
  540: 
  541: sub startpage {
  542:     my $r=shift;
  543: 
  544:     my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
  545:                                             'onUnload="pclose()"');
  546:     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting');
  547:     my $selscript=&Apache::loncommon::studentbrowser_javascript();
  548:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
  549:     my $html=&Apache::lonxml::xmlbegin();
  550:     $r->print(<<ENDHEAD);
  551: $html
  552: <head>
  553: <title>LON-CAPA Course Parameters</title>
  554: <script>
  555: 
  556:     function pclose() {
  557:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
  558:                  "height=350,width=350,scrollbars=no,menubar=no");
  559:         parmwin.close();
  560:     }
  561: 
  562:     $pjump_def
  563: 
  564:     function psub() {
  565:         pclose();
  566:         if (document.parmform.pres_marker.value!='') {
  567:             document.parmform.action+='#'+document.parmform.pres_marker.value;
  568:             var typedef=new Array();
  569:             typedef=document.parmform.pres_type.value.split('_');
  570:            if (document.parmform.pres_type.value!='') {
  571:             if (typedef[0]=='date') {
  572:                 eval('document.parmform.recent_'+
  573:                      document.parmform.pres_type.value+
  574: 		     '.value=document.parmform.pres_value.value;');
  575:             } else {
  576:                 eval('document.parmform.recent_'+typedef[0]+
  577: 		     '.value=document.parmform.pres_value.value;');
  578:             }
  579: 	   }
  580:             document.parmform.submit();
  581:         } else {
  582:             document.parmform.pres_value.value='';
  583:             document.parmform.pres_marker.value='';
  584:         }
  585:     }
  586: 
  587:     function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
  588:         var options = "width=" + w + ",height=" + h + ",";
  589:         options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
  590:         options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
  591:         var newWin = window.open(url, wdwName, options);
  592:         newWin.focus();
  593:     }
  594: </script>
  595: $selscript
  596: </head>
  597: $bodytag
  598: $breadcrumbs
  599: <form method="post" action="/adm/parmset?action=settable" name="parmform">
  600: <input type="hidden" value='' name="pres_value">
  601: <input type="hidden" value='' name="pres_type">
  602: <input type="hidden" value='' name="pres_marker">
  603: <input type="hidden" value='1' name="prevvisit">
  604: ENDHEAD
  605: }
  606: 
  607: 
  608: sub print_row {
  609:     my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
  610: 	$defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
  611: # get the values for the parameter in cascading order
  612: # empty levels will remain empty
  613:     my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
  614: 				  $rid,$$default{$which},$uname,$udom,$csec);
  615: # get the type for the parameters
  616: # problem: these may not be set for all levels
  617:     my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
  618:                                           $$name{$which}.'.type',
  619: 				  $rid,$$defaulttype{$which},$uname,$udom,$csec);
  620: # cascade down manually
  621:     my $cascadetype=$$defaulttype{$which};
  622:     for (my $i=11;$i>0;$i--) {
  623: 	 if ($typeoutpar[$i]) { 
  624:             $cascadetype=$typeoutpar[$i];
  625: 	} else {
  626:             $typeoutpar[$i]=$cascadetype;
  627:         }
  628:     }
  629:     my $parm=$$display{$which};
  630: 
  631:     if ($parmlev eq 'full') {
  632:         $r->print('<td bgcolor='.$defbgtwo.' align="center">'
  633:                   .$$part{$which}.'</td>');
  634:     } else {    
  635:         $parm=~s|\[.*\]\s||g;
  636:     }
  637:     my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
  638:     if ($automatic) {
  639: 	$parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>';
  640:     }
  641:     $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
  642:    
  643:     my $thismarker=$which;
  644:     $thismarker=~s/^parameter\_//;
  645:     my $mprefix=$rid.'&'.$thismarker.'&';
  646: 
  647:     if ($parmlev eq 'general') {
  648: 
  649:         if ($uname) {
  650:             &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  651:         } elsif ($csec) {
  652:             &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); 
  653:         } else {
  654:             &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); 
  655:         }
  656:     } elsif ($parmlev eq 'map') {
  657: 
  658:         if ($uname) {
  659:             &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  660:         } elsif ($csec) {
  661:             &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  662:         } else {
  663:             &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  664:         }
  665:     } else {
  666: 
  667:         &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  668: 
  669: 	&print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  670: 	&print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  671: 	&print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  672: 	&print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  673: 	
  674: 	if ($csec) {
  675: 	    &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  676: 	    &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  677: 	    &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  678: 	}
  679: 	if ($uname) {
  680: 	    &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  681: 	    &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  682: 	    &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  683: 	}
  684: 
  685:     } # end of $parmlev if/else
  686: 
  687:     $r->print('<td bgcolor=#CCCCFF align="center">'.
  688:                   &valout($outpar[$result],$typeoutpar[$result]).'</td>');
  689: 
  690:     if ($parmlev eq 'full') {
  691:         my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
  692:                                         '.'.$$name{$which},$$symbp{$rid});
  693:         my $sessionvaltype=$typeoutpar[$result];
  694:         if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
  695:         $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
  696:                   &valout($sessionval,$sessionvaltype).'&nbsp;'.
  697:                   '</font></td>');
  698:     }
  699:     $r->print('</tr>');
  700:     $r->print("\n");
  701: }
  702: 
  703: sub print_td {
  704:     my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
  705:     $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
  706:               ' align="center">');
  707:     if ($which<8 || $which > 9) {
  708: 	$r->print(&plink($$typeoutpar[$which],
  709: 			 $$display{$value},$$outpar[$which],
  710: 			 $mprefix."$which",'parmform.pres','psub'));
  711:     } else {
  712: 	$r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
  713:     }
  714:     $r->print('</td>'."\n");
  715: }
  716: 
  717: 
  718: =pod
  719: 
  720: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
  721: 
  722: Input: See list below:
  723: 
  724: =over 4
  725: 
  726: =item B<ids>: An array that will contain all of the ids in the course.
  727: 
  728: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
  729: 
  730: =item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
  731: 
  732: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
  733: 
  734: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
  735: 
  736: =item B<allkeys>: hash, full key to part->display value (what's display value?)
  737: 
  738: =item B<allmaps>: hash, ???
  739: 
  740: =item B<fcat>: ???
  741: 
  742: =item B<defp>: hash, ???
  743: 
  744: =item B<mapp>: ??
  745: 
  746: =item B<symbp>: hash, id->full sym?
  747: 
  748: =back
  749: 
  750: =cut
  751: 
  752: sub extractResourceInformation {
  753:     my $ids = shift;
  754:     my $typep = shift;
  755:     my $keyp = shift;
  756:     my $allparms = shift;
  757:     my $allparts = shift;
  758:     my $allmaps = shift;
  759:     my $mapp = shift;
  760:     my $symbp = shift;
  761:     my $maptitles=shift;
  762:     my $uris=shift;
  763:     my $keyorder=shift;
  764:     my $defkeytype=shift;
  765: 
  766:     my $keyordercnt=100;
  767: 
  768:     my $navmap = Apache::lonnavmaps::navmap->new();
  769:     my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
  770:     foreach my $resource (@allres) {
  771: 	my $id=$resource->id();
  772:         my ($mapid,$resid)=split(/\./,$id);
  773: 	if ($mapid eq '0') { next; }
  774: 	$$ids[$#$ids+1]=$id;
  775: 	my $srcf=$resource->src();
  776: 	$srcf=~/\.(\w+)$/;
  777: 	$$typep{$id}=$1;
  778: 	$$keyp{$id}='';
  779:         $$uris{$id}=$srcf;
  780: 	foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
  781: 	    if ($_=~/^parameter\_(.*)/) {
  782: 		my $key=$_;
  783: # Hidden parameters
  784: 		if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
  785: 		    next;
  786: 		}
  787: 		my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
  788: 		my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
  789: 		my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
  790: #
  791: # allparms is a hash of parameter names
  792: #
  793: 		my $parmdis = $display;
  794: 		$parmdis =~ s/\[Part.*$//g;
  795:                 $$allparms{$name}=$parmdis;
  796: 		$$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
  797: #
  798: # allparts is a hash of all parts
  799: #
  800: 		$$allparts{$part} = "Part: $part";
  801: #
  802: # Remember all keys going with this resource
  803: #
  804: 		if ($$keyp{$id}) {
  805: 		    $$keyp{$id}.=','.$key;
  806: 		} else {
  807: 		    $$keyp{$id}=$key;
  808: 		}
  809: #
  810: # Put in order
  811: # 
  812:                 unless ($$keyorder{$key}) {
  813:                     $$keyorder{$key}=$keyordercnt;
  814:                     $keyordercnt++;
  815: 		}
  816: 
  817: 	    }
  818: 	}
  819: 	$$mapp{$id}=
  820: 	    &Apache::lonnet::declutter($resource->enclosing_map_src());
  821: 	$$mapp{$mapid}=$$mapp{$id};
  822: 	$$allmaps{$mapid}=$$mapp{$id};
  823: 	if ($mapid eq '1') {
  824: 	    $$maptitles{$mapid}='Main Course Documents';
  825: 	} else {
  826: 	    $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
  827: 	}
  828: 	$$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
  829: 	$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
  830: 	$$symbp{$mapid}=$$mapp{$id}.'___(all)';
  831:     }
  832: }
  833: 
  834: 
  835: ##################################################
  836: ##################################################
  837: 
  838: sub isdateparm {
  839:     my $type=shift;
  840:     return (($type=~/^date/) && (!($type eq 'date_interval')));
  841: }
  842: 
  843: sub parmmenu {
  844:     my ($r,$allparms,$pscat,$keyorder)=@_;
  845:     my $tempkey;
  846:     $r->print(<<ENDSCRIPT);
  847: <script type="text/javascript">
  848:     function checkall(value, checkName) {
  849: 	for (i=0; i<document.forms.parmform.elements.length; i++) {
  850:             ele = document.forms.parmform.elements[i];
  851:             if (ele.name == checkName) {
  852:                 document.forms.parmform.elements[i].checked=value;
  853:             }
  854:         }
  855:     }
  856: 
  857:     function checkthis(thisvalue, checkName) {
  858: 	for (i=0; i<document.forms.parmform.elements.length; i++) {
  859:             ele = document.forms.parmform.elements[i];
  860:             if (ele.name == checkName) {
  861: 		if (ele.value == thisvalue) {
  862: 		    document.forms.parmform.elements[i].checked=true;
  863: 		}
  864:             }
  865:         }
  866:     }
  867: 
  868:     function checkdates() {
  869: 	checkthis('duedate','pscat');
  870:  	checkthis('opendate','pscat');
  871: 	checkthis('answerdate','pscat');
  872:     }
  873: 
  874:     function checkdisset() {
  875: 	checkthis('discussend','pscat');
  876:  	checkthis('discusshide','pscat');
  877:     }
  878: 
  879:     function checkcontdates() {
  880: 	checkthis('contentopen','pscat');
  881:  	checkthis('contentclose','pscat');
  882:     }
  883:  
  884: 
  885:     function checkvisi() {
  886: 	checkthis('hiddenresource','pscat');
  887:  	checkthis('encrypturl','pscat');
  888: 	checkthis('problemstatus','pscat');
  889: 	checkthis('contentopen','pscat');
  890: 	checkthis('opendate','pscat');
  891:     }
  892: 
  893:     function checkparts() {
  894: 	checkthis('hiddenparts','pscat');
  895: 	checkthis('display','pscat');
  896: 	checkthis('ordered','pscat');
  897:     }
  898: 
  899:     function checkstandard() {
  900:         checkall(false,'pscat');
  901: 	checkdates();
  902: 	checkthis('weight','pscat');
  903: 	checkthis('maxtries','pscat');
  904:     }
  905: 
  906: </script>
  907: ENDSCRIPT
  908:     $r->print();
  909:     $r->print("\n<table><tr>");
  910:     my $cnt=0;
  911:     foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
  912: 	$r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' ");
  913: 	$r->print('value="'.$tempkey.'"');
  914: 	if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
  915: 	    $r->print(' checked');
  916: 	}
  917: 	$r->print('>'.$$allparms{$tempkey}.'</label></font></td>');
  918:  	$cnt++;
  919:         if ($cnt==3) {
  920: 	    $r->print("</tr>\n<tr>");
  921: 	    $cnt=0;
  922: 	}
  923:     }
  924:     $r->print('
  925: </tr><tr><td>
  926: <a href="javascript:checkall(true, \'pscat\')">Select&nbsp;All</a><br />
  927: <a href="javascript:checkstandard()">Select&nbsp;Common&nbsp;Only</a>
  928: </td><td>
  929: <a href="javascript:checkdates()">Add&nbsp;Problem&nbsp;Dates</a>
  930: <a href="javascript:checkcontdates()">Add&nbsp;Content&nbsp;Dates</a><br />
  931: <a href="javascript:checkdisset()">Add&nbsp;Discussion&nbsp;Settings</a>
  932: <a href="javascript:checkvisi()">Add&nbsp;Visibilities</a><br />
  933: <a href="javascript:checkparts()">Add&nbsp;Part&nbsp;Parameters</a>
  934: </td><td>
  935: <a href="javascript:checkall(false, \'pscat\')">Unselect&nbsp;All</a>
  936: </td>
  937: ');
  938:     $r->print('</tr></table>');
  939: }
  940: 
  941: sub partmenu {
  942:     my ($r,$allparts,$psprt)=@_;
  943:     $r->print('<select multiple name="psprt" size="8">');
  944:     $r->print('<option value="all"');
  945:     $r->print(' selected') unless (@{$psprt});
  946:     $r->print('>'.&mt('All Parts').'</option>');
  947:     my %temphash=();
  948:     foreach (@{$psprt}) { $temphash{$_}=1; }
  949:     foreach my $tempkey (sort {
  950: 	if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
  951:     } keys(%{$allparts})) {
  952: 	unless ($tempkey =~ /\./) {
  953: 	    $r->print('<option value="'.$tempkey.'"');
  954: 	    if ($$psprt[0] eq "all" ||  $temphash{$tempkey}) {
  955: 		$r->print(' selected');
  956: 	    }
  957: 	    $r->print('>'.$$allparts{$tempkey}.'</option>');
  958: 	}
  959:     }
  960:     $r->print('</select>');
  961: }
  962: 
  963: sub usermenu {
  964:     my ($r,$uname,$id,$udom,$csec)=@_;
  965:     my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
  966:         &Apache::loncommon::selectstudent_link('parmform','uname','udom');
  967:     my $selscript=&Apache::loncommon::studentbrowser_javascript();
  968:     my %lt=&Apache::lonlocal::texthash(
  969: 		    'sg'    => "Section/Group",
  970: 		    'fu'    => "For User",
  971: 		    'oi'    => "or ID",
  972: 		    'ad'    => "at Domain"
  973: 				       );
  974:     my %sectionhash=();
  975:     my $sections='';
  976:     if (&Apache::loncommon::get_sections(
  977:                  $env{'course.'.$env{'request.course.id'}.'.domain'},
  978:                  $env{'course.'.$env{'request.course.id'}.'.num'},
  979: 					 \%sectionhash)) {
  980:         $sections=$lt{'sg'}.': <select name="csec">';
  981: 	foreach ('',sort keys %sectionhash) {
  982: 	    $sections.='<option value="'.$_.'"'.
  983: 		($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>';
  984:         }
  985:         $sections.='</select>';
  986:      }
  987:      $r->print(<<ENDMENU);
  988: <b>
  989: $sections
  990: <br />
  991: $lt{'fu'} 
  992: <input type="text" value="$uname" size="12" name="uname" />
  993: $lt{'oi'}
  994: <input type="text" value="$id" size="12" name="id" /> 
  995: $lt{'ad'}
  996: $chooseopt
  997: </b>
  998: ENDMENU
  999: }
 1000: 
 1001: sub displaymenu {
 1002:     my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
 1003:     $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
 1004: 	     &mt('Select Parts to View').'</th></tr><tr><td>');  
 1005:     &parmmenu($r,$allparms,$pscat,$keyorder);
 1006:     $r->print('</td><td>');
 1007:     &partmenu($r,$allparts,$psprt);
 1008:     $r->print('</td></tr></table>');
 1009: }
 1010: 
 1011: sub mapmenu {
 1012:     my ($r,$allmaps,$pschp,$maptitles)=@_;
 1013:     $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
 1014:     $r->print('<select name="pschp">');
 1015:     $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
 1016:     foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
 1017: 	$r->print('<option value="'.$_.'"');
 1018: 	if (($pschp eq $_)) { $r->print(' selected'); }
 1019: 	$r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
 1020:     }
 1021:     $r->print("</select>");
 1022: }
 1023: 
 1024: sub levelmenu {
 1025:     my ($r,$alllevs,$parmlev)=@_;
 1026:     $r->print('<b>'.&mt('Select Parameter Level').
 1027: 	      &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
 1028:     $r->print('<select name="parmlev">');
 1029:     foreach (reverse sort keys %{$alllevs}) {
 1030: 	$r->print('<option value="'.$$alllevs{$_}.'"');
 1031: 	if ($parmlev eq $$alllevs{$_}) {
 1032: 	    $r->print(' selected'); 
 1033: 	}
 1034: 	$r->print('>'.$_.'</option>');
 1035:     }
 1036:     $r->print("</select>");
 1037: }
 1038: 
 1039: 
 1040: sub sectionmenu {
 1041:     my ($r,$selectedsections)=@_;
 1042:     my %sectionhash=();
 1043: 
 1044:     if (&Apache::loncommon::get_sections(
 1045:                  $env{'course.'.$env{'request.course.id'}.'.domain'},
 1046:                  $env{'course.'.$env{'request.course.id'}.'.num'},
 1047: 					 \%sectionhash)) {
 1048: 	$r->print('<select name="Section" multiple="true" size="8" >');
 1049: 	foreach my $s ('all',sort keys %sectionhash) {
 1050: 	    $r->print('    <option value="'.$s.'"');
 1051: 	    foreach (@{$selectedsections}) {
 1052: 		if ($s eq $_) {
 1053: 		    $r->print(' selected');
 1054: 		    last;
 1055: 		}
 1056: 	    }
 1057: 	    $r->print('>'.$s."</option>\n");
 1058: 	}
 1059: 	$r->print("</select>\n");
 1060:     }
 1061: }
 1062: 
 1063: sub keysplit {
 1064:     my $keyp=shift;
 1065:     return (split(/\,/,$keyp));
 1066: }
 1067: 
 1068: sub keysinorder {
 1069:     my ($name,$keyorder)=@_;
 1070:     return sort {
 1071: 	$$keyorder{$a} <=> $$keyorder{$b};
 1072:     } (keys %{$name});
 1073: }
 1074: 
 1075: sub keysinorder_bytype {
 1076:     my ($name,$keyorder)=@_;
 1077:     return sort {
 1078: 	my $ta=(split('_',$a))[-1];
 1079: 	my $tb=(split('_',$b))[-1];
 1080: 	if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
 1081: 	    return ($a cmp $b);
 1082: 	}
 1083: 	$$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
 1084:     } (keys %{$name});
 1085: }
 1086: 
 1087: sub keysindisplayorder {
 1088:     my ($name,$keyorder)=@_;
 1089:     return sort {
 1090: 	$$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
 1091:     } (keys %{$name});
 1092: }
 1093: 
 1094: sub sortmenu {
 1095:     my ($r,$sortorder)=@_;
 1096:     $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
 1097:     if ($sortorder eq 'realmstudent') {
 1098:        $r->print(' checked="on"');
 1099:     }
 1100:     $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
 1101:     $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
 1102:     if ($sortorder eq 'studentrealm') {
 1103:        $r->print(' checked="on"');
 1104:     }
 1105:     $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
 1106: 	      '</label>');
 1107: }
 1108: 
 1109: sub standardkeyorder {
 1110:     return ('parameter_0_opendate' => 1,
 1111: 	    'parameter_0_duedate' => 2,
 1112: 	    'parameter_0_answerdate' => 3,
 1113: 	    'parameter_0_interval' => 4,
 1114: 	    'parameter_0_weight' => 5,
 1115: 	    'parameter_0_maxtries' => 6,
 1116: 	    'parameter_0_hinttries' => 7,
 1117: 	    'parameter_0_contentopen' => 8,
 1118: 	    'parameter_0_contentclose' => 9,
 1119: 	    'parameter_0_type' => 10,
 1120: 	    'parameter_0_problemstatus' => 11,
 1121: 	    'parameter_0_hiddenresource' => 12,
 1122: 	    'parameter_0_hiddenparts' => 13,
 1123: 	    'parameter_0_display' => 14,
 1124: 	    'parameter_0_ordered' => 15,
 1125: 	    'parameter_0_tol' => 16,
 1126: 	    'parameter_0_sig' => 17,
 1127: 	    'parameter_0_turnoffunit' => 18,
 1128:             'parameter_0_discussend' => 19,
 1129:             'parameter_0_discusshide' => 20);
 1130: }
 1131: 
 1132: ##################################################
 1133: ##################################################
 1134: 
 1135: =pod
 1136: 
 1137: =item assessparms
 1138: 
 1139: Show assessment data and parameters.  This is a large routine that should
 1140: be simplified and shortened... someday.
 1141: 
 1142: Inputs: $r
 1143: 
 1144: Returns: nothing
 1145: 
 1146: Variables used (guessed by Jeremy):
 1147: 
 1148: =over 4
 1149: 
 1150: =item B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
 1151: 
 1152: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
 1153: 
 1154: =item B<allmaps>:
 1155: 
 1156: =back
 1157: 
 1158: =cut
 1159: 
 1160: ##################################################
 1161: ##################################################
 1162: sub assessparms {
 1163: 
 1164:     my $r=shift;
 1165: 
 1166:     my @ids=();
 1167:     my %symbp=();
 1168:     my %mapp=();
 1169:     my %typep=();
 1170:     my %keyp=();
 1171:     my %uris=();
 1172:     my %maptitles=();
 1173: 
 1174: # -------------------------------------------------------- Variable declaration
 1175: 
 1176:     my %allmaps=();
 1177:     my %alllevs=();
 1178: 
 1179:     my $uname;
 1180:     my $udom;
 1181:     my $uhome;
 1182:     my $csec;
 1183:  
 1184:     my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
 1185: 
 1186:     $alllevs{'Resource Level'}='full';
 1187:     $alllevs{'Map/Folder Level'}='map';
 1188:     $alllevs{'Course Level'}='general';
 1189: 
 1190:     my %allparms;
 1191:     my %allparts;
 1192: #
 1193: # Order in which these parameters will be displayed
 1194: #
 1195:     my %keyorder=&standardkeyorder();
 1196: 
 1197:     @ids=();
 1198:     %symbp=();
 1199:     %typep=();
 1200: 
 1201:     my $message='';
 1202: 
 1203:     $csec=$env{'form.csec'};
 1204: 
 1205:     if      ($udom=$env{'form.udom'}) {
 1206:     } elsif ($udom=$env{'request.role.domain'}) {
 1207:     } elsif ($udom=$env{'user.domain'}) {
 1208:     } else {
 1209: 	$udom=$r->dir_config('lonDefDomain');
 1210:     }
 1211: 
 1212:     my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
 1213:     my $pschp=$env{'form.pschp'};
 1214:     my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
 1215:     if (!@psprt) { $psprt[0]='0'; }
 1216: 
 1217:     my $pssymb='';
 1218:     my $parmlev='';
 1219:  
 1220:     unless ($env{'form.parmlev'}) {
 1221:         $parmlev = 'map';
 1222:     } else {
 1223:         $parmlev = $env{'form.parmlev'};
 1224:     }
 1225: 
 1226: # ----------------------------------------------- Was this started from grades?
 1227: 
 1228:     if (($env{'form.command'} eq 'set') && ($env{'form.url'})
 1229: 	&& (!$env{'form.dis'})) {
 1230: 	my $url=$env{'form.url'};
 1231: 	$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
 1232: 	$pssymb=&Apache::lonnet::symbread($url);
 1233: 	if (!@pscat) { @pscat=('all'); }
 1234: 	$pschp='';
 1235:         $parmlev = 'full';
 1236:     } elsif ($env{'form.symb'}) {
 1237: 	$pssymb=$env{'form.symb'};
 1238: 	if (!@pscat) { @pscat=('all'); }
 1239: 	$pschp='';
 1240:         $parmlev = 'full';
 1241:     } else {
 1242: 	$env{'form.url'}='';
 1243:     }
 1244: 
 1245:     my $id=$env{'form.id'};
 1246:     if (($id) && ($udom)) {
 1247: 	$uname=(&Apache::lonnet::idget($udom,$id))[1];
 1248: 	if ($uname) {
 1249: 	    $id='';
 1250: 	} else {
 1251: 	    $message=
 1252: 		"<font color=red>".&mt("Unknown ID")." '$id' ".
 1253: 		&mt('at domain')." '$udom'</font>";
 1254: 	}
 1255:     } else {
 1256: 	$uname=$env{'form.uname'};
 1257:     }
 1258:     unless ($udom) { $uname=''; }
 1259:     $uhome='';
 1260:     if ($uname) {
 1261: 	$uhome=&Apache::lonnet::homeserver($uname,$udom);
 1262:         if ($uhome eq 'no_host') {
 1263: 	    $message=
 1264: 		"<font color=red>".&mt("Unknown user")." '$uname' ".
 1265: 		&mt("at domain")." '$udom'</font>";
 1266: 	    $uname='';
 1267:         } else {
 1268: 	    $csec=&Apache::lonnet::getsection($udom,$uname,
 1269: 					      $env{'request.course.id'});
 1270: 	    if ($csec eq '-1') {
 1271: 		$message="<font color=red>".
 1272: 		    &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
 1273: 		    &mt("not in this course")."</font>";
 1274: 		$uname='';
 1275: 		$csec=$env{'form.csec'};
 1276: 	    } else {
 1277: 		my %name=&Apache::lonnet::userenvironment($udom,$uname,
 1278: 		      ('firstname','middlename','lastname','generation','id'));
 1279: 		$message="\n<p>\n".&mt("Full Name").": ".
 1280: 		    $name{'firstname'}.' '.$name{'middlename'}.' '
 1281: 			.$name{'lastname'}.' '.$name{'generation'}.
 1282: 			    "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
 1283: 	    }
 1284:         }
 1285:     }
 1286: 
 1287:     unless ($csec) { $csec=''; }
 1288: 
 1289: # --------------------------------------------------------- Get all assessments
 1290:     &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, 
 1291: 				\%mapp, \%symbp,\%maptitles,\%uris,
 1292: 				\%keyorder);
 1293: 
 1294:     $mapp{'0.0'} = '';
 1295:     $symbp{'0.0'} = '';
 1296: 
 1297: # ---------------------------------------------------------- Anything to store?
 1298:     if ($env{'form.pres_marker'}) {
 1299:         my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
 1300:         my @values=split(/\&\&\&/,$env{'form.pres_value'});
 1301:         my @types=split(/\&\&\&/,$env{'form.pres_type'});
 1302: 	for (my $i=0;$i<=$#markers;$i++) {
 1303: 	    $message.=&storeparm(split(/\&/,$markers[$i]),
 1304: 				 $values[$i],
 1305: 				 $types[$i],
 1306: 				 $uname,$udom,$csec);
 1307: 	}
 1308: # ---------------------------------------------------------------- Done storing
 1309: 	$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
 1310:     }
 1311: #----------------------------------------------- if all selected, fill in array
 1312:     if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
 1313:     if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') }; 
 1314:     if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
 1315: # ------------------------------------------------------------------ Start page
 1316: 
 1317:     &startpage($r);
 1318: 
 1319:     foreach ('tolerance','date_default','date_start','date_end',
 1320: 	     'date_interval','int','float','string') {
 1321: 	$r->print('<input type="hidden" value="'.
 1322: 		  $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
 1323:     }
 1324:                         
 1325:     if (!$pssymb) {
 1326:         $r->print('<table border="1"><tr><td>');
 1327:         &levelmenu($r,\%alllevs,$parmlev);
 1328: 	if ($parmlev ne 'general') {
 1329:             $r->print('<td>');
 1330: 	    &mapmenu($r,\%allmaps,$pschp,\%maptitles);
 1331: 	    $r->print('</td>');
 1332: 	}
 1333:         $r->print('</td></tr></table>');
 1334: 	&displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
 1335:     } else {
 1336:         my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
 1337:         $r->print(&mt('Specific Resource').": ".$resource.
 1338:                   '<input type="hidden" value="'.$pssymb.'" name="symb">'.
 1339: 		  '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
 1340: 		  ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
 1341:     }
 1342:     &usermenu($r,$uname,$id,$udom,$csec);    
 1343: 
 1344:     $r->print('<p>'.$message.'</p>');
 1345: 
 1346:     $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
 1347: 
 1348:     my @temp_pscat;
 1349:     map {
 1350:         my $cat = $_;
 1351:         push(@temp_pscat, map { $_.'.'.$cat } @psprt);
 1352:     } @pscat;
 1353: 
 1354:     @pscat = @temp_pscat;
 1355: 
 1356:     if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
 1357: # ----------------------------------------------------------------- Start Table
 1358:         my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
 1359:         my $csuname=$env{'user.name'};
 1360:         my $csudom=$env{'user.domain'};
 1361: 
 1362:         if ($parmlev eq 'full') {
 1363:            my $coursespan=$csec?8:5;
 1364:            $r->print('<p><table border=2>');
 1365:            $r->print('<tr><td colspan=5></td>');
 1366:            $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
 1367:            if ($uname) {
 1368:                $r->print("<th colspan=3 rowspan=2>");
 1369:                $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
 1370:            }
 1371: 	   my %lt=&Apache::lonlocal::texthash(
 1372: 				  'pie'    => "Parameter in Effect",
 1373: 				  'csv'    => "Current Session Value",
 1374:                                   'at'     => 'at',
 1375:                                   'rl'     => "Resource Level",
 1376: 				  'ic'     => 'in Course',
 1377: 				  'aut'    => "Assessment URL and Title",
 1378: 				  'type'   => 'Type',
 1379: 				  'emof'   => "Enclosing Map or Folder",
 1380: 				  'part'   => 'Part',
 1381:                                   'pn'     => 'Parameter Name',
 1382: 				  'def'    => 'default',
 1383: 				  'femof'  => 'from Enclosing Map or Folder',
 1384: 				  'gen'    => 'general',
 1385: 				  'foremf' => 'for Enclosing Map or Folder',
 1386: 				  'fr'     => 'for Resource'
 1387: 					      );
 1388:            $r->print(<<ENDTABLETWO);
 1389: <th rowspan=3>$lt{'pie'}</th>
 1390: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
 1391: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
 1392: <th colspan=1>$lt{'ic'}</th>
 1393: 
 1394: ENDTABLETWO
 1395:            if ($csec) {
 1396:                 $r->print("<th colspan=3>".
 1397: 			  &mt("in Section/Group")." $csec</th>");
 1398:            }
 1399:            $r->print(<<ENDTABLEHEADFOUR);
 1400: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
 1401: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
 1402: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
 1403: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
 1404: ENDTABLEHEADFOUR
 1405: 
 1406:            if ($csec) {
 1407:                $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
 1408:            }
 1409: 
 1410:            if ($uname) {
 1411:                $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
 1412:            }
 1413: 
 1414:            $r->print('</tr>');
 1415: 
 1416:            my $defbgone='';
 1417:            my $defbgtwo='';
 1418: 
 1419:            foreach (@ids) {
 1420: 
 1421:                 my $rid=$_;
 1422:                 my ($inmapid)=($rid=~/\.(\d+)$/);
 1423: 
 1424:                 if ((!$pssymb && 
 1425: 		     (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
 1426: 		    ||
 1427: 		    ($pssymb && $pssymb eq $symbp{$rid})) {
 1428: # ------------------------------------------------------ Entry for one resource
 1429:                     if ($defbgone eq '"#E0E099"') {
 1430:                         $defbgone='"#E0E0DD"';
 1431:                     } else {
 1432:                         $defbgone='"#E0E099"';
 1433:                     }
 1434:                     if ($defbgtwo eq '"#FFFF99"') {
 1435:                         $defbgtwo='"#FFFFDD"';
 1436:                     } else {
 1437:                         $defbgtwo='"#FFFF99"';
 1438:                     }
 1439:                     my $thistitle='';
 1440:                     my %name=   ();
 1441:                     undef %name;
 1442:                     my %part=   ();
 1443:                     my %display=();
 1444:                     my %type=   ();
 1445:                     my %default=();
 1446:                     my $uri=&Apache::lonnet::declutter($uris{$rid});
 1447: 
 1448:                     foreach (&keysplit($keyp{$rid})) {
 1449:                         my $tempkeyp = $_;
 1450:                         if (grep $_ eq $tempkeyp, @catmarker) {
 1451:                           $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
 1452:                           $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
 1453:                           $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
 1454:                           unless ($display{$_}) { $display{$_}=''; }
 1455:                           $display{$_}.=' ('.$name{$_}.')';
 1456:                           $default{$_}=&Apache::lonnet::metadata($uri,$_);
 1457:                           $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
 1458:                           $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
 1459:                         }
 1460:                     }
 1461:                     my $totalparms=scalar keys %name;
 1462:                     if ($totalparms>0) {
 1463:                         my $firstrow=1;
 1464: 			my $title=&Apache::lonnet::gettitle($symbp{$rid});
 1465:                         $r->print('<tr><td bgcolor='.$defbgone.
 1466:                              ' rowspan='.$totalparms.
 1467:                              '><tt><font size=-1>'.
 1468:                              join(' / ',split(/\//,$uri)).
 1469:                              '</font></tt><p><b>'.
 1470:                              "<a href=\"javascript:openWindow('".
 1471: 				  &Apache::lonnet::clutter($uri).'?symb='.
 1472: 				  &Apache::lonnet::escape($symbp{$rid}).
 1473:                              "', 'metadatafile', '450', '500', 'no', 'yes')\";".
 1474:                              " TARGET=_self>$title");
 1475: 
 1476:                         if ($thistitle) {
 1477:                             $r->print(' ('.$thistitle.')');
 1478:                         }
 1479:                         $r->print('</a></b></td>');
 1480:                         $r->print('<td bgcolor='.$defbgtwo.
 1481:                                       ' rowspan='.$totalparms.'>'.$typep{$rid}.
 1482:                                       '</td>');
 1483: 
 1484:                         $r->print('<td bgcolor='.$defbgone.
 1485:                                       ' rowspan='.$totalparms.
 1486:                                       '>'.$maptitles{$mapp{$rid}}.'</td>');
 1487: 
 1488:                         foreach (&keysinorder_bytype(\%name,\%keyorder)) {
 1489:                             unless ($firstrow) {
 1490:                                 $r->print('<tr>');
 1491:                             } else {
 1492:                                 undef $firstrow;
 1493:                             }
 1494: 
 1495:                             &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
 1496:                                        \%type,\%display,$defbgone,$defbgtwo,
 1497:                                        $parmlev,$uname,$udom,$csec);
 1498:                         }
 1499:                     }
 1500:                 }
 1501:             } # end foreach ids
 1502: # -------------------------------------------------- End entry for one resource
 1503:             $r->print('</table>');
 1504:         } # end of  full
 1505: #--------------------------------------------------- Entry for parm level map
 1506:         if ($parmlev eq 'map') {
 1507:             my $defbgone = '"E0E099"';
 1508:             my $defbgtwo = '"FFFF99"';
 1509: 
 1510:             my %maplist;
 1511: 
 1512:             if ($pschp eq 'all') {
 1513:                 %maplist = %allmaps; 
 1514:             } else {
 1515:                 %maplist = ($pschp => $mapp{$pschp});
 1516:             }
 1517: 
 1518: #-------------------------------------------- for each map, gather information
 1519:             my $mapid;
 1520: 	    foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
 1521:                 my $maptitle = $maplist{$mapid};
 1522: 
 1523: #-----------------------  loop through ids and get all parameter types for map
 1524: #-----------------------------------------          and associated information
 1525:                 my %name = ();
 1526:                 my %part = ();
 1527:                 my %display = ();
 1528:                 my %type = ();
 1529:                 my %default = ();
 1530:                 my $map = 0;
 1531: 
 1532: #		$r->print("Catmarker: @catmarker<br />\n");
 1533:                
 1534:                 foreach (@ids) {
 1535:                   ($map)=(/([\d]*?)\./);
 1536:                   my $rid = $_;
 1537:         
 1538: #                  $r->print("$mapid:$map:   $rid <br /> \n");
 1539: 
 1540:                   if ($map eq $mapid) {
 1541:                     my $uri=&Apache::lonnet::declutter($uris{$rid});
 1542: #                    $r->print("Keys: $keyp{$rid} <br />\n");
 1543: 
 1544: #--------------------------------------------------------------------
 1545: # @catmarker contains list of all possible parameters including part #s
 1546: # $fullkeyp contains the full part/id # for the extraction of proper parameters
 1547: # $tempkeyp contains part 0 only (no ids - ie, subparts)
 1548: # When storing information, store as part 0
 1549: # When requesting information, request from full part
 1550: #-------------------------------------------------------------------
 1551:                     foreach (&keysplit($keyp{$rid})) {
 1552:                       my $tempkeyp = $_;
 1553:                       my $fullkeyp = $tempkeyp;
 1554:                       $tempkeyp =~ s/_\w+_/_0_/;
 1555:                       
 1556:                       if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
 1557:                         $part{$tempkeyp}="0";
 1558:                         $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
 1559:                         $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
 1560:                         unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
 1561:                         $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
 1562:                         $display{$tempkeyp} =~ s/_\w+_/_0_/;
 1563:                         $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
 1564:                         $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
 1565:                       }
 1566:                     } # end loop through keys
 1567:                   }
 1568:                 } # end loop through ids
 1569:                                  
 1570: #---------------------------------------------------- print header information
 1571:                 my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
 1572:                 my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
 1573:                 $r->print(<<ENDMAPONE);
 1574: <center><h4>
 1575: Set Defaults for All Resources in $foldermap<br />
 1576: <font color="red"><i>$showtitle</i></font><br />
 1577: Specifically for
 1578: ENDMAPONE
 1579:                 if ($uname) {
 1580: 		    my $person=&Apache::loncommon::plainname($uname,$udom);
 1581:                     $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
 1582:                         &mt('in')." \n");
 1583:                 } else {
 1584:                     $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
 1585:                 }
 1586:             
 1587:                 if ($csec) {$r->print(&mt("Section")." <font color=\"red\"><i>$csec</i></font> ".
 1588: 				      &mt('of')." \n")};
 1589: 
 1590:                 $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
 1591:                 $r->print("</h4>\n");
 1592: #---------------------------------------------------------------- print table
 1593:                 $r->print('<p><table border="2">');
 1594:                 $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
 1595:                 $r->print('<th>'.&mt('Default Value').'</th>');
 1596:                 $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
 1597: 
 1598: 	        foreach (&keysinorder(\%name,\%keyorder)) {
 1599:                     $r->print('<tr>');
 1600:                     &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
 1601:                            \%type,\%display,$defbgone,$defbgtwo,
 1602:                            $parmlev,$uname,$udom,$csec);
 1603:                 }
 1604:                 $r->print("</table></center>");
 1605:             } # end each map
 1606:         } # end of $parmlev eq map
 1607: #--------------------------------- Entry for parm level general (Course level)
 1608:         if ($parmlev eq 'general') {
 1609:             my $defbgone = '"E0E099"';
 1610:             my $defbgtwo = '"FFFF99"';
 1611: 
 1612: #-------------------------------------------- for each map, gather information
 1613:             my $mapid="0.0";
 1614: #-----------------------  loop through ids and get all parameter types for map
 1615: #-----------------------------------------          and associated information
 1616:             my %name = ();
 1617:             my %part = ();
 1618:             my %display = ();
 1619:             my %type = ();
 1620:             my %default = ();
 1621:                
 1622:             foreach (@ids) {
 1623:                 my $rid = $_;
 1624:         
 1625:                 my $uri=&Apache::lonnet::declutter($uris{$rid});
 1626: 
 1627: #--------------------------------------------------------------------
 1628: # @catmarker contains list of all possible parameters including part #s
 1629: # $fullkeyp contains the full part/id # for the extraction of proper parameters
 1630: # $tempkeyp contains part 0 only (no ids - ie, subparts)
 1631: # When storing information, store as part 0
 1632: # When requesting information, request from full part
 1633: #-------------------------------------------------------------------
 1634:                 foreach (&keysplit($keyp{$rid})) {
 1635:                   my $tempkeyp = $_;
 1636:                   my $fullkeyp = $tempkeyp;
 1637:                   $tempkeyp =~ s/_\w+_/_0_/;
 1638:                   if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
 1639:                     $part{$tempkeyp}="0";
 1640:                     $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
 1641:                     $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
 1642:                     unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
 1643:                     $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
 1644:                     $display{$tempkeyp} =~ s/_\w+_/_0_/;
 1645:                     $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
 1646:                     $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
 1647:                   }
 1648:                 } # end loop through keys
 1649:             } # end loop through ids
 1650:                                  
 1651: #---------------------------------------------------- print header information
 1652: 	    my $setdef=&mt("Set Defaults for All Resources in Course");
 1653:             $r->print(<<ENDMAPONE);
 1654: <center><h4>$setdef
 1655: <font color="red"><i>$coursename</i></font><br />
 1656: ENDMAPONE
 1657:             if ($uname) {
 1658: 		my $person=&Apache::loncommon::plainname($uname,$udom);
 1659:                 $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
 1660:             } else {
 1661:                 $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
 1662:             }
 1663:             
 1664:             if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
 1665:             $r->print("</h4>\n");
 1666: #---------------------------------------------------------------- print table
 1667:             $r->print('<p><table border="2">');
 1668:             $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
 1669:             $r->print('<th>'.&mt('Default Value').'</th>');
 1670:             $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
 1671: 
 1672: 	    foreach (&keysinorder(\%name,\%keyorder)) {
 1673:                 $r->print('<tr>');
 1674:                 &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
 1675:                        \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
 1676:             }
 1677:             $r->print("</table></center>");
 1678:         } # end of $parmlev eq general
 1679:     }
 1680:     $r->print('</form></body></html>');
 1681: } # end sub assessparms
 1682: 
 1683: 
 1684: ##################################################
 1685: ##################################################
 1686: 
 1687: =pod
 1688: 
 1689: =item crsenv
 1690: 
 1691: Show and set course data and parameters.  This is a large routine that should
 1692: be simplified and shortened... someday.
 1693: 
 1694: Inputs: $r
 1695: 
 1696: Returns: nothing
 1697: 
 1698: =cut
 1699: 
 1700: ##################################################
 1701: ##################################################
 1702: sub crsenv {
 1703:     my $r=shift;
 1704:     my $setoutput='';
 1705:     my $bodytag=&Apache::loncommon::bodytag(
 1706:                              'Set Course Environment Parameters');
 1707:     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,
 1708: 						    'Edit Course Environment');
 1709:     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 1710:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 1711: 
 1712:     #
 1713:     # Go through list of changes
 1714:     foreach (keys %env) {
 1715:         next if ($_!~/^form\.(.+)\_setparmval$/);
 1716:         my $name  = $1;
 1717:         my $value = $env{'form.'.$name.'_value'};
 1718:         if ($name eq 'newp') {
 1719:             $name = $env{'form.newp_name'};
 1720:         }
 1721:         if ($name eq 'url') {
 1722:             $value=~s/^\/res\///;
 1723:             my $bkuptime=time;
 1724:             my @tmp = &Apache::lonnet::get
 1725:                 ('environment',['url'],$dom,$crs);
 1726:             $setoutput.=&mt('Backing up previous URL').': '.
 1727:                 &Apache::lonnet::put
 1728:                 ('environment',
 1729:                  {'top level map backup '.$bkuptime => $tmp[1] },
 1730:                  $dom,$crs).
 1731:                      '<br>';
 1732:         }
 1733:         #
 1734:         # Deal with modified default spreadsheets
 1735:         if ($name =~ /^spreadsheet_default_(classcalc|
 1736:                                             studentcalc|
 1737:                                             assesscalc)$/x) {
 1738:             my $sheettype = $1; 
 1739:             if ($sheettype eq 'classcalc') {
 1740:                 # no need to do anything since viewing the sheet will
 1741:                 # cause it to be updated. 
 1742:             } elsif ($sheettype eq 'studentcalc') {
 1743:                 # expire all the student spreadsheets
 1744:                 &Apache::lonnet::expirespread('','','studentcalc');
 1745:             } else {
 1746:                 # expire all the assessment spreadsheets 
 1747:                 #    this includes non-default spreadsheets, but better to
 1748:                 #    be safe than sorry.
 1749:                 &Apache::lonnet::expirespread('','','assesscalc');
 1750:                 # expire all the student spreadsheets
 1751:                 &Apache::lonnet::expirespread('','','studentcalc');
 1752:             }
 1753:         }
 1754:         #
 1755:         # Deal with the enrollment dates
 1756:         if ($name =~ /^default_enrollment_(start|end)_date$/) {
 1757:             $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
 1758:         }
 1759:         # Get existing cloners
 1760:         my @oldcloner = ();
 1761:         if ($name eq 'cloners') {
 1762:             my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
 1763:             if ($clonenames{'cloners'} =~ /,/) {
 1764:                 @oldcloner = split/,/,$clonenames{'cloners'};
 1765:             } else {
 1766:                 $oldcloner[0] = $clonenames{'cloners'};
 1767:             }
 1768:         }
 1769:         #
 1770:         # Let the user know we made the changes
 1771:         if ($name && defined($value)) {
 1772:             my $failed_cloners;
 1773:             if ($name eq 'cloners') {
 1774:                 $value =~ s/\s//g;
 1775:                 $value =~ s/^,//;
 1776:                 $value =~ s/,$//;
 1777:                 # check requested clones are valid users.
 1778:                 $failed_cloners = &check_cloners(\$value,\@oldcloner);
 1779:             }
 1780:             my $put_result = &Apache::lonnet::put('environment',
 1781:                                                   {$name=>$value},$dom,$crs);
 1782:             if ($put_result eq 'ok') {
 1783:                 $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
 1784:                 if ($name eq 'cloners') {
 1785:                     &change_clone($value,\@oldcloner);
 1786:                 }
 1787:                 # Flush the course logs so course description is immediately updated
 1788:                 if ($name eq 'description' && defined($value)) {
 1789:                     &Apache::lonnet::flushcourselogs();
 1790:                 }
 1791:             } else {
 1792:                 $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
 1793: 		    ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
 1794:             }
 1795:             if (($name eq 'cloners') && ($failed_cloners)) {
 1796:                 $setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '.
 1797:                  &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
 1798:                  '.<br />'.&mt('Please ').
 1799:                  ' <a href="/adm/createuser">'.
 1800:                  &mt('add the user(s)').'</a>, '.
 1801:                  &mt('and then return to the ').
 1802:                  '<a href="/admparmset?action=crsenv">'.
 1803:                  &mt('Course Parameters page').'</a> '.
 1804:                  &mt('to add the new user(s) to the list of possible cloners').
 1805:                  '.<br />';
 1806:             }
 1807:         }
 1808:     }
 1809: # ------------------------- Re-init course environment entries for this session
 1810: 
 1811:     &Apache::lonnet::coursedescription($env{'request.course.id'});
 1812: 
 1813: # -------------------------------------------------------- Get parameters again
 1814: 
 1815:     my %values=&Apache::lonnet::dump('environment',$dom,$crs);
 1816:     my $SelectStyleFile=&mt('Select Style File');
 1817:     my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
 1818:     my $output='';
 1819:     if (! exists($values{'con_lost'})) {
 1820:         my %descriptions=
 1821: 	    ('url'            => '<b>'.&mt('Top Level Map').'</b> '.
 1822:                                  '<a href="javascript:openbrowser'.
 1823:                                  "('envform','url','sequence')\">".
 1824:                                  &mt('Select Map').'</a><br /><font color=red> '.
 1825:                                  &mt('Modification may make assessment data inaccessible').
 1826:                                  '</font>',
 1827:              'description'    => '<b>'.&mt('Course Description').'</b>',
 1828:              'courseid'       => '<b>'.&mt('Course ID or number').
 1829:                                  '</b><br />'.
 1830:                                  '('.&mt('internal').', '.&mt('optional').')',
 1831:              'cloners'        => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
 1832:              'grading'        => '<b>'.&mt('Grading').'</b><br />'.
 1833:                                  '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
 1834:              'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
 1835:                     '<a href="javascript:openbrowser'.
 1836:                     "('envform','default_xml_style'".
 1837:                     ",'sty')\">$SelectStyleFile</a><br>",
 1838:              'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
 1839:                                  '</b><br />(<tt>user:domain,'.
 1840:                                  'user:domain(section;section;...;*;...),...</tt>)',
 1841:              'comment.email'  => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
 1842:                                  '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
 1843:              'policy.email'   => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
 1844:                                  '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
 1845:              'hideemptyrows'  => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
 1846:                                  '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
 1847:              'pageseparators'  => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
 1848:                                  '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
 1849:                                  &mt('changes will not show until next login').')',
 1850:              'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b>'.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
 1851: 
 1852:              'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
 1853:                                   '</b><br />"<tt>st</tt>": '.
 1854:                                   &mt('student').', "<tt>ta</tt>": '.
 1855:                                   'TA, "<tt>in</tt>": '.
 1856:                                   &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
 1857: 	       Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
 1858:              'plc.users.denied' => 
 1859:                           '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
 1860:                                  '(<tt>user:domain,user:domain,...</tt>)',
 1861: 
 1862:              'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
 1863:                                   '</b><br />"<tt>st</tt>": '.
 1864:                                   'student, "<tt>ta</tt>": '.
 1865:                                   'TA, "<tt>in</tt>": '.
 1866:                                   'instructor;<br /><tt>role,role,...</tt>) '.
 1867: 	       Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
 1868:              'pch.users.denied' => 
 1869:                           '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
 1870:                                  '(<tt>user:domain,user:domain,...</tt>)',
 1871:              'spreadsheet_default_classcalc' 
 1872:                  => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
 1873:                     '<a href="javascript:openbrowser'.
 1874:                     "('envform','spreadsheet_default_classcalc'".
 1875:                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
 1876:              'spreadsheet_default_studentcalc' 
 1877:                  => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
 1878:                     '<a href="javascript:openbrowser'.
 1879:                     "('envform','spreadsheet_default_calc'".
 1880:                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
 1881:              'spreadsheet_default_assesscalc' 
 1882:                  => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
 1883:                     '<a href="javascript:openbrowser'.
 1884:                     "('envform','spreadsheet_default_assesscalc'".
 1885:                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
 1886: 	     'allow_limited_html_in_feedback'
 1887: 	         => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
 1888: 	            '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
 1889:              'allow_discussion_post_editing'
 1890:                  => '<b>'.&mt('Allow users to edit/delete their own discussion posts').'</b><br />'.
 1891:                     '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
 1892: 	     'rndseed'
 1893: 	         => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
 1894:                     '<font color="red">'.&mt('Modifying this will make problems').' '.
 1895:                     &mt('have different numbers and answers').'</font>',
 1896: 	     'receiptalg'
 1897: 	         => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
 1898:                     &mt('This controls how receipt numbers are generated.'),
 1899:              'suppress_tries'
 1900:                  => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
 1901:                     ' ('.&mt('"[_1]" to suppress, anything else to not suppress','<tt>yes</tt>').')',
 1902:              'problem_stream_switch'
 1903:                  => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
 1904:                     ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
 1905:              'default_paper_size' 
 1906:                  => '<b>'.&mt('Default paper type').'</b><br />'.
 1907:                     ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. 
 1908:                     ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. 
 1909:                     ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
 1910:              'anonymous_quiz'
 1911:                  => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
 1912:                     ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
 1913:              'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
 1914:              'default_enrollment_end_date'   => '<b>'.&mt('Default ending date for student access.').'</b>',
 1915:              'nothideprivileged'   => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
 1916:                                  '<br />(<tt>user:domain,user:domain,...</tt>)',
 1917:              'languages' => '<b>'.&mt('Languages used').'</b>',
 1918:              'disable_receipt_display'
 1919:                  => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
 1920:                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
 1921: 	     'task_messages'
 1922: 	         => '<b>'.&mt('Send message to student when clicking Done on Tasks. [_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','<tt>only_student</tt>','<tt>student_and_user_notes_screen</tt>').'</b>',
 1923: 	     'disablesigfigs'
 1924: 	         => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
 1925:                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
 1926: 	     'disableexampointprint'
 1927: 	         => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
 1928:                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
 1929: 	     'tthoptions'
 1930: 	         => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
 1931:              ); 
 1932:         my @Display_Order = ('url','description','courseid','cloners','grading',
 1933:                              'default_xml_style','pageseparators',
 1934:                              'question.email','comment.email','policy.email',
 1935:                              'student_classlist_view',
 1936:                              'plc.roles.denied','plc.users.denied',
 1937:                              'pch.roles.denied','pch.users.denied',
 1938:                              'allow_limited_html_in_feedback',
 1939:                              'allow_discussion_post_editing',
 1940:                              'languages',
 1941: 			     'nothideprivileged',
 1942:                              'rndseed',
 1943:                              'receiptalg',
 1944:                              'problem_stream_switch',
 1945: 			     'suppress_tries',
 1946:                              'default_paper_size',
 1947:                              'disable_receipt_display',
 1948:                              'spreadsheet_default_classcalc',
 1949:                              'spreadsheet_default_studentcalc',
 1950:                              'spreadsheet_default_assesscalc', 
 1951:                              'hideemptyrows',
 1952:                              'default_enrollment_start_date',
 1953:                              'default_enrollment_end_date',
 1954: 			     'tthoptions',
 1955: 			     'disablesigfigs',
 1956: 			     'disableexampointprint',
 1957: 			     'task_messages'
 1958:                              );
 1959: 	foreach my $parameter (sort(keys(%values))) {
 1960:             unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
 1961:                 if (! $descriptions{$parameter}) {
 1962:                     $descriptions{$parameter}=$parameter;
 1963:                     push(@Display_Order,$parameter);
 1964:                 }
 1965:             }
 1966: 	}
 1967:         foreach my $parameter (@Display_Order) {
 1968:             my $description = $descriptions{$parameter};
 1969:             # onchange is javascript to automatically check the 'Set' button.
 1970:             my $onchange = 'onFocus="javascript:window.document.forms'.
 1971:                 "['envform'].elements['".$parameter."_setparmval']".
 1972:                 '.checked=true;"';
 1973:             $output .= '<tr><td>'.$description.'</td>';
 1974:             if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
 1975:                 $output .= '<td>'.
 1976:                     &Apache::lonhtmlcommon::date_setter('envform',
 1977:                                                         $parameter.'_value',
 1978:                                                         $values{$parameter},
 1979:                                                         $onchange).
 1980:                                                         '</td>';
 1981:             } else {
 1982:                 $output .= '<td>'.
 1983:                     &Apache::lonhtmlcommon::textbox($parameter.'_value',
 1984:                                                     $values{$parameter},
 1985:                                                     40,$onchange).'</td>';
 1986:             }
 1987:             $output .= '<td>'.
 1988:                 &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
 1989:                 '</td>';
 1990:             $output .= "</tr>\n";
 1991: 	}
 1992:         my $onchange = 'onFocus="javascript:window.document.forms'.
 1993:             '[\'envform\'].elements[\'newp_setparmval\']'.
 1994:             '.checked=true;"';
 1995: 	$output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
 1996: 	    '<input type="text" size=40 name="newp_name" '.
 1997:                 $onchange.' /></td><td>'.
 1998:             '<input type="text" size=40 name="newp_value" '.
 1999:                 $onchange.' /></td><td>'.
 2000: 	    '<input type="checkbox" name="newp_setparmval" /></td></tr>';
 2001:     }
 2002:     my %lt=&Apache::lonlocal::texthash(
 2003: 		    'par'   => 'Parameter',
 2004: 		    'val'   => 'Value',
 2005: 		    'set'   => 'Set',
 2006: 		    'sce'   => 'Set Course Environment'
 2007: 				       );
 2008: 
 2009:     my $Parameter=&mt('Parameter');
 2010:     my $Value=&mt('Value');
 2011:     my $Set=&mt('Set');
 2012:     my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset');
 2013:     my $html=&Apache::lonxml::xmlbegin();
 2014:     $r->print(<<ENDenv);
 2015: $html
 2016: <head>
 2017: <script type="text/javascript" language="Javascript" >
 2018: $browse_js
 2019: </script>
 2020: <title>LON-CAPA Course Environment</title>
 2021: </head>
 2022: $bodytag
 2023: $breadcrumbs
 2024: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
 2025: $setoutput
 2026: <p>
 2027: <table border=2>
 2028: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
 2029: $output
 2030: </table>
 2031: <input type="submit" name="crsenv" value="$lt{'sce'}">
 2032: </form>
 2033: </body>
 2034: </html>    
 2035: ENDenv
 2036: }
 2037: ##################################################
 2038: # Overview mode
 2039: ##################################################
 2040: my $tableopen;
 2041: 
 2042: sub tablestart {
 2043:     if ($tableopen) {
 2044: 	return '';
 2045:     } else {
 2046: 	$tableopen=1;
 2047: 	return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
 2048: 	    &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
 2049:     }
 2050: }
 2051: 
 2052: sub tableend {
 2053:     if ($tableopen) {
 2054: 	$tableopen=0;
 2055: 	return '</table>';
 2056:     } else {
 2057: 	return'';
 2058:     }
 2059: }
 2060: 
 2061: sub readdata {
 2062:     my ($crs,$dom)=@_;
 2063: # Read coursedata
 2064:     my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
 2065: # Read userdata
 2066: 
 2067:     my $classlist=&Apache::loncoursedata::get_classlist();
 2068:     foreach (keys %$classlist) {
 2069:         # the following undefs are for 'domain', and 'username' respectively.
 2070:         if ($_=~/^(\w+)\:(\w+)$/) {
 2071: 	    my ($tuname,$tudom)=($1,$2);
 2072: 	    my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
 2073:             foreach my $userkey (keys %{$useropt}) {
 2074: 		if ($userkey=~/^$env{'request.course.id'}/) {
 2075:                     my $newkey=$userkey;
 2076: 		    $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
 2077: 		    $$resourcedata{$newkey}=$$useropt{$userkey};
 2078: 		}
 2079: 	    }
 2080: 	}
 2081:     }
 2082:     return $resourcedata;
 2083: }
 2084: 
 2085: 
 2086: # Setting
 2087: 
 2088: sub storedata {
 2089:     my ($r,$crs,$dom)=@_;
 2090: # Set userlevel immediately
 2091: # Do an intermediate store of course level
 2092:     my $olddata=&readdata($crs,$dom);
 2093:     my %newdata=();
 2094:     undef %newdata;
 2095:     my @deldata=();
 2096:     undef @deldata;
 2097:     foreach (keys %env) {
 2098: 	if ($_=~/^form\.([a-z]+)\_(.+)$/) {
 2099: 	    my $cmd=$1;
 2100: 	    my $thiskey=$2;
 2101: 	    my ($tuname,$tudom)=&extractuser($thiskey);
 2102: 	    my $tkey=$thiskey;
 2103:             if ($tuname) {
 2104: 		$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
 2105: 	    }
 2106: 	    if ($cmd eq 'set') {
 2107: 		my $data=$env{$_};
 2108:                 my $typeof=$env{'form.typeof_'.$thiskey};
 2109:  		if ($$olddata{$thiskey} ne $data) { 
 2110: 		    if ($tuname) {
 2111: 			if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
 2112: 								 $tkey.'.type' => $typeof},
 2113: 						 $tudom,$tuname) eq 'ok') {
 2114: 			    $r->print('<br />'.&mt('Stored modified parameter for').' '.
 2115: 				      &Apache::loncommon::plainname($tuname,$tudom));
 2116: 			} else {
 2117: 			    $r->print('<h2><font color="red">'.
 2118: 				      &mt('Error storing parameters').'</font></h2>');
 2119: 			}
 2120: 			&Apache::lonnet::devalidateuserresdata($tuname,$tudom);
 2121: 		    } else {
 2122: 			$newdata{$thiskey}=$data;
 2123:  			$newdata{$thiskey.'.type'}=$typeof; 
 2124:                    } 
 2125: 		}
 2126: 	    } elsif ($cmd eq 'del') {
 2127: 		if ($tuname) {
 2128: 		    if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
 2129: 			$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
 2130: 		    } else {
 2131: 			$r->print('<h2><font color="red">'.
 2132: 				  &mt('Error deleting parameters').'</font></h2>');
 2133: 		    }
 2134: 		    &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
 2135: 		} else {
 2136: 		    push (@deldata,$thiskey);
 2137: 		}
 2138: 	    } elsif ($cmd eq 'datepointer') {
 2139: 		my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
 2140:                 my $typeof=$env{'form.typeof_'.$thiskey};
 2141: 		if (defined($data) and $$olddata{$thiskey} ne $data) { 
 2142: 		    if ($tuname) {
 2143: 			if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
 2144: 								 $tkey.'.type' => $typeof},
 2145: 						 $tudom,$tuname) eq 'ok') {
 2146: 			    $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
 2147: 			} else {
 2148: 			    $r->print('<h2><font color="red">'.
 2149: 				      &mt('Error storing parameters').'</font></h2>');
 2150: 			}
 2151: 			&Apache::lonnet::devalidateuserresdata($tuname,$tudom);
 2152: 		    } else {
 2153: 			$newdata{$thiskey}=$data;
 2154: 			$newdata{$thiskey.'.type'}=$typeof; 
 2155: 		    }
 2156: 		}
 2157: 	    }
 2158: 	}
 2159:     }
 2160: # Store all course level
 2161:     my $delentries=$#deldata+1;
 2162:     my @newdatakeys=keys %newdata;
 2163:     my $putentries=$#newdatakeys+1;
 2164:     if ($delentries) {
 2165: 	if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
 2166: 	    $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
 2167: 	} else {
 2168: 	    $r->print('<h2><font color="red">'.
 2169: 		      &mt('Error deleting parameters').'</font></h2>');
 2170: 	}
 2171: 	&Apache::lonnet::devalidatecourseresdata($crs,$dom);
 2172:     }
 2173:     if ($putentries) {
 2174: 	if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
 2175: 	    $r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>');
 2176: 	} else {
 2177: 	    $r->print('<h2><font color="red">'.
 2178: 		      &mt('Error storing parameters').'</font></h2>');
 2179: 	}
 2180: 	&Apache::lonnet::devalidatecourseresdata($crs,$dom);
 2181:     }
 2182: }
 2183: 
 2184: sub extractuser {
 2185:     my $key=shift;
 2186:     return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
 2187: }
 2188: 
 2189: sub listdata {
 2190:     my ($r,$resourcedata,$listdata,$sortorder)=@_;
 2191: # Start list output
 2192: 
 2193:     my $oldsection='';
 2194:     my $oldrealm='';
 2195:     my $oldpart='';
 2196:     my $pointer=0;
 2197:     $tableopen=0;
 2198:     my $foundkeys=0;
 2199:     my %keyorder=&standardkeyorder();
 2200:     foreach my $thiskey (sort {
 2201: 	if ($sortorder eq 'realmstudent') {
 2202: 	    my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
 2203: 	    my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
 2204: 	    if (!defined($astudent)) {
 2205: 		($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
 2206: 	    }
 2207: 	    if (!defined($bstudent)) {
 2208: 		($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
 2209: 	    }
 2210: 	    $arealm=~s/\.type//;
 2211: 	    my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
 2212: 	    $aparm=$keyorder{'parameter_0_'.$aparm};
 2213: 	    $brealm=~s/\.type//;
 2214: 	    my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
 2215: 	    $bparm=$keyorder{'parameter_0_'.$bparm};	   
 2216: 	    if ($ares eq $bres) {
 2217: 		if (defined($aparm) && defined($bparm)) {
 2218: 		    ($aparm <=> $bparm);
 2219: 		} elsif (defined($aparm)) {
 2220: 		    -1;
 2221: 		} elsif (defined($bparm)) {
 2222: 		    1;
 2223: 		} else {
 2224: 		    ($arealm cmp $brealm) || ($astudent cmp $bstudent);
 2225: 		}
 2226: 	    } else {
 2227: 		($arealm cmp $brealm) || ($astudent cmp $bstudent);
 2228: 	    }
 2229: 	} else {
 2230: 	    $a cmp $b;
 2231: 	}
 2232:     } keys %{$listdata}) {
 2233: 	 
 2234: 	if ($$listdata{$thiskey.'.type'}) {
 2235:             my $thistype=$$listdata{$thiskey.'.type'};
 2236:             if ($$resourcedata{$thiskey.'.type'}) {
 2237: 		$thistype=$$resourcedata{$thiskey.'.type'};
 2238: 	    }
 2239: 	    my ($middle,$part,$name)=
 2240: 		($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
 2241: 	    my $section=&mt('All Students');
 2242: 	    if ($middle=~/^\[(.*)\]/) {
 2243: 		my $issection=$1;
 2244: 		if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
 2245: 		    $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
 2246: 		} else {
 2247: 		    $section=&mt('Group/Section').': '.$issection;
 2248: 		}
 2249: 		$middle=~s/^\[(.*)\]//;
 2250: 	    }
 2251: 	    $middle=~s/\.+$//;
 2252: 	    $middle=~s/^\.+//;
 2253: 	    my $realm='<font color="red">'.&mt('All Resources').'</font>';
 2254: 	    if ($middle=~/^(.+)\_\_\_\(all\)$/) {
 2255: 		$realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
 2256: 	    } elsif ($middle) {
 2257: 		my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
 2258: 		$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
 2259: 	    }
 2260: 	    if ($sortorder eq 'realmstudent') {
 2261: 		if ($realm ne $oldrealm) {
 2262: 		    $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
 2263: 		    $oldrealm=$realm;
 2264: 		    $oldsection='';
 2265: 		}
 2266: 		if ($section ne $oldsection) {
 2267: 		    $r->print(&tableend()."\n<h2>$section</h2>");
 2268: 		    $oldsection=$section;
 2269: 		    $oldpart='';
 2270: 		}
 2271: 	    } else {
 2272: 		if ($section ne $oldsection) {
 2273: 		    $r->print(&tableend()."\n<hr /><h1>$section</h1>");
 2274: 		    $oldsection=$section;
 2275: 		    $oldrealm='';
 2276: 		}
 2277: 		if ($realm ne $oldrealm) {
 2278: 		    $r->print(&tableend()."\n<h2>$realm</h2>");
 2279: 		    $oldrealm=$realm;
 2280: 		    $oldpart='';
 2281: 		}
 2282: 	    }
 2283: 	    if ($part ne $oldpart) {
 2284: 		$r->print(&tableend().
 2285: 			  "\n<font color='blue'>".&mt('Part').": $part</font>");
 2286: 		$oldpart=$part;
 2287: 	    }
 2288: #
 2289: # Preset defaults?
 2290: #
 2291:             my ($hour,$min,$sec,$val)=('','','','');
 2292: 	    unless ($$resourcedata{$thiskey}) {
 2293: 		my ($parmname)=($thiskey=~/\.(\w+)$/);
 2294: 		($hour,$min,$sec,$val)=&preset_defaults($parmname);
 2295: 	    }
 2296: 
 2297: #
 2298: # Ready to print
 2299: #
 2300: 	    $r->print(&tablestart().'<tr><td><b>'.$name.
 2301: 		      ':</b></td><td><input type="checkbox" name="del_'.
 2302: 		      $thiskey.'" /></td><td>');
 2303: 	    $foundkeys++;
 2304: 	    if (&isdateparm($thistype)) {
 2305: 		my $jskey='key_'.$pointer;
 2306: 		$pointer++;
 2307: 		$r->print(
 2308: 			  &Apache::lonhtmlcommon::date_setter('parmform',
 2309: 							      $jskey,
 2310: 						      $$resourcedata{$thiskey},
 2311: 							      '',1,'','',$hour,$min,$sec).
 2312: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
 2313: 			  );
 2314: 	    } elsif ($thistype eq 'string_yesno') {
 2315: 		my $showval;
 2316: 		if (defined($$resourcedata{$thiskey})) {
 2317: 		    $showval=$$resourcedata{$thiskey};
 2318: 		} else {
 2319: 		    $showval=$val;
 2320: 		}
 2321: 		$r->print('<label><input type="radio" name="set_'.$thiskey.
 2322: 			  '" value="yes"');
 2323: 		if ($showval eq 'yes') {
 2324: 		    $r->print(' checked="checked"');
 2325: 		}
 2326:                 $r->print(' />'.&mt('Yes').'</label> ');
 2327: 		$r->print('<label><input type="radio" name="set_'.$thiskey.
 2328: 			  '" value="no"');
 2329: 		if ($showval eq 'no') {
 2330: 		    $r->print(' checked="checked"');
 2331: 		}
 2332:                 $r->print(' />'.&mt('No').'</label>');
 2333: 	    } else {
 2334: 		my $showval;
 2335: 		if (defined($$resourcedata{$thiskey})) {
 2336: 		    $showval=$$resourcedata{$thiskey};
 2337: 		} else {
 2338: 		    $showval=$val;
 2339: 		}
 2340: 		$r->print('<input type="text" name="set_'.$thiskey.'" value="'.
 2341: 			  $showval.'">');
 2342: 	    }
 2343: 	    $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
 2344: 		      $thistype.'">');
 2345: 	    $r->print('</td></tr>');
 2346: 	}
 2347:     }
 2348:     return $foundkeys;
 2349: }
 2350: 
 2351: sub newoverview {
 2352:     my $r=shift;
 2353:     my $bodytag=&Apache::loncommon::bodytag('Set Parameters');
 2354:     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 2355:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 2356:     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
 2357:     my $html=&Apache::lonxml::xmlbegin();
 2358:     $r->print(<<ENDOVER);
 2359: $html
 2360: <head>
 2361: <title>LON-CAPA Parameters</title>
 2362: </head>
 2363: $bodytag
 2364: $breadcrumbs
 2365: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
 2366: ENDOVER
 2367:     my @ids=();
 2368:     my %typep=();
 2369:     my %keyp=();
 2370:     my %allparms=();
 2371:     my %allparts=();
 2372:     my %allmaps=();
 2373:     my %mapp=();
 2374:     my %symbp=();
 2375:     my %maptitles=();
 2376:     my %uris=();
 2377:     my %keyorder=&standardkeyorder();
 2378:     my %defkeytype=();
 2379: 
 2380:     my %alllevs=();
 2381:     $alllevs{'Resource Level'}='full';
 2382:     $alllevs{'Map/Folder Level'}='map';
 2383:     $alllevs{'Course Level'}='general';
 2384: 
 2385:     my $csec=$env{'form.csec'};
 2386: 
 2387:     my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
 2388:     my $pschp=$env{'form.pschp'};
 2389:     my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
 2390:     if (!@psprt) { $psprt[0]='0'; }
 2391: 
 2392:     my @selected_sections = 
 2393: 	&Apache::loncommon::get_env_multiple('form.Section');
 2394:     @selected_sections = ('all') if (! @selected_sections);
 2395:     foreach (@selected_sections) {
 2396:         if ($_ eq 'all') {
 2397:             @selected_sections = ('all');
 2398:         }
 2399:     }
 2400: 
 2401:     my $pssymb='';
 2402:     my $parmlev='';
 2403:  
 2404:     unless ($env{'form.parmlev'}) {
 2405:         $parmlev = 'map';
 2406:     } else {
 2407:         $parmlev = $env{'form.parmlev'};
 2408:     }
 2409: 
 2410:     &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, 
 2411: 				\%mapp, \%symbp,\%maptitles,\%uris,
 2412: 				\%keyorder,\%defkeytype);
 2413: 
 2414: # Menu to select levels, etc
 2415: 
 2416:     $r->print('<table border="1"><tr><td>');
 2417:     &levelmenu($r,\%alllevs,$parmlev);
 2418:     if ($parmlev ne 'general') {
 2419: 	$r->print('<td>');
 2420: 	&mapmenu($r,\%allmaps,$pschp,\%maptitles);
 2421: 	$r->print('</td>');
 2422:     }
 2423:     $r->print('</td></tr></table>');
 2424: 
 2425:     $r->print('<table border="1"><tr><td>');  
 2426:     &parmmenu($r,\%allparms,\@pscat,\%keyorder);
 2427:     $r->print('</td><td>');
 2428:     &partmenu($r,\%allparts,\@psprt);
 2429:     $r->print('</td><td>');
 2430:     &sectionmenu($r,\@selected_sections);
 2431: 
 2432:     $r->print('</td></tr></table>');
 2433:  
 2434:     my $sortorder=$env{'form.sortorder'};
 2435:     unless ($sortorder) { $sortorder='realmstudent'; }
 2436:     &sortmenu($r,$sortorder);
 2437: 
 2438:     $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
 2439: 
 2440: # Build the list data hash from the specified parms
 2441: 
 2442:     my $listdata;
 2443:     %{$listdata}=();
 2444: 
 2445:     foreach my $cat (@pscat) {
 2446: 	foreach my $section (@selected_sections) {
 2447: 	    foreach my $part (@psprt) {
 2448:                 my $rootparmkey=$env{'request.course.id'};
 2449:                 if (($section ne 'all') && ($section ne 'none') && ($section)) {
 2450: 		    $rootparmkey.='.['.$section.']';
 2451: 		}
 2452: 		if ($parmlev eq 'general') {
 2453: # course-level parameter
 2454: 		    my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
 2455: 		    $$listdata{$newparmkey}=1;
 2456: 		    $$listdata{$newparmkey.'.type'}=$defkeytype{$cat};
 2457: 		} elsif ($parmlev eq 'map') {
 2458: # map-level parameter
 2459: 		    foreach my $mapid (keys %allmaps) {
 2460: 			if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
 2461: 			my $newparmkey=$rootparmkey.'.'.$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
 2462:                         $$listdata{$newparmkey}=1;
 2463:                         $$listdata{$newparmkey.'.type'}=$defkeytype{$cat};
 2464: 		    }
 2465: 		} else {
 2466: # resource-level parameter
 2467: 		    foreach my $rid (@ids) {
 2468: 			my ($map,$resid,$url)=&Apache::lonnet::decode_symb($symbp{$rid});
 2469: 			if (($pschp ne 'all') && ($allmaps{$pschp} ne $map)) { next; }
 2470: 			my $newparmkey=$rootparmkey.'.'.$symbp{$rid}.'.'.$part.'.'.$cat;
 2471:                         $$listdata{$newparmkey}=1;
 2472:                         $$listdata{$newparmkey.'.type'}=$defkeytype{$cat};
 2473: 		    }
 2474: 		}
 2475: 	    }
 2476: 	}
 2477:     }
 2478: 
 2479:     if (($env{'form.store'}) || ($env{'form.dis'})) {
 2480: 
 2481: 	if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
 2482: 
 2483: # Read modified data
 2484: 
 2485: 	my $resourcedata=&readdata($crs,$dom);
 2486: 
 2487: # List data
 2488: 
 2489: 	&listdata($r,$resourcedata,$listdata,$sortorder);
 2490:     }
 2491:     $r->print(&tableend().
 2492: 	     ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':'').
 2493: 	      '</form></body></html>');
 2494: }
 2495: 
 2496: sub overview {
 2497:     my $r=shift;
 2498:     my $bodytag=&Apache::loncommon::bodytag('Modify Parameters');
 2499:     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 2500:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 2501:     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
 2502:     my $html=&Apache::lonxml::xmlbegin();
 2503:     $r->print(<<ENDOVER);
 2504: $html
 2505: <head>
 2506: <title>LON-CAPA Parameters</title>
 2507: </head>
 2508: $bodytag
 2509: $breadcrumbs
 2510: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
 2511: ENDOVER
 2512: # Store modified
 2513: 
 2514:     &storedata($r,$crs,$dom);
 2515: 
 2516: # Read modified data
 2517: 
 2518:     my $resourcedata=&readdata($crs,$dom);
 2519: 
 2520: 
 2521:     my $sortorder=$env{'form.sortorder'};
 2522:     unless ($sortorder) { $sortorder='realmstudent'; }
 2523:     &sortmenu($r,$sortorder);
 2524: 
 2525: # List data
 2526: 
 2527:     my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
 2528: 
 2529:     $r->print(&tableend().'<p>'.
 2530: 	($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form></body></html>');
 2531: }
 2532: 
 2533: ##################################################
 2534: ##################################################
 2535:                                                                                             
 2536: =pod
 2537: 
 2538: =item check_cloners
 2539: 
 2540: Checks if new users included in list of allowed cloners
 2541: are valid users.  Replaces supplied list with 
 2542: cleaned list containing only users with valid usernames
 2543: and domains.
 2544: 
 2545: Inputs: $clonelist, $oldcloner 
 2546: where $clonelist is ref to array of requested cloners,
 2547: and $oldcloner is ref to array of currently allowed
 2548: cloners.
 2549: 
 2550: Returns: string - comma separated list of requested
 2551: cloners (username:domain) who do not exist in system.
 2552: 
 2553: =item change_clone
 2554: 
 2555: Modifies the list of courses a user can clone (stored
 2556: in the user's environment.db file), called when a
 2557: change is made to the list of users allowed to clone
 2558: a course.
 2559: 
 2560: Inputs: $action,$cloner
 2561: where $action is add or drop, and $cloner is identity of 
 2562: user for whom cloning ability is to be changed in course. 
 2563: 
 2564: =cut
 2565:                                                                                             
 2566: ##################################################
 2567: ##################################################
 2568: 
 2569: sub extract_cloners {
 2570:     my ($clonelist,$allowclone) = @_;
 2571:     if ($clonelist =~ /,/) {
 2572:         @{$allowclone} = split/,/,$clonelist;
 2573:     } else {
 2574:         $$allowclone[0] = $clonelist;
 2575:     }
 2576: }
 2577: 
 2578: 
 2579: sub check_cloners {
 2580:     my ($clonelist,$oldcloner) = @_;
 2581:     my ($clean_clonelist,$disallowed);
 2582:     my @allowclone = ();
 2583:     &extract_cloners($$clonelist,\@allowclone);
 2584:     foreach my $currclone (@allowclone) {
 2585:         if (!grep/^$currclone$/,@$oldcloner) {
 2586:             my ($uname,$udom) = split/:/,$currclone;
 2587:             if ($uname && $udom) {
 2588:                 if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
 2589:                     $disallowed .= $currclone.',';   
 2590:                 } else {
 2591:                     $clean_clonelist .= $currclone.',';
 2592:                 }
 2593:             }
 2594:         } else {
 2595:             $clean_clonelist .= $currclone.',';
 2596:         }
 2597:     }
 2598:     if ($disallowed) {
 2599:         $disallowed =~ s/,$//;
 2600:     }
 2601:     if ($clean_clonelist) {
 2602:         $clean_clonelist =~ s/,$//;
 2603:     }
 2604:     $$clonelist = $clean_clonelist;
 2605:     return $disallowed;
 2606: }  
 2607: 
 2608: sub change_clone {
 2609:     my ($clonelist,$oldcloner) = @_;
 2610:     my ($uname,$udom);
 2611:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 2612:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 2613:     my $clone_crs = $cnum.':'.$cdom;
 2614:     
 2615:     if ($cnum && $cdom) {
 2616:         my @allowclone;
 2617:         &extract_cloners($clonelist,\@allowclone);
 2618:         foreach my $currclone (@allowclone) {
 2619:             if (!grep/^$currclone$/,@$oldcloner) {
 2620:                 ($uname,$udom) = split/:/,$currclone;
 2621:                 if ($uname && $udom) {
 2622:                     unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
 2623:                         my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
 2624:                         if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
 2625:                             if ($currclonecrs{'cloneable'} eq '') {
 2626:                                 $currclonecrs{'cloneable'} = $clone_crs;
 2627:                             } else {
 2628:                                 $currclonecrs{'cloneable'} .= ','.$clone_crs;
 2629:                             }
 2630:                             &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
 2631:                         }
 2632:                     }
 2633:                 }
 2634:             }
 2635:         }
 2636:         foreach my $oldclone (@$oldcloner) {
 2637:             if (!grep/^$oldclone$/,@allowclone) {
 2638:                 ($uname,$udom) = split/:/,$oldclone;
 2639:                 if ($uname && $udom) {
 2640:                     unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
 2641:                         my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
 2642:                         my %newclonecrs = ();
 2643:                         if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
 2644:                             if ($currclonecrs{'cloneable'} =~ /,/) {
 2645:                                 my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
 2646:                                 foreach (@currclonecrs) {
 2647:                                     unless ($_ eq $clone_crs) {
 2648:                                         $newclonecrs{'cloneable'} .= $_.',';
 2649:                                     }
 2650:                                 }
 2651:                                 $newclonecrs{'cloneable'} =~ s/,$//;
 2652:                             } else {
 2653:                                 $newclonecrs{'cloneable'} = '';
 2654:                             }
 2655:                             &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
 2656:                         }
 2657:                     }
 2658:                 }
 2659:             }
 2660:         }
 2661:     }
 2662: }
 2663: 
 2664: 
 2665: ##################################################
 2666: ##################################################
 2667: 
 2668: =pod
 2669: 
 2670: =item * header
 2671: 
 2672: Output html header for page
 2673: 
 2674: =cut
 2675: 
 2676: ##################################################
 2677: ##################################################
 2678: sub header {
 2679:     my $html=&Apache::lonxml::xmlbegin();
 2680:     my $bodytag=&Apache::loncommon::bodytag('Parameter Manager');
 2681:     my $title = &mt('LON-CAPA Parameter Manager');
 2682:     return(<<ENDHEAD);
 2683: $html
 2684: <head>
 2685: <title>$title</title>
 2686: </head>
 2687: $bodytag
 2688: ENDHEAD
 2689: }
 2690: ##################################################
 2691: ##################################################
 2692: sub print_main_menu {
 2693:     my ($r,$parm_permission)=@_;
 2694:     #
 2695:     $r->print(<<ENDMAINFORMHEAD);
 2696: <form method="post" enctype="multipart/form-data"
 2697:       action="/adm/parmset" name="studentform">
 2698: ENDMAINFORMHEAD
 2699: #
 2700:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 2701:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 2702:     my $vgr  = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
 2703: 
 2704:     my @menu =
 2705:         (
 2706:           { text => 'Set Course Environment Parameters',
 2707: 	    action => 'crsenv',
 2708:             permission => $parm_permission,
 2709:             },
 2710:           { text => 'Set Portfolio Metadata',
 2711: 	    action => 'setrestrictmeta',
 2712:             permission => $parm_permission,
 2713:             },
 2714: 	  { text => 'Manage Course Slots',
 2715: 	    url => '/adm/slotrequest?command=showslots',
 2716: 	    permission => $vgr,
 2717:             },
 2718: 	  { divider => 1,
 2719: 	    },
 2720:           { text => 'Set/Modify Resource Parameters - Helper Mode',
 2721:             url => '/adm/helper/parameter.helper',
 2722:             permission => $parm_permission,
 2723:             },
 2724:           { text => 'Modify Resource Parameters - Overview Mode',
 2725:             action => 'setoverview',
 2726:             permission => $parm_permission,
 2727:             },          
 2728: 	  { text => 'Set Resource Parameters - Overview Mode',
 2729:             action => 'newoverview',
 2730:             permission => $parm_permission,
 2731:             },
 2732:           { text => 'Set/Modify Resource Parameters - Table Mode',
 2733:             action => 'settable',
 2734:             permission => $parm_permission,
 2735:             help => 'Cascading_Parameters',
 2736:             },
 2737:           { text => 'Set Parameter Setting Default Actions',
 2738:             action => 'setdefaults',
 2739:             permission => $parm_permission,
 2740:             },
 2741:           );
 2742:     my $menu_html = '';
 2743:     foreach my $menu_item (@menu) {
 2744: 	if ($menu_item->{'divider'}) {
 2745: 	    $menu_html .= '<hr />';
 2746: 	    next;
 2747: 	}
 2748:         next if (! $menu_item->{'permission'});
 2749:         $menu_html.='<p>';
 2750:         $menu_html.='<font size="+1">';
 2751:         if (exists($menu_item->{'url'})) {
 2752:             $menu_html.=qq{<a href="$menu_item->{'url'}">};
 2753:         } else {
 2754:             $menu_html.=
 2755:                 qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
 2756:         }
 2757:         $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
 2758:         if (exists($menu_item->{'help'})) {
 2759:             $menu_html.=
 2760:                 &Apache::loncommon::help_open_topic($menu_item->{'help'});
 2761:         }
 2762:         $menu_html.='</p>'.$/;
 2763:     }
 2764:     $r->print($menu_html);
 2765:     return;
 2766: }
 2767: ### Set portfolio metadata
 2768: sub output_row {
 2769:     my ($r, $field_name, $field_text) = @_;
 2770:     my $output;
 2771:     my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
 2772:     my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
 2773:     unless (defined($options)) {
 2774:         $options = 'active,stuadd';
 2775:         $values = '';
 2776:     }
 2777:     $output.='<strong>'.$field_text.':</strong>';
 2778:     $output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />';
 2779: 
 2780:     my @options= ( ['active', 'Show to student'],
 2781: 		   ['onlyone','Student may select only one choice'],
 2782: 		   ['stuadd', 'Student may type choices']);
 2783:     foreach my $opt (@options) {
 2784: 	my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
 2785: 	$output.=('&nbsp;'x5).'<label><input type="checkbox" name="'.
 2786: 	    $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
 2787: 	    &mt($opt->[1]).'</label> <br />';
 2788:     }
 2789:     return ($output);
 2790: }
 2791: 
 2792: sub setrestrictmeta {
 2793:     my ($r)=@_;
 2794:     my $next_meta;
 2795:     my $output;
 2796:     my $item_num;
 2797:     my $put_result;
 2798:     $r->print(&Apache::lonxml::xmlbegin());
 2799:     $r->print('<head>
 2800:             <title>LON-CAPA Restrict Metadata</title>
 2801:             </head>');
 2802:     $r->print(&Apache::loncommon::bodytag('Restrict Metadata'));
 2803:     $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
 2804: 						    'Restrict Metadata'));
 2805:     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 2806:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 2807:     my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
 2808:     my $save_field = '';
 2809:     if ($env{'form.restrictmeta'}) {
 2810:         foreach my $field (sort(keys(%env))) {
 2811:             if ($field=~m/^form.(.+)_(.+)$/) {
 2812:                 my $options;
 2813:                 my $meta_field = $1;
 2814:                 my $meta_key = $2;
 2815:                 if ($save_field ne $meta_field) {
 2816:                     $save_field = $meta_field;
 2817:             	    if ($env{'form.'.$meta_field.'_stuadd'}) {
 2818:             	        $options.='stuadd,';
 2819:             	    } 
 2820:             	    if ($env{'form.'.$meta_field.'_onlyone'}) {
 2821:             	        $options.='onlyone,';
 2822:             	    } 
 2823:             	    if ($env{'form.'.$meta_field.'_active'}) {
 2824:             	        $options.='active,';
 2825:             	    }
 2826:                     my $name = $save_field;
 2827:                      $put_result = &Apache::lonnet::put('environment',
 2828:                                                   {'metadata.'.$meta_field.'.options'=>$options,
 2829:                                                    'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
 2830:                                                    },$dom,$crs);
 2831:                 }
 2832:             }
 2833:         }
 2834:     }
 2835:     &Apache::lonnet::coursedescription($env{'request.course.id'});
 2836:     my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
 2837:     foreach my $field (sort(keys(%metadata_fields))) {
 2838:         &Apache::lonnet::logthis ($field);
 2839:         if ($field ne 'courserestricted') {
 2840: 	    $output.= &output_row($r, $field, $metadata_fields{$field});
 2841: 	}
 2842:     }
 2843:     $r->print(<<ENDenv);       
 2844:         <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
 2845:         <p>
 2846:         $output
 2847:         <input type="submit" name="restrictmeta" value="Update Metadata Restrictions">
 2848:         </form>
 2849: ENDenv
 2850:     $r->print('</body>
 2851:                 </html>');
 2852:     return 'ok';
 2853: }
 2854: ##################################################
 2855: 
 2856: sub defaultsetter {
 2857:     my $r=shift;
 2858:     my $bodytag=&Apache::loncommon::bodytag('Parameter Setting Default Actions');
 2859:     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 2860:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 2861:     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults');
 2862:     my $html=&Apache::lonxml::xmlbegin();
 2863:     $r->print(<<ENDDEFHEAD);
 2864: $html
 2865: <head>
 2866: <title>LON-CAPA Parameters</title>
 2867: </head>
 2868: $bodytag
 2869: $breadcrumbs
 2870: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
 2871: ENDDEFHEAD
 2872:     my @ids=();
 2873:     my %typep=();
 2874:     my %keyp=();
 2875:     my %allparms=();
 2876:     my %allparts=();
 2877:     my %allmaps=();
 2878:     my %mapp=();
 2879:     my %symbp=();
 2880:     my %maptitles=();
 2881:     my %uris=();
 2882:     my %keyorder=&standardkeyorder();
 2883:     my %defkeytype=();
 2884: 
 2885:     &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, 
 2886: 				\%mapp, \%symbp,\%maptitles,\%uris,
 2887: 				\%keyorder,\%defkeytype);
 2888:     if ($env{'form.storerules'}) {
 2889: 	my %newrules=();
 2890: 	my @delrules=();
 2891: 	my %triggers=();
 2892: 	foreach my $key (keys(%env)) {
 2893:             if ($key=~/^form\.(\w+)\_action$/) {
 2894: 		my $tempkey=$1;
 2895: 		my $action=$env{$key};
 2896:                 if ($action) {
 2897: 		    $newrules{$tempkey.'_action'}=$action;
 2898: 		    if ($action ne 'default') {
 2899: 			my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
 2900: 			$triggers{$whichparm}.=$tempkey.':';
 2901: 		    }
 2902: 		    $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
 2903: 		    if (&isdateparm($defkeytype{$tempkey})) {
 2904: 			$newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
 2905: 			$newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
 2906: 			$newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
 2907: 			$newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
 2908: 		    } else {
 2909: 			$newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
 2910: 			$newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
 2911: 		    }
 2912: 		} else {
 2913: 		    push(@delrules,$tempkey.'_action');
 2914: 		    push(@delrules,$tempkey.'_type');
 2915: 		    push(@delrules,$tempkey.'_hours');
 2916: 		    push(@delrules,$tempkey.'_min');
 2917: 		    push(@delrules,$tempkey.'_sec');
 2918: 		    push(@delrules,$tempkey.'_value');
 2919: 		}
 2920: 	    }
 2921: 	}
 2922: 	foreach my $key (keys %allparms) {
 2923: 	    $newrules{$key.'_triggers'}=$triggers{$key};
 2924: 	}
 2925: 	&Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
 2926: 	&Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
 2927: 	&resetrulescache();
 2928:     }
 2929:     my %lt=&Apache::lonlocal::texthash('days' => 'Days',
 2930: 				       'hours' => 'Hours',
 2931: 				       'min' => 'Minutes',
 2932: 				       'sec' => 'Seconds',
 2933: 				       'yes' => 'Yes',
 2934: 				       'no' => 'No');
 2935:     my @standardoptions=('','default');
 2936:     my @standarddisplay=('',&mt('Default value when manually setting'));
 2937:     my @dateoptions=('','default');
 2938:     my @datedisplay=('',&mt('Default value when manually setting'));
 2939:     foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
 2940: 	unless ($tempkey) { next; }
 2941: 	push @standardoptions,'when_setting_'.$tempkey;
 2942: 	push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
 2943: 	if (&isdateparm($defkeytype{$tempkey})) {
 2944: 	    push @dateoptions,'later_than_'.$tempkey;
 2945: 	    push @datedisplay,&mt('Automatically set later than ').$tempkey;
 2946: 	    push @dateoptions,'earlier_than_'.$tempkey;
 2947: 	    push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
 2948: 	} 
 2949:     }
 2950: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
 2951: 	  &mt('Automatic setting rules apply to table mode interfaces only.'));
 2952:     $r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'.
 2953: 	      &mt('Action').'</th><th>'.&mt('Value').'</th></tr>');
 2954:     foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
 2955: 	unless ($tempkey) { next; }
 2956: 	$r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
 2957: 	my $action=&rulescache($tempkey.'_action');
 2958: 	$r->print('<select name="'.$tempkey.'_action">');
 2959: 	if (&isdateparm($defkeytype{$tempkey})) {
 2960: 	    for (my $i=0;$i<=$#dateoptions;$i++) {
 2961: 		if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
 2962: 		$r->print("\n<option value='$dateoptions[$i]'".
 2963: 			  ($dateoptions[$i] eq $action?' selected="selected"':'').
 2964: 			  ">$datedisplay[$i]</option>");
 2965: 	    }
 2966: 	} else {
 2967: 	    for (my $i=0;$i<=$#standardoptions;$i++) {
 2968: 		if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
 2969: 		$r->print("\n<option value='$standardoptions[$i]'".
 2970: 			  ($standardoptions[$i] eq $action?' selected="selected"':'').
 2971: 			  ">$standarddisplay[$i]</option>");
 2972: 	    }
 2973: 	}
 2974: 	$r->print('</select>');
 2975: 	unless (&isdateparm($defkeytype{$tempkey})) {
 2976: 	    $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
 2977: 		      '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
 2978: 	}
 2979: 	$r->print("\n</td><td>\n");
 2980: 
 2981:         if (&isdateparm($defkeytype{$tempkey})) {
 2982: 	    my $days=&rulescache($tempkey.'_days');
 2983: 	    my $hours=&rulescache($tempkey.'_hours');
 2984: 	    my $min=&rulescache($tempkey.'_min');
 2985: 	    my $sec=&rulescache($tempkey.'_sec');
 2986: 	    $r->print(<<ENDINPUTDATE);
 2987: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
 2988: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
 2989: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
 2990: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
 2991: ENDINPUTDATE
 2992: 	} elsif ($defkeytype{$tempkey} eq 'string_yesno') {
 2993:             my $yeschecked='';
 2994:             my $nochecked='';
 2995:             if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
 2996:             if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
 2997: 
 2998: 	    $r->print(<<ENDYESNO);
 2999: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
 3000: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
 3001: ENDYESNO
 3002:         } else {
 3003: 	    $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
 3004: 	}
 3005:         $r->print('</td></tr>');
 3006:     }
 3007:     $r->print("</table>\n<input type='submit' name='storerules' value='".
 3008: 	      &mt('Store Rules')."' /></form>\n</body>\n</html>");
 3009:     return;
 3010: }
 3011: 
 3012: ##################################################
 3013: ##################################################
 3014: 
 3015: =pod
 3016: 
 3017: =item * handler
 3018: 
 3019: Main handler.  Calls &assessparms and &crsenv subroutines.
 3020: 
 3021: =cut
 3022: ##################################################
 3023: ##################################################
 3024: #    use Data::Dumper;
 3025: 
 3026: 
 3027: sub handler {
 3028:     my $r=shift;
 3029: 
 3030:     if ($r->header_only) {
 3031: 	&Apache::loncommon::content_type($r,'text/html');
 3032: 	$r->send_http_header;
 3033: 	return OK;
 3034:     }
 3035:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 3036: 					    ['action','state',
 3037:                                              'pres_marker',
 3038:                                              'pres_value',
 3039:                                              'pres_type',
 3040:                                              'udom','uname','symb','serial']);
 3041: 
 3042: 
 3043:     &Apache::lonhtmlcommon::clear_breadcrumbs();
 3044:     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
 3045: 					    text=>"Parameter Manager",
 3046: 					    faq=>10,
 3047: 					    bug=>'Instructor Interface'});
 3048: 
 3049: # ----------------------------------------------------- Needs to be in a course
 3050:     my $parm_permission =
 3051: 	(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
 3052: 	 &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
 3053: 				  $env{'request.course.sec'}));
 3054:     if ($env{'request.course.id'} &&  $parm_permission) {
 3055: 
 3056:         # Start Page
 3057:         &Apache::loncommon::content_type($r,'text/html');
 3058:         $r->send_http_header;
 3059: 
 3060: 
 3061:         # id numbers can change on re-ordering of folders
 3062: 
 3063:         &resetsymbcache();
 3064: 
 3065:         #
 3066:         # Main switch on form.action and form.state, as appropriate
 3067:         #
 3068:         # Check first if coming from someone else headed directly for
 3069:         #  the table mode
 3070:         if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
 3071: 	     && (!$env{'form.dis'})) || ($env{'form.symb'})) {
 3072: 	    &assessparms($r);
 3073: 
 3074:         } elsif (! exists($env{'form.action'})) {
 3075:             $r->print(&header());
 3076:             $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
 3077: 							 'Parameter Manager'));
 3078:             &print_main_menu($r,$parm_permission);
 3079:         } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
 3080:             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
 3081: 						    text=>"Course Environment"});
 3082:             &crsenv($r); 
 3083:         } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
 3084:             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
 3085: 						    text=>"Overview Mode"});
 3086: 	    &overview($r);
 3087:         } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
 3088:             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
 3089: 						    text=>"Restrict Metadata"});
 3090: 	    &setrestrictmeta($r);
 3091:         } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
 3092:             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
 3093: 						    text=>"Overview Mode"});
 3094: 	    &newoverview($r);
 3095:         }  elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
 3096:             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
 3097: 						    text=>"Set Defaults"});
 3098: 	    &defaultsetter($r);
 3099: 	} elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
 3100:             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
 3101: 						    text=>"Table Mode",
 3102: 						    help => 'Course_Setting_Parameters'});
 3103: 	    &assessparms($r);
 3104:         }
 3105:         
 3106:     } else {
 3107: # ----------------------------- Not in a course, or not allowed to modify parms
 3108: 	$env{'user.error.msg'}=
 3109: 	    "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
 3110: 	return HTTP_NOT_ACCEPTABLE;
 3111:     }
 3112:     return OK;
 3113: }
 3114: 
 3115: 1;
 3116: __END__
 3117: 
 3118: =pod
 3119: 
 3120: =back
 3121: 
 3122: =cut
 3123: 
 3124: 
 3125: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>