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