File:  [LON-CAPA] / loncom / interface / lonparmset.pm
Revision 1.187: download - view: text, annotated - select for diffs
Thu Mar 17 22:12:52 2005 UTC (19 years, 2 months ago) by www
Branches: MAIN
CVS tags: HEAD
Trying to clean up globals, one by one.

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

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