File:  [LON-CAPA] / loncom / interface / lonparmset.pm
Revision 1.190: download - view: text, annotated - select for diffs
Thu Apr 7 06:56:23 2005 UTC (19 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: version_1_99_0_tmcc, HEAD
- ENV -> env

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

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