Annotation of loncom/interface/lonparmset.pm, revision 1.138

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

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