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