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