Annotation of loncom/interface/lonparmset.pm, revision 1.60
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.60 ! albertel 4: # $Id: lonparmset.pm,v 1.59 2002/08/12 18:54:16 matthew 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.36 albertel 59: use Apache::loncommon;
1.1 www 60: use GDBM_File;
1.57 albertel 61: use Apache::lonhomework;
62: use Apache::lonxml;
1.4 www 63:
1.1 www 64:
1.2 www 65: my %courseopt;
66: my %useropt;
67: my %parmhash;
68:
1.3 www 69: my @ids;
70: my %symbp;
1.10 www 71: my %mapp;
1.3 www 72: my %typep;
1.16 www 73: my %keyp;
1.2 www 74:
75: my $uname;
76: my $udom;
77: my $uhome;
78: my $csec;
1.57 albertel 79: my $coursename;
1.2 www 80:
1.59 matthew 81: ##################################################
82: ##################################################
83:
84: =pod
85:
86: =item parmval
87:
88: Figure out a cascading parameter.
89:
90: Inputs: $what $id $def
91:
92: Returns: I am not entirely sure.
1.2 www 93:
1.59 matthew 94: =cut
95:
96: ##################################################
97: ##################################################
1.2 www 98: sub parmval {
1.11 www 99: my ($what,$id,$def)=@_;
1.8 www 100: my $result='';
1.44 albertel 101: my @outpar=();
1.2 www 102: # ----------------------------------------------------- Cascading lookup scheme
1.10 www 103:
1.43 albertel 104: my $symbparm=$symbp{$id}.'.'.$what;
105: my $mapparm=$mapp{$id}.'___(all).'.$what;
1.10 www 106:
1.43 albertel 107: my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what;
108: my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
109: my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
110:
111: my $courselevel=$ENV{'request.course.id'}.'.'.$what;
112: my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
113: my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
1.2 www 114:
1.11 www 115: # -------------------------------------------------------- first, check default
116:
1.43 albertel 117: if ($def) { $outpar[11]=$def; $result=11; }
1.11 www 118:
119: # ----------------------------------------------------- second, check map parms
120:
1.43 albertel 121: my $thisparm=$parmhash{$symbparm};
122: if ($thisparm) { $outpar[10]=$thisparm; $result=10; }
1.11 www 123:
124: # --------------------------------------------------------- third, check course
125:
1.43 albertel 126: if ($courseopt{$courselevel}) {
127: $outpar[9]=$courseopt{$courselevel};
128: $result=9;
129: }
1.11 www 130:
1.43 albertel 131: if ($courseopt{$courselevelm}) {
132: $outpar[8]=$courseopt{$courselevelm};
133: $result=8;
134: }
1.11 www 135:
1.43 albertel 136: if ($courseopt{$courselevelr}) {
137: $outpar[7]=$courseopt{$courselevelr};
138: $result=7;
139: }
1.11 www 140:
1.43 albertel 141: if ($csec) {
142: if ($courseopt{$seclevel}) {
143: $outpar[6]=$courseopt{$seclevel};
144: $result=6;
145: }
146: if ($courseopt{$seclevelm}) {
147: $outpar[5]=$courseopt{$seclevelm};
148: $result=5;
149: }
150:
151: if ($courseopt{$seclevelr}) {
152: $outpar[4]=$courseopt{$seclevelr};
153: $result=4;
154: }
155: }
1.11 www 156:
157: # ---------------------------------------------------------- fourth, check user
158:
1.43 albertel 159: if ($uname) {
160: if ($useropt{$courselevel}) {
161: $outpar[3]=$useropt{$courselevel};
162: $result=3;
163: }
1.10 www 164:
1.43 albertel 165: if ($useropt{$courselevelm}) {
166: $outpar[2]=$useropt{$courselevelm};
167: $result=2;
168: }
1.2 www 169:
1.43 albertel 170: if ($useropt{$courselevelr}) {
171: $outpar[1]=$useropt{$courselevelr};
172: $result=1;
173: }
174: }
1.10 www 175:
1.44 albertel 176: return ($result,@outpar);
1.2 www 177: }
178:
1.59 matthew 179: ##################################################
180: ##################################################
181:
182: =pod
183:
184: =item valout
185:
186: Format a value for output.
187:
188: Inputs: $value, $type
189:
190: Returns: $value, formatted for output. If $type indicates it is a date,
191: localtime($value) is returned.
1.9 www 192:
1.59 matthew 193: =cut
194:
195: ##################################################
196: ##################################################
1.9 www 197: sub valout {
198: my ($value,$type)=@_;
1.59 matthew 199: my $result = '';
200: # Values of zero are valid.
201: if (! $value && $value ne '0') {
202: $result = ' ';
203: } else {
204: if ($type=~/^date/) {
205: $result = localtime($value);
206: } else {
207: $result = $value;
208: }
209: }
210: return $result;
1.9 www 211: }
212:
1.59 matthew 213: ##################################################
214: ##################################################
215:
216: =pod
1.5 www 217:
1.59 matthew 218: =item plink
219:
220: Produces a link anchor.
221:
222: Inputs: $type,$dis,$value,$marker,$return,$call
223:
224: Returns: scalar with html code for a link which will envoke the
225: javascript function 'pjump'.
226:
227: =cut
228:
229: ##################################################
230: ##################################################
1.5 www 231: sub plink {
232: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 233: my $winvalue=$value;
234: unless ($winvalue) {
235: if ($type=~/^date/) {
236: $winvalue=$ENV{'form.recent_'.$type};
237: } else {
238: $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]};
239: }
240: }
241: return
1.43 albertel 242: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
243: .$marker."','".$return."','".$call."'".');">'.
244: &valout($value,$type).'</a><a name="'.$marker.'"></a>';
1.5 www 245: }
246:
1.44 albertel 247:
248: sub startpage {
249: my ($r,$id,$udom,$csec,$uname)=@_;
250: $r->content_type('text/html');
251: $r->send_http_header;
252: $r->print(<<ENDHEAD);
253: <html>
254: <head>
255: <title>LON-CAPA Course Parameters</title>
256: <script>
257:
258: function pclose() {
259: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
260: "height=350,width=350,scrollbars=no,menubar=no");
261: parmwin.close();
262: }
263:
264: function pjump(type,dis,value,marker,ret,call) {
265: document.parmform.pres_marker.value='';
266: parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
267: +"&value="+escape(value)+"&marker="+escape(marker)
268: +"&return="+escape(ret)
269: +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
270: "height=350,width=350,scrollbars=no,menubar=no");
271:
272: }
273:
274: function psub() {
275: pclose();
276: if (document.parmform.pres_marker.value!='') {
277: document.parmform.action+='#'+document.parmform.pres_marker.value;
278: var typedef=new Array();
279: typedef=document.parmform.pres_type.value.split('_');
280: if (document.parmform.pres_type.value!='') {
281: if (typedef[0]=='date') {
282: eval('document.parmform.recent_'+
283: document.parmform.pres_type.value+
284: '.value=document.parmform.pres_value.value;');
285: } else {
286: eval('document.parmform.recent_'+typedef[0]+
287: '.value=document.parmform.pres_value.value;');
288: }
289: }
290: document.parmform.submit();
291: } else {
292: document.parmform.pres_value.value='';
293: document.parmform.pres_marker.value='';
294: }
295: }
296:
1.57 albertel 297: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
298: var options = "width=" + w + ",height=" + h + ",";
299: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
300: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
301: var newWin = window.open(url, wdwName, options);
302: newWin.focus();
303: }
1.44 albertel 304: </script>
305: </head>
306: <body bgcolor="#FFFFFF" onUnload="pclose()">
1.57 albertel 307: <h1>Set Course Parameters for Course:
308: $ENV{'course.'.$ENV{'request.course.id'}.'.description'}</h1>
1.44 albertel 309: <form method="post" action="/adm/parmset" name="envform">
310: <h3>Course Environment</h3>
311: <input type="submit" name="crsenv" value="Set Course Environment">
312: </form>
313: <form method="post" action="/adm/parmset" name="parmform">
314: <h3>Course Assessments</h3>
315: <b>
316: Section/Group:
317: <input type="text" value="$csec" size="6" name="csec">
318: <br>
319: For User
320: <input type="text" value="$uname" size="12" name="uname">
321: or ID
322: <input type="text" value="$id" size="12" name="id">
323: at Domain
324: <input type="text" value="$udom" size="6" name="udom">
325: </b>
326: <input type="hidden" value='' name="pres_value">
327: <input type="hidden" value='' name="pres_type">
328: <input type="hidden" value='' name="pres_marker">
329: ENDHEAD
330:
331: }
332:
333: sub print_row {
334: my ($r,$which,$part,$name,$rid,$default,$type,$display,$defbgone,
1.57 albertel 335: $defbgtwo,$parmlev)=@_;
1.44 albertel 336: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
337: $rid,$$default{$which});
1.57 albertel 338: my $parm=$$display{$which};
339:
340: if ($parmlev eq 'full' || $parmlev eq 'brief') {
341: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
342: .$$part{$which}.'</td>');
343: } else {
344: $parm=~s|\[.*\]\s||g;
345: }
346:
347: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
348:
1.44 albertel 349: my $thismarker=$which;
350: $thismarker=~s/^parameter\_//;
351: my $mprefix=$rid.'&'.$thismarker.'&';
352:
1.57 albertel 353: if ($parmlev eq 'general') {
354:
355: if ($uname) {
356: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
357: } elsif ($csec) {
358: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
359: } else {
360: &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
361: }
362: } elsif ($parmlev eq 'map') {
363:
364: if ($uname) {
365: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
366: } elsif ($csec) {
367: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
368: } else {
369: &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
370: }
371: } else {
372:
373: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,$type,$display);
374:
375: if ($parmlev eq 'brief') {
376:
377: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
378:
379: if ($csec) {
380: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
381: }
382: if ($uname) {
383: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
384: }
385: } else {
386:
387: &print_td($r,10,'#FFDDDD',$result,\@outpar,$mprefix,$_,$type,$display);
388: &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
389: &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
390: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
391:
392: if ($csec) {
393: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
394: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
395: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
396: }
397: if ($uname) {
398: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
399: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
400: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
401: }
402: } # end of $brief if/else
403: } # end of $parmlev if/else
404:
405: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1.59 matthew 406: $r->print('<td bgcolor=#CCCCFF align="center">'.
407: &valout($outpar[$result],$$type{$which}).'</td>');
408: }
1.44 albertel 409: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.57 albertel 410: '.'.$$name{$which},$symbp{$rid});
411: $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
412: &valout($sessionval,$$type{$which}).' '.
413: '</font></td>');
1.44 albertel 414: $r->print('</tr>');
1.57 albertel 415: $r->print("\n");
1.44 albertel 416: }
1.59 matthew 417:
1.44 albertel 418: sub print_td {
419: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$type,$display)=@_;
1.57 albertel 420: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
421: ' align="center">'.
422: &plink($$type{$value},$$display{$value},$$outpar[$which],
423: $mprefix."$which",'parmform.pres','psub').'</td>'."\n");
424: }
425:
426: sub get_env_multiple {
427: my ($name) = @_;
428: my @values;
429: if (defined($ENV{$name})) {
430: # exists is it an array
431: if (ref($ENV{$name})) {
432: @values=@{ $ENV{$name} };
433: } else {
434: $values[0]=$ENV{$name};
435: }
436: }
437: return(@values);
1.44 albertel 438: }
439:
1.59 matthew 440: ##################################################
441: ##################################################
442:
443: =pod
444:
445: =item assessparms
446:
447: Show assessment data and parameters. This is a large routine that should
448: be simplified and shortened... someday.
449:
450: Inputs: $r
451:
452: Returns: nothing
453:
454: =cut
455:
456: ##################################################
457: ##################################################
1.30 www 458: sub assessparms {
1.1 www 459:
1.43 albertel 460: my $r=shift;
1.2 www 461: # -------------------------------------------------------- Variable declaration
1.43 albertel 462: my %allkeys;
463: my %allmaps;
1.57 albertel 464: my %alllevs;
465:
466: $alllevs{'Resource Level'}='full';
467: # $alllevs{'Resource Level [BRIEF]'}='brief';
468: $alllevs{'Map Level'}='map';
469: $alllevs{'Course Level'}='general';
470:
471: my %allparms;
472: my %allparts;
473:
1.43 albertel 474: my %defp;
475: %courseopt=();
476: %useropt=();
1.44 albertel 477: my %bighash=();
1.43 albertel 478:
479: @ids=();
480: %symbp=();
481: %typep=();
482:
483: my $message='';
484:
485: $csec=$ENV{'form.csec'};
486: $udom=$ENV{'form.udom'};
487: unless ($udom) { $udom=$r->dir_config('lonDefDomain'); }
488:
1.57 albertel 489: my @pscat=&get_env_multiple('form.pscat');
1.43 albertel 490: my $pschp=$ENV{'form.pschp'};
1.57 albertel 491: my @psprt=&get_env_multiple('form.psprt');
492: my $showoptions=$ENV{'form.showoptions'};
493:
1.43 albertel 494: my $pssymb='';
1.57 albertel 495: my $parmlev='';
496: my $prevvisit=$ENV{'form.prevvisit'};
497:
498: # unless ($parmlev==$ENV{'form.parmlev'}) {
499: # $parmlev = 'full';
500: # }
501:
502: unless ($ENV{'form.parmlev'}) {
503: $parmlev = 'map';
504: } else {
505: $parmlev = $ENV{'form.parmlev'};
506: }
1.26 www 507:
1.29 www 508: # ----------------------------------------------- Was this started from grades?
509:
1.43 albertel 510: if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
511: && (!$ENV{'form.dis'})) {
512: my $url=$ENV{'form.url'};
513: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
514: $pssymb=&Apache::lonnet::symbread($url);
1.57 albertel 515: @pscat='all';
1.43 albertel 516: $pschp='';
1.57 albertel 517: $parmlev = 'full';
1.43 albertel 518: } elsif ($ENV{'form.symb'}) {
519: $pssymb=$ENV{'form.symb'};
1.57 albertel 520: @pscat='all';
1.43 albertel 521: $pschp='';
1.57 albertel 522: $parmlev = 'full';
1.43 albertel 523: } else {
524: $ENV{'form.url'}='';
525: }
526:
527: my $id=$ENV{'form.id'};
528: if (($id) && ($udom)) {
529: $uname=(&Apache::lonnet::idget($udom,$id))[1];
530: if ($uname) {
531: $id='';
532: } else {
533: $message=
534: "<font color=red>Unknown ID '$id' at domain '$udom'</font>";
535: }
536: } else {
537: $uname=$ENV{'form.uname'};
538: }
539: unless ($udom) { $uname=''; }
540: $uhome='';
541: if ($uname) {
542: $uhome=&Apache::lonnet::homeserver($uname,$udom);
543: if ($uhome eq 'no_host') {
544: $message=
545: "<font color=red>Unknown user '$uname' at domain '$udom'</font>";
546: $uname='';
1.12 www 547: } else {
1.43 albertel 548: $csec=&Apache::lonnet::usection($udom,$uname,
549: $ENV{'request.course.id'});
550: if ($csec eq '-1') {
551: $message="<font color=red>".
1.45 matthew 552: "User '$uname' at domain '$udom' not ".
553: "in this course</font>";
1.43 albertel 554: $uname='';
555: $csec=$ENV{'form.csec'};
556: } else {
557: my %name=&Apache::lonnet::userenvironment($udom,$uname,
558: ('firstname','middlename','lastname','generation','id'));
559: $message="\n<p>\nFull Name: ".
560: $name{'firstname'}.' '.$name{'middlename'}.' '
561: .$name{'lastname'}.' '.$name{'generation'}.
562: "<br>\nID: ".$name{'id'}.'<p>';
563: }
1.12 www 564: }
1.43 albertel 565: }
1.2 www 566:
1.43 albertel 567: unless ($csec) { $csec=''; }
1.12 www 568:
1.44 albertel 569: my $fcat=$ENV{'form.fcat'};
1.43 albertel 570: unless ($fcat) { $fcat=''; }
1.2 www 571:
572: # ------------------------------------------------------------------- Tie hashs
1.44 albertel 573: if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
1.58 albertel 574: &GDBM_READER(),0640))) {
1.44 albertel 575: $r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
576: return ;
577: }
578: if (!(tie(%parmhash,'GDBM_File',
1.58 albertel 579: $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
1.44 albertel 580: $r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
581: return ;
582: }
1.14 www 583: # --------------------------------------------------------- Get all assessments
1.44 albertel 584: foreach (keys %bighash) {
585: if ($_=~/^src\_(\d+)\.(\d+)$/) {
586: my $mapid=$1;
587: my $resid=$2;
588: my $id=$mapid.'.'.$resid;
589: my $srcf=$bighash{$_};
590: if ($srcf=~/\.(problem|exam|quiz|assess|survey|form)$/) {
591: $ids[$#ids+1]=$id;
592: $typep{$id}=$1;
593: $keyp{$id}='';
1.57 albertel 594: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'keys'))) {
595: if ($_=~/^parameter\_(.*)/) {
596: my $key=$_;
597: my $allkey=$1;
598: $allkey=~s/\_/\./g;
599: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
600: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
601: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
602: my $parmdis = $display;
603: $parmdis =~ s|(\[Part.*$)||g;
604: my $partkey = $part;
605: $partkey =~ tr|_|.|;
606: $allparms{$name} = $parmdis;
607: $allparts{$part} = "[Part $part]";
608: $allkeys{$allkey}=$display;
609: if ($allkey eq $fcat) {
610: $defp{$id}= &Apache::lonnet::metadata($srcf,$key);
611: }
612: if ($keyp{$id}) {
613: $keyp{$id}.=','.$key;
614: } else {
615: $keyp{$id}=$key;
1.43 albertel 616: }
1.57 albertel 617: }
1.44 albertel 618: }
619: $mapp{$id}=
620: &Apache::lonnet::declutter($bighash{'map_id_'.$mapid});
1.57 albertel 621: $mapp{$mapid}=$mapp{$id};
1.44 albertel 622: $allmaps{$mapid}=$mapp{$id};
623: $symbp{$id}=$mapp{$id}.
1.14 www 624: '___'.$resid.'___'.
1.16 www 625: &Apache::lonnet::declutter($srcf);
1.57 albertel 626: $symbp{$mapid}=$mapp{$id}.'___(all)';
1.44 albertel 627: }
628: }
629: }
1.57 albertel 630: $mapp{'0.0'} = '';
631: $symbp{'0.0'} = '';
1.14 www 632: # ---------------------------------------------------------- Anything to store?
1.44 albertel 633: if ($ENV{'form.pres_marker'}) {
634: my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'});
635: $spnam=~s/\_([^\_]+)$/\.$1/;
1.15 www 636: # ---------------------------------------------------------- Construct prefixes
1.14 www 637:
1.44 albertel 638: my $symbparm=$symbp{$sresid}.'.'.$spnam;
639: my $mapparm=$mapp{$sresid}.'___(all).'.$spnam;
640:
641: my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam;
642: my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
643: my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
644:
645: my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
646: my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
647: my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
648:
649: my $storeunder='';
650: if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; }
651: if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; }
652: if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
653: if ($snum==6) { $storeunder=$seclevel; }
654: if ($snum==5) { $storeunder=$seclevelm; }
655: if ($snum==4) { $storeunder=$seclevelr; }
656:
1.45 matthew 657: my %storecontent = ($storeunder => $ENV{'form.pres_value'},
658: $storeunder.'type' => $ENV{'form.pres_type'});
1.44 albertel 659: my $reply='';
660: if ($snum>3) {
1.14 www 661: # ---------------------------------------------------------------- Store Course
1.24 www 662: #
663: # Expire sheets
1.44 albertel 664: &Apache::lonnet::expirespread('','','studentcalc');
665: if (($snum==7) || ($snum==4)) {
666: &Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid});
667: } elsif (($snum==8) || ($snum==5)) {
668: &Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid});
669: } else {
670: &Apache::lonnet::expirespread('','','assesscalc');
671: }
1.24 www 672: # Store parameter
1.45 matthew 673: $reply=&Apache::lonnet::cput
674: ('resourcedata',\%storecontent,
675: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
676: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.44 albertel 677: } else {
1.14 www 678: # ------------------------------------------------------------------ Store User
1.24 www 679: #
680: # Expire sheets
1.44 albertel 681: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
682: if ($snum==1) {
683: &Apache::lonnet::expirespread
684: ($uname,$udom,'assesscalc',$symbp{$sresid});
685: } elsif ($snum==2) {
686: &Apache::lonnet::expirespread
687: ($uname,$udom,'assesscalc',$mapp{$sresid});
688: } else {
689: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
690: }
1.24 www 691: # Store parameter
1.45 matthew 692: $reply=&Apache::lonnet::cput
693: ('resourcedata',\%storecontent,$udom,$uname);
1.44 albertel 694: }
1.15 www 695:
1.44 albertel 696: if ($reply=~/^error\:(.*)/) {
697: $message.="<font color=red>Write Error: $1</font>";
698: }
1.15 www 699: # ---------------------------------------------------------------- Done storing
1.44 albertel 700: }
1.2 www 701: # -------------------------------------------------------------- Get coursedata
1.45 matthew 702: %courseopt = &Apache::lonnet::dump
703: ('resourcedata',
704: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
705: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.44 albertel 706: # --------------------------------------------------- Get userdata (if present)
707: if ($uname) {
1.45 matthew 708: %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
1.44 albertel 709: }
1.14 www 710:
1.2 www 711: # ------------------------------------------------------------------- Sort this
1.17 www 712:
1.44 albertel 713: @ids=sort {
714: if ($fcat eq '') {
715: $a<=>$b;
716: } else {
717: my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
718: my $aparm=$outpar[$result];
719: ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
720: my $bparm=$outpar[$result];
721: 1*$aparm<=>1*$bparm;
722: }
723: } @ids;
1.57 albertel 724: #----------------------------------------------- if all selected, fill in array
725: if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
726: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 727: # ------------------------------------------------------------------ Start page
1.44 albertel 728: &startpage($r,$id,$udom,$csec,$uname);
729: # if ($ENV{'form.url'}) {
730: # $r->print('<input type="hidden" value="'.$ENV{'form.url'}.
731: # '" name="url"><input type="hidden" name="command" value="set">');
732: # }
1.57 albertel 733: $r->print('<input type="hidden" value="true" name="prevvisit">');
734:
1.44 albertel 735: foreach ('tolerance','date_default','date_start','date_end',
736: 'date_interval','int','float','string') {
737: $r->print('<input type="hidden" value="'.
738: $ENV{'form.recent_'.$_}.'" name="recent_'.$_.'">');
739: }
740:
1.57 albertel 741: $r->print('<h2>'.$message.'</h2><table>');
742:
743: $r->print('<tr><td><hr /></td></tr>');
744:
745: my $submitmessage;
746: if (($prevvisit) || ($pschp) || ($pssymb)) {
747: $submitmessage = "Update Display";
748: } else {
749: $submitmessage = "Display";
1.13 www 750: }
1.44 albertel 751: if (!$pssymb) {
1.57 albertel 752: $r->print('<tr><td>Select Parameter Level</td><td>');
753: $r->print('<select name="parmlev">');
754: foreach (reverse sort keys %alllevs) {
755: $r->print('<option value="'.$alllevs{$_}.'"');
756: if ($parmlev eq $alllevs{$_}) {
757: $r->print(' selected');
758: }
759: $r->print('>'.$_.'</option>');
760: }
761: $r->print("</select></td>\n");
762:
763: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
764:
765: $r->print('</tr><tr><td><hr /></td>');
766:
767: $r->print('<tr><td>Select Enclosing Map</td>');
768: $r->print('<td colspan="2"><select name="pschp">');
769: $r->print('<option value="all">All Maps</option>');
770: foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
771: $r->print('<option value="'.$_.'"');
772: if (($pschp eq $_)) { $r->print(' selected'); }
773: $r->print('>/res/'.$allmaps{$_}.'</option>');
774: }
775: $r->print("</select></td></tr>\n");
1.44 albertel 776: } else {
1.57 albertel 777: my ($map,$id,$resource)=split(/___/,$pssymb);
778: $r->print("<tr><td>Specific Resource</td><td>$resource</td>");
779: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
780: $r->print('</tr>');
781: $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
782: }
783:
784: $r->print('<tr><td colspan="3"><hr /><input type="checkbox"');
785: if ($showoptions eq 'show') {$r->print(" checked ");}
786: $r->print(' name="showoptions" value="show" onclick="form.submit();">Show More Options<hr /></td></tr>');
787: # $r->print("<tr><td>Show: $showoptions</td></tr>");
788: # $r->print("<tr><td>pscat: @pscat</td></tr>");
789: # $r->print("<tr><td>psprt: @psprt</td></tr>");
790: # $r->print("<tr><td>fcat: $fcat</td></tr>");
791:
792: if ($showoptions eq 'show') {
793: my $tempkey;
794:
795: $r->print('<tr><td colspan="3" align="center">Select Parameters to View</td></tr>');
796:
797: $r->print('<tr><td colspan="2"><table>');
798: $r->print('<tr><td><input type="checkbox" name="pscat" value="all"');
799: $r->print(' checked') unless (@pscat);
800: $r->print('>All Parameters</td>');
801:
802: my $cnt=0;
803:
804: foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
805: keys %allparms ) {
806: ++$cnt;
807: $r->print('</tr><tr>') unless ($cnt%2);
808: $r->print('<td><input type="checkbox" name="pscat" ');
809: $r->print('value="'.$tempkey.'"');
810: if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
811: $r->print(' checked');
812: }
813: $r->print('>'.$allparms{$tempkey}.'</td>');
814: }
815: $r->print('</tr></table>');
816:
817: # $r->print('<tr><td>Select Parts</td><td>');
818: $r->print('<td><select multiple name="psprt" size="5">');
819: $r->print('<option value="all"');
820: $r->print(' selected') unless (@psprt);
821: $r->print('>All Parts</option>');
822: foreach $tempkey (sort keys %allparts) {
823: unless ($tempkey =~ /\./) {
824: $r->print('<option value="'.$tempkey.'"');
825: if ($psprt[0] eq "all" || grep $_ == $tempkey, @psprt) {
826: $r->print(' selected');
827: }
828: $r->print('>'.$allparts{$tempkey}.'</option>');
829: }
830: }
831: $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
832:
833: $r->print('<tr><td>Sort list by</td><td>');
834: $r->print('<select name="fcat">');
835: $r->print('<option value="">Enclosing Map</option>');
836: foreach (sort keys %allkeys) {
837: $r->print('<option value="'.$_.'"');
838: if ($fcat eq $_) { $r->print(' selected'); }
839: $r->print('>'.$allkeys{$_}.'</option>');
840: }
841: $r->print('</select></td>');
842:
843: $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
844:
845: } else { # hide options - include any necessary extras here
846:
847: $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
848:
849: unless (@pscat) {
850: foreach (keys %allparms ) {
851: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
852: }
853: } else {
854: foreach (@pscat) {
855: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
856: }
857: }
858:
859: unless (@psprt) {
860: foreach (keys %allparts ) {
861: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
862: }
863: } else {
864: foreach (@psprt) {
865: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
866: }
867: }
868:
1.44 albertel 869: }
1.57 albertel 870: $r->print('</table>');
871:
872: my @temp_psprt;
1.60 ! albertel 873: foreach my $t (@psprt) {
! 874: push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
! 875: }
1.57 albertel 876:
877: @psprt = @temp_psprt;
878:
879: my @temp_pscat;
880: map {
881: my $cat = $_;
882: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
883: } @pscat;
884:
885: @pscat = @temp_pscat;
886:
887: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.10 www 888: # ----------------------------------------------------------------- Start Table
1.57 albertel 889: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
890: my $csuname=$ENV{'user.name'};
891: my $csudom=$ENV{'user.domain'};
892:
893:
894: if ($parmlev eq 'full' || $parmlev eq 'brief') {
895:
896: my $coursespan=$csec?8:5;
897: $r->print('<p><table border=2>');
898: $r->print('<tr><td colspan=5></td>');
899: $r->print('<th colspan='.($coursespan).'>Any User</th>');
900: if ($uname) {
901: $r->print("<th colspan=3 rowspan=2>");
902: $r->print("User $uname at Domain $udom</th>");
903: }
904: $r->print(<<ENDTABLETWO);
1.33 www 905: <th rowspan=3>Parameter in Effect</th>
906: <th rowspan=3>Current Session Value<br>($csuname at $csudom)</th>
1.57 albertel 907: </tr><tr><td colspan=5></td><th colspan=2>Resource Level</th>
1.10 www 908: <th colspan=3>in Course</th>
909: ENDTABLETWO
1.57 albertel 910: if ($csec) {
911: $r->print("<th colspan=3>in Section/Group $csec</th>");
912: }
913: $r->print(<<ENDTABLEHEADFOUR);
1.11 www 914: </tr><tr><th>Assessment URL and Title</th><th>Type</th>
1.10 www 915: <th>Enclosing Map</th><th>Part No.</th><th>Parameter Name</th>
1.11 www 916: <th>default</th><th>from Enclosing Map</th>
1.10 www 917: <th>general</th><th>for Enclosing Map</th><th>for Resource</th>
918: ENDTABLEHEADFOUR
1.57 albertel 919:
920: if ($csec) {
921: $r->print('<th>general</th><th>for Enclosing Map</th><th>for Resource</th>');
922: }
923:
924: if ($uname) {
925: $r->print('<th>general</th><th>for Enclosing Map</th><th>for Resource</th>');
926: }
927:
928: $r->print('</tr>');
929:
930: my $defbgone='';
931: my $defbgtwo='';
932:
933: foreach (@ids) {
934:
935: my $rid=$_;
936: my ($inmapid)=($rid=~/\.(\d+)$/);
937:
938: if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) ||
939: ($pssymb eq $symbp{$rid})) {
1.4 www 940: # ------------------------------------------------------ Entry for one resource
1.57 albertel 941: if ($defbgone eq '"E0E099"') {
942: $defbgone='"E0E0DD"';
943: } else {
944: $defbgone='"E0E099"';
945: }
946: if ($defbgtwo eq '"FFFF99"') {
947: $defbgtwo='"FFFFDD"';
948: } else {
949: $defbgtwo='"FFFF99"';
950: }
951: my $thistitle='';
952: my %name= ();
953: undef %name;
954: my %part= ();
955: my %display=();
956: my %type= ();
957: my %default=();
958: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
959:
960: foreach (split(/\,/,$keyp{$rid})) {
961: my $tempkeyp = $_;
962: if (grep $_ eq $tempkeyp, @catmarker) {
963: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
964: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
965: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
966: unless ($display{$_}) { $display{$_}=''; }
967: $display{$_}.=' ('.$name{$_}.')';
968: $default{$_}=&Apache::lonnet::metadata($uri,$_);
969: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
970: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
971: }
972: }
973: my $totalparms=scalar keys %name;
974: if ($totalparms>0) {
975: my $firstrow=1;
976:
977: $r->print('<tr><td bgcolor='.$defbgone.
978: ' rowspan='.$totalparms.
979: '><tt><font size=-1>'.
980: join(' / ',split(/\//,$uri)).
981: '</font></tt><p><b>'.
982: "<a href=\"javascript:openWindow('/res/".$uri.
983: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
984: " TARGET=_self>$bighash{'title_'.$rid}");
985:
986: if ($thistitle) {
987: $r->print(' ('.$thistitle.')');
988: }
989: $r->print('</a></b></td>');
990: $r->print('<td bgcolor='.$defbgtwo.
991: ' rowspan='.$totalparms.'>'.$typep{$rid}.
992: '</td>');
993:
994: $r->print('<td bgcolor='.$defbgone.
995: ' rowspan='.$totalparms.
996: '><tt><font size=-1>');
997:
998: $r->print(' / res / ');
999: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1000:
1001: $r->print('</font></tt></td>');
1002:
1003: foreach (sort keys %name) {
1004: unless ($firstrow) {
1005: $r->print('<tr>');
1006: } else {
1007: undef $firstrow;
1008: }
1009:
1010: &print_row($r,$_,\%part,\%name,$rid,\%default,
1011: \%type,\%display,$defbgone,$defbgtwo,
1012: $parmlev);
1013: }
1014: }
1015: }
1016: } # end foreach ids
1.43 albertel 1017: # -------------------------------------------------- End entry for one resource
1.57 albertel 1018: $r->print('</table>');
1019: } # end of brief/full
1020: #--------------------------------------------------- Entry for parm level map
1021: if ($parmlev eq 'map') {
1022: my $defbgone = '"E0E099"';
1023: my $defbgtwo = '"FFFF99"';
1024:
1025: my %maplist;
1026:
1027: if ($pschp eq 'all') {
1028: %maplist = %allmaps;
1029: } else {
1030: %maplist = ($pschp => $mapp{$pschp});
1031: }
1032:
1033: #-------------------------------------------- for each map, gather information
1034: my $mapid;
1.60 ! albertel 1035: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
! 1036: my $maptitle = $maplist{$mapid};
1.57 albertel 1037:
1038: #----------------------- loop through ids and get all parameter types for map
1039: #----------------------------------------- and associated information
1040: my %name = ();
1041: my %part = ();
1042: my %display = ();
1043: my %type = ();
1044: my %default = ();
1045: my $map = 0;
1046:
1047: # $r->print("Catmarker: @catmarker<br />\n");
1048:
1049: foreach (@ids) {
1050: ($map)=(/([\d]*?)\./);
1051: my $rid = $_;
1052:
1053: # $r->print("$mapid:$map: $rid <br /> \n");
1054:
1055: if ($map eq $mapid) {
1056: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1057: # $r->print("Keys: $keyp{$rid} <br />\n");
1058:
1059: #--------------------------------------------------------------------
1060: # @catmarker contains list of all possible parameters including part #s
1061: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1062: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1063: # When storing information, store as part 0
1064: # When requesting information, request from full part
1065: #-------------------------------------------------------------------
1066: foreach (split(/\,/,$keyp{$rid})) {
1067: my $tempkeyp = $_;
1068: my $fullkeyp = $tempkeyp;
1069: $tempkeyp =~ s/_[\d_]+_/_0_/;
1070:
1071: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1072: $part{$tempkeyp}="0";
1073: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1074: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1075: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1076: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1077: $display{$tempkeyp} =~ s/_[\d_]+_/_0_/;
1078: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1079: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1080: }
1081: } # end loop through keys
1082: }
1083: } # end loop through ids
1084:
1085: #---------------------------------------------------- print header information
1086: $r->print(<<ENDMAPONE);
1087: <center><h4>
1088: <font color="red">Set Defaults for All Resources in map
1089: <i>$maptitle</i><br />
1090: Specifically for
1091: ENDMAPONE
1092: if ($uname) {
1093: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1094: ('firstname','middlename','lastname','generation', 'id'));
1095: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1096: .$name{'lastname'}.' '.$name{'generation'};
1097: $r->print("User <i>$uname \($person\) </i> in \n");
1098: } else {
1099: $r->print("<i>all</i> users in \n");
1100: }
1101:
1102: if ($csec) {$r->print("Section <i>$csec</i> of \n")};
1103:
1104: $r->print("<i>$coursename</i><br />");
1105: $r->print("</font></h4>\n");
1106: #---------------------------------------------------------------- print table
1107: $r->print('<p><table border="2">');
1108: $r->print('<tr><th>Parameter Name</th>');
1109: $r->print('<th>Default Value</th>');
1110: $r->print('<th>Parameter in Effect</th></tr>');
1111:
1112: foreach (sort keys %name) {
1113: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1114: \%type,\%display,$defbgone,$defbgtwo,
1115: $parmlev);
1116: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1117: }
1118: $r->print("</table></center>");
1119: } # end each map
1120: } # end of $parmlev eq map
1121: #--------------------------------- Entry for parm level general (Course level)
1122: if ($parmlev eq 'general') {
1123: my $defbgone = '"E0E099"';
1124: my $defbgtwo = '"FFFF99"';
1125:
1126: #-------------------------------------------- for each map, gather information
1127: my $mapid="0.0";
1128: #----------------------- loop through ids and get all parameter types for map
1129: #----------------------------------------- and associated information
1130: my %name = ();
1131: my %part = ();
1132: my %display = ();
1133: my %type = ();
1134: my %default = ();
1135:
1136: foreach (@ids) {
1137: my $rid = $_;
1138:
1139: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1140:
1141: #--------------------------------------------------------------------
1142: # @catmarker contains list of all possible parameters including part #s
1143: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1144: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1145: # When storing information, store as part 0
1146: # When requesting information, request from full part
1147: #-------------------------------------------------------------------
1148: foreach (split(/\,/,$keyp{$rid})) {
1149: my $tempkeyp = $_;
1150: my $fullkeyp = $tempkeyp;
1151: $tempkeyp =~ s/_[\d_]+_/_0_/;
1152: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1153: $part{$tempkeyp}="0";
1154: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1155: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1156: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1157: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1158: $display{$tempkeyp} =~ s/_[\d_]+_/_0_/;
1159: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1160: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1161: }
1162: } # end loop through keys
1163: } # end loop through ids
1164:
1165: #---------------------------------------------------- print header information
1166: $r->print(<<ENDMAPONE);
1167: <center><h4>
1168: <font color="red">Set Defaults for All Resources in Course
1169: <i>$coursename</i><br />
1170: ENDMAPONE
1171: if ($uname) {
1172: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1173: ('firstname','middlename','lastname','generation', 'id'));
1174: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1175: .$name{'lastname'}.' '.$name{'generation'};
1176: $r->print(" User <i>$uname \($person\) </i> \n");
1177: } else {
1178: $r->print("<i>ALL</i> USERS \n");
1179: }
1180:
1181: if ($csec) {$r->print("Section <i>$csec</i>\n")};
1182: $r->print("</font></h4>\n");
1183: #---------------------------------------------------------------- print table
1184: $r->print('<p><table border="2">');
1185: $r->print('<tr><th>Parameter Name</th>');
1186: $r->print('<th>Default Value</th>');
1187: $r->print('<th>Parameter in Effect</th></tr>');
1188:
1189: foreach (sort keys %name) {
1190: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1191: \%type,\%display,$defbgone,$defbgtwo,$parmlev);
1192: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1193: }
1194: $r->print("</table></center>");
1195: } # end of $parmlev eq general
1.43 albertel 1196: }
1.44 albertel 1197: $r->print('</form></body></html>');
1198: untie(%bighash);
1199: untie(%parmhash);
1.57 albertel 1200: } # end sub assessparms
1.30 www 1201:
1.59 matthew 1202:
1203: ##################################################
1204: ##################################################
1205:
1206: =pod
1207:
1208: =item crsenv
1209:
1210: Show course data and parameters. This is a large routine that should
1211: be simplified and shortened... someday.
1212:
1213: Inputs: $r
1214:
1215: Returns: nothing
1216:
1217: =cut
1218:
1219: ##################################################
1220: ##################################################
1.30 www 1221: sub crsenv {
1222: my $r=shift;
1223: my $setoutput='';
1.45 matthew 1224: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1225: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1.30 www 1226: # -------------------------------------------------- Go through list of changes
1.38 harris41 1227: foreach (keys %ENV) {
1.30 www 1228: if ($_=~/^form\.(.+)\_setparmval$/) {
1229: my $name=$1;
1230: my $value=$ENV{'form.'.$name.'_value'};
1231: if ($name eq 'newp') {
1232: $name=$ENV{'form.newp_name'};
1233: }
1234: if ($name eq 'url') {
1235: $value=~s/^\/res\///;
1.45 matthew 1236: my @tmp = &Apache::lonnet::get
1237: ('environment',['url'],$dom,$crs);
1.30 www 1238: $setoutput.='Backing up previous URL: '.
1.45 matthew 1239: &Apache::lonnet::put
1240: ('environment',
1241: {'top level map backup ' => $tmp[1] },
1242: $dom,$crs).
1243: '<br>';
1.30 www 1244: }
1245: if ($name) {
1.45 matthew 1246: $setoutput.='Setting <tt>'.$name.'</tt> to <tt>'.
1247: $value.'</tt>: '.
1248: &Apache::lonnet::put
1249: ('environment',{$name=>$value},$dom,$crs).
1250: '<br>';
1.30 www 1251: }
1252: }
1.38 harris41 1253: }
1.30 www 1254: # -------------------------------------------------------- Get parameters again
1.45 matthew 1255:
1256: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.30 www 1257: my $output='';
1.45 matthew 1258: if (! exists($values{'con_lost'})) {
1.30 www 1259: my %descriptions=
1.47 matthew 1260: ('url' => '<b>Top Level Map</b> '.
1.46 matthew 1261: '<a href="javascript:openbrowser'.
1.47 matthew 1262: "('envform','url','sequence')\">".
1.46 matthew 1263: 'Browse</a><br><font color=red> '.
1.45 matthew 1264: 'Modification may make assessment data '.
1265: 'inaccessible</font>',
1266: 'description' => '<b>Course Description</b>',
1267: 'courseid' => '<b>Course ID or number</b><br>'.
1268: '(internal, optional)',
1.52 www 1269: 'default_xml_style' => '<b>Default XML Style File</b> '.
1270: '<a href="javascript:openbrowser'.
1271: "('envform','default_xml_style'".
1272: ",'sty')\">Browse</a><br>",
1.45 matthew 1273: 'question.email' => '<b>Feedback Addresses for Content '.
1274: 'Questions</b><br>(<tt>user:domain,'.
1275: 'user:domain,...</tt>)',
1276: 'comment.email' => '<b>Feedback Addresses for Comments</b><br>'.
1277: '(<tt>user:domain,user:domain,...</tt>)',
1278: 'policy.email' => '<b>Feedback Addresses for Course Policy</b>'.
1279: '<br>(<tt>user:domain,user:domain,...</tt>)',
1280: 'hideemptyrows' => '<b>Hide Empty Rows in Spreadsheets</b><br>'.
1281: '("<tt>yes</tt>" for default hiding)',
1.54 www 1282: 'pageseparators' => '<b>Visibly Separate Items on Pages</b><br>'.
1283: '("<tt>yes</tt>" for visible separation)',
1.45 matthew 1284: 'pch.roles.denied'=> '<b>Disallow Resource Discussion for '.
1.57 albertel 1285: 'Roles</b> ' .
1286: Apache::loncommon::help_open_topic("Course_Disable_Discussion")
1287: ,
1.53 www 1288: 'pch.users.denied' =>
1289: '<b>Disallow Resource Discussion for Users</b><br>'.
1290: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 1291: 'spreadsheet_default_classcalc'
1.52 www 1292: => '<b>Default Course Spreadsheet</b> '.
1.50 matthew 1293: '<a href="javascript:openbrowser'.
1294: "('envform','spreadsheet_default_classcalc'".
1295: ",'spreadsheet')\">Browse</a><br>",
1.49 matthew 1296: 'spreadsheet_default_studentcalc'
1.52 www 1297: => '<b>Default Student Spreadsheet</b> '.
1.50 matthew 1298: '<a href="javascript:openbrowser'.
1299: "('envform','spreadsheet_default_calc'".
1300: ",'spreadsheet')\">Browse</a><br>",
1.49 matthew 1301: 'spreadsheet_default_assesscalc'
1.52 www 1302: => '<b>Default Assessment Spreadsheet</b> '.
1.50 matthew 1303: '<a href="javascript:openbrowser'.
1304: "('envform','spreadsheet_default_assesscalc'".
1305: ",'spreadsheet')\">Browse</a><br>",
1.45 matthew 1306: );
1307: foreach (keys(%values)) {
1308: unless ($descriptions{$_}) {
1309: $descriptions{$_}=$_;
1.43 albertel 1310: }
1311: }
1312: foreach (sort keys %descriptions) {
1.51 matthew 1313: # onchange is javascript to automatically check the 'Set' button.
1314: my $onchange = 'onchange="javascript:window.document.forms'.
1315: '[\'envform\'].elements[\''.$_.'_setparmval\']'.
1316: '.checked=true;"';
1317: $output.='<tr><td>'.$descriptions{$_}.'</td>'.
1318: '<td><input name="'.$_.'_value" size=40 '.
1319: 'value="'.$values{$_}.'" '.$onchange.' /></td>'.
1320: '<td><input type=checkbox name="'.$_.'_setparmval"></td>'.
1321: '</tr>'."\n";
1322: }
1323: my $onchange = 'onchange="javascript:window.document.forms'.
1324: '[\'envform\'].elements[\'newp_setparmval\']'.
1325: '.checked=true;"';
1326: $output.='<tr><td><i>Create New Environment Variable</i><br />'.
1327: '<input type="text" size=40 name="newp_name" '.
1328: $onchange.' /></td><td>'.
1329: '<input type="text" size=40 name="newp_value" '.
1330: $onchange.' /></td><td>'.
1331: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 1332: }
1.30 www 1333: $r->print(<<ENDENV);
1334: <html>
1.46 matthew 1335: <script type="text/javascript" language="Javascript" >
1336: var editbrowser;
1.47 matthew 1337: function openbrowser(formname,elementname,only,omit) {
1.46 matthew 1338: var url = '/res/?';
1339: if (editbrowser == null) {
1340: url += 'launch=1&';
1341: }
1342: url += 'catalogmode=interactive&';
1343: url += 'mode=parmset&';
1344: url += 'form=' + formname + '&';
1.47 matthew 1345: if (only != null) {
1346: url += 'only=' + only + '&';
1347: }
1348: if (omit != null) {
1349: url += 'omit=' + omit + '&';
1350: }
1.46 matthew 1351: url += 'element=' + elementname + '';
1352: var title = 'Browser';
1353: var options = 'scrollbars=1,resizable=1,menubar=0';
1354: options += ',width=700,height=600';
1355: editbrowser = open(url,title,options,'1');
1356: editbrowser.focus();
1357: }
1358: </script>
1.30 www 1359: <head>
1360: <title>LON-CAPA Course Environment</title>
1361: </head>
1362: <body bgcolor="#FFFFFF">
1363: <h1>Set Course Parameters</h1>
1364: <form method="post" action="/adm/parmset" name="envform">
1365: <h2>Course: $ENV{'course.'.$ENV{'request.course.id'}.'.description'}</h2>
1366: <h3>Course Environment</h3>
1367: $setoutput
1368: <p>
1369: <table border=2>
1370: <tr><th>Parameter</th><th>Value</th><th>Set?</th></tr>
1371: $output
1372: </table>
1373: <input type="submit" name="crsenv" value="Set Course Environment">
1374: </form>
1375: </body>
1376: </html>
1377: ENDENV
1378: }
1379:
1.59 matthew 1380: ##################################################
1381: ##################################################
1.30 www 1382:
1.59 matthew 1383: =pod
1384:
1385: =item handler
1386:
1387: Main handler. Calls &assessparms and &crsenv subroutines.
1388:
1389: =cut
1390:
1391: ##################################################
1392: ##################################################
1.30 www 1393: sub handler {
1.43 albertel 1394: my $r=shift;
1.30 www 1395:
1.43 albertel 1396: if ($r->header_only) {
1397: $r->content_type('text/html');
1398: $r->send_http_header;
1399: return OK;
1400: }
1401: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.30 www 1402: # ----------------------------------------------------- Needs to be in a course
1403:
1.43 albertel 1404: if (($ENV{'request.course.id'}) &&
1405: (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) {
1.57 albertel 1406:
1407: $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1.30 www 1408:
1.43 albertel 1409: unless (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
1.30 www 1410: # --------------------------------------------------------- Bring up assessment
1.43 albertel 1411: &assessparms($r);
1.30 www 1412: # ---------------------------------------------- This is for course environment
1.43 albertel 1413: } else {
1414: &crsenv($r);
1415: }
1416: } else {
1.1 www 1417: # ----------------------------- Not in a course, or not allowed to modify parms
1.43 albertel 1418: $ENV{'user.error.msg'}=
1419: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
1420: return HTTP_NOT_ACCEPTABLE;
1421: }
1422: return OK;
1.1 www 1423: }
1424:
1425: 1;
1426: __END__
1427:
1.59 matthew 1428: =pod
1.38 harris41 1429:
1430: =back
1431:
1432: =cut
1.1 www 1433:
1434:
1435:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>