Annotation of loncom/interface/lonparmset.pm, revision 1.283
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.283 ! albertel 4: # $Id: lonparmset.pm,v 1.282 2006/04/10 21:40:08 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.197 www 65: use Apache::lonnavmaps;
1.1 www 66:
1.198 www 67: # --- Caches local to lonparmset
1.2 www 68:
1.199 www 69: my $parmhashid;
70: my %parmhash;
1.201 www 71: my $symbsid;
72: my %symbs;
1.221 www 73: my $rulesid;
74: my %rules;
1.198 www 75:
76: # --- end local caches
77:
1.59 matthew 78: ##################################################
79: ##################################################
80:
81: =pod
82:
83: =item parmval
84:
85: Figure out a cascading parameter.
86:
1.71 albertel 87: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 88: $id - a bighash Id number
1.71 albertel 89: $def - the resource's default value 'stupid emacs
90:
1.269 raeburn 91: Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels
1.71 albertel 92:
1.269 raeburn 93: 14 - General Course
94: 13 - Map or Folder level in course
95: 12- resource default
96: 11- map default
97: 10 - resource level in course
98: 9 - General for section
99: 8 - Map or Folder level for section
100: 7 - resource level in section
101: 6 - General for group
102: 5 - Map or Folder level for group
103: 4 - resource level in group
1.71 albertel 104: 3 - General for specific student
1.82 www 105: 2 - Map or Folder level for specific student
1.71 albertel 106: 1 - resource level for specific student
1.2 www 107:
1.59 matthew 108: =cut
109:
110: ##################################################
1.2 www 111: sub parmval {
1.275 raeburn 112: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
113: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
114: $cgroup,$courseopt);
1.201 www 115: }
116:
117: sub parmval_by_symb {
1.275 raeburn 118: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.198 www 119: # load caches
1.200 www 120:
1.198 www 121: &cacheparmhash();
1.200 www 122:
123: my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
124:
1.8 www 125: my $result='';
1.44 albertel 126: my @outpar=();
1.2 www 127: # ----------------------------------------------------- Cascading lookup scheme
1.201 www 128: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.10 www 129:
1.201 www 130: my $symbparm=$symb.'.'.$what;
131: my $mapparm=$map.'___(all).'.$what;
1.10 www 132:
1.269 raeburn 133: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
134: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
135: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
136:
1.190 albertel 137: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
138: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
139: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
140:
141: my $courselevel=$env{'request.course.id'}.'.'.$what;
142: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
143: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 144:
1.11 www 145:
1.182 albertel 146: # --------------------------------------------------------- first, check course
1.11 www 147:
1.200 www 148: if (defined($$courseopt{$courselevel})) {
1.269 raeburn 149: $outpar[14]=$$courseopt{$courselevel};
150: $result=14;
1.43 albertel 151: }
1.11 www 152:
1.200 www 153: if (defined($$courseopt{$courselevelm})) {
1.269 raeburn 154: $outpar[13]=$$courseopt{$courselevelm};
155: $result=13;
1.43 albertel 156: }
1.11 www 157:
1.182 albertel 158: # ------------------------------------------------------- second, check default
159:
1.269 raeburn 160: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 161:
162: # ------------------------------------------------------ third, check map parms
163:
164: my $thisparm=$parmhash{$symbparm};
1.269 raeburn 165: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 166:
1.200 www 167: if (defined($$courseopt{$courselevelr})) {
1.269 raeburn 168: $outpar[10]=$$courseopt{$courselevelr};
169: $result=10;
1.43 albertel 170: }
1.11 www 171:
1.182 albertel 172: # ------------------------------------------------------ fourth, back to course
1.71 albertel 173: if (defined($csec)) {
1.200 www 174: if (defined($$courseopt{$seclevel})) {
1.269 raeburn 175: $outpar[9]=$$courseopt{$seclevel};
176: $result=9;
1.43 albertel 177: }
1.200 www 178: if (defined($$courseopt{$seclevelm})) {
1.269 raeburn 179: $outpar[8]=$$courseopt{$seclevelm};
180: $result=8;
1.43 albertel 181: }
182:
1.200 www 183: if (defined($$courseopt{$seclevelr})) {
1.269 raeburn 184: $outpar[7]=$$courseopt{$seclevelr};
185: $result=7;
1.43 albertel 186: }
187: }
1.275 raeburn 188: # ------------------------------------------------------ fifth, check course group
1.269 raeburn 189: if (defined($cgroup)) {
190: if (defined($$courseopt{$grplevel})) {
191: $outpar[6]=$$courseopt{$grplevel};
192: $result=6;
193: }
194: if (defined($$courseopt{$grplevelm})) {
195: $outpar[5]=$$courseopt{$grplevelm};
196: $result=5;
197: }
198: if (defined($$courseopt{$grplevelr})) {
199: $outpar[4]=$$courseopt{$grplevelr};
200: $result=4;
201: }
202: }
1.11 www 203:
1.182 albertel 204: # ---------------------------------------------------------- fifth, check user
1.11 www 205:
1.71 albertel 206: if (defined($uname)) {
1.200 www 207: if (defined($$useropt{$courselevel})) {
208: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 209: $result=3;
210: }
1.10 www 211:
1.200 www 212: if (defined($$useropt{$courselevelm})) {
213: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 214: $result=2;
215: }
1.2 www 216:
1.200 www 217: if (defined($$useropt{$courselevelr})) {
218: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 219: $result=1;
220: }
221: }
1.44 albertel 222: return ($result,@outpar);
1.2 www 223: }
224:
1.198 www 225: sub resetparmhash {
226: $parmhashid='';
227: }
228:
229: sub cacheparmhash {
230: if ($parmhashid eq $env{'request.course.fn'}) { return; }
231: my %parmhashfile;
232: if (tie(%parmhashfile,'GDBM_File',
233: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
234: %parmhash=%parmhashfile;
235: untie %parmhashfile;
236: $parmhashid=$env{'request.course.fn'};
237: }
238: }
239:
1.203 www 240: sub resetsymbcache {
241: $symbsid='';
242: }
243:
1.201 www 244: sub symbcache {
245: my $id=shift;
246: if ($symbsid ne $env{'request.course.id'}) {
247: %symbs=();
248: }
249: unless ($symbs{$id}) {
250: my $navmap = Apache::lonnavmaps::navmap->new();
251: if ($id=~/\./) {
252: my $resource=$navmap->getById($id);
253: $symbs{$id}=$resource->symb();
254: } else {
255: my $resource=$navmap->getByMapPc($id);
256: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
257: }
258: $symbsid=$env{'request.course.id'};
259: }
260: return $symbs{$id};
261: }
262:
1.221 www 263: sub resetrulescache {
264: $rulesid='';
265: }
266:
267: sub rulescache {
268: my $id=shift;
269: if ($rulesid ne $env{'request.course.id'}) {
270: %rules=();
271: }
1.224 www 272: unless (defined($rules{$id})) {
1.221 www 273: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
274: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.224 www 275: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
1.221 www 276: $rulesid=$env{'request.course.id'};
277: }
278: return $rules{$id};
279: }
280:
1.229 www 281: sub preset_defaults {
282: my $type=shift;
283: if (&rulescache($type.'_action') eq 'default') {
284: # yes, there is something
285: return (&rulescache($type.'_hours'),
286: &rulescache($type.'_min'),
287: &rulescache($type.'_sec'),
288: &rulescache($type.'_value'));
289: } else {
290: # nothing there or something else
291: return ('','','','','');
292: }
293: }
294:
1.186 www 295: ##################################################
1.277 www 296:
297: sub date_sanity_info {
298: my $checkdate=shift;
299: unless ($checkdate) { return ''; }
300: my $result='';
301: my $crsprefix='course.'.$env{'request.course.id'}.'.';
302: if ($env{$crsprefix.'default_enrollment_end_date'}) {
303: if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
304: $result.='<br />'.&mt('After course enrollment end!');
305: }
306: }
307: if ($env{$crsprefix.'default_enrollment_start_date'}) {
308: if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
309: $result.='<br />'.&mt('Before course enrollment start!');
310: }
311: }
312: return $result;
313: }
314: ##################################################
1.186 www 315: ##################################################
316: #
1.197 www 317: # Store a parameter by ID
1.186 www 318: #
319: # Takes
320: # - resource id
321: # - name of parameter
322: # - level
323: # - new value
324: # - new type
1.187 www 325: # - username
326: # - userdomain
327:
1.186 www 328: sub storeparm {
1.269 raeburn 329: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 raeburn 330: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 331: }
332:
333: #
334: # Store a parameter by symb
335: #
336: # Takes
337: # - symb
338: # - name of parameter
339: # - level
340: # - new value
341: # - new type
342: # - username
343: # - userdomain
344:
1.226 www 345: my %recstack;
1.197 www 346: sub storeparm_by_symb {
1.275 raeburn 347: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 348: unless ($recflag) {
349: # first time call
350: %recstack=();
351: $recflag=1;
352: }
353: # store parameter
354: &storeparm_by_symb_inner
1.269 raeburn 355: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 356: # don't do anything if parameter was reset
357: unless ($nval) { return; }
1.226 www 358: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
359: # remember that this was set
360: $recstack{$parm}=1;
361: # what does this trigger?
362: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
363: # don't backfire
364: unless ((!$triggered) || ($recstack{$triggered})) {
365: my $action=&rulescache($triggered.'_action');
366: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
367: # set triggered parameter on same level
368: my $newspnam=$prefix.$triggered;
1.227 www 369: my $newvalue='';
1.228 www 370: my $active=1;
371: if ($action=~/^when\_setting/) {
372: # are there restrictions?
373: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
374: $active=0;
375: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
376: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
377: }
378: }
379: $newvalue=&rulescache($triggered.'_value');
1.227 www 380: } else {
381: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
1.228 www 382: if ($action=~/^later\_than/) {
383: $newvalue=$nval+$totalsecs;
384: } else {
385: $newvalue=$nval-$totalsecs;
386: }
387: }
388: if ($active) {
389: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
1.275 raeburn 390: $uname,$udom,$csec,$recflag,$cgroup);
1.227 www 391: }
1.226 www 392: }
393: }
394: return '';
395: }
396:
397: sub storeparm_by_symb_inner {
1.197 www 398: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 399: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 400: # ---------------------------------------------------------- Construct prefixes
1.186 www 401: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 402: my $map=(&Apache::lonnet::decode_symb($symb))[0];
403: my $symbparm=$symb.'.'.$spnam;
404: my $mapparm=$map.'___(all).'.$spnam;
405:
1.269 raeburn 406: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
407: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
408: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
409:
1.190 albertel 410: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
411: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
412: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 413:
1.190 albertel 414: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
415: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
416: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 417:
418: my $storeunder='';
1.269 raeburn 419: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
420: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
421: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
422: if ($snum==9) { $storeunder=$seclevel; }
423: if ($snum==8) { $storeunder=$seclevelm; }
424: if ($snum==7) { $storeunder=$seclevelr; }
425: if ($snum==6) { $storeunder=$grplevel; }
426: if ($snum==5) { $storeunder=$grplevelm; }
427: if ($snum==4) { $storeunder=$grplevelr; }
428:
1.186 www 429:
430: my $delete;
431: if ($nval eq '') { $delete=1;}
432: my %storecontent = ($storeunder => $nval,
433: $storeunder.'.type' => $ntype);
434: my $reply='';
435: if ($snum>3) {
436: # ---------------------------------------------------------------- Store Course
437: #
1.200 www 438: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
439: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 440: # Expire sheets
441: &Apache::lonnet::expirespread('','','studentcalc');
1.269 raeburn 442: if (($snum==10) || ($snum==7) || ($snum==4)) {
1.197 www 443: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.269 raeburn 444: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
1.197 www 445: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 446: } else {
447: &Apache::lonnet::expirespread('','','assesscalc');
448: }
449: # Store parameter
450: if ($delete) {
451: $reply=&Apache::lonnet::del
1.200 www 452: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.186 www 453: } else {
454: $reply=&Apache::lonnet::cput
1.200 www 455: ('resourcedata',\%storecontent,$cdom,$cnum);
1.186 www 456: }
1.200 www 457: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 458: } else {
459: # ------------------------------------------------------------------ Store User
460: #
461: # Expire sheets
462: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
463: if ($snum==1) {
464: &Apache::lonnet::expirespread
1.197 www 465: ($uname,$udom,'assesscalc',$symb);
1.186 www 466: } elsif ($snum==2) {
467: &Apache::lonnet::expirespread
1.197 www 468: ($uname,$udom,'assesscalc',$map);
1.186 www 469: } else {
470: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
471: }
472: # Store parameter
473: if ($delete) {
474: $reply=&Apache::lonnet::del
475: ('resourcedata',[keys(%storecontent)],$udom,$uname);
476: } else {
477: $reply=&Apache::lonnet::cput
478: ('resourcedata',\%storecontent,$udom,$uname);
479: }
1.191 albertel 480: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 481: }
482:
483: if ($reply=~/^error\:(.*)/) {
484: return "<font color=red>Write Error: $1</font>";
485: }
486: return '';
487: }
488:
1.59 matthew 489: ##################################################
490: ##################################################
491:
492: =pod
493:
494: =item valout
495:
496: Format a value for output.
497:
498: Inputs: $value, $type
499:
500: Returns: $value, formatted for output. If $type indicates it is a date,
501: localtime($value) is returned.
1.9 www 502:
1.59 matthew 503: =cut
504:
505: ##################################################
506: ##################################################
1.9 www 507: sub valout {
508: my ($value,$type)=@_;
1.59 matthew 509: my $result = '';
510: # Values of zero are valid.
511: if (! $value && $value ne '0') {
1.71 albertel 512: $result = ' ';
1.59 matthew 513: } else {
1.66 www 514: if ($type eq 'date_interval') {
515: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
516: $year=$year-70;
517: $mday--;
518: if ($year) {
519: $result.=$year.' yrs ';
520: }
521: if ($mon) {
522: $result.=$mon.' mths ';
523: }
524: if ($mday) {
525: $result.=$mday.' days ';
526: }
527: if ($hour) {
528: $result.=$hour.' hrs ';
529: }
530: if ($min) {
531: $result.=$min.' mins ';
532: }
533: if ($sec) {
534: $result.=$sec.' secs ';
535: }
536: $result=~s/\s+$//;
1.213 www 537: } elsif (&isdateparm($type)) {
1.277 www 538: $result = localtime($value).&date_sanity_info($value);
1.59 matthew 539: } else {
540: $result = $value;
541: }
542: }
543: return $result;
1.9 www 544: }
545:
1.59 matthew 546: ##################################################
547: ##################################################
548:
549: =pod
1.5 www 550:
1.59 matthew 551: =item plink
552:
553: Produces a link anchor.
554:
555: Inputs: $type,$dis,$value,$marker,$return,$call
556:
557: Returns: scalar with html code for a link which will envoke the
558: javascript function 'pjump'.
559:
560: =cut
561:
562: ##################################################
563: ##################################################
1.5 www 564: sub plink {
565: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 566: my $winvalue=$value;
567: unless ($winvalue) {
1.213 www 568: if (&isdateparm($type)) {
1.190 albertel 569: $winvalue=$env{'form.recent_'.$type};
1.23 www 570: } else {
1.190 albertel 571: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 572: }
573: }
1.229 www 574: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
575: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
576: unless (defined($winvalue)) { $winvalue=$val; }
1.270 www 577: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.
1.43 albertel 578: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.229 www 579: .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
1.270 www 580: &valout($value,$type).'</a></td></tr></table>';
1.5 www 581: }
582:
1.280 albertel 583: sub page_js {
584:
1.81 www 585: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 586: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.280 albertel 587:
588: return(<<ENDJS);
589: <script type="text/javascript">
1.44 albertel 590:
591: function pclose() {
592: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
593: "height=350,width=350,scrollbars=no,menubar=no");
594: parmwin.close();
595: }
596:
1.88 matthew 597: $pjump_def
1.44 albertel 598:
599: function psub() {
600: pclose();
601: if (document.parmform.pres_marker.value!='') {
602: document.parmform.action+='#'+document.parmform.pres_marker.value;
603: var typedef=new Array();
604: typedef=document.parmform.pres_type.value.split('_');
605: if (document.parmform.pres_type.value!='') {
606: if (typedef[0]=='date') {
607: eval('document.parmform.recent_'+
608: document.parmform.pres_type.value+
609: '.value=document.parmform.pres_value.value;');
610: } else {
611: eval('document.parmform.recent_'+typedef[0]+
612: '.value=document.parmform.pres_value.value;');
613: }
614: }
615: document.parmform.submit();
616: } else {
617: document.parmform.pres_value.value='';
618: document.parmform.pres_marker.value='';
619: }
620: }
621:
1.57 albertel 622: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
623: var options = "width=" + w + ",height=" + h + ",";
624: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
625: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
626: var newWin = window.open(url, wdwName, options);
627: newWin.focus();
628: }
1.44 albertel 629: </script>
1.81 www 630: $selscript
1.280 albertel 631: ENDJS
632:
633: }
634: sub startpage {
635: my ($r) = @_;
1.281 albertel 636:
1.282 albertel 637: my %loaditems = ('onunload' => "pclose()",
1.283 ! albertel 638: 'onload' => "group_or_section('cgroup')",);
1.280 albertel 639:
1.281 albertel 640: my $start_page =
641: &Apache::loncommon::start_page('Set/Modify Course Parameters',
642: &page_js(),
1.282 albertel 643: {'add_entries' => \%loaditems,});
1.280 albertel 644: my $breadcrumbs =
645: &Apache::lonhtmlcommon::breadcrumbs(undef,
646: 'Table Mode Parameter Setting');
647: $r->print(<<ENDHEAD);
1.281 albertel 648: $start_page
1.193 albertel 649: $breadcrumbs
650: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.280 albertel 651: <input type="hidden" value='' name="pres_value" />
652: <input type="hidden" value='' name="pres_type" />
653: <input type="hidden" value='' name="pres_marker" />
654: <input type="hidden" value='1' name="prevvisit" />
1.44 albertel 655: ENDHEAD
656: }
657:
1.209 www 658:
1.44 albertel 659: sub print_row {
1.201 www 660: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.275 raeburn 661: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
662: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
663: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
664: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 665: # get the values for the parameter in cascading order
666: # empty levels will remain empty
1.44 albertel 667: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.275 raeburn 668: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 669: # get the type for the parameters
670: # problem: these may not be set for all levels
671: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 raeburn 672: $$name{$which}.'.type',$rid,
673: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 674: # cascade down manually
1.182 albertel 675: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 676: for (my $i=14;$i>0;$i--) {
1.66 www 677: if ($typeoutpar[$i]) {
678: $cascadetype=$typeoutpar[$i];
679: } else {
680: $typeoutpar[$i]=$cascadetype;
681: }
682: }
1.57 albertel 683: my $parm=$$display{$which};
684:
1.203 www 685: if ($parmlev eq 'full') {
1.57 albertel 686: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
687: .$$part{$which}.'</td>');
688: } else {
689: $parm=~s|\[.*\]\s||g;
690: }
1.231 www 691: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
692: if ($automatic) {
693: $parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>';
694: }
1.159 albertel 695: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 696:
1.44 albertel 697: my $thismarker=$which;
698: $thismarker=~s/^parameter\_//;
699: my $mprefix=$rid.'&'.$thismarker.'&';
1.275 raeburn 700: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
701: my ($othergrp,$grp_parm,$controlgrp);
1.44 albertel 702:
1.57 albertel 703: if ($parmlev eq 'general') {
704:
705: if ($uname) {
1.66 www 706: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 707: } elsif ($cgroup) {
708: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 709: } elsif ($csec) {
1.269 raeburn 710: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 711: } else {
1.269 raeburn 712: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 713: }
714: } elsif ($parmlev eq 'map') {
715:
716: if ($uname) {
1.66 www 717: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 718: } elsif ($cgroup) {
719: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 720: } elsif ($csec) {
1.269 raeburn 721: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 722: } else {
1.269 raeburn 723: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 724: }
725: } else {
1.275 raeburn 726: if ($uname) {
727: if (@{$usersgroups} > 1) {
728: my ($coursereply,$grp_parm,$controlgrp);
729: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
730: &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
731: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
732: if ($coursereply && $result > 3) {
733: if (defined($controlgrp)) {
734: if ($cgroup ne $controlgrp) {
735: $effective_parm = $grp_parm;
736: $result = 0;
737: }
738: }
739: }
740: }
741: }
1.57 albertel 742:
1.269 raeburn 743: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 744:
1.269 raeburn 745: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
746: &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
747: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 748: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
749:
750: if ($csec) {
1.269 raeburn 751: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
752: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
753: &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 754: }
1.269 raeburn 755:
756: if ($cgroup) {
757: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
758: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
759: &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
760: }
1.275 raeburn 761:
1.203 www 762: if ($uname) {
1.275 raeburn 763: if ($othergrp) {
764: $r->print($othergrp);
765: }
1.203 www 766: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
767: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
768: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
769: }
1.57 albertel 770:
771: } # end of $parmlev if/else
1.275 raeburn 772: $r->print('<td bgcolor="#CCCCFF" align="center">'.$effective_parm.'</td>');
1.136 albertel 773:
1.203 www 774: if ($parmlev eq 'full') {
1.136 albertel 775: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 776: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 777: my $sessionvaltype=$typeoutpar[$result];
778: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.275 raeburn 779: $r->print('<td bgcolor="#999999" align="center"><font color="#FFFFFF">'.
1.66 www 780: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 781: '</font></td>');
1.136 albertel 782: }
1.44 albertel 783: $r->print('</tr>');
1.57 albertel 784: $r->print("\n");
1.44 albertel 785: }
1.59 matthew 786:
1.44 albertel 787: sub print_td {
1.66 www 788: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 789: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 790: ' align="center">');
1.269 raeburn 791: if ($which<11 || $which > 12) {
1.114 www 792: $r->print(&plink($$typeoutpar[$which],
793: $$display{$value},$$outpar[$which],
794: $mprefix."$which",'parmform.pres','psub'));
795: } else {
796: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
797: }
798: $r->print('</td>'."\n");
1.57 albertel 799: }
800:
1.275 raeburn 801: sub print_usergroups {
802: my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
803: my $courseid = $env{'request.course.id'};
804: my $output;
805: my $symb = &symbcache($rid);
806: my $symbparm=$symb.'.'.$what;
807: my $map=(&Apache::lonnet::decode_symb($symb))[0];
808: my $mapparm=$map.'___(all).'.$what;
809: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
810: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
811: $courseopt);
812: my $bgcolor = $defbg;
813: my $grp_parm;
814: if (($coursereply) && ($cgroup ne $resultgroup)) {
815: if ($result > 3) {
816: $bgcolor = '"#AAFFAA"';
817: $grp_parm = &valout($coursereply,$resulttype);
818: }
819: $grp_parm = &valout($coursereply,$resulttype);
820: $output = '<td bgcolor='.$bgcolor.' align="center">';
821: if ($resultgroup && $resultlevel) {
822: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
823: } else {
824: $output .= ' ';
825: }
826: $output .= '</td>';
827: } else {
828: $output .= '<td bgcolor='.$bgcolor.'> </td>';
829: }
830: return ($coursereply,$output,$grp_parm,$resultgroup);
831: }
832:
833: sub parm_control_group {
834: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
835: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
836: my $grpfound = 0;
837: my @levels = ($symbparm,$mapparm,$what);
838: my @levelnames = ('resource','map/folder','general');
839: foreach my $group (@{$usersgroups}) {
840: if ($grpfound) { last; }
841: for (my $i=0; $i<@levels; $i++) {
842: my $item = $courseid.'.['.$group.'].'.$levels[$i];
843: if (defined($$courseopt{$item})) {
844: $coursereply = $$courseopt{$item};
845: $resultitem = $item;
846: $resultgroup = $group;
847: $resultlevel = $levelnames[$i];
848: $resulttype = $$courseopt{$item.'.type'};
849: $grpfound = 1;
850: last;
851: }
852: }
853: }
854: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
855: }
1.201 www 856:
1.63 bowersj2 857: =pod
858:
859: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
860:
861: Input: See list below:
862:
863: =over 4
864:
865: =item B<ids>: An array that will contain all of the ids in the course.
866:
867: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
868:
1.171 www 869: =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 870:
871: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
872:
873: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
874:
875: =item B<allkeys>: hash, full key to part->display value (what's display value?)
876:
877: =item B<allmaps>: hash, ???
878:
879: =item B<fcat>: ???
880:
881: =item B<defp>: hash, ???
882:
883: =item B<mapp>: ??
884:
885: =item B<symbp>: hash, id->full sym?
886:
887: =back
888:
889: =cut
890:
891: sub extractResourceInformation {
892: my $ids = shift;
893: my $typep = shift;
894: my $keyp = shift;
895: my $allparms = shift;
896: my $allparts = shift;
897: my $allmaps = shift;
898: my $mapp = shift;
899: my $symbp = shift;
1.82 www 900: my $maptitles=shift;
1.196 www 901: my $uris=shift;
1.210 www 902: my $keyorder=shift;
1.211 www 903: my $defkeytype=shift;
1.196 www 904:
1.210 www 905: my $keyordercnt=100;
1.63 bowersj2 906:
1.196 www 907: my $navmap = Apache::lonnavmaps::navmap->new();
908: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
909: foreach my $resource (@allres) {
910: my $id=$resource->id();
911: my ($mapid,$resid)=split(/\./,$id);
912: if ($mapid eq '0') { next; }
913: $$ids[$#$ids+1]=$id;
914: my $srcf=$resource->src();
915: $srcf=~/\.(\w+)$/;
916: $$typep{$id}=$1;
917: $$keyp{$id}='';
918: $$uris{$id}=$srcf;
919: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
920: if ($_=~/^parameter\_(.*)/) {
921: my $key=$_;
1.209 www 922: # Hidden parameters
923: if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
924: next;
1.63 bowersj2 925: }
1.196 www 926: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
927: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
928: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.209 www 929: #
930: # allparms is a hash of parameter names
931: #
1.196 www 932: my $parmdis = $display;
1.209 www 933: $parmdis =~ s/\[Part.*$//g;
934: $$allparms{$name}=$parmdis;
1.211 www 935: $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
1.209 www 936: #
937: # allparts is a hash of all parts
938: #
939: $$allparts{$part} = "Part: $part";
940: #
941: # Remember all keys going with this resource
942: #
1.196 www 943: if ($$keyp{$id}) {
944: $$keyp{$id}.=','.$key;
1.175 albertel 945: } else {
1.196 www 946: $$keyp{$id}=$key;
1.175 albertel 947: }
1.210 www 948: #
949: # Put in order
950: #
951: unless ($$keyorder{$key}) {
952: $$keyorder{$key}=$keyordercnt;
953: $keyordercnt++;
954: }
955:
1.63 bowersj2 956: }
957: }
1.196 www 958: $$mapp{$id}=
959: &Apache::lonnet::declutter($resource->enclosing_map_src());
960: $$mapp{$mapid}=$$mapp{$id};
961: $$allmaps{$mapid}=$$mapp{$id};
962: if ($mapid eq '1') {
963: $$maptitles{$mapid}='Main Course Documents';
964: } else {
965: $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
966: }
967: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
968: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
969: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.63 bowersj2 970: }
971: }
972:
1.208 www 973:
974: ##################################################
975: ##################################################
976:
1.213 www 977: sub isdateparm {
978: my $type=shift;
979: return (($type=~/^date/) && (!($type eq 'date_interval')));
980: }
981:
1.208 www 982: sub parmmenu {
1.211 www 983: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 984: my $tempkey;
985: $r->print(<<ENDSCRIPT);
986: <script type="text/javascript">
987: function checkall(value, checkName) {
988: for (i=0; i<document.forms.parmform.elements.length; i++) {
989: ele = document.forms.parmform.elements[i];
990: if (ele.name == checkName) {
991: document.forms.parmform.elements[i].checked=value;
992: }
993: }
994: }
1.210 www 995:
996: function checkthis(thisvalue, checkName) {
997: for (i=0; i<document.forms.parmform.elements.length; i++) {
998: ele = document.forms.parmform.elements[i];
999: if (ele.name == checkName) {
1000: if (ele.value == thisvalue) {
1001: document.forms.parmform.elements[i].checked=true;
1002: }
1003: }
1004: }
1005: }
1006:
1007: function checkdates() {
1008: checkthis('duedate','pscat');
1009: checkthis('opendate','pscat');
1010: checkthis('answerdate','pscat');
1.218 www 1011: }
1012:
1013: function checkdisset() {
1014: checkthis('discussend','pscat');
1015: checkthis('discusshide','pscat');
1016: }
1017:
1018: function checkcontdates() {
1019: checkthis('contentopen','pscat');
1020: checkthis('contentclose','pscat');
1021: }
1022:
1.210 www 1023:
1024: function checkvisi() {
1025: checkthis('hiddenresource','pscat');
1026: checkthis('encrypturl','pscat');
1027: checkthis('problemstatus','pscat');
1028: checkthis('contentopen','pscat');
1029: checkthis('opendate','pscat');
1030: }
1031:
1032: function checkparts() {
1033: checkthis('hiddenparts','pscat');
1034: checkthis('display','pscat');
1035: checkthis('ordered','pscat');
1036: }
1037:
1038: function checkstandard() {
1039: checkall(false,'pscat');
1040: checkdates();
1041: checkthis('weight','pscat');
1042: checkthis('maxtries','pscat');
1043: }
1044:
1.208 www 1045: </script>
1046: ENDSCRIPT
1.209 www 1047: $r->print();
1.208 www 1048: $r->print("\n<table><tr>");
1049: my $cnt=0;
1.211 www 1050: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.235 albertel 1051: $r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' ");
1.208 www 1052: $r->print('value="'.$tempkey.'"');
1053: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1054: $r->print(' checked');
1055: }
1.235 albertel 1056: $r->print('>'.$$allparms{$tempkey}.'</label></font></td>');
1.209 www 1057: $cnt++;
1058: if ($cnt==3) {
1059: $r->print("</tr>\n<tr>");
1060: $cnt=0;
1061: }
1.208 www 1062: }
1063: $r->print('
1064: </tr><tr><td>
1.233 albertel 1065: <a href="javascript:checkall(true, \'pscat\')">Select All</a><br />
1066: <a href="javascript:checkstandard()">Select Common Only</a>
1.210 www 1067: </td><td>
1.233 albertel 1068: <a href="javascript:checkdates()">Add Problem Dates</a>
1069: <a href="javascript:checkcontdates()">Add Content Dates</a><br />
1070: <a href="javascript:checkdisset()">Add Discussion Settings</a>
1071: <a href="javascript:checkvisi()">Add Visibilities</a><br />
1072: <a href="javascript:checkparts()">Add Part Parameters</a>
1.210 www 1073: </td><td>
1.233 albertel 1074: <a href="javascript:checkall(false, \'pscat\')">Unselect All</a>
1.208 www 1075: </td>
1076: ');
1077: $r->print('</tr></table>');
1078: }
1079:
1.209 www 1080: sub partmenu {
1081: my ($r,$allparts,$psprt)=@_;
1.211 www 1082: $r->print('<select multiple name="psprt" size="8">');
1.208 www 1083: $r->print('<option value="all"');
1084: $r->print(' selected') unless (@{$psprt});
1085: $r->print('>'.&mt('All Parts').'</option>');
1086: my %temphash=();
1087: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1088: foreach my $tempkey (sort {
1089: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1090: } keys(%{$allparts})) {
1.208 www 1091: unless ($tempkey =~ /\./) {
1092: $r->print('<option value="'.$tempkey.'"');
1093: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1094: $r->print(' selected');
1095: }
1096: $r->print('>'.$$allparts{$tempkey}.'</option>');
1097: }
1098: }
1.209 www 1099: $r->print('</select>');
1100: }
1101:
1102: sub usermenu {
1.275 raeburn 1103: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1104: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1105: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1106: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1107: my %lt=&Apache::lonlocal::texthash(
1.269 raeburn 1108: 'se' => "Section",
1109: 'gr' => "Group",
1.209 www 1110: 'fu' => "For User",
1111: 'oi' => "or ID",
1112: 'ad' => "at Domain"
1113: );
1114: my %sectionhash=();
1115: my $sections='';
1.269 raeburn 1116: my $numsec = &Apache::loncommon::get_sections(
1.209 www 1117: $env{'course.'.$env{'request.course.id'}.'.domain'},
1118: $env{'course.'.$env{'request.course.id'}.'.num'},
1.269 raeburn 1119: \%sectionhash);
1120: my $groups;
1121: my %grouphash;
1122: my $numgrp = &Apache::loncommon::coursegroups(
1123: \%grouphash,
1124: $env{'course.'.$env{'request.course.id'}.'.domain'},
1125: $env{'course.'.$env{'request.course.id'}.'.num'});
1126: if ($numsec > 0) {
1127: $sections=$lt{'se'}.': <select name="csec"';
1128: if ($numsec && $numgrp && $parmlev ne 'full') {
1129: $sections .= qq| onchange="group_or_section('csec')" |;
1130: }
1131: $sections .= '>';
1.275 raeburn 1132: foreach my $section ('',sort keys %sectionhash) {
1133: $sections.='<option value="'.$section.'" '.
1134: ($section eq $csec?'selected="selected"':'').'>'.$section.
1135: '</option>';
1.209 www 1136: }
1137: $sections.='</select>';
1.269 raeburn 1138: }
1139: if ($numsec && $numgrp && $parmlev ne 'full') {
1140: $sections .= ' or ';
1141: $sections .= qq|
1142: <script type="text/javascript">
1143: function group_or_section(caller) {
1144: if (caller == "cgroup") {
1145: if (document.parmform.cgroup.selectedIndex != 0) {
1146: document.parmform.csec.selectedIndex = 0;
1147: }
1148: } else {
1149: if (document.parmform.csec.selectedIndex != 0) {
1150: document.parmform.cgroup.selectedIndex = 0;
1151: }
1152: }
1153: }
1154: </script>
1155: |;
1156: } else {
1157: $sections .= qq|
1158: <script type="text/javascript">
1159: function group_or_section(caller) {
1160: return;
1161: }
1162: </script>
1163: |;
1164: }
1165: if ($numgrp > 0) {
1166: $groups=$lt{'gr'}.': <select name="cgroup"';
1167: if ($numsec && $numgrp && $env{'form.action'} eq 'settable') {
1168: $groups .= qq| onchange="group_or_section('cgroup')" |;
1169: }
1170: $groups .= '>';
1.275 raeburn 1171: foreach my $grp ('',sort keys %grouphash) {
1172: $groups.='<option value="'.$grp.'" ';
1173: if ($grp eq $cgroup) {
1174: unless ((defined($uname)) && ($grp eq '')) {
1175: $groups .= 'selected="selected" ';
1176: }
1177: } elsif (!defined($cgroup)) {
1178: if (@{$usersgroups} == 1) {
1179: if ($grp eq $$usersgroups[0]) {
1180: $groups .= 'selected="selected" ';
1181: }
1182: }
1183: }
1184: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1185: }
1186: $groups.='</select>';
1187: }
1188: $r->print(<<ENDMENU);
1.209 www 1189: <b>
1190: $sections
1.269 raeburn 1191: $groups
1.209 www 1192: <br />
1193: $lt{'fu'}
1194: <input type="text" value="$uname" size="12" name="uname" />
1195: $lt{'oi'}
1196: <input type="text" value="$id" size="12" name="id" />
1197: $lt{'ad'}
1198: $chooseopt
1199: </b>
1200: ENDMENU
1201: }
1202:
1203: sub displaymenu {
1.211 www 1204: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1205: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1206: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1207: &parmmenu($r,$allparms,$pscat,$keyorder);
1.209 www 1208: $r->print('</td><td>');
1209: &partmenu($r,$allparts,$psprt);
1210: $r->print('</td></tr></table>');
1211: }
1212:
1213: sub mapmenu {
1214: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1215: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1216: $r->print('<select name="pschp">');
1217: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1218: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1219: $r->print('<option value="'.$_.'"');
1.209 www 1220: if (($pschp eq $_)) { $r->print(' selected'); }
1221: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1222: }
1223: $r->print("</select>");
1224: }
1225:
1226: sub levelmenu {
1227: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1228: $r->print('<b>'.&mt('Select Parameter Level').
1229: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1230: $r->print('<select name="parmlev">');
1231: foreach (reverse sort keys %{$alllevs}) {
1232: $r->print('<option value="'.$$alllevs{$_}.'"');
1233: if ($parmlev eq $$alllevs{$_}) {
1234: $r->print(' selected');
1235: }
1236: $r->print('>'.$_.'</option>');
1.208 www 1237: }
1.209 www 1238: $r->print("</select>");
1.208 www 1239: }
1240:
1.211 www 1241:
1242: sub sectionmenu {
1243: my ($r,$selectedsections)=@_;
1.212 www 1244: my %sectionhash=();
1.269 raeburn 1245: my $sections='';
1246: my $numsec = &Apache::loncommon::get_sections(
1.212 www 1247: $env{'course.'.$env{'request.course.id'}.'.domain'},
1248: $env{'course.'.$env{'request.course.id'}.'.num'},
1.269 raeburn 1249: \%sectionhash);
1250: if ($numsec) {
1.212 www 1251: $r->print('<select name="Section" multiple="true" size="8" >');
1252: foreach my $s ('all',sort keys %sectionhash) {
1253: $r->print(' <option value="'.$s.'"');
1254: foreach (@{$selectedsections}) {
1255: if ($s eq $_) {
1256: $r->print(' selected');
1257: last;
1258: }
1259: }
1260: $r->print('>'.$s."</option>\n");
1261: }
1.269 raeburn 1262: $r->print("</select>\n");
1263: }
1264: }
1265:
1266: sub groupmenu {
1267: my ($r,$selectedgroups)=@_;
1268: my %grouphash;
1269: my $numgrp = &Apache::loncommon::coursegroups(
1270: \%grouphash,
1271: $env{'course.'.$env{'request.course.id'}.'.domain'},
1272: $env{'course.'.$env{'request.course.id'}.'.num'});
1273: if ($numgrp) {
1274: $r->print('<select name="Group" multiple="true" size="8" >');
1275: foreach my $group (sort(keys(%grouphash))) {
1276: $r->print(' <option value="'.$group.'"');
1277: foreach (@{$selectedgroups}) {
1278: if ($group eq $_) {
1279: $r->print(' selected');
1280: last;
1281: }
1282: }
1283: $r->print('>'.$group."</option>\n");
1284: }
1285: $r->print("</select>\n");
1.211 www 1286: }
1287: }
1288:
1.269 raeburn 1289:
1.210 www 1290: sub keysplit {
1291: my $keyp=shift;
1292: return (split(/\,/,$keyp));
1293: }
1294:
1295: sub keysinorder {
1296: my ($name,$keyorder)=@_;
1297: return sort {
1298: $$keyorder{$a} <=> $$keyorder{$b};
1299: } (keys %{$name});
1300: }
1301:
1.236 albertel 1302: sub keysinorder_bytype {
1303: my ($name,$keyorder)=@_;
1304: return sort {
1305: my $ta=(split('_',$a))[-1];
1306: my $tb=(split('_',$b))[-1];
1307: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1308: return ($a cmp $b);
1309: }
1310: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1311: } (keys %{$name});
1312: }
1313:
1.211 www 1314: sub keysindisplayorder {
1315: my ($name,$keyorder)=@_;
1316: return sort {
1317: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1318: } (keys %{$name});
1319: }
1320:
1.214 www 1321: sub sortmenu {
1322: my ($r,$sortorder)=@_;
1.236 albertel 1323: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1324: if ($sortorder eq 'realmstudent') {
1325: $r->print(' checked="on"');
1326: }
1327: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1328: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1329: if ($sortorder eq 'studentrealm') {
1330: $r->print(' checked="on"');
1331: }
1.236 albertel 1332: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1333: '</label>');
1.214 www 1334: }
1335:
1.211 www 1336: sub standardkeyorder {
1337: return ('parameter_0_opendate' => 1,
1338: 'parameter_0_duedate' => 2,
1339: 'parameter_0_answerdate' => 3,
1340: 'parameter_0_interval' => 4,
1341: 'parameter_0_weight' => 5,
1342: 'parameter_0_maxtries' => 6,
1343: 'parameter_0_hinttries' => 7,
1344: 'parameter_0_contentopen' => 8,
1345: 'parameter_0_contentclose' => 9,
1346: 'parameter_0_type' => 10,
1347: 'parameter_0_problemstatus' => 11,
1348: 'parameter_0_hiddenresource' => 12,
1349: 'parameter_0_hiddenparts' => 13,
1350: 'parameter_0_display' => 14,
1351: 'parameter_0_ordered' => 15,
1352: 'parameter_0_tol' => 16,
1353: 'parameter_0_sig' => 17,
1.218 www 1354: 'parameter_0_turnoffunit' => 18,
1355: 'parameter_0_discussend' => 19,
1356: 'parameter_0_discusshide' => 20);
1.211 www 1357: }
1358:
1.59 matthew 1359: ##################################################
1360: ##################################################
1361:
1362: =pod
1363:
1364: =item assessparms
1365:
1366: Show assessment data and parameters. This is a large routine that should
1367: be simplified and shortened... someday.
1368:
1369: Inputs: $r
1370:
1371: Returns: nothing
1372:
1.63 bowersj2 1373: Variables used (guessed by Jeremy):
1374:
1375: =over 4
1376:
1377: =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.
1378:
1379: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
1380:
1381: =item B<allmaps>:
1382:
1383: =back
1384:
1.59 matthew 1385: =cut
1386:
1387: ##################################################
1388: ##################################################
1.30 www 1389: sub assessparms {
1.1 www 1390:
1.43 albertel 1391: my $r=shift;
1.201 www 1392:
1393: my @ids=();
1394: my %symbp=();
1395: my %mapp=();
1396: my %typep=();
1397: my %keyp=();
1398: my %uris=();
1399: my %maptitles=();
1400:
1.2 www 1401: # -------------------------------------------------------- Variable declaration
1.209 www 1402:
1.129 www 1403: my %allmaps=();
1404: my %alllevs=();
1.57 albertel 1405:
1.187 www 1406: my $uname;
1407: my $udom;
1408: my $uhome;
1409: my $csec;
1.269 raeburn 1410: my $cgroup;
1.275 raeburn 1411: my $grouplist;
1412: my @usersgroups = ();
1.187 www 1413:
1.190 albertel 1414: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1415:
1.57 albertel 1416: $alllevs{'Resource Level'}='full';
1.215 www 1417: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1418: $alllevs{'Course Level'}='general';
1419:
1420: my %allparms;
1421: my %allparts;
1.210 www 1422: #
1423: # Order in which these parameters will be displayed
1424: #
1.211 www 1425: my %keyorder=&standardkeyorder();
1426:
1.43 albertel 1427: @ids=();
1428: %symbp=();
1429: %typep=();
1430:
1431: my $message='';
1432:
1.190 albertel 1433: $csec=$env{'form.csec'};
1.269 raeburn 1434: $cgroup=$env{'form.cgroup'};
1.188 www 1435:
1.190 albertel 1436: if ($udom=$env{'form.udom'}) {
1437: } elsif ($udom=$env{'request.role.domain'}) {
1438: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1439: } else {
1440: $udom=$r->dir_config('lonDefDomain');
1441: }
1.43 albertel 1442:
1.134 albertel 1443: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1444: my $pschp=$env{'form.pschp'};
1.134 albertel 1445: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1446: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1447:
1.43 albertel 1448: my $pssymb='';
1.57 albertel 1449: my $parmlev='';
1450:
1.190 albertel 1451: unless ($env{'form.parmlev'}) {
1.57 albertel 1452: $parmlev = 'map';
1453: } else {
1.190 albertel 1454: $parmlev = $env{'form.parmlev'};
1.57 albertel 1455: }
1.26 www 1456:
1.29 www 1457: # ----------------------------------------------- Was this started from grades?
1458:
1.190 albertel 1459: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1460: && (!$env{'form.dis'})) {
1461: my $url=$env{'form.url'};
1.194 albertel 1462: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1463: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1464: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1465: $pschp='';
1.57 albertel 1466: $parmlev = 'full';
1.190 albertel 1467: } elsif ($env{'form.symb'}) {
1468: $pssymb=$env{'form.symb'};
1.92 albertel 1469: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1470: $pschp='';
1.57 albertel 1471: $parmlev = 'full';
1.43 albertel 1472: } else {
1.190 albertel 1473: $env{'form.url'}='';
1.43 albertel 1474: }
1475:
1.190 albertel 1476: my $id=$env{'form.id'};
1.43 albertel 1477: if (($id) && ($udom)) {
1478: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1479: if ($uname) {
1480: $id='';
1481: } else {
1482: $message=
1.133 www 1483: "<font color=red>".&mt("Unknown ID")." '$id' ".
1484: &mt('at domain')." '$udom'</font>";
1.43 albertel 1485: }
1486: } else {
1.190 albertel 1487: $uname=$env{'form.uname'};
1.43 albertel 1488: }
1489: unless ($udom) { $uname=''; }
1490: $uhome='';
1491: if ($uname) {
1492: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1493: if ($uhome eq 'no_host') {
1494: $message=
1.133 www 1495: "<font color=red>".&mt("Unknown user")." '$uname' ".
1496: &mt("at domain")." '$udom'</font>";
1.43 albertel 1497: $uname='';
1.12 www 1498: } else {
1.103 albertel 1499: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1500: $env{'request.course.id'});
1.269 raeburn 1501:
1.43 albertel 1502: if ($csec eq '-1') {
1503: $message="<font color=red>".
1.133 www 1504: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1505: &mt("not in this course")."</font>";
1.43 albertel 1506: $uname='';
1.190 albertel 1507: $csec=$env{'form.csec'};
1.269 raeburn 1508: $cgroup=$env{'form.cgroup'};
1.43 albertel 1509: } else {
1510: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1511: ('firstname','middlename','lastname','generation','id'));
1.133 www 1512: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1513: $name{'firstname'}.' '.$name{'middlename'}.' '
1514: .$name{'lastname'}.' '.$name{'generation'}.
1.133 www 1515: "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1516: }
1.275 raeburn 1517: $grouplist = &Apache::lonnet::get_users_groups(
1518: $udom,$uname,$env{'request.course.id'});
1.269 raeburn 1519: if ($grouplist) {
1.275 raeburn 1520: @usersgroups = &Apache::lonnet::sort_course_groups($grouplist,
1521: $env{'request.course.id'});
1522: unless (grep/^\Q$cgroup\E$/,@usersgroups) {
1523: $cgroup = $usersgroups[0];
1524: }
1525: } else {
1526: $cgroup = '';
1.269 raeburn 1527: }
1.12 www 1528: }
1.43 albertel 1529: }
1.2 www 1530:
1.43 albertel 1531: unless ($csec) { $csec=''; }
1.269 raeburn 1532: unless ($cgroup) { $cgroup=''; }
1.12 www 1533:
1.14 www 1534: # --------------------------------------------------------- Get all assessments
1.210 www 1535: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1536: \%mapp, \%symbp,\%maptitles,\%uris,
1537: \%keyorder);
1.63 bowersj2 1538:
1.57 albertel 1539: $mapp{'0.0'} = '';
1540: $symbp{'0.0'} = '';
1.99 albertel 1541:
1.14 www 1542: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1543: if ($env{'form.pres_marker'}) {
1.205 www 1544: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1545: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1546: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1547: for (my $i=0;$i<=$#markers;$i++) {
1548: $message.=&storeparm(split(/\&/,$markers[$i]),
1549: $values[$i],
1550: $types[$i],
1.269 raeburn 1551: $uname,$udom,$csec,$cgroup);
1.205 www 1552: }
1.68 www 1553: # ---------------------------------------------------------------- Done storing
1.130 www 1554: $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 1555: }
1.57 albertel 1556: #----------------------------------------------- if all selected, fill in array
1.209 www 1557: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1558: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1559: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1560: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1561:
1.209 www 1562: &startpage($r);
1.57 albertel 1563:
1.44 albertel 1564: foreach ('tolerance','date_default','date_start','date_end',
1565: 'date_interval','int','float','string') {
1566: $r->print('<input type="hidden" value="'.
1.190 albertel 1567: $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
1.44 albertel 1568: }
1.57 albertel 1569:
1.44 albertel 1570: if (!$pssymb) {
1.209 www 1571: $r->print('<table border="1"><tr><td>');
1572: &levelmenu($r,\%alllevs,$parmlev);
1.128 albertel 1573: if ($parmlev ne 'general') {
1.209 www 1574: $r->print('<td>');
1575: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1576: $r->print('</td>');
1.128 albertel 1577: }
1.209 www 1578: $r->print('</td></tr></table>');
1.211 www 1579: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1580: } else {
1.125 www 1581: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.209 www 1582: $r->print(&mt('Specific Resource').": ".$resource.
1.238 www 1583: '<input type="hidden" value="'.$pssymb.'" name="symb">'.
1584: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1585: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1586: }
1.275 raeburn 1587: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.57 albertel 1588:
1.210 www 1589: $r->print('<p>'.$message.'</p>');
1590:
1.209 www 1591: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1592:
1593: my @temp_pscat;
1594: map {
1595: my $cat = $_;
1596: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1597: } @pscat;
1598:
1599: @pscat = @temp_pscat;
1600:
1.209 www 1601: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1602: # ----------------------------------------------------------------- Start Table
1.57 albertel 1603: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1604: my $csuname=$env{'user.name'};
1605: my $csudom=$env{'user.domain'};
1.57 albertel 1606:
1.203 www 1607: if ($parmlev eq 'full') {
1.57 albertel 1608: my $coursespan=$csec?8:5;
1.275 raeburn 1609: my $userspan=3;
1.269 raeburn 1610: if ($cgroup ne '') {
1611: $coursespan += 3;
1612: }
1613:
1.57 albertel 1614: $r->print('<p><table border=2>');
1615: $r->print('<tr><td colspan=5></td>');
1.130 www 1616: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1617: if ($uname) {
1.275 raeburn 1618: if (@usersgroups > 1) {
1619: $userspan ++;
1620: }
1621: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1622: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1623: }
1.133 www 1624: my %lt=&Apache::lonlocal::texthash(
1625: 'pie' => "Parameter in Effect",
1626: 'csv' => "Current Session Value",
1627: 'at' => 'at',
1628: 'rl' => "Resource Level",
1629: 'ic' => 'in Course',
1630: 'aut' => "Assessment URL and Title",
1.143 albertel 1631: 'type' => 'Type',
1.133 www 1632: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1633: 'part' => 'Part',
1.133 www 1634: 'pn' => 'Parameter Name',
1635: 'def' => 'default',
1636: 'femof' => 'from Enclosing Map or Folder',
1637: 'gen' => 'general',
1638: 'foremf' => 'for Enclosing Map or Folder',
1639: 'fr' => 'for Resource'
1640: );
1.57 albertel 1641: $r->print(<<ENDTABLETWO);
1.133 www 1642: <th rowspan=3>$lt{'pie'}</th>
1643: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1644: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1645: <th colspan=1>$lt{'ic'}</th>
1646:
1.10 www 1647: ENDTABLETWO
1.57 albertel 1648: if ($csec) {
1.133 www 1649: $r->print("<th colspan=3>".
1.269 raeburn 1650: &mt("in Section")." $csec</th>");
1651: }
1652: if ($cgroup) {
1653: $r->print("<th colspan=3>".
1654: &mt("in Group")." $cgroup</th>");
1.57 albertel 1655: }
1656: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1657: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1658: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1659: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1660: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1661: ENDTABLEHEADFOUR
1.57 albertel 1662:
1663: if ($csec) {
1.130 www 1664: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1665: }
1666:
1.269 raeburn 1667: if ($cgroup) {
1668: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1669: }
1670:
1.57 albertel 1671: if ($uname) {
1.275 raeburn 1672: if (@usersgroups > 1) {
1673: $r->print('<th>'.&mt('Control by other group?').'</th>');
1674: }
1.130 www 1675: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1676: }
1677:
1678: $r->print('</tr>');
1679:
1680: my $defbgone='';
1681: my $defbgtwo='';
1.269 raeburn 1682: my $defbgthree = '';
1.57 albertel 1683:
1684: foreach (@ids) {
1685:
1686: my $rid=$_;
1687: my ($inmapid)=($rid=~/\.(\d+)$/);
1688:
1.152 albertel 1689: if ((!$pssymb &&
1690: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1691: ||
1692: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1693: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1694: if ($defbgone eq '"#E0E099"') {
1695: $defbgone='"#E0E0DD"';
1.57 albertel 1696: } else {
1.184 albertel 1697: $defbgone='"#E0E099"';
1.57 albertel 1698: }
1.184 albertel 1699: if ($defbgtwo eq '"#FFFF99"') {
1700: $defbgtwo='"#FFFFDD"';
1.57 albertel 1701: } else {
1.184 albertel 1702: $defbgtwo='"#FFFF99"';
1.57 albertel 1703: }
1.269 raeburn 1704: if ($defbgthree eq '"#FFBB99"') {
1705: $defbgthree='"#FFBBDD"';
1706: } else {
1707: $defbgthree='"#FFBB99"';
1708: }
1709:
1.57 albertel 1710: my $thistitle='';
1711: my %name= ();
1712: undef %name;
1713: my %part= ();
1714: my %display=();
1715: my %type= ();
1716: my %default=();
1.196 www 1717: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1718:
1.210 www 1719: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1720: my $tempkeyp = $_;
1721: if (grep $_ eq $tempkeyp, @catmarker) {
1722: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1723: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1724: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1725: unless ($display{$_}) { $display{$_}=''; }
1726: $display{$_}.=' ('.$name{$_}.')';
1727: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1728: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1729: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1730: }
1731: }
1732: my $totalparms=scalar keys %name;
1733: if ($totalparms>0) {
1734: my $firstrow=1;
1.274 albertel 1735: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.57 albertel 1736: $r->print('<tr><td bgcolor='.$defbgone.
1737: ' rowspan='.$totalparms.
1738: '><tt><font size=-1>'.
1739: join(' / ',split(/\//,$uri)).
1740: '</font></tt><p><b>'.
1.154 albertel 1741: "<a href=\"javascript:openWindow('".
1.274 albertel 1742: &Apache::lonnet::clutter($uri).'?symb='.
1743: &Apache::lonnet::escape($symbp{$rid}).
1.57 albertel 1744: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1.127 albertel 1745: " TARGET=_self>$title");
1.57 albertel 1746:
1747: if ($thistitle) {
1748: $r->print(' ('.$thistitle.')');
1749: }
1750: $r->print('</a></b></td>');
1751: $r->print('<td bgcolor='.$defbgtwo.
1752: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1753: '</td>');
1754:
1755: $r->print('<td bgcolor='.$defbgone.
1756: ' rowspan='.$totalparms.
1.238 www 1757: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 1758:
1.236 albertel 1759: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 1760: unless ($firstrow) {
1761: $r->print('<tr>');
1762: } else {
1763: undef $firstrow;
1764: }
1.201 www 1765: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 1766: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 1767: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 1768: $cgroup,\@usersgroups);
1.57 albertel 1769: }
1770: }
1771: }
1772: } # end foreach ids
1.43 albertel 1773: # -------------------------------------------------- End entry for one resource
1.57 albertel 1774: $r->print('</table>');
1.203 www 1775: } # end of full
1.57 albertel 1776: #--------------------------------------------------- Entry for parm level map
1777: if ($parmlev eq 'map') {
1778: my $defbgone = '"E0E099"';
1779: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1780: my $defbgthree = '"FFBB99"';
1.57 albertel 1781:
1782: my %maplist;
1783:
1784: if ($pschp eq 'all') {
1785: %maplist = %allmaps;
1786: } else {
1787: %maplist = ($pschp => $mapp{$pschp});
1788: }
1789:
1790: #-------------------------------------------- for each map, gather information
1791: my $mapid;
1.60 albertel 1792: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1793: my $maptitle = $maplist{$mapid};
1.57 albertel 1794:
1795: #----------------------- loop through ids and get all parameter types for map
1796: #----------------------------------------- and associated information
1797: my %name = ();
1798: my %part = ();
1799: my %display = ();
1800: my %type = ();
1801: my %default = ();
1802: my $map = 0;
1803:
1804: # $r->print("Catmarker: @catmarker<br />\n");
1805:
1806: foreach (@ids) {
1807: ($map)=(/([\d]*?)\./);
1808: my $rid = $_;
1809:
1810: # $r->print("$mapid:$map: $rid <br /> \n");
1811:
1812: if ($map eq $mapid) {
1.196 www 1813: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1814: # $r->print("Keys: $keyp{$rid} <br />\n");
1815:
1816: #--------------------------------------------------------------------
1817: # @catmarker contains list of all possible parameters including part #s
1818: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1819: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1820: # When storing information, store as part 0
1821: # When requesting information, request from full part
1822: #-------------------------------------------------------------------
1.210 www 1823: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1824: my $tempkeyp = $_;
1825: my $fullkeyp = $tempkeyp;
1.73 albertel 1826: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1827:
1828: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1829: $part{$tempkeyp}="0";
1830: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1831: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1832: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1833: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1834: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1835: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1836: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1837: }
1838: } # end loop through keys
1839: }
1840: } # end loop through ids
1841:
1842: #---------------------------------------------------- print header information
1.133 www 1843: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1844: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1845: $r->print(<<ENDMAPONE);
1846: <center><h4>
1.135 albertel 1847: Set Defaults for All Resources in $foldermap<br />
1848: <font color="red"><i>$showtitle</i></font><br />
1.57 albertel 1849: Specifically for
1850: ENDMAPONE
1851: if ($uname) {
1.267 albertel 1852: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 1853: $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1.130 www 1854: &mt('in')." \n");
1.57 albertel 1855: } else {
1.135 albertel 1856: $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
1.57 albertel 1857: }
1.269 raeburn 1858: if ($cgroup) {
1859: $r->print(&mt("Group")." <font color=\"red\"><i>$cgroup".
1860: "</i></font> ".&mt('of')." \n");
1861: $csec = '';
1862: } elsif ($csec) {
1863: $r->print(&mt("Section")." <font color=\"red\"><i>$csec".
1864: "</i></font> ".&mt('of')." \n");
1865: }
1.135 albertel 1866: $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
1867: $r->print("</h4>\n");
1.57 albertel 1868: #---------------------------------------------------------------- print table
1869: $r->print('<p><table border="2">');
1.130 www 1870: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1871: $r->print('<th>'.&mt('Default Value').'</th>');
1872: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1873:
1.210 www 1874: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 1875: $r->print('<tr>');
1.201 www 1876: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 1877: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1878: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 1879: }
1880: $r->print("</table></center>");
1881: } # end each map
1882: } # end of $parmlev eq map
1883: #--------------------------------- Entry for parm level general (Course level)
1884: if ($parmlev eq 'general') {
1885: my $defbgone = '"E0E099"';
1886: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1887: my $defbgthree = '"FFBB99"';
1.57 albertel 1888:
1889: #-------------------------------------------- for each map, gather information
1890: my $mapid="0.0";
1891: #----------------------- loop through ids and get all parameter types for map
1892: #----------------------------------------- and associated information
1893: my %name = ();
1894: my %part = ();
1895: my %display = ();
1896: my %type = ();
1897: my %default = ();
1898:
1899: foreach (@ids) {
1900: my $rid = $_;
1901:
1.196 www 1902: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1903:
1904: #--------------------------------------------------------------------
1905: # @catmarker contains list of all possible parameters including part #s
1906: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1907: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1908: # When storing information, store as part 0
1909: # When requesting information, request from full part
1910: #-------------------------------------------------------------------
1.210 www 1911: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1912: my $tempkeyp = $_;
1913: my $fullkeyp = $tempkeyp;
1.73 albertel 1914: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1915: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1916: $part{$tempkeyp}="0";
1917: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1918: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1919: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1920: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1921: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1922: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1923: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1924: }
1925: } # end loop through keys
1926: } # end loop through ids
1927:
1928: #---------------------------------------------------- print header information
1.133 www 1929: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1930: $r->print(<<ENDMAPONE);
1.133 www 1931: <center><h4>$setdef
1.135 albertel 1932: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 1933: ENDMAPONE
1934: if ($uname) {
1.267 albertel 1935: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 1936: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 1937: } else {
1.135 albertel 1938: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 1939: }
1940:
1.135 albertel 1941: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.269 raeburn 1942: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.135 albertel 1943: $r->print("</h4>\n");
1.57 albertel 1944: #---------------------------------------------------------------- print table
1945: $r->print('<p><table border="2">');
1.130 www 1946: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1947: $r->print('<th>'.&mt('Default Value').'</th>');
1948: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1949:
1.210 www 1950: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 1951: $r->print('<tr>');
1.201 www 1952: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 1953: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1954: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 1955: }
1956: $r->print("</table></center>");
1957: } # end of $parmlev eq general
1.43 albertel 1958: }
1.280 albertel 1959: $r->print('</form>'.&Apache::loncommon::end_page());
1.57 albertel 1960: } # end sub assessparms
1.30 www 1961:
1.59 matthew 1962:
1963: ##################################################
1964: ##################################################
1965:
1966: =pod
1967:
1968: =item crsenv
1969:
1.105 matthew 1970: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1971: be simplified and shortened... someday.
1972:
1973: Inputs: $r
1974:
1975: Returns: nothing
1976:
1977: =cut
1978:
1979: ##################################################
1980: ##################################################
1.30 www 1981: sub crsenv {
1982: my $r=shift;
1983: my $setoutput='';
1.280 albertel 1984:
1.194 albertel 1985: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,
1986: 'Edit Course Environment');
1.190 albertel 1987: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1988: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 1989:
1990: #
1991: # Go through list of changes
1.190 albertel 1992: foreach (keys %env) {
1.105 matthew 1993: next if ($_!~/^form\.(.+)\_setparmval$/);
1994: my $name = $1;
1.190 albertel 1995: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 1996: if ($name eq 'newp') {
1.190 albertel 1997: $name = $env{'form.newp_name'};
1.105 matthew 1998: }
1999: if ($name eq 'url') {
2000: $value=~s/^\/res\///;
2001: my $bkuptime=time;
2002: my @tmp = &Apache::lonnet::get
2003: ('environment',['url'],$dom,$crs);
1.130 www 2004: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2005: &Apache::lonnet::put
2006: ('environment',
2007: {'top level map backup '.$bkuptime => $tmp[1] },
2008: $dom,$crs).
2009: '<br>';
2010: }
2011: #
2012: # Deal with modified default spreadsheets
2013: if ($name =~ /^spreadsheet_default_(classcalc|
2014: studentcalc|
2015: assesscalc)$/x) {
2016: my $sheettype = $1;
2017: if ($sheettype eq 'classcalc') {
2018: # no need to do anything since viewing the sheet will
2019: # cause it to be updated.
2020: } elsif ($sheettype eq 'studentcalc') {
2021: # expire all the student spreadsheets
2022: &Apache::lonnet::expirespread('','','studentcalc');
2023: } else {
2024: # expire all the assessment spreadsheets
2025: # this includes non-default spreadsheets, but better to
2026: # be safe than sorry.
2027: &Apache::lonnet::expirespread('','','assesscalc');
2028: # expire all the student spreadsheets
2029: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2030: }
1.105 matthew 2031: }
2032: #
1.107 matthew 2033: # Deal with the enrollment dates
2034: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2035: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2036: }
1.178 raeburn 2037: # Get existing cloners
2038: my @oldcloner = ();
2039: if ($name eq 'cloners') {
2040: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2041: if ($clonenames{'cloners'} =~ /,/) {
2042: @oldcloner = split/,/,$clonenames{'cloners'};
2043: } else {
2044: $oldcloner[0] = $clonenames{'cloners'};
2045: }
2046: }
1.107 matthew 2047: #
1.105 matthew 2048: # Let the user know we made the changes
1.153 albertel 2049: if ($name && defined($value)) {
1.239 raeburn 2050: my $failed_cloners;
1.178 raeburn 2051: if ($name eq 'cloners') {
1.239 raeburn 2052: $value =~ s/\s//g;
1.178 raeburn 2053: $value =~ s/^,//;
2054: $value =~ s/,$//;
1.239 raeburn 2055: # check requested clones are valid users.
2056: $failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2057: }
1.105 matthew 2058: my $put_result = &Apache::lonnet::put('environment',
2059: {$name=>$value},$dom,$crs);
2060: if ($put_result eq 'ok') {
1.130 www 2061: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
1.178 raeburn 2062: if ($name eq 'cloners') {
2063: &change_clone($value,\@oldcloner);
2064: }
1.179 raeburn 2065: # Flush the course logs so course description is immediately updated
2066: if ($name eq 'description' && defined($value)) {
2067: &Apache::lonnet::flushcourselogs();
2068: }
1.105 matthew 2069: } else {
1.130 www 2070: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2071: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2072: }
1.239 raeburn 2073: if (($name eq 'cloners') && ($failed_cloners)) {
2074: $setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '.
2075: &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
2076: '.<br />'.&mt('Please ').
2077: ' <a href="/adm/createuser">'.
2078: &mt('add the user(s)').'</a>, '.
2079: &mt('and then return to the ').
2080: '<a href="/admparmset?action=crsenv">'.
2081: &mt('Course Parameters page').'</a> '.
2082: &mt('to add the new user(s) to the list of possible cloners').
2083: '.<br />';
2084: }
1.30 www 2085: }
1.38 harris41 2086: }
1.108 www 2087: # ------------------------- Re-init course environment entries for this session
2088:
1.190 albertel 2089: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.105 matthew 2090:
1.30 www 2091: # -------------------------------------------------------- Get parameters again
1.45 matthew 2092:
2093: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2094: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2095: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2096: my $output='';
1.45 matthew 2097: if (! exists($values{'con_lost'})) {
1.30 www 2098: my %descriptions=
1.140 sakharuk 2099: ('url' => '<b>'.&mt('Top Level Map').'</b> '.
1.46 matthew 2100: '<a href="javascript:openbrowser'.
1.47 matthew 2101: "('envform','url','sequence')\">".
1.140 sakharuk 2102: &mt('Select Map').'</a><br /><font color=red> '.
2103: &mt('Modification may make assessment data inaccessible').
2104: '</font>',
2105: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2106: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2107: '</b><br />'.
2108: '('.&mt('internal').', '.&mt('optional').')',
1.177 raeburn 2109: '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 2110: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
2111: '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
1.140 sakharuk 2112: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
1.52 www 2113: '<a href="javascript:openbrowser'.
2114: "('envform','default_xml_style'".
1.140 sakharuk 2115: ",'sty')\">$SelectStyleFile</a><br>",
1.141 sakharuk 2116: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
2117: '</b><br />(<tt>user:domain,'.
1.74 www 2118: 'user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2119: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
1.74 www 2120: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2121: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
1.75 albertel 2122: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2123: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
1.158 sakharuk 2124: '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
1.141 sakharuk 2125: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
1.158 sakharuk 2126: '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
1.141 sakharuk 2127: &mt('changes will not show until next login').')',
1.169 matthew 2128: '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 2129:
1.141 sakharuk 2130: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
2131: '</b><br />"<tt>st</tt>": '.
1.158 sakharuk 2132: &mt('student').', "<tt>ta</tt>": '.
1.118 matthew 2133: 'TA, "<tt>in</tt>": '.
1.158 sakharuk 2134: &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
1.118 matthew 2135: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
2136: 'plc.users.denied' =>
1.141 sakharuk 2137: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.118 matthew 2138: '(<tt>user:domain,user:domain,...</tt>)',
2139:
1.141 sakharuk 2140: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
2141: '</b><br />"<tt>st</tt>": '.
1.61 albertel 2142: 'student, "<tt>ta</tt>": '.
2143: 'TA, "<tt>in</tt>": '.
1.75 albertel 2144: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 2145: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2146: 'pch.users.denied' =>
1.141 sakharuk 2147: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.53 www 2148: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 2149: 'spreadsheet_default_classcalc'
1.141 sakharuk 2150: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2151: '<a href="javascript:openbrowser'.
2152: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2153: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2154: 'spreadsheet_default_studentcalc'
1.141 sakharuk 2155: => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
1.50 matthew 2156: '<a href="javascript:openbrowser'.
2157: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2158: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2159: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2160: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2161: '<a href="javascript:openbrowser'.
2162: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2163: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2164: 'allow_limited_html_in_feedback'
1.141 sakharuk 2165: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.158 sakharuk 2166: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.170 raeburn 2167: 'allow_discussion_post_editing'
1.276 raeburn 2168: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />"<tt>st</tt>": '.
2169: &mt('student').', "<tt>ta</tt>": '.
2170: 'TA, "<tt>in</tt>": '.
2171: &mt('instructor').'; (<tt>'.&mt('role:section,role:section,..., e.g., st:001,st:002,in,cc would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').'</tt>)<br />'.
2172: '('.&mt('or set value to "[_1]" to allow all roles',"<tt>yes</tt>").')',
1.89 albertel 2173: 'rndseed'
1.140 sakharuk 2174: => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
2175: '<font color="red">'.&mt('Modifying this will make problems').' '.
2176: &mt('have different numbers and answers').'</font>',
1.151 albertel 2177: 'receiptalg'
2178: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2179: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2180: 'suppress_tries'
1.272 albertel 2181: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.273 www 2182: ' ('.&mt('"[_1]" to suppress, anything else to not suppress','<tt>yes</tt>').')',
1.113 sakharuk 2183: 'problem_stream_switch'
1.141 sakharuk 2184: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.158 sakharuk 2185: ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
1.161 sakharuk 2186: 'default_paper_size'
2187: => '<b>'.&mt('Default paper type').'</b><br />'.
2188: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2189: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2190: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.111 sakharuk 2191: 'anonymous_quiz'
1.150 www 2192: => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
1.141 sakharuk 2193: ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
1.217 albertel 2194: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2195: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.150 www 2196: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
2197: '<br />(<tt>user:domain,user:domain,...</tt>)',
1.140 sakharuk 2198: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2199: 'disable_receipt_display'
1.141 sakharuk 2200: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2201: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.163 albertel 2202: 'disablesigfigs'
2203: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2204: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2205: 'disableexampointprint'
2206: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2207: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2208: 'externalsyllabus'
1.279 www 2209: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2210: 'tthoptions'
2211: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
1.107 matthew 2212: );
1.177 raeburn 2213: my @Display_Order = ('url','description','courseid','cloners','grading',
1.278 www 2214: 'externalsyllabus',
1.107 matthew 2215: 'default_xml_style','pageseparators',
2216: 'question.email','comment.email','policy.email',
1.169 matthew 2217: 'student_classlist_view',
1.118 matthew 2218: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2219: 'pch.roles.denied','pch.users.denied',
2220: 'allow_limited_html_in_feedback',
1.170 raeburn 2221: 'allow_discussion_post_editing',
1.108 www 2222: 'languages',
1.150 www 2223: 'nothideprivileged',
1.107 matthew 2224: 'rndseed',
1.151 albertel 2225: 'receiptalg',
1.107 matthew 2226: 'problem_stream_switch',
1.164 sakharuk 2227: 'suppress_tries',
1.161 sakharuk 2228: 'default_paper_size',
1.115 www 2229: 'disable_receipt_display',
1.107 matthew 2230: 'spreadsheet_default_classcalc',
2231: 'spreadsheet_default_studentcalc',
2232: 'spreadsheet_default_assesscalc',
2233: 'hideemptyrows',
2234: 'default_enrollment_start_date',
2235: 'default_enrollment_end_date',
1.163 albertel 2236: 'tthoptions',
1.251 albertel 2237: 'disablesigfigs',
2238: 'disableexampointprint'
1.107 matthew 2239: );
2240: foreach my $parameter (sort(keys(%values))) {
1.244 banghart 2241: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
1.142 raeburn 2242: if (! $descriptions{$parameter}) {
2243: $descriptions{$parameter}=$parameter;
2244: push(@Display_Order,$parameter);
2245: }
2246: }
1.43 albertel 2247: }
1.107 matthew 2248: foreach my $parameter (@Display_Order) {
2249: my $description = $descriptions{$parameter};
1.51 matthew 2250: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2251: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2252: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2253: '.checked=true;"';
1.107 matthew 2254: $output .= '<tr><td>'.$description.'</td>';
2255: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2256: $output .= '<td>'.
2257: &Apache::lonhtmlcommon::date_setter('envform',
2258: $parameter.'_value',
2259: $values{$parameter},
2260: $onchange).
2261: '</td>';
2262: } else {
2263: $output .= '<td>'.
2264: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2265: $values{$parameter},
2266: 40,$onchange).'</td>';
2267: }
2268: $output .= '<td>'.
2269: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2270: '</td>';
2271: $output .= "</tr>\n";
1.51 matthew 2272: }
1.69 www 2273: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2274: '[\'envform\'].elements[\'newp_setparmval\']'.
2275: '.checked=true;"';
1.130 www 2276: $output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2277: '<input type="text" size=40 name="newp_name" '.
2278: $onchange.' /></td><td>'.
2279: '<input type="text" size=40 name="newp_value" '.
2280: $onchange.' /></td><td>'.
2281: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 2282: }
1.157 sakharuk 2283: my %lt=&Apache::lonlocal::texthash(
2284: 'par' => 'Parameter',
2285: 'val' => 'Value',
2286: 'set' => 'Set',
2287: 'sce' => 'Set Course Environment'
2288: );
2289:
1.140 sakharuk 2290: my $Parameter=&mt('Parameter');
2291: my $Value=&mt('Value');
1.141 sakharuk 2292: my $Set=&mt('Set');
1.280 albertel 2293: my $browse_js=
2294: '<script type="text/javascript" language="Javascript">'.
2295: &Apache::loncommon::browser_and_searcher_javascript('parmset').
2296: '</script>';
2297:
2298: my $start_page =
2299: &Apache::loncommon::start_page('Set Course Environment Parameters',
2300: $browse_js);
2301: my $end_page =
2302: &Apache::loncommon::end_page();
2303: $r->print(<<ENDENV);
2304: $start_page
1.193 albertel 2305: $breadcrumbs
2306: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2307: $setoutput
2308: <p>
2309: <table border=2>
1.157 sakharuk 2310: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
1.30 www 2311: $output
2312: </table>
1.157 sakharuk 2313: <input type="submit" name="crsenv" value="$lt{'sce'}">
1.30 www 2314: </form>
1.280 albertel 2315: $end_page
2316: ENDENV
1.30 www 2317: }
1.120 www 2318: ##################################################
1.207 www 2319: # Overview mode
2320: ##################################################
1.124 www 2321: my $tableopen;
2322:
2323: sub tablestart {
2324: if ($tableopen) {
2325: return '';
2326: } else {
2327: $tableopen=1;
1.130 www 2328: return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
2329: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2330: }
2331: }
2332:
2333: sub tableend {
2334: if ($tableopen) {
2335: $tableopen=0;
2336: return '</table>';
2337: } else {
2338: return'';
2339: }
2340: }
2341:
1.207 www 2342: sub readdata {
2343: my ($crs,$dom)=@_;
2344: # Read coursedata
2345: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2346: # Read userdata
2347:
2348: my $classlist=&Apache::loncoursedata::get_classlist();
2349: foreach (keys %$classlist) {
2350: # the following undefs are for 'domain', and 'username' respectively.
2351: if ($_=~/^(\w+)\:(\w+)$/) {
2352: my ($tuname,$tudom)=($1,$2);
2353: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2354: foreach my $userkey (keys %{$useropt}) {
2355: if ($userkey=~/^$env{'request.course.id'}/) {
2356: my $newkey=$userkey;
2357: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2358: $$resourcedata{$newkey}=$$useropt{$userkey};
2359: }
2360: }
2361: }
2362: }
2363: return $resourcedata;
2364: }
2365:
2366:
1.124 www 2367: # Setting
1.208 www 2368:
2369: sub storedata {
2370: my ($r,$crs,$dom)=@_;
1.207 www 2371: # Set userlevel immediately
2372: # Do an intermediate store of course level
2373: my $olddata=&readdata($crs,$dom);
1.124 www 2374: my %newdata=();
2375: undef %newdata;
2376: my @deldata=();
2377: undef @deldata;
1.190 albertel 2378: foreach (keys %env) {
1.124 www 2379: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2380: my $cmd=$1;
2381: my $thiskey=$2;
1.207 www 2382: my ($tuname,$tudom)=&extractuser($thiskey);
2383: my $tkey=$thiskey;
2384: if ($tuname) {
2385: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2386: }
1.124 www 2387: if ($cmd eq 'set') {
1.190 albertel 2388: my $data=$env{$_};
1.212 www 2389: my $typeof=$env{'form.typeof_'.$thiskey};
2390: if ($$olddata{$thiskey} ne $data) {
1.207 www 2391: if ($tuname) {
1.212 www 2392: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2393: $tkey.'.type' => $typeof},
2394: $tudom,$tuname) eq 'ok') {
1.207 www 2395: $r->print('<br />'.&mt('Stored modified parameter for').' '.
2396: &Apache::loncommon::plainname($tuname,$tudom));
2397: } else {
2398: $r->print('<h2><font color="red">'.
2399: &mt('Error storing parameters').'</font></h2>');
2400: }
2401: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2402: } else {
2403: $newdata{$thiskey}=$data;
1.212 www 2404: $newdata{$thiskey.'.type'}=$typeof;
2405: }
1.207 www 2406: }
1.124 www 2407: } elsif ($cmd eq 'del') {
1.207 www 2408: if ($tuname) {
2409: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
2410: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2411: } else {
2412: $r->print('<h2><font color="red">'.
2413: &mt('Error deleting parameters').'</font></h2>');
2414: }
2415: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2416: } else {
2417: push (@deldata,$thiskey);
2418: }
1.124 www 2419: } elsif ($cmd eq 'datepointer') {
1.190 albertel 2420: my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
1.212 www 2421: my $typeof=$env{'form.typeof_'.$thiskey};
1.207 www 2422: if (defined($data) and $$olddata{$thiskey} ne $data) {
2423: if ($tuname) {
1.212 www 2424: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2425: $tkey.'.type' => $typeof},
2426: $tudom,$tuname) eq 'ok') {
1.207 www 2427: $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2428: } else {
2429: $r->print('<h2><font color="red">'.
2430: &mt('Error storing parameters').'</font></h2>');
2431: }
2432: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2433: } else {
1.212 www 2434: $newdata{$thiskey}=$data;
2435: $newdata{$thiskey.'.type'}=$typeof;
1.207 www 2436: }
2437: }
1.124 www 2438: }
2439: }
2440: }
1.207 www 2441: # Store all course level
1.144 www 2442: my $delentries=$#deldata+1;
2443: my @newdatakeys=keys %newdata;
2444: my $putentries=$#newdatakeys+1;
2445: if ($delentries) {
2446: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
2447: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2448: } else {
2449: $r->print('<h2><font color="red">'.
2450: &mt('Error deleting parameters').'</font></h2>');
2451: }
1.205 www 2452: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2453: }
2454: if ($putentries) {
2455: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.212 www 2456: $r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2457: } else {
2458: $r->print('<h2><font color="red">'.
2459: &mt('Error storing parameters').'</font></h2>');
2460: }
1.205 www 2461: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2462: }
1.208 www 2463: }
1.207 www 2464:
1.208 www 2465: sub extractuser {
2466: my $key=shift;
2467: return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
2468: }
1.206 www 2469:
1.208 www 2470: sub listdata {
1.214 www 2471: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2472: # Start list output
1.206 www 2473:
1.122 www 2474: my $oldsection='';
2475: my $oldrealm='';
2476: my $oldpart='';
1.123 www 2477: my $pointer=0;
1.124 www 2478: $tableopen=0;
1.145 www 2479: my $foundkeys=0;
1.248 albertel 2480: my %keyorder=&standardkeyorder();
1.214 www 2481: foreach my $thiskey (sort {
2482: if ($sortorder eq 'realmstudent') {
1.247 albertel 2483: my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2484: my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2485: if (!defined($astudent)) {
2486: ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.237 albertel 2487: }
1.247 albertel 2488: if (!defined($bstudent)) {
2489: ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2490: }
1.248 albertel 2491: $arealm=~s/\.type//;
2492: my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
2493: $aparm=$keyorder{'parameter_0_'.$aparm};
2494: $brealm=~s/\.type//;
2495: my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
2496: $bparm=$keyorder{'parameter_0_'.$bparm};
2497: if ($ares eq $bres) {
2498: if (defined($aparm) && defined($bparm)) {
2499: ($aparm <=> $bparm);
2500: } elsif (defined($aparm)) {
2501: -1;
2502: } elsif (defined($bparm)) {
2503: 1;
2504: } else {
2505: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2506: }
2507: } else {
2508: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2509: }
1.214 www 2510: } else {
2511: $a cmp $b;
2512: }
2513: } keys %{$listdata}) {
1.247 albertel 2514:
1.211 www 2515: if ($$listdata{$thiskey.'.type'}) {
2516: my $thistype=$$listdata{$thiskey.'.type'};
2517: if ($$resourcedata{$thiskey.'.type'}) {
2518: $thistype=$$resourcedata{$thiskey.'.type'};
2519: }
1.207 www 2520: my ($middle,$part,$name)=
2521: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2522: my $section=&mt('All Students');
1.207 www 2523: if ($middle=~/^\[(.*)\]/) {
1.206 www 2524: my $issection=$1;
2525: if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
2526: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
2527: } else {
2528: $section=&mt('Group/Section').': '.$issection;
2529: }
1.207 www 2530: $middle=~s/^\[(.*)\]//;
1.122 www 2531: }
1.207 www 2532: $middle=~s/\.+$//;
2533: $middle=~s/^\.+//;
1.130 www 2534: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.122 www 2535: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.174 albertel 2536: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.122 www 2537: } elsif ($middle) {
1.174 albertel 2538: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
2539: $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 2540: }
1.214 www 2541: if ($sortorder eq 'realmstudent') {
2542: if ($realm ne $oldrealm) {
2543: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
2544: $oldrealm=$realm;
2545: $oldsection='';
2546: }
2547: if ($section ne $oldsection) {
2548: $r->print(&tableend()."\n<h2>$section</h2>");
2549: $oldsection=$section;
2550: $oldpart='';
2551: }
2552: } else {
2553: if ($section ne $oldsection) {
2554: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
2555: $oldsection=$section;
2556: $oldrealm='';
2557: }
2558: if ($realm ne $oldrealm) {
2559: $r->print(&tableend()."\n<h2>$realm</h2>");
2560: $oldrealm=$realm;
2561: $oldpart='';
2562: }
1.122 www 2563: }
2564: if ($part ne $oldpart) {
1.124 www 2565: $r->print(&tableend().
1.214 www 2566: "\n<font color='blue'>".&mt('Part').": $part</font>");
1.122 www 2567: $oldpart=$part;
2568: }
1.123 www 2569: #
1.230 www 2570: # Preset defaults?
2571: #
2572: my ($hour,$min,$sec,$val)=('','','','');
2573: unless ($$resourcedata{$thiskey}) {
2574: my ($parmname)=($thiskey=~/\.(\w+)$/);
2575: ($hour,$min,$sec,$val)=&preset_defaults($parmname);
2576: }
2577:
2578: #
1.123 www 2579: # Ready to print
2580: #
1.124 www 2581: $r->print(&tablestart().'<tr><td><b>'.$name.
2582: ':</b></td><td><input type="checkbox" name="del_'.
2583: $thiskey.'" /></td><td>');
1.145 www 2584: $foundkeys++;
1.213 www 2585: if (&isdateparm($thistype)) {
1.123 www 2586: my $jskey='key_'.$pointer;
2587: $pointer++;
2588: $r->print(
1.232 albertel 2589: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 2590: $jskey,
1.219 www 2591: $$resourcedata{$thiskey},
1.230 www 2592: '',1,'','',$hour,$min,$sec).
1.277 www 2593: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
2594: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 2595: );
1.219 www 2596: } elsif ($thistype eq 'string_yesno') {
1.230 www 2597: my $showval;
2598: if (defined($$resourcedata{$thiskey})) {
2599: $showval=$$resourcedata{$thiskey};
2600: } else {
2601: $showval=$val;
2602: }
1.219 www 2603: $r->print('<label><input type="radio" name="set_'.$thiskey.
2604: '" value="yes"');
1.230 www 2605: if ($showval eq 'yes') {
1.219 www 2606: $r->print(' checked="checked"');
2607: }
2608: $r->print(' />'.&mt('Yes').'</label> ');
2609: $r->print('<label><input type="radio" name="set_'.$thiskey.
2610: '" value="no"');
1.230 www 2611: if ($showval eq 'no') {
1.219 www 2612: $r->print(' checked="checked"');
2613: }
2614: $r->print(' />'.&mt('No').'</label>');
1.123 www 2615: } else {
1.230 www 2616: my $showval;
2617: if (defined($$resourcedata{$thiskey})) {
2618: $showval=$$resourcedata{$thiskey};
2619: } else {
2620: $showval=$val;
2621: }
1.211 www 2622: $r->print('<input type="text" name="set_'.$thiskey.'" value="'.
1.230 www 2623: $showval.'">');
1.123 www 2624: }
1.211 www 2625: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
2626: $thistype.'">');
1.124 www 2627: $r->print('</td></tr>');
1.122 www 2628: }
1.121 www 2629: }
1.208 www 2630: return $foundkeys;
2631: }
2632:
2633: sub newoverview {
1.280 albertel 2634: my ($r) = @_;
2635:
1.208 www 2636: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2637: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 2638: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.208 www 2639: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
2640: $r->print(<<ENDOVER);
1.280 albertel 2641: $start_page
1.208 www 2642: $breadcrumbs
1.232 albertel 2643: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 2644: ENDOVER
1.211 www 2645: my @ids=();
2646: my %typep=();
2647: my %keyp=();
2648: my %allparms=();
2649: my %allparts=();
2650: my %allmaps=();
2651: my %mapp=();
2652: my %symbp=();
2653: my %maptitles=();
2654: my %uris=();
2655: my %keyorder=&standardkeyorder();
2656: my %defkeytype=();
2657:
2658: my %alllevs=();
2659: $alllevs{'Resource Level'}='full';
1.215 www 2660: $alllevs{'Map/Folder Level'}='map';
1.211 www 2661: $alllevs{'Course Level'}='general';
2662:
2663: my $csec=$env{'form.csec'};
1.269 raeburn 2664: my $cgroup=$env{'form.cgroup'};
1.211 www 2665:
2666: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
2667: my $pschp=$env{'form.pschp'};
2668: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
2669: if (!@psprt) { $psprt[0]='0'; }
2670:
2671: my @selected_sections =
2672: &Apache::loncommon::get_env_multiple('form.Section');
2673: @selected_sections = ('all') if (! @selected_sections);
2674: foreach (@selected_sections) {
2675: if ($_ eq 'all') {
2676: @selected_sections = ('all');
2677: }
2678: }
1.269 raeburn 2679: my @selected_groups =
2680: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 2681:
2682: my $pssymb='';
2683: my $parmlev='';
2684:
2685: unless ($env{'form.parmlev'}) {
2686: $parmlev = 'map';
2687: } else {
2688: $parmlev = $env{'form.parmlev'};
2689: }
2690:
2691: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
2692: \%mapp, \%symbp,\%maptitles,\%uris,
2693: \%keyorder,\%defkeytype);
2694:
2695: # Menu to select levels, etc
2696:
2697: $r->print('<table border="1"><tr><td>');
2698: &levelmenu($r,\%alllevs,$parmlev);
2699: if ($parmlev ne 'general') {
2700: $r->print('<td>');
2701: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
2702: $r->print('</td>');
2703: }
2704: $r->print('</td></tr></table>');
2705:
2706: $r->print('<table border="1"><tr><td>');
2707: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.269 raeburn 2708: $r->print('</td><td><table border="0" cellspacing="0" cellpadding="0">'.
2709: '<tr><td>'.&mt('Parts').'</td><td></td><td>'.&mt('Section(s)').
2710: '</td><td></td><td>'.&mt('Group(s)').'</td></tr><tr><td>');
1.211 www 2711: &partmenu($r,\%allparts,\@psprt);
1.269 raeburn 2712: $r->print('</td><td> </td><td>');
1.211 www 2713: §ionmenu($r,\@selected_sections);
1.269 raeburn 2714: $r->print('</td><td> </td><td>');
2715: &groupmenu($r,\@selected_groups);
2716: $r->print('</td></tr></table>');
1.214 www 2717: $r->print('</td></tr></table>');
2718:
2719: my $sortorder=$env{'form.sortorder'};
2720: unless ($sortorder) { $sortorder='realmstudent'; }
2721: &sortmenu($r,$sortorder);
2722:
2723: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 2724:
2725: # Build the list data hash from the specified parms
2726:
2727: my $listdata;
2728: %{$listdata}=();
2729:
2730: foreach my $cat (@pscat) {
1.269 raeburn 2731: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
2732: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 2733: }
2734:
1.212 www 2735: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 2736:
1.212 www 2737: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 2738:
2739: # Read modified data
2740:
2741: my $resourcedata=&readdata($crs,$dom);
2742:
2743: # List data
2744:
1.214 www 2745: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 2746: }
2747: $r->print(&tableend().
1.212 www 2748: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':'').
1.280 albertel 2749: '</form>'.&Apache::loncommon::end_page());
1.208 www 2750: }
2751:
1.269 raeburn 2752: sub secgroup_lister {
2753: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
2754: foreach my $item (@{$selections}) {
2755: foreach my $part (@{$psprt}) {
2756: my $rootparmkey=$env{'request.course.id'};
2757: if (($item ne 'all') && ($item ne 'none') && ($item)) {
2758: $rootparmkey.='.['.$item.']';
2759: }
2760: if ($parmlev eq 'general') {
2761: # course-level parameter
2762: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
2763: $$listdata{$newparmkey}=1;
2764: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2765: } elsif ($parmlev eq 'map') {
2766: # map-level parameter
2767: foreach my $mapid (keys %{$allmaps}) {
2768: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
2769: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
2770: $$listdata{$newparmkey}=1;
2771: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2772: }
2773: } else {
2774: # resource-level parameter
2775: foreach my $rid (@{$ids}) {
2776: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
2777: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
2778: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
2779: $$listdata{$newparmkey}=1;
2780: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2781: }
2782: }
2783: }
2784: }
2785: }
2786:
1.208 www 2787: sub overview {
1.280 albertel 2788: my ($r) = @_;
1.208 www 2789: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2790: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 2791:
2792: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.208 www 2793: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
2794: $r->print(<<ENDOVER);
1.280 albertel 2795: $start_page
1.208 www 2796: $breadcrumbs
1.232 albertel 2797: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 2798: ENDOVER
2799: # Store modified
2800:
2801: &storedata($r,$crs,$dom);
2802:
2803: # Read modified data
2804:
2805: my $resourcedata=&readdata($crs,$dom);
2806:
1.214 www 2807:
2808: my $sortorder=$env{'form.sortorder'};
2809: unless ($sortorder) { $sortorder='realmstudent'; }
2810: &sortmenu($r,$sortorder);
2811:
1.208 www 2812: # List data
2813:
1.214 www 2814: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 2815:
1.145 www 2816: $r->print(&tableend().'<p>'.
1.280 albertel 2817: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
2818: &Apache::loncommon::end_page());
1.120 www 2819: }
1.121 www 2820:
1.59 matthew 2821: ##################################################
2822: ##################################################
1.178 raeburn 2823:
2824: =pod
1.239 raeburn 2825:
2826: =item check_cloners
2827:
2828: Checks if new users included in list of allowed cloners
2829: are valid users. Replaces supplied list with
2830: cleaned list containing only users with valid usernames
2831: and domains.
2832:
2833: Inputs: $clonelist, $oldcloner
2834: where $clonelist is ref to array of requested cloners,
2835: and $oldcloner is ref to array of currently allowed
2836: cloners.
2837:
2838: Returns: string - comma separated list of requested
2839: cloners (username:domain) who do not exist in system.
2840:
2841: =item change_clone
2842:
1.178 raeburn 2843: Modifies the list of courses a user can clone (stored
1.239 raeburn 2844: in the user's environment.db file), called when a
1.178 raeburn 2845: change is made to the list of users allowed to clone
2846: a course.
1.239 raeburn 2847:
1.178 raeburn 2848: Inputs: $action,$cloner
2849: where $action is add or drop, and $cloner is identity of
2850: user for whom cloning ability is to be changed in course.
2851:
2852: =cut
2853:
2854: ##################################################
2855: ##################################################
2856:
1.239 raeburn 2857: sub extract_cloners {
2858: my ($clonelist,$allowclone) = @_;
2859: if ($clonelist =~ /,/) {
2860: @{$allowclone} = split/,/,$clonelist;
2861: } else {
2862: $$allowclone[0] = $clonelist;
2863: }
2864: }
2865:
2866:
2867: sub check_cloners {
2868: my ($clonelist,$oldcloner) = @_;
2869: my ($clean_clonelist,$disallowed);
2870: my @allowclone = ();
2871: &extract_cloners($$clonelist,\@allowclone);
2872: foreach my $currclone (@allowclone) {
2873: if (!grep/^$currclone$/,@$oldcloner) {
2874: my ($uname,$udom) = split/:/,$currclone;
2875: if ($uname && $udom) {
2876: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2877: $disallowed .= $currclone.',';
2878: } else {
2879: $clean_clonelist .= $currclone.',';
2880: }
2881: }
2882: } else {
2883: $clean_clonelist .= $currclone.',';
2884: }
2885: }
2886: if ($disallowed) {
2887: $disallowed =~ s/,$//;
2888: }
2889: if ($clean_clonelist) {
2890: $clean_clonelist =~ s/,$//;
2891: }
2892: $$clonelist = $clean_clonelist;
2893: return $disallowed;
2894: }
1.178 raeburn 2895:
2896: sub change_clone {
2897: my ($clonelist,$oldcloner) = @_;
2898: my ($uname,$udom);
1.190 albertel 2899: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2900: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 2901: my $clone_crs = $cnum.':'.$cdom;
2902:
2903: if ($cnum && $cdom) {
1.239 raeburn 2904: my @allowclone;
2905: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 2906: foreach my $currclone (@allowclone) {
2907: if (!grep/^$currclone$/,@$oldcloner) {
2908: ($uname,$udom) = split/:/,$currclone;
2909: if ($uname && $udom) {
2910: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2911: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2912: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
2913: if ($currclonecrs{'cloneable'} eq '') {
2914: $currclonecrs{'cloneable'} = $clone_crs;
2915: } else {
2916: $currclonecrs{'cloneable'} .= ','.$clone_crs;
2917: }
2918: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
2919: }
2920: }
2921: }
2922: }
2923: }
2924: foreach my $oldclone (@$oldcloner) {
2925: if (!grep/^$oldclone$/,@allowclone) {
2926: ($uname,$udom) = split/:/,$oldclone;
2927: if ($uname && $udom) {
2928: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2929: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2930: my %newclonecrs = ();
2931: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
2932: if ($currclonecrs{'cloneable'} =~ /,/) {
2933: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
2934: foreach (@currclonecrs) {
2935: unless ($_ eq $clone_crs) {
2936: $newclonecrs{'cloneable'} .= $_.',';
2937: }
2938: }
2939: $newclonecrs{'cloneable'} =~ s/,$//;
2940: } else {
2941: $newclonecrs{'cloneable'} = '';
2942: }
2943: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
2944: }
2945: }
2946: }
2947: }
2948: }
2949: }
2950: }
2951:
1.193 albertel 2952:
2953: ##################################################
2954: ##################################################
2955:
2956: =pod
2957:
2958: =item * header
2959:
2960: Output html header for page
2961:
2962: =cut
2963:
2964: ##################################################
2965: ##################################################
2966: sub header {
1.280 albertel 2967: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 2968: }
2969: ##################################################
2970: ##################################################
2971: sub print_main_menu {
2972: my ($r,$parm_permission)=@_;
2973: #
2974: $r->print(<<ENDMAINFORMHEAD);
2975: <form method="post" enctype="multipart/form-data"
2976: action="/adm/parmset" name="studentform">
2977: ENDMAINFORMHEAD
2978: #
1.195 albertel 2979: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2980: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 2981: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
2982:
1.193 albertel 2983: my @menu =
2984: (
2985: { text => 'Set Course Environment Parameters',
1.204 www 2986: action => 'crsenv',
1.193 albertel 2987: permission => $parm_permission,
2988: },
1.255 banghart 2989: { text => 'Set Portfolio Metadata',
1.259 banghart 2990: action => 'setrestrictmeta',
1.240 banghart 2991: permission => $parm_permission,
2992: },
1.271 www 2993: { text => 'Manage Course Slots',
1.268 albertel 2994: url => '/adm/slotrequest?command=showslots',
2995: permission => $vgr,
2996: },
2997: { divider => 1,
2998: },
1.216 www 2999: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3000: url => '/adm/helper/parameter.helper',
3001: permission => $parm_permission,
3002: },
1.216 www 3003: { text => 'Modify Resource Parameters - Overview Mode',
1.193 albertel 3004: action => 'setoverview',
3005: permission => $parm_permission,
1.208 www 3006: },
1.216 www 3007: { text => 'Set Resource Parameters - Overview Mode',
1.208 www 3008: action => 'newoverview',
3009: permission => $parm_permission,
1.193 albertel 3010: },
1.216 www 3011: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3012: action => 'settable',
3013: permission => $parm_permission,
1.204 www 3014: help => 'Cascading_Parameters',
1.193 albertel 3015: },
1.220 www 3016: { text => 'Set Parameter Setting Default Actions',
3017: action => 'setdefaults',
3018: permission => $parm_permission,
3019: },
1.193 albertel 3020: );
3021: my $menu_html = '';
3022: foreach my $menu_item (@menu) {
1.268 albertel 3023: if ($menu_item->{'divider'}) {
3024: $menu_html .= '<hr />';
3025: next;
3026: }
1.193 albertel 3027: next if (! $menu_item->{'permission'});
3028: $menu_html.='<p>';
3029: $menu_html.='<font size="+1">';
3030: if (exists($menu_item->{'url'})) {
3031: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3032: } else {
3033: $menu_html.=
3034: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3035: }
3036: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
3037: if (exists($menu_item->{'help'})) {
3038: $menu_html.=
3039: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3040: }
3041: $menu_html.='</p>'.$/;
3042: }
3043: $r->print($menu_html);
3044: return;
3045: }
1.255 banghart 3046: ### Set portfolio metadata
1.252 banghart 3047: sub output_row {
1.255 banghart 3048: my ($r, $field_name, $field_text) = @_;
1.252 banghart 3049: my $output;
1.263 banghart 3050: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3051: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.254 banghart 3052: unless (defined($options)) {
3053: $options = 'active,stuadd';
1.261 banghart 3054: $values = '';
1.252 banghart 3055: }
1.260 banghart 3056: $output.='<strong>'.$field_text.':</strong>';
1.264 albertel 3057: $output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />';
3058:
3059: my @options= ( ['active', 'Show to student'],
3060: ['onlyone','Student may select only one choice'],
3061: ['stuadd', 'Student may type choices']);
3062: foreach my $opt (@options) {
3063: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3064: $output.=(' 'x5).'<label><input type="checkbox" name="'.
3065: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3066: &mt($opt->[1]).'</label> <br />';
1.252 banghart 3067: }
3068: return ($output);
3069: }
1.259 banghart 3070:
3071: sub setrestrictmeta {
1.240 banghart 3072: my ($r)=@_;
1.242 banghart 3073: my $next_meta;
1.244 banghart 3074: my $output;
1.245 banghart 3075: my $item_num;
1.246 banghart 3076: my $put_result;
1.280 albertel 3077:
3078: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.240 banghart 3079: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
1.260 banghart 3080: 'Restrict Metadata'));
1.240 banghart 3081: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3082: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3083: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3084: my $save_field = '';
1.259 banghart 3085: if ($env{'form.restrictmeta'}) {
1.254 banghart 3086: foreach my $field (sort(keys(%env))) {
1.252 banghart 3087: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3088: my $options;
1.252 banghart 3089: my $meta_field = $1;
3090: my $meta_key = $2;
1.253 banghart 3091: if ($save_field ne $meta_field) {
1.252 banghart 3092: $save_field = $meta_field;
1.253 banghart 3093: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3094: $options.='stuadd,';
3095: }
1.253 banghart 3096: if ($env{'form.'.$meta_field.'_onlyone'}) {
1.254 banghart 3097: $options.='onlyone,';
3098: }
3099: if ($env{'form.'.$meta_field.'_active'}) {
3100: $options.='active,';
1.253 banghart 3101: }
1.259 banghart 3102: my $name = $save_field;
1.253 banghart 3103: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3104: {'metadata.'.$meta_field.'.options'=>$options,
3105: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 3106: },$dom,$crs);
1.252 banghart 3107: }
3108: }
3109: }
3110: }
3111: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.258 albertel 3112: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
3113: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 3114: &Apache::lonnet::logthis ($field);
3115: if ($field ne 'courserestricted') {
3116: $output.= &output_row($r, $field, $metadata_fields{$field});
3117: }
1.255 banghart 3118: }
1.244 banghart 3119: $r->print(<<ENDenv);
1.259 banghart 3120: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 3121: <p>
3122: $output
1.259 banghart 3123: <input type="submit" name="restrictmeta" value="Update Metadata Restrictions">
1.244 banghart 3124: </form>
3125: ENDenv
1.280 albertel 3126: $r->print(&Apache::loncommon::end_page());
1.240 banghart 3127: return 'ok';
3128: }
1.220 www 3129: ##################################################
1.193 albertel 3130:
1.220 www 3131: sub defaultsetter {
1.280 albertel 3132: my ($r) = @_;
3133:
3134: my $start_page =
3135: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.220 www 3136: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults');
3137: $r->print(<<ENDDEFHEAD);
1.280 albertel 3138: $start_page
1.220 www 3139: $breadcrumbs
3140: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
3141: ENDDEFHEAD
1.280 albertel 3142:
3143: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3144: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 3145: my @ids=();
3146: my %typep=();
3147: my %keyp=();
3148: my %allparms=();
3149: my %allparts=();
3150: my %allmaps=();
3151: my %mapp=();
3152: my %symbp=();
3153: my %maptitles=();
3154: my %uris=();
3155: my %keyorder=&standardkeyorder();
3156: my %defkeytype=();
3157:
3158: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3159: \%mapp, \%symbp,\%maptitles,\%uris,
3160: \%keyorder,\%defkeytype);
1.224 www 3161: if ($env{'form.storerules'}) {
3162: my %newrules=();
3163: my @delrules=();
1.226 www 3164: my %triggers=();
1.225 albertel 3165: foreach my $key (keys(%env)) {
3166: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 3167: my $tempkey=$1;
1.226 www 3168: my $action=$env{$key};
3169: if ($action) {
3170: $newrules{$tempkey.'_action'}=$action;
3171: if ($action ne 'default') {
3172: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
3173: $triggers{$whichparm}.=$tempkey.':';
3174: }
3175: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 3176: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3177: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 3178: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
3179: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
3180: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
3181: } else {
3182: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 3183: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 3184: }
3185: } else {
1.225 albertel 3186: push(@delrules,$tempkey.'_action');
1.226 www 3187: push(@delrules,$tempkey.'_type');
1.225 albertel 3188: push(@delrules,$tempkey.'_hours');
3189: push(@delrules,$tempkey.'_min');
3190: push(@delrules,$tempkey.'_sec');
3191: push(@delrules,$tempkey.'_value');
1.224 www 3192: }
3193: }
3194: }
1.226 www 3195: foreach my $key (keys %allparms) {
3196: $newrules{$key.'_triggers'}=$triggers{$key};
3197: }
1.224 www 3198: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
3199: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
3200: &resetrulescache();
3201: }
1.227 www 3202: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
3203: 'hours' => 'Hours',
1.221 www 3204: 'min' => 'Minutes',
3205: 'sec' => 'Seconds',
3206: 'yes' => 'Yes',
3207: 'no' => 'No');
1.222 www 3208: my @standardoptions=('','default');
3209: my @standarddisplay=('',&mt('Default value when manually setting'));
3210: my @dateoptions=('','default');
3211: my @datedisplay=('',&mt('Default value when manually setting'));
3212: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
3213: unless ($tempkey) { next; }
3214: push @standardoptions,'when_setting_'.$tempkey;
3215: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
3216: if (&isdateparm($defkeytype{$tempkey})) {
3217: push @dateoptions,'later_than_'.$tempkey;
3218: push @datedisplay,&mt('Automatically set later than ').$tempkey;
3219: push @dateoptions,'earlier_than_'.$tempkey;
3220: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
3221: }
3222: }
1.231 www 3223: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
3224: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.221 www 3225: $r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'.
1.222 www 3226: &mt('Action').'</th><th>'.&mt('Value').'</th></tr>');
1.221 www 3227: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 3228: unless ($tempkey) { next; }
1.221 www 3229: $r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 3230: my $action=&rulescache($tempkey.'_action');
3231: $r->print('<select name="'.$tempkey.'_action">');
3232: if (&isdateparm($defkeytype{$tempkey})) {
3233: for (my $i=0;$i<=$#dateoptions;$i++) {
3234: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
3235: $r->print("\n<option value='$dateoptions[$i]'".
3236: ($dateoptions[$i] eq $action?' selected="selected"':'').
3237: ">$datedisplay[$i]</option>");
3238: }
3239: } else {
3240: for (my $i=0;$i<=$#standardoptions;$i++) {
3241: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
3242: $r->print("\n<option value='$standardoptions[$i]'".
3243: ($standardoptions[$i] eq $action?' selected="selected"':'').
3244: ">$standarddisplay[$i]</option>");
3245: }
3246: }
3247: $r->print('</select>');
1.227 www 3248: unless (&isdateparm($defkeytype{$tempkey})) {
3249: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
3250: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
3251: }
1.222 www 3252: $r->print("\n</td><td>\n");
3253:
1.221 www 3254: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3255: my $days=&rulescache($tempkey.'_days');
1.222 www 3256: my $hours=&rulescache($tempkey.'_hours');
3257: my $min=&rulescache($tempkey.'_min');
3258: my $sec=&rulescache($tempkey.'_sec');
1.221 www 3259: $r->print(<<ENDINPUTDATE);
1.227 www 3260: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 3261: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
3262: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
3263: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 3264: ENDINPUTDATE
3265: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 3266: my $yeschecked='';
3267: my $nochecked='';
3268: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
3269: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
3270:
1.221 www 3271: $r->print(<<ENDYESNO);
1.224 www 3272: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
3273: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 3274: ENDYESNO
3275: } else {
1.224 www 3276: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 3277: }
3278: $r->print('</td></tr>');
3279: }
1.224 www 3280: $r->print("</table>\n<input type='submit' name='storerules' value='".
1.280 albertel 3281: &mt('Store Rules')."' /></form>\n".
3282: &Apache::loncommon::end_page());
1.220 www 3283: return;
3284: }
1.193 albertel 3285:
1.178 raeburn 3286: ##################################################
3287: ##################################################
1.30 www 3288:
1.59 matthew 3289: =pod
3290:
1.83 bowersj2 3291: =item * handler
1.59 matthew 3292:
3293: Main handler. Calls &assessparms and &crsenv subroutines.
3294:
3295: =cut
3296: ##################################################
3297: ##################################################
1.220 www 3298: # use Data::Dumper;
3299:
1.259 banghart 3300:
1.30 www 3301: sub handler {
1.43 albertel 3302: my $r=shift;
1.30 www 3303:
1.43 albertel 3304: if ($r->header_only) {
1.126 www 3305: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 3306: $r->send_http_header;
3307: return OK;
3308: }
1.193 albertel 3309: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 3310: ['action','state',
3311: 'pres_marker',
3312: 'pres_value',
1.206 www 3313: 'pres_type',
1.243 banghart 3314: 'udom','uname','symb','serial']);
1.131 www 3315:
1.83 bowersj2 3316:
1.193 albertel 3317: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 3318: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
3319: text=>"Parameter Manager",
1.204 www 3320: faq=>10,
1.194 albertel 3321: bug=>'Instructor Interface'});
1.203 www 3322:
1.30 www 3323: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 3324: my $parm_permission =
3325: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 3326: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 3327: $env{'request.course.sec'}));
1.194 albertel 3328: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 3329:
3330: # Start Page
1.126 www 3331: &Apache::loncommon::content_type($r,'text/html');
1.106 www 3332: $r->send_http_header;
1.30 www 3333:
1.203 www 3334:
3335: # id numbers can change on re-ordering of folders
3336:
3337: &resetsymbcache();
3338:
1.193 albertel 3339: #
3340: # Main switch on form.action and form.state, as appropriate
3341: #
3342: # Check first if coming from someone else headed directly for
3343: # the table mode
3344: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
3345: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
3346: &assessparms($r);
3347:
3348: } elsif (! exists($env{'form.action'})) {
3349: $r->print(&header());
1.194 albertel 3350: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
3351: 'Parameter Manager'));
1.193 albertel 3352: &print_main_menu($r,$parm_permission);
3353: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 3354: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
3355: text=>"Course Environment"});
1.193 albertel 3356: &crsenv($r);
3357: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 3358: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3359: text=>"Overview Mode"});
1.121 www 3360: &overview($r);
1.259 banghart 3361: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
3362: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
3363: text=>"Restrict Metadata"});
3364: &setrestrictmeta($r);
1.208 www 3365: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
3366: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3367: text=>"Overview Mode"});
3368: &newoverview($r);
1.220 www 3369: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
3370: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
3371: text=>"Set Defaults"});
3372: &defaultsetter($r);
3373: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 3374: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 3375: text=>"Table Mode",
3376: help => 'Course_Setting_Parameters'});
1.121 www 3377: &assessparms($r);
1.193 albertel 3378: }
3379:
1.43 albertel 3380: } else {
1.1 www 3381: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 3382: $env{'user.error.msg'}=
1.43 albertel 3383: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
3384: return HTTP_NOT_ACCEPTABLE;
3385: }
3386: return OK;
1.1 www 3387: }
3388:
3389: 1;
3390: __END__
3391:
1.59 matthew 3392: =pod
1.38 harris41 3393:
3394: =back
3395:
3396: =cut
1.1 www 3397:
3398:
3399:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>