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