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