File:  [LON-CAPA] / loncom / interface / lonparmset.pm
Revision 1.181: download - view: text, annotated - select for diffs
Wed Feb 2 19:23:59 2005 UTC (19 years, 3 months ago) by albertel
Branches: MAIN
CVS tags: version_1_3_X, version_1_3_3, version_1_3_2, HEAD
- BUG#3886 - currentURL should have the version in it
           - build a symb using encode_symb, otherwise you are likely to get it wrong

    1: # The LearningOnline Network with CAPA
    2: # Handler to set parameters for assessments
    3: #
    4: # $Id: lonparmset.pm,v 1.181 2005/02/02 19:23:59 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: 
   66: my %courseopt;
   67: my %useropt;
   68: my %parmhash;
   69: 
   70: my @ids;
   71: my %symbp;
   72: my %mapp;
   73: my %typep;
   74: my %keyp;
   75: 
   76: my %maptitles;
   77: 
   78: my $uname;
   79: my $udom;
   80: my $uhome;
   81: my $csec;
   82: my $coursename;
   83: 
   84: ##################################################
   85: ##################################################
   86: 
   87: =pod
   88: 
   89: =item parmval
   90: 
   91: Figure out a cascading parameter.
   92: 
   93: Inputs:  $what - a parameter spec (incluse part info and name I.E. 0.weight)
   94:          $id   - a bighash Id number
   95:          $def  - the resource's default value   'stupid emacs
   96: 
   97: 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
   98: 
   99: 11- resource default
  100: 10- map default
  101: 9 - General Course
  102: 8 - Map or Folder level in course
  103: 7 - resource level in course
  104: 6 - General for section
  105: 5 - Map or Folder level for section
  106: 4 - resource level in section
  107: 3 - General for specific student
  108: 2 - Map or Folder level for specific student
  109: 1 - resource level for specific student
  110: 
  111: =cut
  112: 
  113: ##################################################
  114: ##################################################
  115: sub parmval {
  116:     my ($what,$id,$def)=@_;
  117:     my $result='';
  118:     my @outpar=();
  119: # ----------------------------------------------------- Cascading lookup scheme
  120: 
  121:     my $symbparm=$symbp{$id}.'.'.$what;
  122:     my $mapparm=$mapp{$id}.'___(all).'.$what;
  123: 
  124:     my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what;
  125:     my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
  126:     my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
  127: 
  128:     my $courselevel=$ENV{'request.course.id'}.'.'.$what;
  129:     my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
  130:     my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
  131: 
  132: # -------------------------------------------------------- first, check default
  133: 
  134:     if (defined($def)) { $outpar[11]=$def; $result=11; }
  135: 
  136: # ----------------------------------------------------- second, check map parms
  137: 
  138:     my $thisparm=$parmhash{$symbparm};
  139:     if (defined($thisparm)) { $outpar[10]=$thisparm; $result=10; }
  140: 
  141: # --------------------------------------------------------- third, check course
  142: 
  143:     if (defined($courseopt{$courselevel})) {
  144: 	$outpar[9]=$courseopt{$courselevel};
  145: 	$result=9;
  146:     }
  147: 
  148:     if (defined($courseopt{$courselevelm})) {
  149: 	$outpar[8]=$courseopt{$courselevelm};
  150: 	$result=8;
  151:     }
  152: 
  153:     if (defined($courseopt{$courselevelr})) {
  154: 	$outpar[7]=$courseopt{$courselevelr};
  155: 	$result=7;
  156:     }
  157: 
  158:     if (defined($csec)) {
  159:         if (defined($courseopt{$seclevel})) {
  160: 	    $outpar[6]=$courseopt{$seclevel};
  161: 	    $result=6;
  162: 	}
  163:         if (defined($courseopt{$seclevelm})) {
  164: 	    $outpar[5]=$courseopt{$seclevelm};
  165: 	    $result=5;
  166: 	}
  167: 
  168:         if (defined($courseopt{$seclevelr})) {
  169: 	    $outpar[4]=$courseopt{$seclevelr};
  170: 	    $result=4;
  171: 	}
  172:     }
  173: 
  174: # ---------------------------------------------------------- fourth, check user
  175: 
  176:     if (defined($uname)) {
  177: 	if (defined($useropt{$courselevel})) {
  178: 	    $outpar[3]=$useropt{$courselevel};
  179: 	    $result=3;
  180: 	}
  181: 
  182: 	if (defined($useropt{$courselevelm})) {
  183: 	    $outpar[2]=$useropt{$courselevelm};
  184: 	    $result=2;
  185: 	}
  186: 
  187: 	if (defined($useropt{$courselevelr})) {
  188: 	    $outpar[1]=$useropt{$courselevelr};
  189: 	    $result=1;
  190: 	}
  191:     }
  192:     return ($result,@outpar);
  193: }
  194: 
  195: ##################################################
  196: ##################################################
  197: 
  198: =pod
  199: 
  200: =item valout
  201: 
  202: Format a value for output.
  203: 
  204: Inputs:  $value, $type
  205: 
  206: Returns: $value, formatted for output.  If $type indicates it is a date,
  207: localtime($value) is returned.
  208: 
  209: =cut
  210: 
  211: ##################################################
  212: ##################################################
  213: sub valout {
  214:     my ($value,$type)=@_;
  215:     my $result = '';
  216:     # Values of zero are valid.
  217:     if (! $value && $value ne '0') {
  218: 	$result = '  ';
  219:     } else {
  220:         if ($type eq 'date_interval') {
  221:             my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
  222:             $year=$year-70;
  223:             $mday--;
  224:             if ($year) {
  225: 		$result.=$year.' yrs ';
  226:             }
  227:             if ($mon) {
  228: 		$result.=$mon.' mths ';
  229:             }
  230:             if ($mday) {
  231: 		$result.=$mday.' days ';
  232:             }
  233:             if ($hour) {
  234: 		$result.=$hour.' hrs ';
  235:             }
  236:             if ($min) {
  237: 		$result.=$min.' mins ';
  238:             }
  239:             if ($sec) {
  240: 		$result.=$sec.' secs ';
  241:             }
  242:             $result=~s/\s+$//;
  243:         } elsif ($type=~/^date/) {
  244:             $result = localtime($value);
  245:         } else {
  246:             $result = $value;
  247:         }
  248:     }
  249:     return $result;
  250: }
  251: 
  252: ##################################################
  253: ##################################################
  254: 
  255: =pod
  256: 
  257: =item plink
  258: 
  259: Produces a link anchor.
  260: 
  261: Inputs: $type,$dis,$value,$marker,$return,$call
  262: 
  263: Returns: scalar with html code for a link which will envoke the 
  264: javascript function 'pjump'.
  265: 
  266: =cut
  267: 
  268: ##################################################
  269: ##################################################
  270: sub plink {
  271:     my ($type,$dis,$value,$marker,$return,$call)=@_;
  272:     my $winvalue=$value;
  273:     unless ($winvalue) {
  274: 	if ($type=~/^date/) {
  275:             $winvalue=$ENV{'form.recent_'.$type};
  276:         } else {
  277:             $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]};
  278:         }
  279:     }
  280:     return 
  281: 	'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
  282: 	    .$marker."','".$return."','".$call."'".');">'.
  283: 		&valout($value,$type).'</a><a name="'.$marker.'"></a>';
  284: }
  285: 
  286: 
  287: sub startpage {
  288:     my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_;
  289: 
  290:     my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
  291:                                             'onUnload="pclose()"');
  292:     my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
  293:         &Apache::loncommon::selectstudent_link('parmform','uname','udom');
  294:     my $selscript=&Apache::loncommon::studentbrowser_javascript();
  295:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
  296:     my %lt=&Apache::lonlocal::texthash(
  297: 		    'cep'   => "Course Environment Parameters",
  298: 		    'scep'  => "Set Course Environment Parameters",
  299: 		    'smcap' => "Set/Modify Course Assessment Parameter",
  300: 		    'mcap'  => "Modify Course Assessment Parameters",
  301: 		    'caphm' => "Course Assessment Parameter - Helper Mode",
  302: 		    'capom' => "Course Assessment Parameters - Overview Mode",
  303:                     'captm' => "Course Assessments Parameters - Table Mode",
  304: 		    'sg'    => "Section/Group",
  305: 		    'fu'    => "For User",
  306: 		    'oi'    => "or ID",
  307: 		    'ad'    => "at Domain"
  308: 				       );
  309:     my $overallhelp=
  310: 	&Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface');
  311:     my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters");
  312:     $r->print(<<ENDHEAD);
  313: <html>
  314: <head>
  315: <title>LON-CAPA Course Parameters</title>
  316: <script>
  317: 
  318:     function pclose() {
  319:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
  320:                  "height=350,width=350,scrollbars=no,menubar=no");
  321:         parmwin.close();
  322:     }
  323: 
  324:     $pjump_def
  325: 
  326:     function psub() {
  327:         pclose();
  328:         if (document.parmform.pres_marker.value!='') {
  329:             document.parmform.action+='#'+document.parmform.pres_marker.value;
  330:             var typedef=new Array();
  331:             typedef=document.parmform.pres_type.value.split('_');
  332:            if (document.parmform.pres_type.value!='') {
  333:             if (typedef[0]=='date') {
  334:                 eval('document.parmform.recent_'+
  335:                      document.parmform.pres_type.value+
  336: 		     '.value=document.parmform.pres_value.value;');
  337:             } else {
  338:                 eval('document.parmform.recent_'+typedef[0]+
  339: 		     '.value=document.parmform.pres_value.value;');
  340:             }
  341: 	   }
  342:             document.parmform.submit();
  343:         } else {
  344:             document.parmform.pres_value.value='';
  345:             document.parmform.pres_marker.value='';
  346:         }
  347:     }
  348: 
  349:     function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
  350:         var options = "width=" + w + ",height=" + h + ",";
  351:         options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
  352:         options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
  353:         var newWin = window.open(url, wdwName, options);
  354:         newWin.focus();
  355:     }
  356: </script>
  357: $selscript
  358: </head>
  359: $bodytag
  360: $overallhelp
  361: ENDHEAD
  362: 
  363:     unless ($trimheader) {$r->print(<<ENDHEAD2);
  364: <form method="post" action="/adm/parmset" name="envform">
  365: <h4>$lt{'cep'}</h4>
  366: <input type="submit" name="crsenv" value="$lt{'scep'}" />
  367: </form>
  368: <hr />
  369: $assessparmhelp
  370: <form method="post" action="/adm/helper/parameter.helper" name="helpform">
  371: <h4>$lt{'caphm'}</h4>
  372: <input type="submit" value="$lt{'smcap'}" />
  373: </form>
  374: <hr />
  375: <form method="post" action="/adm/parmset" name="overview">
  376: <h4>$lt{'capom'}</h4>
  377: <input type="submit" name="overview" value="$lt{'mcap'}" />
  378: </form>
  379: <hr />
  380: ENDHEAD2
  381: }
  382:     $r->print(<<ENDHEAD3);
  383: <form method="post" action="/adm/parmset" name="parmform">
  384: <h4>$lt{'captm'}</h4>
  385: ENDHEAD3
  386: 
  387:     if (!$have_assesments) {
  388: 	$r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />');	
  389:     } else {
  390: 	$r->print(<<ENDHEAD);
  391: <b>
  392: $lt{'sg'}:
  393: <input type="text" value="$csec" size="6" name="csec">
  394: <br>
  395: $lt{'fu'} 
  396: <input type="text" value="$uname" size="12" name="uname">
  397: $lt{'oi'}
  398: <input type="text" value="$id" size="12" name="id"> 
  399: $lt{'ad'}
  400: $chooseopt
  401: </b>
  402: <input type="hidden" value='' name="pres_value">
  403: <input type="hidden" value='' name="pres_type">
  404: <input type="hidden" value='' name="pres_marker">
  405: ENDHEAD
  406:     }
  407: }
  408: 
  409: sub print_row {
  410:     my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
  411: 	$defbgtwo,$parmlev)=@_;
  412: # get the values for the parameter in cascading order
  413: # empty levels will remain empty
  414:     my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
  415: 				  $rid,$$default{$which});
  416: # get the type for the parameters
  417: # problem: these may not be set for all levels
  418:     my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
  419:                                           $$name{$which}.'.type',
  420: 				  $rid,$$defaulttype{$which});
  421: # cascade down manually
  422:     my $cascadetype=$defaulttype;
  423:     for (my $i=$#typeoutpar;$i>0;$i--) {
  424: 	 if ($typeoutpar[$i]) { 
  425:             $cascadetype=$typeoutpar[$i];
  426: 	} else {
  427:             $typeoutpar[$i]=$cascadetype;
  428:         }
  429:     }
  430:  
  431:     my $parm=$$display{$which};
  432: 
  433:     if ($parmlev eq 'full' || $parmlev eq 'brief') {
  434:         $r->print('<td bgcolor='.$defbgtwo.' align="center">'
  435:                   .$$part{$which}.'</td>');
  436:     } else {    
  437:         $parm=~s|\[.*\]\s||g;
  438:     }
  439: 
  440:     $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
  441:    
  442:     my $thismarker=$which;
  443:     $thismarker=~s/^parameter\_//;
  444:     my $mprefix=$rid.'&'.$thismarker.'&';
  445: 
  446:     if ($parmlev eq 'general') {
  447: 
  448:         if ($uname) {
  449:             &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  450:         } elsif ($csec) {
  451:             &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); 
  452:         } else {
  453:             &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); 
  454:         }
  455:     } elsif ($parmlev eq 'map') {
  456: 
  457:         if ($uname) {
  458:             &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  459:         } elsif ($csec) {
  460:             &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  461:         } else {
  462:             &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  463:         }
  464:     } else {
  465: 
  466:         &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  467: 
  468:         if ($parmlev eq 'brief') {
  469: 
  470:            &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  471: 
  472:            if ($csec) {
  473:                &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  474:            }
  475:            if ($uname) {
  476:                &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  477:            }
  478:         } else {
  479: 
  480:            &print_td($r,10,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  481:            &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  482:            &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  483:            &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  484: 
  485:            if ($csec) {
  486:                &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  487:                &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  488:                &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  489:            }
  490:            if ($uname) {
  491:                &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  492:                &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  493:                &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
  494:            }
  495:         } # end of $brief if/else
  496:     } # end of $parmlev if/else
  497: 
  498:     $r->print('<td bgcolor=#CCCCFF align="center">'.
  499:                   &valout($outpar[$result],$typeoutpar[$result]).'</td>');
  500: 
  501:     if ($parmlev eq 'full' || $parmlev eq 'brief') {
  502:         my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
  503:                                         '.'.$$name{$which},$symbp{$rid});
  504: 
  505: # this doesn't seem to work, and I don't think is correct
  506: #    my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
  507: #                                      '.'.$$name{$which}.'.type',$symbp{$rid});
  508: # this seems to work
  509:         my $sessionvaltype=$typeoutpar[$result];
  510:         if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
  511:         $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
  512:                   &valout($sessionval,$sessionvaltype).'&nbsp;'.
  513:                   '</font></td>');
  514:     }
  515:     $r->print('</tr>');
  516:     $r->print("\n");
  517: }
  518: 
  519: sub print_td {
  520:     my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
  521:     $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
  522:               ' align="center">');
  523:     if ($which<10) {
  524: 	$r->print(&plink($$typeoutpar[$which],
  525: 			 $$display{$value},$$outpar[$which],
  526: 			 $mprefix."$which",'parmform.pres','psub'));
  527:     } else {
  528: 	$r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
  529:     }
  530:     $r->print('</td>'."\n");
  531: }
  532: 
  533: =pod
  534: 
  535: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
  536: 
  537: Input: See list below:
  538: 
  539: =over 4
  540: 
  541: =item B<ids>: An array that will contain all of the ids in the course.
  542: 
  543: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
  544: 
  545: =item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
  546: 
  547: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
  548: 
  549: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
  550: 
  551: =item B<allkeys>: hash, full key to part->display value (what's display value?)
  552: 
  553: =item B<allmaps>: hash, ???
  554: 
  555: =item B<fcat>: ???
  556: 
  557: =item B<defp>: hash, ???
  558: 
  559: =item B<mapp>: ??
  560: 
  561: =item B<symbp>: hash, id->full sym?
  562: 
  563: =back
  564: 
  565: =cut
  566: 
  567: sub extractResourceInformation {
  568:     my $bighash = shift;
  569:     my $ids = shift;
  570:     my $typep = shift;
  571:     my $keyp = shift;
  572:     my $allparms = shift;
  573:     my $allparts = shift;
  574:     my $allkeys = shift;
  575:     my $allmaps = shift;
  576:     my $fcat = shift;
  577:     my $defp = shift;
  578:     my $mapp = shift;
  579:     my $symbp = shift;
  580:     my $maptitles=shift;
  581: 
  582:     foreach (keys %$bighash) {
  583: 	if ($_=~/^src\_(\d+)\.(\d+)$/) {
  584: 	    # there are no resources in the 0 level
  585: 	    if ($1 eq '0') { next; }
  586: 	    my $mapid=$1;
  587: 	    my $resid=$2;
  588: 	    my $id=$mapid.'.'.$resid;
  589: 	    my $srcf=$$bighash{$_};
  590: 	    if (1) {
  591: 		$srcf=~/\.(\w+)$/;
  592: 		$$ids[$#$ids+1]=$id;
  593: 		$$typep{$id}=$1;
  594: 		$$keyp{$id}='';
  595: 		foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
  596: 		  if ($_=~/^parameter\_(.*)/) {
  597:                     my $key=$_;
  598:                     my $allkey=$1;
  599:                     $allkey=~s/\_/\./g;
  600: 		    if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 
  601: 			'parm') {
  602: 			next; #hide hidden things
  603: 		    }
  604:                     my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
  605:                     my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
  606:                     my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
  607:                     my $parmdis = $display;
  608:                     $parmdis =~ s|(\[Part.*$)||g;
  609:                     my $partkey = $part;
  610:                     $partkey =~ tr|_|.|;
  611:                     $$allparms{$name} = $parmdis;
  612:                     $$allparts{$part} = "[Part $part]";
  613:                     $$allkeys{$allkey}=$display;
  614:                     if ($allkey eq $fcat) {
  615: 		        $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
  616: 		    }
  617: 		    if ($$keyp{$id}) {
  618: 		        $$keyp{$id}.=','.$key;
  619: 		    } else {
  620: 		        $$keyp{$id}=$key;
  621: 		    }
  622: 		  }
  623: 		}
  624: 		$$mapp{$id}=
  625: 		    &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid});
  626:                 $$mapp{$mapid}=$$mapp{$id};
  627: 		$$allmaps{$mapid}=$$mapp{$id};
  628: 		if ($mapid eq '1') {
  629: 		    $$maptitles{$mapid}='Main Course Documents';
  630: 		} else {
  631: 		    $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
  632: 		}
  633: 		$$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
  634: 		$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
  635:                 $$symbp{$mapid}=$$mapp{$id}.'___(all)';
  636: 	    }
  637: 	}
  638:     }
  639: }
  640: 
  641: ##################################################
  642: ##################################################
  643: 
  644: =pod
  645: 
  646: =item assessparms
  647: 
  648: Show assessment data and parameters.  This is a large routine that should
  649: be simplified and shortened... someday.
  650: 
  651: Inputs: $r
  652: 
  653: Returns: nothing
  654: 
  655: Variables used (guessed by Jeremy):
  656: 
  657: =over 4
  658: 
  659: =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.
  660: 
  661: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
  662: 
  663: =item B<allmaps>:
  664: 
  665: =back
  666: 
  667: =cut
  668: 
  669: ##################################################
  670: ##################################################
  671: sub assessparms {
  672: 
  673:     my $r=shift;
  674: # -------------------------------------------------------- Variable declaration
  675:     my %allkeys=();
  676:     my %allmaps=();
  677:     my %alllevs=();
  678: 
  679:     $alllevs{'Resource Level'}='full';
  680: #    $alllevs{'Resource Level [BRIEF]'}='brief';
  681:     $alllevs{'Map Level'}='map';
  682:     $alllevs{'Course Level'}='general';
  683: 
  684:     my %allparms;
  685:     my %allparts;
  686: 
  687:     my %defp;
  688:     %courseopt=();
  689:     %useropt=();
  690:     my %bighash=();
  691: 
  692:     @ids=();
  693:     %symbp=();
  694:     %typep=();
  695: 
  696:     my $message='';
  697: 
  698:     $csec=$ENV{'form.csec'};
  699:     if      ($udom=$ENV{'form.udom'}) {
  700:     } elsif ($udom=$ENV{'request.role.domain'}) {
  701:     } elsif ($udom=$ENV{'user.domain'}) {
  702:     } else {
  703: 	$udom=$r->dir_config('lonDefDomain');
  704:     }
  705: 
  706:     my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
  707:     my $pschp=$ENV{'form.pschp'};
  708:     my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
  709:     if (!@psprt) { $psprt[0]='0'; }
  710:     my $showoptions=$ENV{'form.showoptions'};
  711: 
  712:     my $pssymb='';
  713:     my $parmlev='';
  714:     my $trimheader='';
  715:     my $prevvisit=$ENV{'form.prevvisit'};
  716: 
  717: #    unless ($parmlev==$ENV{'form.parmlev'}) {
  718: #        $parmlev = 'full';
  719: #    }
  720:  
  721:     unless ($ENV{'form.parmlev'}) {
  722:         $parmlev = 'map';
  723:     } else {
  724:         $parmlev = $ENV{'form.parmlev'};
  725:     }
  726: 
  727: # ----------------------------------------------- Was this started from grades?
  728: 
  729:     if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
  730: 	&& (!$ENV{'form.dis'})) {
  731: 	my $url=$ENV{'form.url'};
  732: 	$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
  733: 	$pssymb=&Apache::lonnet::symbread($url);
  734: 	if (!@pscat) { @pscat=('all'); }
  735: 	$pschp='';
  736:         $parmlev = 'full';
  737:         $trimheader='yes';
  738:     } elsif ($ENV{'form.symb'}) {
  739: 	$pssymb=$ENV{'form.symb'};
  740: 	if (!@pscat) { @pscat=('all'); }
  741: 	$pschp='';
  742:         $parmlev = 'full';
  743:         $trimheader='yes';
  744:     } else {
  745: 	$ENV{'form.url'}='';
  746:     }
  747: 
  748:     my $id=$ENV{'form.id'};
  749:     if (($id) && ($udom)) {
  750: 	$uname=(&Apache::lonnet::idget($udom,$id))[1];
  751: 	if ($uname) {
  752: 	    $id='';
  753: 	} else {
  754: 	    $message=
  755: 		"<font color=red>".&mt("Unknown ID")." '$id' ".
  756: 		&mt('at domain')." '$udom'</font>";
  757: 	}
  758:     } else {
  759: 	$uname=$ENV{'form.uname'};
  760:     }
  761:     unless ($udom) { $uname=''; }
  762:     $uhome='';
  763:     if ($uname) {
  764: 	$uhome=&Apache::lonnet::homeserver($uname,$udom);
  765:         if ($uhome eq 'no_host') {
  766: 	    $message=
  767: 		"<font color=red>".&mt("Unknown user")." '$uname' ".
  768: 		&mt("at domain")." '$udom'</font>";
  769: 	    $uname='';
  770:         } else {
  771: 	    $csec=&Apache::lonnet::getsection($udom,$uname,
  772: 					      $ENV{'request.course.id'});
  773: 	    if ($csec eq '-1') {
  774: 		$message="<font color=red>".
  775: 		    &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
  776: 		    &mt("not in this course")."</font>";
  777: 		$uname='';
  778: 		$csec=$ENV{'form.csec'};
  779: 	    } else {
  780: 		my %name=&Apache::lonnet::userenvironment($udom,$uname,
  781: 		      ('firstname','middlename','lastname','generation','id'));
  782: 		$message="\n<p>\n".&mt("Full Name").": ".
  783: 		    $name{'firstname'}.' '.$name{'middlename'}.' '
  784: 			.$name{'lastname'}.' '.$name{'generation'}.
  785: 			    "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
  786: 	    }
  787:         }
  788:     }
  789: 
  790:     unless ($csec) { $csec=''; }
  791: 
  792:     my $fcat=$ENV{'form.fcat'};
  793:     unless ($fcat) { $fcat=''; }
  794: 
  795: # ------------------------------------------------------------------- Tie hashs
  796:     if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
  797: 	      &GDBM_READER(),0640))) {
  798: 	$r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
  799: 	return ;
  800:     }
  801:     if (!(tie(%parmhash,'GDBM_File',
  802: 	      $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
  803: 	$r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
  804: 	return ;
  805:     }
  806: 
  807: # --------------------------------------------------------- Get all assessments
  808:     extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles);
  809: 
  810:     $mapp{'0.0'} = '';
  811:     $symbp{'0.0'} = '';
  812: 
  813: # ---------------------------------------------------------- Anything to store?
  814:     if ($ENV{'form.pres_marker'}) {
  815: 	my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'});
  816: 	$spnam=~s/\_([^\_]+)$/\.$1/;
  817: # ---------------------------------------------------------- Construct prefixes
  818: 
  819: 	my $symbparm=$symbp{$sresid}.'.'.$spnam;
  820: 	my $mapparm=$mapp{$sresid}.'___(all).'.$spnam;
  821: 	
  822: 	my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam;
  823: 	my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
  824: 	my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
  825: 	
  826: 	my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
  827: 	my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
  828: 	my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
  829: 	
  830: 	my $storeunder='';
  831: 	if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; }
  832: 	if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; }
  833: 	if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
  834: 	if ($snum==6) { $storeunder=$seclevel; }
  835: 	if ($snum==5) { $storeunder=$seclevelm; }
  836: 	if ($snum==4) { $storeunder=$seclevelr; }
  837: 	
  838: 	my $delete;
  839: 	if ($ENV{'form.pres_value'} eq '') { $delete=1;}
  840:         my %storecontent = ($storeunder         => $ENV{'form.pres_value'},
  841:                             $storeunder.'.type' => $ENV{'form.pres_type'});
  842: 	my $reply='';
  843: 	if ($snum>3) {
  844: # ---------------------------------------------------------------- Store Course
  845: #
  846: # Expire sheets
  847: 	    &Apache::lonnet::expirespread('','','studentcalc');
  848: 	    if (($snum==7) || ($snum==4)) {
  849: 		&Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid});
  850: 	    } elsif (($snum==8) || ($snum==5)) {
  851: 		&Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid});
  852: 	    } else {
  853: 		&Apache::lonnet::expirespread('','','assesscalc');
  854: 	    }
  855: # Store parameter
  856: 	    if ($delete) {
  857: 		$reply=&Apache::lonnet::del
  858: 		    ('resourcedata',[keys(%storecontent)],
  859: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  860: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  861: 	    } else {
  862: 		$reply=&Apache::lonnet::cput
  863: 		    ('resourcedata',\%storecontent,
  864: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  865: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  866: 	    }
  867: 	} else {
  868: # ------------------------------------------------------------------ Store User
  869: #
  870: # Expire sheets
  871: 	    &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
  872: 	    if ($snum==1) {
  873: 		&Apache::lonnet::expirespread
  874: 		    ($uname,$udom,'assesscalc',$symbp{$sresid});
  875: 	    } elsif ($snum==2) {
  876: 		&Apache::lonnet::expirespread
  877: 		    ($uname,$udom,'assesscalc',$mapp{$sresid});
  878: 	    } else {
  879: 		&Apache::lonnet::expirespread($uname,$udom,'assesscalc');
  880: 	    }
  881: # Store parameter
  882: 	    if ($delete) {
  883: 		$reply=&Apache::lonnet::del
  884: 		    ('resourcedata',[keys(%storecontent)],$udom,$uname);
  885: 	    } else {
  886: 		$reply=&Apache::lonnet::cput
  887: 		    ('resourcedata',\%storecontent,$udom,$uname);
  888: 	    }
  889: 	}
  890: 
  891: 	if ($reply=~/^error\:(.*)/) {
  892: 	    $message.="<font color=red>Write Error: $1</font>";
  893: 	}
  894: # ---------------------------------------------------------------- Done storing
  895: 	$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
  896:     }
  897: # --------------------------------------------- Devalidate cache for this child
  898:     &Apache::lonnet::devalidatecourseresdata(
  899:                  $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
  900:                  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
  901:     &Apache::lonnet::clear_EXT_cache_status();
  902: # -------------------------------------------------------------- Get coursedata
  903:     %courseopt = &Apache::lonnet::dump
  904:         ('resourcedata',
  905:          $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  906:          $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  907: # --------------------------------------------------- Get userdata (if present)
  908:     if ($uname) {
  909:         %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
  910:     }
  911: 
  912: # ------------------------------------------------------------------- Sort this
  913: 
  914:     @ids=sort  {
  915: 	if ($fcat eq '') {
  916: 	    $a<=>$b;
  917: 	} else {
  918: 	    my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
  919: 	    my $aparm=$outpar[$result];
  920: 	    ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
  921: 	    my $bparm=$outpar[$result];
  922: 	    1*$aparm<=>1*$bparm;
  923: 	}
  924:     } @ids;
  925: #----------------------------------------------- if all selected, fill in array
  926:     if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
  927:     if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
  928: # ------------------------------------------------------------------ Start page
  929: 
  930:     my $have_assesments=1;
  931:     if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
  932: 
  933:     &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
  934: 
  935:     if (!$have_assesments) {
  936: 	untie(%bighash);
  937: 	untie(%parmhash);
  938: 	return '';
  939:     }
  940: #    if ($ENV{'form.url'}) {
  941: #	$r->print('<input type="hidden" value="'.$ENV{'form.url'}.
  942: #		  '" name="url"><input type="hidden" name="command" value="set">');
  943: #    }
  944:     $r->print('<input type="hidden" value="true" name="prevvisit">');
  945: 
  946:     foreach ('tolerance','date_default','date_start','date_end',
  947: 	     'date_interval','int','float','string') {
  948: 	$r->print('<input type="hidden" value="'.
  949: 		  $ENV{'form.recent_'.$_}.'" name="recent_'.$_.'">');
  950:     }
  951: 
  952:     $r->print('<h2>'.$message.'</h2><table>');
  953:                         
  954:     my $submitmessage = &mt('Update Section or Specific User');
  955:     if (!$pssymb) {
  956:         $r->print('<tr><td>'.&mt('Select Parameter Level').
  957:        &Apache::loncommon::help_open_topic('Course_Parameter_Levels').
  958: 		  '</td><td colspan="2">');
  959:         $r->print('<select name="parmlev">');
  960:         foreach (reverse sort keys %alllevs) {
  961:             $r->print('<option value="'.$alllevs{$_}.'"');
  962:             if ($parmlev eq $alllevs{$_}) {
  963:                $r->print(' selected'); 
  964:             }
  965:             $r->print('>'.$_.'</option>');
  966:         }
  967:         $r->print("</select></td>\n");
  968: 
  969:         $r->print('</tr>');
  970: 	if ($parmlev ne 'general') {
  971: 	    $r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>');
  972: 	    $r->print('<td colspan="2"><select name="pschp">');
  973: 	    $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
  974: 	    foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
  975: 		$r->print('<option value="'.$_.'"');
  976: 		if (($pschp eq $_)) { $r->print(' selected'); }
  977: 		$r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?'  ['.$allmaps{$_}.']':'').'</option>');
  978: 	    }
  979: 	    $r->print("</select></td></tr>\n");
  980: 	}
  981:     } else {
  982:         my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
  983:         $r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>");
  984:         $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
  985:         $r->print('</tr>');
  986:         $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
  987:     }
  988: 
  989:     $r->print('<tr><td colspan="3"><hr /><input type="checkbox"');
  990:     if ($showoptions eq 'show') {$r->print(" checked ");}
  991:     $r->print(' name="showoptions" value="show">'.&mt('Show More Options').'<hr /></td></tr>');
  992: #    $r->print("<tr><td>Show: $showoptions</td></tr>");
  993: #    $r->print("<tr><td>pscat: @pscat</td></tr>");
  994: #    $r->print("<tr><td>psprt: @psprt</td></tr>");
  995: #    $r->print("<tr><td>fcat:  $fcat</td></tr>");
  996: 
  997:     if ($showoptions eq 'show') {
  998:         my $tempkey;
  999: 
 1000:         $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');
 1001: 
 1002:         $r->print('<tr><td colspan="2"><table><tr>');
 1003:         my $cnt=0;
 1004:         foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
 1005:                       keys %allparms ) {
 1006:             ++$cnt;
 1007:             $r->print('</tr><tr>') if ($cnt%2);
 1008:             $r->print('<td><input type="checkbox" name="pscat" ');
 1009:             $r->print('value="'.$tempkey.'"');
 1010:             if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
 1011:                 $r->print(' checked');
 1012:             }
 1013: 	    $r->print('>'.$allparms{$tempkey}.'</td>');
 1014: 	}
 1015: 	$r->print('
 1016: </tr><tr><td>
 1017: <script type="text/javascript">
 1018:     function checkall(value, checkName) {
 1019: 	for (i=0; i<document.forms.parmform.elements.length; i++) {
 1020:             ele = document.forms.parmform.elements[i];
 1021:             if (ele.name == checkName) {
 1022:                 document.forms.parmform.elements[i].checked=value;
 1023:             }
 1024:         }
 1025:     }
 1026: </script>
 1027: <input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
 1028: </td><td>
 1029: <input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
 1030: </td>
 1031: ');
 1032:         $r->print('</tr></table>');
 1033: 
 1034: #        $r->print('<tr><td>Select Parts</td><td>');
 1035:         $r->print('<td><select multiple name="psprt" size="5">');
 1036:         $r->print('<option value="all"');
 1037:         $r->print(' selected') unless (@psprt);
 1038:         $r->print('>'.&mt('All Parts').'</option>');
 1039:         my %temphash=();
 1040:         foreach (@psprt) { $temphash{$_}=1; }
 1041:         foreach $tempkey (sort keys %allparts) {
 1042:             unless ($tempkey =~ /\./) {
 1043:                 $r->print('<option value="'.$tempkey.'"');
 1044:                 if ($psprt[0] eq "all" ||  $temphash{$tempkey}) {
 1045:                     $r->print(' selected');
 1046:                 }
 1047:                 $r->print('>'.$allparts{$tempkey}.'</option>');
 1048:             }
 1049:         }
 1050:         $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
 1051: 
 1052:         $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
 1053:         $r->print('<select name="fcat">');
 1054:         $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
 1055:         foreach (sort keys %allkeys) {
 1056:             $r->print('<option value="'.$_.'"');
 1057:             if ($fcat eq $_) { $r->print(' selected'); }
 1058:             $r->print('>'.$allkeys{$_}.'</option>');
 1059:         }
 1060:         $r->print('</select></td>');
 1061: 
 1062:         $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
 1063: 
 1064:     } else { # hide options - include any necessary extras here
 1065: 
 1066:         $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
 1067: 
 1068:         unless (@pscat) {
 1069:           foreach (keys %allparms ) {
 1070:             $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
 1071:           }
 1072:         } else {
 1073:           foreach (@pscat) {
 1074:             $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
 1075:           }
 1076:         }
 1077: 
 1078:         unless (@psprt) {
 1079:           foreach (keys %allparts ) {
 1080:             $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
 1081:           }
 1082:         } else {
 1083:           foreach (@psprt) {
 1084:             $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
 1085:           }
 1086:         }
 1087: 
 1088:     }
 1089:     $r->print('</table><br />');
 1090:     if (($prevvisit) || ($pschp) || ($pssymb)) {
 1091:         $submitmessage = &mt("Update Course Assessment Parameter Display");
 1092:     } else {
 1093:         $submitmessage = &mt("Set/Modify Course Assessment Parameters");
 1094:     }
 1095:     $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
 1096: 
 1097: #    my @temp_psprt;
 1098: #    foreach my $t (@psprt) {
 1099: #	push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
 1100: #    }
 1101: 
 1102: #    @psprt = @temp_psprt;
 1103: 
 1104:     my @temp_pscat;
 1105:     map {
 1106:         my $cat = $_;
 1107:         push(@temp_pscat, map { $_.'.'.$cat } @psprt);
 1108:     } @pscat;
 1109: 
 1110:     @pscat = @temp_pscat;
 1111: 
 1112:     if (($prevvisit) || ($pschp) || ($pssymb)) {
 1113: # ----------------------------------------------------------------- Start Table
 1114:         my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
 1115:         my $csuname=$ENV{'user.name'};
 1116:         my $csudom=$ENV{'user.domain'};
 1117: 
 1118:         if ($parmlev eq 'full' || $parmlev eq 'brief') {
 1119:            my $coursespan=$csec?8:5;
 1120:            $r->print('<p><table border=2>');
 1121:            $r->print('<tr><td colspan=5></td>');
 1122:            $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
 1123:            if ($uname) {
 1124:                $r->print("<th colspan=3 rowspan=2>");
 1125:                $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
 1126:            }
 1127: 	   my %lt=&Apache::lonlocal::texthash(
 1128: 				  'pie'    => "Parameter in Effect",
 1129: 				  'csv'    => "Current Session Value",
 1130:                                   'at'     => 'at',
 1131:                                   'rl'     => "Resource Level",
 1132: 				  'ic'     => 'in Course',
 1133: 				  'aut'    => "Assessment URL and Title",
 1134: 				  'type'   => 'Type',
 1135: 				  'emof'   => "Enclosing Map or Folder",
 1136: 				  'part'   => 'Part',
 1137:                                   'pn'     => 'Parameter Name',
 1138: 				  'def'    => 'default',
 1139: 				  'femof'  => 'from Enclosing Map or Folder',
 1140: 				  'gen'    => 'general',
 1141: 				  'foremf' => 'for Enclosing Map or Folder',
 1142: 				  'fr'     => 'for Resource'
 1143: 					      );
 1144:            $r->print(<<ENDTABLETWO);
 1145: <th rowspan=3>$lt{'pie'}</th>
 1146: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
 1147: </tr><tr><td colspan=5></td><th colspan=2>$lt{'rl'}</th>
 1148: <th colspan=3>$lt{'ic'}</th>
 1149: ENDTABLETWO
 1150:            if ($csec) {
 1151:                 $r->print("<th colspan=3>".
 1152: 			  &mt("in Section/Group")." $csec</th>");
 1153:            }
 1154:            $r->print(<<ENDTABLEHEADFOUR);
 1155: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
 1156: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
 1157: <th>$lt{'def'}</th><th>$lt{'femof'}</th>
 1158: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th><th>$lt{'fr'}</th>
 1159: ENDTABLEHEADFOUR
 1160: 
 1161:            if ($csec) {
 1162:                $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
 1163:            }
 1164: 
 1165:            if ($uname) {
 1166:                $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
 1167:            }
 1168: 
 1169:            $r->print('</tr>');
 1170: 
 1171:            my $defbgone='';
 1172:            my $defbgtwo='';
 1173: 
 1174:            foreach (@ids) {
 1175: 
 1176:                 my $rid=$_;
 1177:                 my ($inmapid)=($rid=~/\.(\d+)$/);
 1178: 
 1179:                 if ((!$pssymb && 
 1180: 		     (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
 1181: 		    ||
 1182: 		    ($pssymb && $pssymb eq $symbp{$rid})) {
 1183: # ------------------------------------------------------ Entry for one resource
 1184:                     if ($defbgone eq '"E0E099"') {
 1185:                         $defbgone='"E0E0DD"';
 1186:                     } else {
 1187:                         $defbgone='"E0E099"';
 1188:                     }
 1189:                     if ($defbgtwo eq '"FFFF99"') {
 1190:                         $defbgtwo='"FFFFDD"';
 1191:                     } else {
 1192:                         $defbgtwo='"FFFF99"';
 1193:                     }
 1194:                     my $thistitle='';
 1195:                     my %name=   ();
 1196:                     undef %name;
 1197:                     my %part=   ();
 1198:                     my %display=();
 1199:                     my %type=   ();
 1200:                     my %default=();
 1201:                     my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
 1202: 
 1203:                     foreach (split(/\,/,$keyp{$rid})) {
 1204:                         my $tempkeyp = $_;
 1205:                         if (grep $_ eq $tempkeyp, @catmarker) {
 1206:                           $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
 1207:                           $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
 1208:                           $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
 1209:                           unless ($display{$_}) { $display{$_}=''; }
 1210:                           $display{$_}.=' ('.$name{$_}.')';
 1211:                           $default{$_}=&Apache::lonnet::metadata($uri,$_);
 1212:                           $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
 1213:                           $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
 1214:                         }
 1215:                     }
 1216:                     my $totalparms=scalar keys %name;
 1217:                     if ($totalparms>0) {
 1218:                         my $firstrow=1;
 1219: 			my $title=&Apache::lonnet::gettitle($uri);
 1220:                         $r->print('<tr><td bgcolor='.$defbgone.
 1221:                              ' rowspan='.$totalparms.
 1222:                              '><tt><font size=-1>'.
 1223:                              join(' / ',split(/\//,$uri)).
 1224:                              '</font></tt><p><b>'.
 1225:                              "<a href=\"javascript:openWindow('".
 1226: 				  &Apache::lonnet::clutter($uri).
 1227:                              "', 'metadatafile', '450', '500', 'no', 'yes')\";".
 1228:                              " TARGET=_self>$title");
 1229: 
 1230:                         if ($thistitle) {
 1231:                             $r->print(' ('.$thistitle.')');
 1232:                         }
 1233:                         $r->print('</a></b></td>');
 1234:                         $r->print('<td bgcolor='.$defbgtwo.
 1235:                                       ' rowspan='.$totalparms.'>'.$typep{$rid}.
 1236:                                       '</td>');
 1237: 
 1238:                         $r->print('<td bgcolor='.$defbgone.
 1239:                                       ' rowspan='.$totalparms.
 1240:                                       '><tt><font size=-1>');
 1241: 
 1242:                         $r->print(' / res / ');
 1243:                         $r->print(join(' / ', split(/\//,$mapp{$rid})));
 1244: 
 1245:                         $r->print('</font></tt></td>');
 1246: 
 1247:                         foreach (sort keys %name) {
 1248:                             unless ($firstrow) {
 1249:                                 $r->print('<tr>');
 1250:                             } else {
 1251:                                 undef $firstrow;
 1252:                             }
 1253: 
 1254:                             &print_row($r,$_,\%part,\%name,$rid,\%default,
 1255:                                        \%type,\%display,$defbgone,$defbgtwo,
 1256:                                        $parmlev);
 1257:                         }
 1258:                     }
 1259:                 }
 1260:             } # end foreach ids
 1261: # -------------------------------------------------- End entry for one resource
 1262:             $r->print('</table>');
 1263:         } # end of  brief/full
 1264: #--------------------------------------------------- Entry for parm level map
 1265:         if ($parmlev eq 'map') {
 1266:             my $defbgone = '"E0E099"';
 1267:             my $defbgtwo = '"FFFF99"';
 1268: 
 1269:             my %maplist;
 1270: 
 1271:             if ($pschp eq 'all') {
 1272:                 %maplist = %allmaps; 
 1273:             } else {
 1274:                 %maplist = ($pschp => $mapp{$pschp});
 1275:             }
 1276: 
 1277: #-------------------------------------------- for each map, gather information
 1278:             my $mapid;
 1279: 	    foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
 1280:                 my $maptitle = $maplist{$mapid};
 1281: 
 1282: #-----------------------  loop through ids and get all parameter types for map
 1283: #-----------------------------------------          and associated information
 1284:                 my %name = ();
 1285:                 my %part = ();
 1286:                 my %display = ();
 1287:                 my %type = ();
 1288:                 my %default = ();
 1289:                 my $map = 0;
 1290: 
 1291: #		$r->print("Catmarker: @catmarker<br />\n");
 1292:                
 1293:                 foreach (@ids) {
 1294:                   ($map)=(/([\d]*?)\./);
 1295:                   my $rid = $_;
 1296:         
 1297: #                  $r->print("$mapid:$map:   $rid <br /> \n");
 1298: 
 1299:                   if ($map eq $mapid) {
 1300:                     my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
 1301: #                    $r->print("Keys: $keyp{$rid} <br />\n");
 1302: 
 1303: #--------------------------------------------------------------------
 1304: # @catmarker contains list of all possible parameters including part #s
 1305: # $fullkeyp contains the full part/id # for the extraction of proper parameters
 1306: # $tempkeyp contains part 0 only (no ids - ie, subparts)
 1307: # When storing information, store as part 0
 1308: # When requesting information, request from full part
 1309: #-------------------------------------------------------------------
 1310:                     foreach (split(/\,/,$keyp{$rid})) {
 1311:                       my $tempkeyp = $_;
 1312:                       my $fullkeyp = $tempkeyp;
 1313:                       $tempkeyp =~ s/_\w+_/_0_/;
 1314:                       
 1315:                       if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
 1316:                         $part{$tempkeyp}="0";
 1317:                         $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
 1318:                         $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
 1319:                         unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
 1320:                         $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
 1321:                         $display{$tempkeyp} =~ s/_\w+_/_0_/;
 1322:                         $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
 1323:                         $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
 1324:                       }
 1325:                     } # end loop through keys
 1326:                   }
 1327:                 } # end loop through ids
 1328:                                  
 1329: #---------------------------------------------------- print header information
 1330:                 my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
 1331:                 my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
 1332:                 $r->print(<<ENDMAPONE);
 1333: <center><h4>
 1334: Set Defaults for All Resources in $foldermap<br />
 1335: <font color="red"><i>$showtitle</i></font><br />
 1336: Specifically for
 1337: ENDMAPONE
 1338:                 if ($uname) {
 1339:                     my %name=&Apache::lonnet::userenvironment($udom,$uname,
 1340:                       ('firstname','middlename','lastname','generation', 'id'));
 1341:                     my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
 1342:                            .$name{'lastname'}.' '.$name{'generation'};
 1343:                     $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
 1344:                         &mt('in')." \n");
 1345:                 } else {
 1346:                     $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
 1347:                 }
 1348:             
 1349:                 if ($csec) {$r->print(&mt("Section")." <font color=\"red\"><i>$csec</i></font> ".
 1350: 				      &mt('of')." \n")};
 1351: 
 1352:                 $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
 1353:                 $r->print("</h4>\n");
 1354: #---------------------------------------------------------------- print table
 1355:                 $r->print('<p><table border="2">');
 1356:                 $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
 1357:                 $r->print('<th>'.&mt('Default Value').'</th>');
 1358:                 $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
 1359: 
 1360: 	        foreach (sort keys %name) {
 1361:                     $r->print('<tr>');
 1362:                     &print_row($r,$_,\%part,\%name,$mapid,\%default,
 1363:                            \%type,\%display,$defbgone,$defbgtwo,
 1364:                            $parmlev);
 1365: #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
 1366:                 }
 1367:                 $r->print("</table></center>");
 1368:             } # end each map
 1369:         } # end of $parmlev eq map
 1370: #--------------------------------- Entry for parm level general (Course level)
 1371:         if ($parmlev eq 'general') {
 1372:             my $defbgone = '"E0E099"';
 1373:             my $defbgtwo = '"FFFF99"';
 1374: 
 1375: #-------------------------------------------- for each map, gather information
 1376:             my $mapid="0.0";
 1377: #-----------------------  loop through ids and get all parameter types for map
 1378: #-----------------------------------------          and associated information
 1379:             my %name = ();
 1380:             my %part = ();
 1381:             my %display = ();
 1382:             my %type = ();
 1383:             my %default = ();
 1384:                
 1385:             foreach (@ids) {
 1386:                 my $rid = $_;
 1387:         
 1388:                 my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
 1389: 
 1390: #--------------------------------------------------------------------
 1391: # @catmarker contains list of all possible parameters including part #s
 1392: # $fullkeyp contains the full part/id # for the extraction of proper parameters
 1393: # $tempkeyp contains part 0 only (no ids - ie, subparts)
 1394: # When storing information, store as part 0
 1395: # When requesting information, request from full part
 1396: #-------------------------------------------------------------------
 1397:                 foreach (split(/\,/,$keyp{$rid})) {
 1398:                   my $tempkeyp = $_;
 1399:                   my $fullkeyp = $tempkeyp;
 1400:                   $tempkeyp =~ s/_\w+_/_0_/;
 1401:                   if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
 1402:                     $part{$tempkeyp}="0";
 1403:                     $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
 1404:                     $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
 1405:                     unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
 1406:                     $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
 1407:                     $display{$tempkeyp} =~ s/_\w+_/_0_/;
 1408:                     $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
 1409:                     $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
 1410:                   }
 1411:                 } # end loop through keys
 1412:             } # end loop through ids
 1413:                                  
 1414: #---------------------------------------------------- print header information
 1415: 	    my $setdef=&mt("Set Defaults for All Resources in Course");
 1416:             $r->print(<<ENDMAPONE);
 1417: <center><h4>$setdef
 1418: <font color="red"><i>$coursename</i></font><br />
 1419: ENDMAPONE
 1420:             if ($uname) {
 1421:                 my %name=&Apache::lonnet::userenvironment($udom,$uname,
 1422:                   ('firstname','middlename','lastname','generation', 'id'));
 1423:                 my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
 1424:                        .$name{'lastname'}.' '.$name{'generation'};
 1425:                 $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
 1426:             } else {
 1427:                 $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
 1428:             }
 1429:             
 1430:             if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
 1431:             $r->print("</h4>\n");
 1432: #---------------------------------------------------------------- print table
 1433:             $r->print('<p><table border="2">');
 1434:             $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
 1435:             $r->print('<th>'.&mt('Default Value').'</th>');
 1436:             $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
 1437: 
 1438: 	    foreach (sort keys %name) {
 1439:                 $r->print('<tr>');
 1440:                 &print_row($r,$_,\%part,\%name,$mapid,\%default,
 1441:                        \%type,\%display,$defbgone,$defbgtwo,$parmlev);
 1442: #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
 1443:             }
 1444:             $r->print("</table></center>");
 1445:         } # end of $parmlev eq general
 1446:     }
 1447:     $r->print('</form></body></html>');
 1448:     untie(%bighash);
 1449:     untie(%parmhash);
 1450: } # end sub assessparms
 1451: 
 1452: 
 1453: ##################################################
 1454: ##################################################
 1455: 
 1456: =pod
 1457: 
 1458: =item crsenv
 1459: 
 1460: Show and set course data and parameters.  This is a large routine that should
 1461: be simplified and shortened... someday.
 1462: 
 1463: Inputs: $r
 1464: 
 1465: Returns: nothing
 1466: 
 1467: =cut
 1468: 
 1469: ##################################################
 1470: ##################################################
 1471: sub crsenv {
 1472:     my $r=shift;
 1473:     my $setoutput='';
 1474:     my $bodytag=&Apache::loncommon::bodytag(
 1475:                              'Set Course Environment Parameters');
 1476:     my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
 1477:     my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
 1478: 
 1479:     #
 1480:     # Go through list of changes
 1481:     foreach (keys %ENV) {
 1482:         next if ($_!~/^form\.(.+)\_setparmval$/);
 1483:         my $name  = $1;
 1484:         my $value = $ENV{'form.'.$name.'_value'};
 1485:         if ($name eq 'newp') {
 1486:             $name = $ENV{'form.newp_name'};
 1487:         }
 1488:         if ($name eq 'url') {
 1489:             $value=~s/^\/res\///;
 1490:             my $bkuptime=time;
 1491:             my @tmp = &Apache::lonnet::get
 1492:                 ('environment',['url'],$dom,$crs);
 1493:             $setoutput.=&mt('Backing up previous URL').': '.
 1494:                 &Apache::lonnet::put
 1495:                 ('environment',
 1496:                  {'top level map backup '.$bkuptime => $tmp[1] },
 1497:                  $dom,$crs).
 1498:                      '<br>';
 1499:         }
 1500:         #
 1501:         # Deal with modified default spreadsheets
 1502:         if ($name =~ /^spreadsheet_default_(classcalc|
 1503:                                             studentcalc|
 1504:                                             assesscalc)$/x) {
 1505:             my $sheettype = $1; 
 1506:             if ($sheettype eq 'classcalc') {
 1507:                 # no need to do anything since viewing the sheet will
 1508:                 # cause it to be updated. 
 1509:             } elsif ($sheettype eq 'studentcalc') {
 1510:                 # expire all the student spreadsheets
 1511:                 &Apache::lonnet::expirespread('','','studentcalc');
 1512:             } else {
 1513:                 # expire all the assessment spreadsheets 
 1514:                 #    this includes non-default spreadsheets, but better to
 1515:                 #    be safe than sorry.
 1516:                 &Apache::lonnet::expirespread('','','assesscalc');
 1517:                 # expire all the student spreadsheets
 1518:                 &Apache::lonnet::expirespread('','','studentcalc');
 1519:             }
 1520:         }
 1521:         #
 1522:         # Deal with the enrollment dates
 1523:         if ($name =~ /^default_enrollment_(start|end)_date$/) {
 1524:             $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
 1525:         }
 1526:         # Get existing cloners
 1527:         my @oldcloner = ();
 1528:         if ($name eq 'cloners') {
 1529:             my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
 1530:             if ($clonenames{'cloners'} =~ /,/) {
 1531:                 @oldcloner = split/,/,$clonenames{'cloners'};
 1532:             } else {
 1533:                 $oldcloner[0] = $clonenames{'cloners'};
 1534:             }
 1535:         }
 1536:         #
 1537:         # Let the user know we made the changes
 1538:         if ($name && defined($value)) {
 1539:             if ($name eq 'cloners') {
 1540:                 $value =~ s/^,//;
 1541:                 $value =~ s/,$//;
 1542:             }
 1543:             my $put_result = &Apache::lonnet::put('environment',
 1544:                                                   {$name=>$value},$dom,$crs);
 1545:             if ($put_result eq 'ok') {
 1546:                 $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
 1547:                 if ($name eq 'cloners') {
 1548:                     &change_clone($value,\@oldcloner);
 1549:                 }
 1550:                 # Flush the course logs so course description is immediately updated
 1551:                 if ($name eq 'description' && defined($value)) {
 1552:                     &Apache::lonnet::flushcourselogs();
 1553:                 }
 1554:             } else {
 1555:                 $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
 1556: 		    ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
 1557:             }
 1558:         }
 1559:     }
 1560: # ------------------------- Re-init course environment entries for this session
 1561: 
 1562:     &Apache::lonnet::coursedescription($ENV{'request.course.id'});
 1563: 
 1564: # -------------------------------------------------------- Get parameters again
 1565: 
 1566:     my %values=&Apache::lonnet::dump('environment',$dom,$crs);
 1567:     my $SelectStyleFile=&mt('Select Style File');
 1568:     my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
 1569:     my $output='';
 1570:     if (! exists($values{'con_lost'})) {
 1571:         my %descriptions=
 1572: 	    ('url'            => '<b>'.&mt('Top Level Map').'</b> '.
 1573:                                  '<a href="javascript:openbrowser'.
 1574:                                  "('envform','url','sequence')\">".
 1575:                                  &mt('Select Map').'</a><br /><font color=red> '.
 1576:                                  &mt('Modification may make assessment data inaccessible').
 1577:                                  '</font>',
 1578:              'description'    => '<b>'.&mt('Course Description').'</b>',
 1579:              'courseid'       => '<b>'.&mt('Course ID or number').
 1580:                                  '</b><br />'.
 1581:                                  '('.&mt('internal').', '.&mt('optional').')',
 1582:              '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.'),
 1583:              'grading'        => '<b>'.&mt('Grading').'</b><br />'.
 1584:                                  '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
 1585:              'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
 1586:                     '<a href="javascript:openbrowser'.
 1587:                     "('envform','default_xml_style'".
 1588:                     ",'sty')\">$SelectStyleFile</a><br>",
 1589:              'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
 1590:                                  '</b><br />(<tt>user:domain,'.
 1591:                                  'user:domain(section;section;...;*;...),...</tt>)',
 1592:              'comment.email'  => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
 1593:                                  '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
 1594:              'policy.email'   => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
 1595:                                  '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
 1596:              'hideemptyrows'  => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
 1597:                                  '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
 1598:              'pageseparators'  => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
 1599:                                  '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
 1600:                                  &mt('changes will not show until next login').')',
 1601:              '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.'),
 1602: 
 1603:              'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
 1604:                                   '</b><br />"<tt>st</tt>": '.
 1605:                                   &mt('student').', "<tt>ta</tt>": '.
 1606:                                   'TA, "<tt>in</tt>": '.
 1607:                                   &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
 1608: 	       Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
 1609:              'plc.users.denied' => 
 1610:                           '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
 1611:                                  '(<tt>user:domain,user:domain,...</tt>)',
 1612: 
 1613:              'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
 1614:                                   '</b><br />"<tt>st</tt>": '.
 1615:                                   'student, "<tt>ta</tt>": '.
 1616:                                   'TA, "<tt>in</tt>": '.
 1617:                                   'instructor;<br /><tt>role,role,...</tt>) '.
 1618: 	       Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
 1619:              'pch.users.denied' => 
 1620:                           '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
 1621:                                  '(<tt>user:domain,user:domain,...</tt>)',
 1622:              'spreadsheet_default_classcalc' 
 1623:                  => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
 1624:                     '<a href="javascript:openbrowser'.
 1625:                     "('envform','spreadsheet_default_classcalc'".
 1626:                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
 1627:              'spreadsheet_default_studentcalc' 
 1628:                  => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
 1629:                     '<a href="javascript:openbrowser'.
 1630:                     "('envform','spreadsheet_default_calc'".
 1631:                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
 1632:              'spreadsheet_default_assesscalc' 
 1633:                  => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
 1634:                     '<a href="javascript:openbrowser'.
 1635:                     "('envform','spreadsheet_default_assesscalc'".
 1636:                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
 1637: 	     'allow_limited_html_in_feedback'
 1638: 	         => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
 1639: 	            '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
 1640:              'allow_discussion_post_editing'
 1641:                  => '<b>'.&mt('Allow users to edit/delete their own discussion posts').'</b><br />'.
 1642:                     '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
 1643: 	     'rndseed'
 1644: 	         => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
 1645:                     '<font color="red">'.&mt('Modifying this will make problems').' '.
 1646:                     &mt('have different numbers and answers').'</font>',
 1647: 	     'receiptalg'
 1648: 	         => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
 1649:                     &mt('This controls how receipt numbers are generated.'),
 1650:              'suppress_tries'
 1651:                  => '<b>'.&mt('Suppress number of tries in printing').'</b>('.
 1652:                     &mt('yes if supress').')',
 1653:              'problem_stream_switch'
 1654:                  => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
 1655:                     ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
 1656:              'default_paper_size' 
 1657:                  => '<b>'.&mt('Default paper type').'</b><br />'.
 1658:                     ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. 
 1659:                     ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. 
 1660:                     ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
 1661:              'anonymous_quiz'
 1662:                  => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
 1663:                     ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
 1664:              'default_enrollment_start_date' => '<b>'.&mt('Default beginning date when enrolling students').'</b>',
 1665:              'default_enrollment_end_date'   => '<b>'.&mt('Default ending date when enrolling students').'</b>',
 1666:              'nothideprivileged'   => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
 1667:                                  '<br />(<tt>user:domain,user:domain,...</tt>)',
 1668:              'languages' => '<b>'.&mt('Languages used').'</b>',
 1669:              'disable_receipt_display'
 1670:                  => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
 1671:                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
 1672: 	     'disablesigfigs'
 1673: 	         => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
 1674:                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
 1675: 	     'tthoptions'
 1676: 	         => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
 1677:              ); 
 1678:         my @Display_Order = ('url','description','courseid','cloners','grading',
 1679:                              'default_xml_style','pageseparators',
 1680:                              'question.email','comment.email','policy.email',
 1681:                              'student_classlist_view',
 1682:                              'plc.roles.denied','plc.users.denied',
 1683:                              'pch.roles.denied','pch.users.denied',
 1684:                              'allow_limited_html_in_feedback',
 1685:                              'allow_discussion_post_editing',
 1686:                              'languages',
 1687: 			     'nothideprivileged',
 1688:                              'rndseed',
 1689:                              'receiptalg',
 1690:                              'problem_stream_switch',
 1691: 			     'suppress_tries',
 1692:                              'default_paper_size',
 1693:                              'disable_receipt_display',
 1694:                              'spreadsheet_default_classcalc',
 1695:                              'spreadsheet_default_studentcalc',
 1696:                              'spreadsheet_default_assesscalc', 
 1697:                              'hideemptyrows',
 1698:                              'default_enrollment_start_date',
 1699:                              'default_enrollment_end_date',
 1700: 			     'tthoptions',
 1701: 			     'disablesigfigs'
 1702:                              );
 1703: 	foreach my $parameter (sort(keys(%values))) {
 1704:             unless ($parameter =~ m/^internal\./) {
 1705:                 if (! $descriptions{$parameter}) {
 1706:                     $descriptions{$parameter}=$parameter;
 1707:                     push(@Display_Order,$parameter);
 1708:                 }
 1709:             }
 1710: 	}
 1711:         foreach my $parameter (@Display_Order) {
 1712:             my $description = $descriptions{$parameter};
 1713:             # onchange is javascript to automatically check the 'Set' button.
 1714:             my $onchange = 'onFocus="javascript:window.document.forms'.
 1715:                 "['envform'].elements['".$parameter."_setparmval']".
 1716:                 '.checked=true;"';
 1717:             $output .= '<tr><td>'.$description.'</td>';
 1718:             if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
 1719:                 $output .= '<td>'.
 1720:                     &Apache::lonhtmlcommon::date_setter('envform',
 1721:                                                         $parameter.'_value',
 1722:                                                         $values{$parameter},
 1723:                                                         $onchange).
 1724:                                                         '</td>';
 1725:             } else {
 1726:                 $output .= '<td>'.
 1727:                     &Apache::lonhtmlcommon::textbox($parameter.'_value',
 1728:                                                     $values{$parameter},
 1729:                                                     40,$onchange).'</td>';
 1730:             }
 1731:             $output .= '<td>'.
 1732:                 &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
 1733:                 '</td>';
 1734:             $output .= "</tr>\n";
 1735: 	}
 1736:         my $onchange = 'onFocus="javascript:window.document.forms'.
 1737:             '[\'envform\'].elements[\'newp_setparmval\']'.
 1738:             '.checked=true;"';
 1739: 	$output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
 1740: 	    '<input type="text" size=40 name="newp_name" '.
 1741:                 $onchange.' /></td><td>'.
 1742:             '<input type="text" size=40 name="newp_value" '.
 1743:                 $onchange.' /></td><td>'.
 1744: 	    '<input type="checkbox" name="newp_setparmval" /></td></tr>';
 1745:     }
 1746:     my %lt=&Apache::lonlocal::texthash(
 1747: 		    'par'   => 'Parameter',
 1748: 		    'val'   => 'Value',
 1749: 		    'set'   => 'Set',
 1750: 		    'sce'   => 'Set Course Environment'
 1751: 				       );
 1752: 
 1753:     my $Parameter=&mt('Parameter');
 1754:     my $Value=&mt('Value');
 1755:     my $Set=&mt('Set');
 1756:     my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset');
 1757:     $r->print(<<ENDENV);
 1758: <html>
 1759: <script type="text/javascript" language="Javascript" >
 1760: $browse_js
 1761: </script>
 1762: <head>
 1763: <title>LON-CAPA Course Environment</title>
 1764: </head>
 1765: $bodytag
 1766: <form method="post" action="/adm/parmset" name="envform">
 1767: $setoutput
 1768: <p>
 1769: <table border=2>
 1770: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
 1771: $output
 1772: </table>
 1773: <input type="submit" name="crsenv" value="$lt{'sce'}">
 1774: </form>
 1775: </body>
 1776: </html>    
 1777: ENDENV
 1778: }
 1779: ##################################################
 1780: 
 1781: my $tableopen;
 1782: 
 1783: sub tablestart {
 1784:     if ($tableopen) {
 1785: 	return '';
 1786:     } else {
 1787: 	$tableopen=1;
 1788: 	return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
 1789: 	    &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
 1790:     }
 1791: }
 1792: 
 1793: sub tableend {
 1794:     if ($tableopen) {
 1795: 	$tableopen=0;
 1796: 	return '</table>';
 1797:     } else {
 1798: 	return'';
 1799:     }
 1800: }
 1801: 
 1802: sub overview {
 1803:     my $r=shift;
 1804:     my $bodytag=&Apache::loncommon::bodytag(
 1805:                              'Set/Modify Course Assessment Parameters');
 1806:     my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
 1807:     my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
 1808:     $r->print(<<ENDOVER);
 1809: <html>
 1810: <head>
 1811: <title>LON-CAPA Course Environment</title>
 1812: </head>
 1813: $bodytag
 1814: <form method="post" action="/adm/parmset" name="overviewform">
 1815: <input type="hidden" name="overview" value="1" />
 1816: ENDOVER
 1817: # Setting
 1818:     my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
 1819:     my %newdata=();
 1820:     undef %newdata;
 1821:     my @deldata=();
 1822:     undef @deldata;
 1823:     foreach (keys %ENV) {
 1824: 	if ($_=~/^form\.([a-z]+)\_(.+)$/) {
 1825: 	    my $cmd=$1;
 1826: 	    my $thiskey=$2;
 1827: 	    if ($cmd eq 'set') {
 1828: 		my $data=$ENV{$_};
 1829: 		if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
 1830: 	    } elsif ($cmd eq 'del') {
 1831: 		push (@deldata,$thiskey);
 1832: 	    } elsif ($cmd eq 'datepointer') {
 1833: 		my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_});
 1834: 		if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
 1835: 	    }
 1836: 	}
 1837:     }
 1838: # Store
 1839:     my $delentries=$#deldata+1;
 1840:     my @newdatakeys=keys %newdata;
 1841:     my $putentries=$#newdatakeys+1;
 1842:     if ($delentries) {
 1843: 	if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
 1844: 	    $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
 1845: 	} else {
 1846: 	    $r->print('<h2><font color="red">'.
 1847: 		      &mt('Error deleting parameters').'</font></h2>');
 1848: 	}
 1849:     }
 1850:     if ($putentries) {
 1851: 	if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
 1852: 	    $r->print('<h2>'.&mt('Stored [_1] parameter(s)</h2>',$putentries));
 1853: 	} else {
 1854: 	    $r->print('<h2><font color="red">'.
 1855: 		      &mt('Error storing parameters').'</font></h2>');
 1856: 	}
 1857:     }
 1858: # Read and display
 1859:     my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
 1860:     my $oldsection='';
 1861:     my $oldrealm='';
 1862:     my $oldpart='';
 1863:     my $pointer=0;
 1864:     $tableopen=0;
 1865:     my $foundkeys=0;
 1866:     foreach my $thiskey (sort keys %resourcedata) {
 1867: 	if ($resourcedata{$thiskey.'.type'}) {
 1868: 	    my ($course,$middle,$part,$name)=
 1869: 		($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
 1870: 	    my $section=&mt('All Students');
 1871: 	    if ($middle=~/^\[(.*)\]\./) {
 1872: 		$section=&mt('Group/Section').': '.$1;
 1873: 		$middle=~s/^\[(.*)\]\.//;
 1874: 	    }
 1875: 	    $middle=~s/\.$//;
 1876: 	    my $realm='<font color="red">'.&mt('All Resources').'</font>';
 1877: 	    if ($middle=~/^(.+)\_\_\_\(all\)$/) {
 1878: 		$realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
 1879: 	    } elsif ($middle) {
 1880: 		my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
 1881: 		$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
 1882: 	    }
 1883: 	    if ($section ne $oldsection) {
 1884: 		$r->print(&tableend()."\n<hr /><h1>$section</h1>");
 1885: 		$oldsection=$section;
 1886: 		$oldrealm='';
 1887: 	    }
 1888: 	    if ($realm ne $oldrealm) {
 1889: 		$r->print(&tableend()."\n<h2>$realm</h2>");
 1890: 		$oldrealm=$realm;
 1891: 		$oldpart='';
 1892: 	    }
 1893: 	    if ($part ne $oldpart) {
 1894: 		$r->print(&tableend().
 1895: 			  "\n<h3><font color='blue'>".&mt('Part').": $part</font></h3>");
 1896: 		$oldpart=$part;
 1897: 	    }
 1898: #
 1899: # Ready to print
 1900: #
 1901: 	    $r->print(&tablestart().'<tr><td><b>'.$name.
 1902: 		      ':</b></td><td><input type="checkbox" name="del_'.
 1903: 		      $thiskey.'" /></td><td>');
 1904: 	    $foundkeys++;
 1905: 	    if ($resourcedata{$thiskey.'.type'}=~/^date/) {
 1906: 		my $jskey='key_'.$pointer;
 1907: 		$pointer++;
 1908: 		$r->print(
 1909: 			  &Apache::lonhtmlcommon::date_setter('overviewform',
 1910: 							      $jskey,
 1911: 						      $resourcedata{$thiskey}).
 1912: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
 1913: 			  );
 1914: 	    } else {
 1915: 		$r->print(
 1916: 			  '<input type="text" name="set_'.$thiskey.'" value="'.
 1917: 			  $resourcedata{$thiskey}.'">');
 1918: 	    }
 1919: 	    $r->print('</td></tr>');
 1920: 	}
 1921:     }
 1922:     
 1923:     $r->print(&tableend().'<p>'.
 1924: 	($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>');
 1925: }
 1926: 
 1927: ##################################################
 1928: ##################################################
 1929:                                                                                             
 1930: =pod
 1931:                                                                                             
 1932: =item change clone
 1933:                                                                                             
 1934: Modifies the list of courses a user can clone (stored
 1935: in the user's environemnt.db file), called when a
 1936: change is made to the list of users allowed to clone
 1937: a course.
 1938:                                                                                             
 1939: Inputs: $action,$cloner
 1940: where $action is add or drop, and $cloner is identity of 
 1941: user for whom cloning ability is to be changed in course. 
 1942:                                                                                             
 1943: Returns: 
 1944: 
 1945: =cut
 1946:                                                                                             
 1947: ##################################################
 1948: ##################################################
 1949: 
 1950: 
 1951: sub change_clone {
 1952:     my ($clonelist,$oldcloner) = @_;
 1953:     my ($uname,$udom);
 1954:     my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
 1955:     my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
 1956:     my $clone_crs = $cnum.':'.$cdom;
 1957:     
 1958:     if ($cnum && $cdom) {
 1959:         my @allowclone = ();
 1960:         if ($clonelist =~ /,/) {
 1961:             @allowclone = split/,/,$clonelist;
 1962:         } else {
 1963:             $allowclone[0] = $clonelist;
 1964:         }
 1965:         foreach my $currclone (@allowclone) {
 1966:             if (!grep/^$currclone$/,@$oldcloner) {
 1967:                 ($uname,$udom) = split/:/,$currclone;
 1968:                 if ($uname && $udom) {
 1969:                     unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
 1970:                         my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
 1971:                         if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
 1972:                             if ($currclonecrs{'cloneable'} eq '') {
 1973:                                 $currclonecrs{'cloneable'} = $clone_crs;
 1974:                             } else {
 1975:                                 $currclonecrs{'cloneable'} .= ','.$clone_crs;
 1976:                             }
 1977:                             &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
 1978:                         }
 1979:                     }
 1980:                 }
 1981:             }
 1982:         }
 1983:         foreach my $oldclone (@$oldcloner) {
 1984:             if (!grep/^$oldclone$/,@allowclone) {
 1985:                 ($uname,$udom) = split/:/,$oldclone;
 1986:                 if ($uname && $udom) {
 1987:                     unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
 1988:                         my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
 1989:                         my %newclonecrs = ();
 1990:                         if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
 1991:                             if ($currclonecrs{'cloneable'} =~ /,/) {
 1992:                                 my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
 1993:                                 foreach (@currclonecrs) {
 1994:                                     unless ($_ eq $clone_crs) {
 1995:                                         $newclonecrs{'cloneable'} .= $_.',';
 1996:                                     }
 1997:                                 }
 1998:                                 $newclonecrs{'cloneable'} =~ s/,$//;
 1999:                             } else {
 2000:                                 $newclonecrs{'cloneable'} = '';
 2001:                             }
 2002:                             &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
 2003:                         }
 2004:                     }
 2005:                 }
 2006:             }
 2007:         }
 2008:     }
 2009: }
 2010: 
 2011: ##################################################
 2012: ##################################################
 2013: 
 2014: =pod
 2015: 
 2016: =item * handler
 2017: 
 2018: Main handler.  Calls &assessparms and &crsenv subroutines.
 2019: 
 2020: =cut
 2021: 
 2022: ##################################################
 2023: ##################################################
 2024:     use Data::Dumper;
 2025: sub handler {
 2026:     my $r=shift;
 2027: 
 2028:     if ($r->header_only) {
 2029: 	&Apache::loncommon::content_type($r,'text/html');
 2030: 	$r->send_http_header;
 2031: 	return OK;
 2032:     }
 2033:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
 2034: 
 2035: # ----------------------------------------------------------- Clear out garbage
 2036: 
 2037:     %courseopt=();
 2038:     %useropt=();
 2039:     %parmhash=();
 2040: 
 2041:     @ids=();
 2042:     %symbp=();
 2043:     %mapp=();
 2044:     %typep=();
 2045:     %keyp=();
 2046: 
 2047:     %maptitles=();
 2048: 
 2049: # ----------------------------------------------------- Needs to be in a course
 2050: 
 2051:     if (($ENV{'request.course.id'}) && 
 2052: 	(&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}) || 
 2053: 	 &Apache::lonnet::allowed('opa',$ENV{'request.course.id'}.'/'.
 2054: 				  $ENV{'request.course.sec'})
 2055: 	 )) {
 2056: 
 2057:         &Apache::loncommon::content_type($r,'text/html');
 2058:         $r->send_http_header;
 2059:  
 2060:         $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
 2061: 
 2062: 	if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
 2063: # ---------------------------------------------- This is for course environment
 2064: # -------------------------- also call if toplevel map coudl not be initialized
 2065: 	    &crsenv($r);
 2066: 	} elsif ($ENV{'form.overview'}) {
 2067: # --------------------------------------------------------------- Overview mode
 2068: 	    &overview($r);
 2069: 	} else {
 2070: # --------------------------------------------------------- Bring up assessment
 2071: 	    &assessparms($r);
 2072: 	}
 2073:     } else {
 2074: # ----------------------------- Not in a course, or not allowed to modify parms
 2075: 	$ENV{'user.error.msg'}=
 2076: 	    "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
 2077: 	return HTTP_NOT_ACCEPTABLE;
 2078:     }
 2079:     return OK;
 2080: }
 2081: 
 2082: 1;
 2083: __END__
 2084: 
 2085: =pod
 2086: 
 2087: =back
 2088: 
 2089: =cut
 2090: 
 2091: 
 2092: 

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