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