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