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