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