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