Annotation of loncom/interface/lonparmset.pm, revision 1.293
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.293 ! www 4: # $Id: lonparmset.pm,v 1.292 2006/04/18 02:13:49 www Exp $
1.40 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.59 matthew 28: ###################################################################
29: ###################################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: lonparmset - Handler to set parameters for assessments and course
36:
37: =head1 SYNOPSIS
38:
39: lonparmset provides an interface to setting course parameters.
40:
41: =head1 DESCRIPTION
42:
43: This module sets coursewide and assessment parameters.
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over 4
48:
49: =cut
50:
51: ###################################################################
52: ###################################################################
1.1 www 53:
54: package Apache::lonparmset;
55:
56: use strict;
57: use Apache::lonnet;
58: use Apache::Constants qw(:common :http REDIRECT);
1.88 matthew 59: use Apache::lonhtmlcommon();
1.36 albertel 60: use Apache::loncommon;
1.1 www 61: use GDBM_File;
1.57 albertel 62: use Apache::lonhomework;
63: use Apache::lonxml;
1.130 www 64: use Apache::lonlocal;
1.197 www 65: use Apache::lonnavmaps;
1.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.190 albertel 2097: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.105 matthew 2098:
1.30 www 2099: # -------------------------------------------------------- Get parameters again
1.45 matthew 2100:
2101: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2102: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2103: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2104: my $output='';
1.45 matthew 2105: if (! exists($values{'con_lost'})) {
1.30 www 2106: my %descriptions=
1.140 sakharuk 2107: ('url' => '<b>'.&mt('Top Level Map').'</b> '.
1.46 matthew 2108: '<a href="javascript:openbrowser'.
1.47 matthew 2109: "('envform','url','sequence')\">".
1.140 sakharuk 2110: &mt('Select Map').'</a><br /><font color=red> '.
2111: &mt('Modification may make assessment data inaccessible').
2112: '</font>',
2113: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2114: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2115: '</b><br />'.
2116: '('.&mt('internal').', '.&mt('optional').')',
1.177 raeburn 2117: '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 2118: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
2119: '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
1.140 sakharuk 2120: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
1.52 www 2121: '<a href="javascript:openbrowser'.
2122: "('envform','default_xml_style'".
1.140 sakharuk 2123: ",'sty')\">$SelectStyleFile</a><br>",
1.141 sakharuk 2124: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
2125: '</b><br />(<tt>user:domain,'.
1.74 www 2126: 'user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2127: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
1.74 www 2128: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2129: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
1.75 albertel 2130: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2131: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
1.158 sakharuk 2132: '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
1.141 sakharuk 2133: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
1.158 sakharuk 2134: '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
1.141 sakharuk 2135: &mt('changes will not show until next login').')',
1.169 matthew 2136: '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 2137:
1.141 sakharuk 2138: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
2139: '</b><br />"<tt>st</tt>": '.
1.158 sakharuk 2140: &mt('student').', "<tt>ta</tt>": '.
1.118 matthew 2141: 'TA, "<tt>in</tt>": '.
1.158 sakharuk 2142: &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
1.118 matthew 2143: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
2144: 'plc.users.denied' =>
1.141 sakharuk 2145: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.118 matthew 2146: '(<tt>user:domain,user:domain,...</tt>)',
2147:
1.141 sakharuk 2148: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
2149: '</b><br />"<tt>st</tt>": '.
1.61 albertel 2150: 'student, "<tt>ta</tt>": '.
2151: 'TA, "<tt>in</tt>": '.
1.75 albertel 2152: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 2153: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2154: 'pch.users.denied' =>
1.141 sakharuk 2155: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.53 www 2156: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 2157: 'spreadsheet_default_classcalc'
1.141 sakharuk 2158: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2159: '<a href="javascript:openbrowser'.
2160: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2161: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2162: 'spreadsheet_default_studentcalc'
1.141 sakharuk 2163: => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
1.50 matthew 2164: '<a href="javascript:openbrowser'.
2165: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2166: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2167: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2168: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2169: '<a href="javascript:openbrowser'.
2170: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2171: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2172: 'allow_limited_html_in_feedback'
1.141 sakharuk 2173: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.158 sakharuk 2174: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.170 raeburn 2175: 'allow_discussion_post_editing'
1.276 raeburn 2176: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />"<tt>st</tt>": '.
2177: &mt('student').', "<tt>ta</tt>": '.
2178: 'TA, "<tt>in</tt>": '.
2179: &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 />'.
2180: '('.&mt('or set value to "[_1]" to allow all roles',"<tt>yes</tt>").')',
1.89 albertel 2181: 'rndseed'
1.140 sakharuk 2182: => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
2183: '<font color="red">'.&mt('Modifying this will make problems').' '.
2184: &mt('have different numbers and answers').'</font>',
1.151 albertel 2185: 'receiptalg'
2186: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2187: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2188: 'suppress_tries'
1.272 albertel 2189: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.273 www 2190: ' ('.&mt('"[_1]" to suppress, anything else to not suppress','<tt>yes</tt>').')',
1.113 sakharuk 2191: 'problem_stream_switch'
1.141 sakharuk 2192: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.158 sakharuk 2193: ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
1.161 sakharuk 2194: 'default_paper_size'
2195: => '<b>'.&mt('Default paper type').'</b><br />'.
2196: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2197: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2198: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.111 sakharuk 2199: 'anonymous_quiz'
1.150 www 2200: => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
1.141 sakharuk 2201: ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
1.217 albertel 2202: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2203: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.150 www 2204: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
2205: '<br />(<tt>user:domain,user:domain,...</tt>)',
1.140 sakharuk 2206: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2207: 'disable_receipt_display'
1.141 sakharuk 2208: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2209: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.163 albertel 2210: 'disablesigfigs'
2211: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2212: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2213: 'disableexampointprint'
2214: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2215: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2216: 'externalsyllabus'
1.279 www 2217: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2218: 'tthoptions'
2219: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
1.107 matthew 2220: );
1.177 raeburn 2221: my @Display_Order = ('url','description','courseid','cloners','grading',
1.278 www 2222: 'externalsyllabus',
1.107 matthew 2223: 'default_xml_style','pageseparators',
2224: 'question.email','comment.email','policy.email',
1.169 matthew 2225: 'student_classlist_view',
1.118 matthew 2226: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2227: 'pch.roles.denied','pch.users.denied',
2228: 'allow_limited_html_in_feedback',
1.170 raeburn 2229: 'allow_discussion_post_editing',
1.108 www 2230: 'languages',
1.150 www 2231: 'nothideprivileged',
1.107 matthew 2232: 'rndseed',
1.151 albertel 2233: 'receiptalg',
1.107 matthew 2234: 'problem_stream_switch',
1.164 sakharuk 2235: 'suppress_tries',
1.161 sakharuk 2236: 'default_paper_size',
1.115 www 2237: 'disable_receipt_display',
1.107 matthew 2238: 'spreadsheet_default_classcalc',
2239: 'spreadsheet_default_studentcalc',
2240: 'spreadsheet_default_assesscalc',
2241: 'hideemptyrows',
2242: 'default_enrollment_start_date',
2243: 'default_enrollment_end_date',
1.163 albertel 2244: 'tthoptions',
1.251 albertel 2245: 'disablesigfigs',
2246: 'disableexampointprint'
1.107 matthew 2247: );
2248: foreach my $parameter (sort(keys(%values))) {
1.244 banghart 2249: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
1.142 raeburn 2250: if (! $descriptions{$parameter}) {
2251: $descriptions{$parameter}=$parameter;
2252: push(@Display_Order,$parameter);
2253: }
2254: }
1.43 albertel 2255: }
1.107 matthew 2256: foreach my $parameter (@Display_Order) {
2257: my $description = $descriptions{$parameter};
1.51 matthew 2258: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2259: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2260: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2261: '.checked=true;"';
1.107 matthew 2262: $output .= '<tr><td>'.$description.'</td>';
2263: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2264: $output .= '<td>'.
2265: &Apache::lonhtmlcommon::date_setter('envform',
2266: $parameter.'_value',
2267: $values{$parameter},
2268: $onchange).
2269: '</td>';
2270: } else {
2271: $output .= '<td>'.
2272: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2273: $values{$parameter},
2274: 40,$onchange).'</td>';
2275: }
2276: $output .= '<td>'.
2277: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2278: '</td>';
2279: $output .= "</tr>\n";
1.51 matthew 2280: }
1.69 www 2281: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2282: '[\'envform\'].elements[\'newp_setparmval\']'.
2283: '.checked=true;"';
1.130 www 2284: $output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2285: '<input type="text" size=40 name="newp_name" '.
2286: $onchange.' /></td><td>'.
2287: '<input type="text" size=40 name="newp_value" '.
2288: $onchange.' /></td><td>'.
2289: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 2290: }
1.157 sakharuk 2291: my %lt=&Apache::lonlocal::texthash(
2292: 'par' => 'Parameter',
2293: 'val' => 'Value',
2294: 'set' => 'Set',
2295: 'sce' => 'Set Course Environment'
2296: );
2297:
1.140 sakharuk 2298: my $Parameter=&mt('Parameter');
2299: my $Value=&mt('Value');
1.141 sakharuk 2300: my $Set=&mt('Set');
1.280 albertel 2301: my $browse_js=
2302: '<script type="text/javascript" language="Javascript">'.
2303: &Apache::loncommon::browser_and_searcher_javascript('parmset').
2304: '</script>';
2305:
2306: my $start_page =
2307: &Apache::loncommon::start_page('Set Course Environment Parameters',
2308: $browse_js);
2309: my $end_page =
2310: &Apache::loncommon::end_page();
2311: $r->print(<<ENDENV);
2312: $start_page
1.193 albertel 2313: $breadcrumbs
2314: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2315: $setoutput
2316: <p>
2317: <table border=2>
1.157 sakharuk 2318: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
1.30 www 2319: $output
2320: </table>
1.157 sakharuk 2321: <input type="submit" name="crsenv" value="$lt{'sce'}">
1.30 www 2322: </form>
1.280 albertel 2323: $end_page
2324: ENDENV
1.30 www 2325: }
1.120 www 2326: ##################################################
1.207 www 2327: # Overview mode
2328: ##################################################
1.124 www 2329: my $tableopen;
2330:
2331: sub tablestart {
2332: if ($tableopen) {
2333: return '';
2334: } else {
2335: $tableopen=1;
1.130 www 2336: return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
2337: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2338: }
2339: }
2340:
2341: sub tableend {
2342: if ($tableopen) {
2343: $tableopen=0;
2344: return '</table>';
2345: } else {
2346: return'';
2347: }
2348: }
2349:
1.207 www 2350: sub readdata {
2351: my ($crs,$dom)=@_;
2352: # Read coursedata
2353: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2354: # Read userdata
2355:
2356: my $classlist=&Apache::loncoursedata::get_classlist();
2357: foreach (keys %$classlist) {
2358: # the following undefs are for 'domain', and 'username' respectively.
2359: if ($_=~/^(\w+)\:(\w+)$/) {
2360: my ($tuname,$tudom)=($1,$2);
2361: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2362: foreach my $userkey (keys %{$useropt}) {
2363: if ($userkey=~/^$env{'request.course.id'}/) {
2364: my $newkey=$userkey;
2365: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2366: $$resourcedata{$newkey}=$$useropt{$userkey};
2367: }
2368: }
2369: }
2370: }
2371: return $resourcedata;
2372: }
2373:
2374:
1.124 www 2375: # Setting
1.208 www 2376:
2377: sub storedata {
2378: my ($r,$crs,$dom)=@_;
1.207 www 2379: # Set userlevel immediately
2380: # Do an intermediate store of course level
2381: my $olddata=&readdata($crs,$dom);
1.124 www 2382: my %newdata=();
2383: undef %newdata;
2384: my @deldata=();
2385: undef @deldata;
1.190 albertel 2386: foreach (keys %env) {
1.124 www 2387: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2388: my $cmd=$1;
2389: my $thiskey=$2;
1.207 www 2390: my ($tuname,$tudom)=&extractuser($thiskey);
2391: my $tkey=$thiskey;
2392: if ($tuname) {
2393: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2394: }
1.124 www 2395: if ($cmd eq 'set') {
1.190 albertel 2396: my $data=$env{$_};
1.212 www 2397: my $typeof=$env{'form.typeof_'.$thiskey};
2398: if ($$olddata{$thiskey} ne $data) {
1.207 www 2399: if ($tuname) {
1.212 www 2400: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2401: $tkey.'.type' => $typeof},
2402: $tudom,$tuname) eq 'ok') {
1.290 www 2403: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.207 www 2404: $r->print('<br />'.&mt('Stored modified parameter for').' '.
2405: &Apache::loncommon::plainname($tuname,$tudom));
2406: } else {
2407: $r->print('<h2><font color="red">'.
2408: &mt('Error storing parameters').'</font></h2>');
2409: }
2410: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2411: } else {
2412: $newdata{$thiskey}=$data;
1.212 www 2413: $newdata{$thiskey.'.type'}=$typeof;
2414: }
1.207 www 2415: }
1.124 www 2416: } elsif ($cmd eq 'del') {
1.207 www 2417: if ($tuname) {
2418: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 2419: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 2420: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2421: } else {
2422: $r->print('<h2><font color="red">'.
2423: &mt('Error deleting parameters').'</font></h2>');
2424: }
2425: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2426: } else {
2427: push (@deldata,$thiskey);
2428: }
1.124 www 2429: } elsif ($cmd eq 'datepointer') {
1.190 albertel 2430: my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
1.212 www 2431: my $typeof=$env{'form.typeof_'.$thiskey};
1.207 www 2432: if (defined($data) and $$olddata{$thiskey} ne $data) {
2433: if ($tuname) {
1.212 www 2434: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2435: $tkey.'.type' => $typeof},
2436: $tudom,$tuname) eq 'ok') {
1.290 www 2437: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.207 www 2438: $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2439: } else {
2440: $r->print('<h2><font color="red">'.
2441: &mt('Error storing parameters').'</font></h2>');
2442: }
2443: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2444: } else {
1.212 www 2445: $newdata{$thiskey}=$data;
2446: $newdata{$thiskey.'.type'}=$typeof;
1.207 www 2447: }
2448: }
1.124 www 2449: }
2450: }
2451: }
1.207 www 2452: # Store all course level
1.144 www 2453: my $delentries=$#deldata+1;
2454: my @newdatakeys=keys %newdata;
2455: my $putentries=$#newdatakeys+1;
2456: if ($delentries) {
2457: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 2458: my %loghash=map { $_ => '' } @deldata;
2459: &log_parmset(\%loghash,1);
1.144 www 2460: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2461: } else {
2462: $r->print('<h2><font color="red">'.
2463: &mt('Error deleting parameters').'</font></h2>');
2464: }
1.205 www 2465: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2466: }
2467: if ($putentries) {
2468: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 2469: &log_parmset(\%newdata,0);
1.212 www 2470: $r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2471: } else {
2472: $r->print('<h2><font color="red">'.
2473: &mt('Error storing parameters').'</font></h2>');
2474: }
1.205 www 2475: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2476: }
1.208 www 2477: }
1.207 www 2478:
1.208 www 2479: sub extractuser {
2480: my $key=shift;
2481: return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
2482: }
1.206 www 2483:
1.208 www 2484: sub listdata {
1.214 www 2485: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2486: # Start list output
1.206 www 2487:
1.122 www 2488: my $oldsection='';
2489: my $oldrealm='';
2490: my $oldpart='';
1.123 www 2491: my $pointer=0;
1.124 www 2492: $tableopen=0;
1.145 www 2493: my $foundkeys=0;
1.248 albertel 2494: my %keyorder=&standardkeyorder();
1.214 www 2495: foreach my $thiskey (sort {
2496: if ($sortorder eq 'realmstudent') {
1.247 albertel 2497: my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2498: my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2499: if (!defined($astudent)) {
2500: ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.237 albertel 2501: }
1.247 albertel 2502: if (!defined($bstudent)) {
2503: ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2504: }
1.248 albertel 2505: $arealm=~s/\.type//;
2506: my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
2507: $aparm=$keyorder{'parameter_0_'.$aparm};
2508: $brealm=~s/\.type//;
2509: my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
2510: $bparm=$keyorder{'parameter_0_'.$bparm};
2511: if ($ares eq $bres) {
2512: if (defined($aparm) && defined($bparm)) {
2513: ($aparm <=> $bparm);
2514: } elsif (defined($aparm)) {
2515: -1;
2516: } elsif (defined($bparm)) {
2517: 1;
2518: } else {
2519: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2520: }
2521: } else {
2522: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2523: }
1.214 www 2524: } else {
2525: $a cmp $b;
2526: }
2527: } keys %{$listdata}) {
1.247 albertel 2528:
1.211 www 2529: if ($$listdata{$thiskey.'.type'}) {
2530: my $thistype=$$listdata{$thiskey.'.type'};
2531: if ($$resourcedata{$thiskey.'.type'}) {
2532: $thistype=$$resourcedata{$thiskey.'.type'};
2533: }
1.207 www 2534: my ($middle,$part,$name)=
2535: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2536: my $section=&mt('All Students');
1.207 www 2537: if ($middle=~/^\[(.*)\]/) {
1.206 www 2538: my $issection=$1;
2539: if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
2540: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
2541: } else {
2542: $section=&mt('Group/Section').': '.$issection;
2543: }
1.207 www 2544: $middle=~s/^\[(.*)\]//;
1.122 www 2545: }
1.207 www 2546: $middle=~s/\.+$//;
2547: $middle=~s/^\.+//;
1.130 www 2548: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.122 www 2549: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.174 albertel 2550: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.122 www 2551: } elsif ($middle) {
1.174 albertel 2552: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
2553: $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 2554: }
1.214 www 2555: if ($sortorder eq 'realmstudent') {
2556: if ($realm ne $oldrealm) {
2557: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
2558: $oldrealm=$realm;
2559: $oldsection='';
2560: }
2561: if ($section ne $oldsection) {
2562: $r->print(&tableend()."\n<h2>$section</h2>");
2563: $oldsection=$section;
2564: $oldpart='';
2565: }
2566: } else {
2567: if ($section ne $oldsection) {
2568: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
2569: $oldsection=$section;
2570: $oldrealm='';
2571: }
2572: if ($realm ne $oldrealm) {
2573: $r->print(&tableend()."\n<h2>$realm</h2>");
2574: $oldrealm=$realm;
2575: $oldpart='';
2576: }
1.122 www 2577: }
2578: if ($part ne $oldpart) {
1.124 www 2579: $r->print(&tableend().
1.214 www 2580: "\n<font color='blue'>".&mt('Part').": $part</font>");
1.122 www 2581: $oldpart=$part;
2582: }
1.123 www 2583: #
1.230 www 2584: # Preset defaults?
2585: #
2586: my ($hour,$min,$sec,$val)=('','','','');
2587: unless ($$resourcedata{$thiskey}) {
2588: my ($parmname)=($thiskey=~/\.(\w+)$/);
2589: ($hour,$min,$sec,$val)=&preset_defaults($parmname);
2590: }
2591:
2592: #
1.123 www 2593: # Ready to print
2594: #
1.293 ! www 2595: $r->print(&tablestart().'<tr><td><b>'.&standard_parameter_names($name).
! 2596: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 2597: $thiskey.'" /></td><td>');
1.145 www 2598: $foundkeys++;
1.213 www 2599: if (&isdateparm($thistype)) {
1.123 www 2600: my $jskey='key_'.$pointer;
2601: $pointer++;
2602: $r->print(
1.232 albertel 2603: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 2604: $jskey,
1.219 www 2605: $$resourcedata{$thiskey},
1.230 www 2606: '',1,'','',$hour,$min,$sec).
1.277 www 2607: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
2608: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 2609: );
1.219 www 2610: } elsif ($thistype eq 'string_yesno') {
1.230 www 2611: my $showval;
2612: if (defined($$resourcedata{$thiskey})) {
2613: $showval=$$resourcedata{$thiskey};
2614: } else {
2615: $showval=$val;
2616: }
1.219 www 2617: $r->print('<label><input type="radio" name="set_'.$thiskey.
2618: '" value="yes"');
1.230 www 2619: if ($showval eq 'yes') {
1.219 www 2620: $r->print(' checked="checked"');
2621: }
2622: $r->print(' />'.&mt('Yes').'</label> ');
2623: $r->print('<label><input type="radio" name="set_'.$thiskey.
2624: '" value="no"');
1.230 www 2625: if ($showval eq 'no') {
1.219 www 2626: $r->print(' checked="checked"');
2627: }
2628: $r->print(' />'.&mt('No').'</label>');
1.123 www 2629: } else {
1.230 www 2630: my $showval;
2631: if (defined($$resourcedata{$thiskey})) {
2632: $showval=$$resourcedata{$thiskey};
2633: } else {
2634: $showval=$val;
2635: }
1.211 www 2636: $r->print('<input type="text" name="set_'.$thiskey.'" value="'.
1.230 www 2637: $showval.'">');
1.123 www 2638: }
1.211 www 2639: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
2640: $thistype.'">');
1.124 www 2641: $r->print('</td></tr>');
1.122 www 2642: }
1.121 www 2643: }
1.208 www 2644: return $foundkeys;
2645: }
2646:
2647: sub newoverview {
1.280 albertel 2648: my ($r) = @_;
2649:
1.208 www 2650: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2651: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 2652: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.208 www 2653: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
2654: $r->print(<<ENDOVER);
1.280 albertel 2655: $start_page
1.208 www 2656: $breadcrumbs
1.232 albertel 2657: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 2658: ENDOVER
1.211 www 2659: my @ids=();
2660: my %typep=();
2661: my %keyp=();
2662: my %allparms=();
2663: my %allparts=();
2664: my %allmaps=();
2665: my %mapp=();
2666: my %symbp=();
2667: my %maptitles=();
2668: my %uris=();
2669: my %keyorder=&standardkeyorder();
2670: my %defkeytype=();
2671:
2672: my %alllevs=();
2673: $alllevs{'Resource Level'}='full';
1.215 www 2674: $alllevs{'Map/Folder Level'}='map';
1.211 www 2675: $alllevs{'Course Level'}='general';
2676:
2677: my $csec=$env{'form.csec'};
1.269 raeburn 2678: my $cgroup=$env{'form.cgroup'};
1.211 www 2679:
2680: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
2681: my $pschp=$env{'form.pschp'};
2682: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
2683: if (!@psprt) { $psprt[0]='0'; }
2684:
2685: my @selected_sections =
2686: &Apache::loncommon::get_env_multiple('form.Section');
2687: @selected_sections = ('all') if (! @selected_sections);
2688: foreach (@selected_sections) {
2689: if ($_ eq 'all') {
2690: @selected_sections = ('all');
2691: }
2692: }
1.269 raeburn 2693: my @selected_groups =
2694: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 2695:
2696: my $pssymb='';
2697: my $parmlev='';
2698:
2699: unless ($env{'form.parmlev'}) {
2700: $parmlev = 'map';
2701: } else {
2702: $parmlev = $env{'form.parmlev'};
2703: }
2704:
2705: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
2706: \%mapp, \%symbp,\%maptitles,\%uris,
2707: \%keyorder,\%defkeytype);
2708:
2709: # Menu to select levels, etc
2710:
2711: $r->print('<table border="1"><tr><td>');
2712: &levelmenu($r,\%alllevs,$parmlev);
2713: if ($parmlev ne 'general') {
2714: $r->print('<td>');
2715: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
2716: $r->print('</td>');
2717: }
2718: $r->print('</td></tr></table>');
2719:
2720: $r->print('<table border="1"><tr><td>');
2721: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.269 raeburn 2722: $r->print('</td><td><table border="0" cellspacing="0" cellpadding="0">'.
2723: '<tr><td>'.&mt('Parts').'</td><td></td><td>'.&mt('Section(s)').
2724: '</td><td></td><td>'.&mt('Group(s)').'</td></tr><tr><td>');
1.211 www 2725: &partmenu($r,\%allparts,\@psprt);
1.269 raeburn 2726: $r->print('</td><td> </td><td>');
1.211 www 2727: §ionmenu($r,\@selected_sections);
1.269 raeburn 2728: $r->print('</td><td> </td><td>');
2729: &groupmenu($r,\@selected_groups);
2730: $r->print('</td></tr></table>');
1.214 www 2731: $r->print('</td></tr></table>');
2732:
2733: my $sortorder=$env{'form.sortorder'};
2734: unless ($sortorder) { $sortorder='realmstudent'; }
2735: &sortmenu($r,$sortorder);
2736:
2737: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 2738:
2739: # Build the list data hash from the specified parms
2740:
2741: my $listdata;
2742: %{$listdata}=();
2743:
2744: foreach my $cat (@pscat) {
1.269 raeburn 2745: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
2746: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 2747: }
2748:
1.212 www 2749: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 2750:
1.212 www 2751: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 2752:
2753: # Read modified data
2754:
2755: my $resourcedata=&readdata($crs,$dom);
2756:
2757: # List data
2758:
1.214 www 2759: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 2760: }
2761: $r->print(&tableend().
1.212 www 2762: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':'').
1.280 albertel 2763: '</form>'.&Apache::loncommon::end_page());
1.208 www 2764: }
2765:
1.269 raeburn 2766: sub secgroup_lister {
2767: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
2768: foreach my $item (@{$selections}) {
2769: foreach my $part (@{$psprt}) {
2770: my $rootparmkey=$env{'request.course.id'};
2771: if (($item ne 'all') && ($item ne 'none') && ($item)) {
2772: $rootparmkey.='.['.$item.']';
2773: }
2774: if ($parmlev eq 'general') {
2775: # course-level parameter
2776: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
2777: $$listdata{$newparmkey}=1;
2778: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2779: } elsif ($parmlev eq 'map') {
2780: # map-level parameter
2781: foreach my $mapid (keys %{$allmaps}) {
2782: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
2783: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
2784: $$listdata{$newparmkey}=1;
2785: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2786: }
2787: } else {
2788: # resource-level parameter
2789: foreach my $rid (@{$ids}) {
2790: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
2791: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
2792: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
2793: $$listdata{$newparmkey}=1;
2794: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2795: }
2796: }
2797: }
2798: }
2799: }
2800:
1.208 www 2801: sub overview {
1.280 albertel 2802: my ($r) = @_;
1.208 www 2803: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2804: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 2805:
2806: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.208 www 2807: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
2808: $r->print(<<ENDOVER);
1.280 albertel 2809: $start_page
1.208 www 2810: $breadcrumbs
1.232 albertel 2811: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 2812: ENDOVER
2813: # Store modified
2814:
2815: &storedata($r,$crs,$dom);
2816:
2817: # Read modified data
2818:
2819: my $resourcedata=&readdata($crs,$dom);
2820:
1.214 www 2821:
2822: my $sortorder=$env{'form.sortorder'};
2823: unless ($sortorder) { $sortorder='realmstudent'; }
2824: &sortmenu($r,$sortorder);
2825:
1.208 www 2826: # List data
2827:
1.214 www 2828: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 2829:
1.145 www 2830: $r->print(&tableend().'<p>'.
1.280 albertel 2831: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
2832: &Apache::loncommon::end_page());
1.120 www 2833: }
1.121 www 2834:
1.59 matthew 2835: ##################################################
2836: ##################################################
1.178 raeburn 2837:
2838: =pod
1.239 raeburn 2839:
2840: =item check_cloners
2841:
2842: Checks if new users included in list of allowed cloners
2843: are valid users. Replaces supplied list with
2844: cleaned list containing only users with valid usernames
2845: and domains.
2846:
2847: Inputs: $clonelist, $oldcloner
2848: where $clonelist is ref to array of requested cloners,
2849: and $oldcloner is ref to array of currently allowed
2850: cloners.
2851:
2852: Returns: string - comma separated list of requested
2853: cloners (username:domain) who do not exist in system.
2854:
2855: =item change_clone
2856:
1.178 raeburn 2857: Modifies the list of courses a user can clone (stored
1.239 raeburn 2858: in the user's environment.db file), called when a
1.178 raeburn 2859: change is made to the list of users allowed to clone
2860: a course.
1.239 raeburn 2861:
1.178 raeburn 2862: Inputs: $action,$cloner
2863: where $action is add or drop, and $cloner is identity of
2864: user for whom cloning ability is to be changed in course.
2865:
2866: =cut
2867:
2868: ##################################################
2869: ##################################################
2870:
1.239 raeburn 2871: sub extract_cloners {
2872: my ($clonelist,$allowclone) = @_;
2873: if ($clonelist =~ /,/) {
2874: @{$allowclone} = split/,/,$clonelist;
2875: } else {
2876: $$allowclone[0] = $clonelist;
2877: }
2878: }
2879:
2880:
2881: sub check_cloners {
2882: my ($clonelist,$oldcloner) = @_;
2883: my ($clean_clonelist,$disallowed);
2884: my @allowclone = ();
2885: &extract_cloners($$clonelist,\@allowclone);
2886: foreach my $currclone (@allowclone) {
2887: if (!grep/^$currclone$/,@$oldcloner) {
2888: my ($uname,$udom) = split/:/,$currclone;
2889: if ($uname && $udom) {
2890: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2891: $disallowed .= $currclone.',';
2892: } else {
2893: $clean_clonelist .= $currclone.',';
2894: }
2895: }
2896: } else {
2897: $clean_clonelist .= $currclone.',';
2898: }
2899: }
2900: if ($disallowed) {
2901: $disallowed =~ s/,$//;
2902: }
2903: if ($clean_clonelist) {
2904: $clean_clonelist =~ s/,$//;
2905: }
2906: $$clonelist = $clean_clonelist;
2907: return $disallowed;
2908: }
1.178 raeburn 2909:
2910: sub change_clone {
2911: my ($clonelist,$oldcloner) = @_;
2912: my ($uname,$udom);
1.190 albertel 2913: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2914: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 2915: my $clone_crs = $cnum.':'.$cdom;
2916:
2917: if ($cnum && $cdom) {
1.239 raeburn 2918: my @allowclone;
2919: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 2920: foreach my $currclone (@allowclone) {
2921: if (!grep/^$currclone$/,@$oldcloner) {
2922: ($uname,$udom) = split/:/,$currclone;
2923: if ($uname && $udom) {
2924: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2925: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2926: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
2927: if ($currclonecrs{'cloneable'} eq '') {
2928: $currclonecrs{'cloneable'} = $clone_crs;
2929: } else {
2930: $currclonecrs{'cloneable'} .= ','.$clone_crs;
2931: }
2932: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
2933: }
2934: }
2935: }
2936: }
2937: }
2938: foreach my $oldclone (@$oldcloner) {
2939: if (!grep/^$oldclone$/,@allowclone) {
2940: ($uname,$udom) = split/:/,$oldclone;
2941: if ($uname && $udom) {
2942: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2943: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2944: my %newclonecrs = ();
2945: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
2946: if ($currclonecrs{'cloneable'} =~ /,/) {
2947: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
2948: foreach (@currclonecrs) {
2949: unless ($_ eq $clone_crs) {
2950: $newclonecrs{'cloneable'} .= $_.',';
2951: }
2952: }
2953: $newclonecrs{'cloneable'} =~ s/,$//;
2954: } else {
2955: $newclonecrs{'cloneable'} = '';
2956: }
2957: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
2958: }
2959: }
2960: }
2961: }
2962: }
2963: }
2964: }
2965:
1.193 albertel 2966:
2967: ##################################################
2968: ##################################################
2969:
2970: =pod
2971:
2972: =item * header
2973:
2974: Output html header for page
2975:
2976: =cut
2977:
2978: ##################################################
2979: ##################################################
2980: sub header {
1.280 albertel 2981: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 2982: }
2983: ##################################################
2984: ##################################################
2985: sub print_main_menu {
2986: my ($r,$parm_permission)=@_;
2987: #
2988: $r->print(<<ENDMAINFORMHEAD);
2989: <form method="post" enctype="multipart/form-data"
2990: action="/adm/parmset" name="studentform">
2991: ENDMAINFORMHEAD
2992: #
1.195 albertel 2993: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2994: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 2995: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
2996:
1.193 albertel 2997: my @menu =
2998: (
2999: { text => 'Set Course Environment Parameters',
1.204 www 3000: action => 'crsenv',
1.193 albertel 3001: permission => $parm_permission,
3002: },
1.255 banghart 3003: { text => 'Set Portfolio Metadata',
1.259 banghart 3004: action => 'setrestrictmeta',
1.240 banghart 3005: permission => $parm_permission,
3006: },
1.271 www 3007: { text => 'Manage Course Slots',
1.268 albertel 3008: url => '/adm/slotrequest?command=showslots',
3009: permission => $vgr,
3010: },
3011: { divider => 1,
3012: },
1.216 www 3013: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3014: url => '/adm/helper/parameter.helper',
3015: permission => $parm_permission,
3016: },
1.216 www 3017: { text => 'Modify Resource Parameters - Overview Mode',
1.193 albertel 3018: action => 'setoverview',
3019: permission => $parm_permission,
1.208 www 3020: },
1.216 www 3021: { text => 'Set Resource Parameters - Overview Mode',
1.208 www 3022: action => 'newoverview',
3023: permission => $parm_permission,
1.193 albertel 3024: },
1.216 www 3025: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3026: action => 'settable',
3027: permission => $parm_permission,
1.204 www 3028: help => 'Cascading_Parameters',
1.193 albertel 3029: },
1.220 www 3030: { text => 'Set Parameter Setting Default Actions',
3031: action => 'setdefaults',
3032: permission => $parm_permission,
1.284 www 3033: },
1.292 www 3034: { text => 'Parameter Change Log and Course Blog Posting/User Notification',
1.284 www 3035: action => 'parameterchangelog',
3036: permission => $parm_permission,
1.220 www 3037: },
1.193 albertel 3038: );
3039: my $menu_html = '';
3040: foreach my $menu_item (@menu) {
1.268 albertel 3041: if ($menu_item->{'divider'}) {
3042: $menu_html .= '<hr />';
3043: next;
3044: }
1.193 albertel 3045: next if (! $menu_item->{'permission'});
3046: $menu_html.='<p>';
3047: $menu_html.='<font size="+1">';
3048: if (exists($menu_item->{'url'})) {
3049: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3050: } else {
3051: $menu_html.=
3052: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3053: }
3054: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
3055: if (exists($menu_item->{'help'})) {
3056: $menu_html.=
3057: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3058: }
3059: $menu_html.='</p>'.$/;
3060: }
3061: $r->print($menu_html);
3062: return;
3063: }
1.255 banghart 3064: ### Set portfolio metadata
1.252 banghart 3065: sub output_row {
1.255 banghart 3066: my ($r, $field_name, $field_text) = @_;
1.252 banghart 3067: my $output;
1.263 banghart 3068: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3069: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.254 banghart 3070: unless (defined($options)) {
3071: $options = 'active,stuadd';
1.261 banghart 3072: $values = '';
1.252 banghart 3073: }
1.260 banghart 3074: $output.='<strong>'.$field_text.':</strong>';
1.264 albertel 3075: $output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />';
3076:
3077: my @options= ( ['active', 'Show to student'],
3078: ['onlyone','Student may select only one choice'],
3079: ['stuadd', 'Student may type choices']);
3080: foreach my $opt (@options) {
3081: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3082: $output.=(' 'x5).'<label><input type="checkbox" name="'.
3083: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3084: &mt($opt->[1]).'</label> <br />';
1.252 banghart 3085: }
3086: return ($output);
3087: }
1.259 banghart 3088:
3089: sub setrestrictmeta {
1.240 banghart 3090: my ($r)=@_;
1.242 banghart 3091: my $next_meta;
1.244 banghart 3092: my $output;
1.245 banghart 3093: my $item_num;
1.246 banghart 3094: my $put_result;
1.280 albertel 3095:
3096: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.240 banghart 3097: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
1.260 banghart 3098: 'Restrict Metadata'));
1.240 banghart 3099: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3100: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3101: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3102: my $save_field = '';
1.259 banghart 3103: if ($env{'form.restrictmeta'}) {
1.254 banghart 3104: foreach my $field (sort(keys(%env))) {
1.252 banghart 3105: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3106: my $options;
1.252 banghart 3107: my $meta_field = $1;
3108: my $meta_key = $2;
1.253 banghart 3109: if ($save_field ne $meta_field) {
1.252 banghart 3110: $save_field = $meta_field;
1.253 banghart 3111: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3112: $options.='stuadd,';
3113: }
1.253 banghart 3114: if ($env{'form.'.$meta_field.'_onlyone'}) {
1.254 banghart 3115: $options.='onlyone,';
3116: }
3117: if ($env{'form.'.$meta_field.'_active'}) {
3118: $options.='active,';
1.253 banghart 3119: }
1.259 banghart 3120: my $name = $save_field;
1.253 banghart 3121: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3122: {'metadata.'.$meta_field.'.options'=>$options,
3123: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 3124: },$dom,$crs);
1.252 banghart 3125: }
3126: }
3127: }
3128: }
3129: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.258 albertel 3130: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
3131: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 3132: &Apache::lonnet::logthis ($field);
3133: if ($field ne 'courserestricted') {
3134: $output.= &output_row($r, $field, $metadata_fields{$field});
3135: }
1.255 banghart 3136: }
1.244 banghart 3137: $r->print(<<ENDenv);
1.259 banghart 3138: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 3139: <p>
3140: $output
1.259 banghart 3141: <input type="submit" name="restrictmeta" value="Update Metadata Restrictions">
1.244 banghart 3142: </form>
3143: ENDenv
1.280 albertel 3144: $r->print(&Apache::loncommon::end_page());
1.240 banghart 3145: return 'ok';
3146: }
1.220 www 3147: ##################################################
1.193 albertel 3148:
1.220 www 3149: sub defaultsetter {
1.280 albertel 3150: my ($r) = @_;
3151:
3152: my $start_page =
3153: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.220 www 3154: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults');
3155: $r->print(<<ENDDEFHEAD);
1.280 albertel 3156: $start_page
1.220 www 3157: $breadcrumbs
3158: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
3159: ENDDEFHEAD
1.280 albertel 3160:
3161: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3162: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 3163: my @ids=();
3164: my %typep=();
3165: my %keyp=();
3166: my %allparms=();
3167: my %allparts=();
3168: my %allmaps=();
3169: my %mapp=();
3170: my %symbp=();
3171: my %maptitles=();
3172: my %uris=();
3173: my %keyorder=&standardkeyorder();
3174: my %defkeytype=();
3175:
3176: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3177: \%mapp, \%symbp,\%maptitles,\%uris,
3178: \%keyorder,\%defkeytype);
1.224 www 3179: if ($env{'form.storerules'}) {
3180: my %newrules=();
3181: my @delrules=();
1.226 www 3182: my %triggers=();
1.225 albertel 3183: foreach my $key (keys(%env)) {
3184: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 3185: my $tempkey=$1;
1.226 www 3186: my $action=$env{$key};
3187: if ($action) {
3188: $newrules{$tempkey.'_action'}=$action;
3189: if ($action ne 'default') {
3190: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
3191: $triggers{$whichparm}.=$tempkey.':';
3192: }
3193: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 3194: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3195: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 3196: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
3197: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
3198: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
3199: } else {
3200: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 3201: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 3202: }
3203: } else {
1.225 albertel 3204: push(@delrules,$tempkey.'_action');
1.226 www 3205: push(@delrules,$tempkey.'_type');
1.225 albertel 3206: push(@delrules,$tempkey.'_hours');
3207: push(@delrules,$tempkey.'_min');
3208: push(@delrules,$tempkey.'_sec');
3209: push(@delrules,$tempkey.'_value');
1.224 www 3210: }
3211: }
3212: }
1.226 www 3213: foreach my $key (keys %allparms) {
3214: $newrules{$key.'_triggers'}=$triggers{$key};
3215: }
1.224 www 3216: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
3217: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
3218: &resetrulescache();
3219: }
1.227 www 3220: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
3221: 'hours' => 'Hours',
1.221 www 3222: 'min' => 'Minutes',
3223: 'sec' => 'Seconds',
3224: 'yes' => 'Yes',
3225: 'no' => 'No');
1.222 www 3226: my @standardoptions=('','default');
3227: my @standarddisplay=('',&mt('Default value when manually setting'));
3228: my @dateoptions=('','default');
3229: my @datedisplay=('',&mt('Default value when manually setting'));
3230: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
3231: unless ($tempkey) { next; }
3232: push @standardoptions,'when_setting_'.$tempkey;
3233: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
3234: if (&isdateparm($defkeytype{$tempkey})) {
3235: push @dateoptions,'later_than_'.$tempkey;
3236: push @datedisplay,&mt('Automatically set later than ').$tempkey;
3237: push @dateoptions,'earlier_than_'.$tempkey;
3238: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
3239: }
3240: }
1.231 www 3241: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
3242: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.221 www 3243: $r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'.
1.222 www 3244: &mt('Action').'</th><th>'.&mt('Value').'</th></tr>');
1.221 www 3245: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 3246: unless ($tempkey) { next; }
1.221 www 3247: $r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 3248: my $action=&rulescache($tempkey.'_action');
3249: $r->print('<select name="'.$tempkey.'_action">');
3250: if (&isdateparm($defkeytype{$tempkey})) {
3251: for (my $i=0;$i<=$#dateoptions;$i++) {
3252: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
3253: $r->print("\n<option value='$dateoptions[$i]'".
3254: ($dateoptions[$i] eq $action?' selected="selected"':'').
3255: ">$datedisplay[$i]</option>");
3256: }
3257: } else {
3258: for (my $i=0;$i<=$#standardoptions;$i++) {
3259: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
3260: $r->print("\n<option value='$standardoptions[$i]'".
3261: ($standardoptions[$i] eq $action?' selected="selected"':'').
3262: ">$standarddisplay[$i]</option>");
3263: }
3264: }
3265: $r->print('</select>');
1.227 www 3266: unless (&isdateparm($defkeytype{$tempkey})) {
3267: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
3268: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
3269: }
1.222 www 3270: $r->print("\n</td><td>\n");
3271:
1.221 www 3272: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3273: my $days=&rulescache($tempkey.'_days');
1.222 www 3274: my $hours=&rulescache($tempkey.'_hours');
3275: my $min=&rulescache($tempkey.'_min');
3276: my $sec=&rulescache($tempkey.'_sec');
1.221 www 3277: $r->print(<<ENDINPUTDATE);
1.227 www 3278: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 3279: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
3280: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
3281: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 3282: ENDINPUTDATE
3283: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 3284: my $yeschecked='';
3285: my $nochecked='';
3286: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
3287: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
3288:
1.221 www 3289: $r->print(<<ENDYESNO);
1.224 www 3290: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
3291: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 3292: ENDYESNO
3293: } else {
1.224 www 3294: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 3295: }
3296: $r->print('</td></tr>');
3297: }
1.224 www 3298: $r->print("</table>\n<input type='submit' name='storerules' value='".
1.280 albertel 3299: &mt('Store Rules')."' /></form>\n".
3300: &Apache::loncommon::end_page());
1.220 www 3301: return;
3302: }
1.193 albertel 3303:
1.290 www 3304: sub components {
1.291 www 3305: my ($key,$uname,$udom,$exeuser,$exedomain)=@_;
1.290 www 3306: my $typeflag=0;
3307: if ($key=~/\.type$/) {
3308: $key=~s/\.type$//;
3309: $typeflag=1;
3310: }
1.291 www 3311: my $issection;
1.290 www 3312: my ($middle,$part,$name)=($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3313: my $section=&mt('All Students');
3314: if ($middle=~/^\[(.*)\]/) {
1.291 www 3315: $issection=$1;
3316: $section=&mt('Group/Section').': '.$issection;
1.290 www 3317: $middle=~s/^\[(.*)\]//;
3318: }
3319: $middle=~s/\.+$//;
3320: $middle=~s/^\.+//;
1.291 www 3321: if ($uname) {
3322: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
3323: $issection='';
3324: }
1.290 www 3325: my $realm='<font color="red">'.&mt('All Resources').'</font>';
3326: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3327: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
3328: } elsif ($middle) {
3329: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
3330: $realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
3331: }
1.291 www 3332: my $what=$part.'.'.$name;
3333: return ($realm,$section,$name,$part,$typeflag,
3334: $what,$middle,$uname,$udom,$issection);
1.290 www 3335: }
1.293 ! www 3336:
1.292 www 3337: sub standard_parameter_names {
3338: my ($name)=@_;
3339: my %standard_parms=&Apache::lonlocal::texthash('duedate' => 'Due Date',
3340: 'answerdate' => 'Answer Date',
3341: 'opendate' => 'Open Date',
3342: 'maxtries' => 'Max. Number of Tries',
3343: 'weight' => 'Weight',
3344: 'date_start' => 'Starting Date',
1.293 ! www 3345: 'date_end' => 'Ending Date',
! 3346: 'int_pos' => 'Positive Integer',
! 3347: 'int_zero_pos' => 'Positive Integer or Zero',
! 3348: 'hinttries' => 'Number of Tries till Hints appear');
1.292 www 3349: if ($standard_parms{$name}) {
3350: return $standard_parms{$name};
3351: } else {
3352: return $name;
3353: }
3354: }
1.290 www 3355:
1.285 albertel 3356: sub parm_change_log {
1.284 www 3357: my ($r)=@_;
3358: &startpage($r);
1.286 www 3359: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
3360: $env{'course.'.$env{'request.course.id'}.'.domain'},
3361: $env{'course.'.$env{'request.course.id'}.'.num'});
3362: my %exetime=();
1.287 albertel 3363: foreach my $key (keys(%parmlog)) {
1.286 www 3364: if ($key=~/^(.+)\_exe\_time$/) {
3365: $exetime{$1}=$parmlog{$key};
3366: }
1.291 www 3367: }
3368: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
3369: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.286 www 3370: $r->print('<table border="2">');
1.293 ! www 3371: my $bgcolor='#EEEEEE';
1.291 www 3372: foreach my $id (sort { $exetime{$b}<=>$exetime{$a} } (keys(%exetime))) {
1.293 ! www 3373: if ($bgcolor eq '#EEEEEE') { $bgcolor='#FFFFCC'; } else { $bgcolor='#EEEEEE'; }
! 3374: my @changes=keys(%{$parmlog{$id.'_logentry'}});
1.290 www 3375: my $count=$#changes+1;
1.288 albertel 3376: my $time =
3377: &Apache::lonlocal::locallocaltime($parmlog{$id.'_exe_time'});
1.289 www 3378: my $plainname =
1.288 albertel 3379: &Apache::loncommon::plainname($parmlog{$id.'_exe_uname'},
3380: $parmlog{$id.'_exe_udom'});
3381: my $about_me_link =
1.289 www 3382: &Apache::loncommon::aboutmewrapper($plainname,
1.288 albertel 3383: $parmlog{$id.'_exe_uname'},
3384: $parmlog{$id.'_exe_udom'});
1.293 ! www 3385: my $send_msg_link='';
1.288 albertel 3386: if ((($parmlog{$id.'_exe_uname'} ne $env{'user.name'})
3387: || ($parmlog{$id.'_exe_udom'} ne $env{'user.domain'}))) {
1.293 ! www 3388: $send_msg_link ='<br />'.
1.288 albertel 3389: &Apache::loncommon::messagewrapper(&mt('Send message'),
3390: $parmlog{$id.'_exe_uname'},
3391: $parmlog{$id.'_exe_udom'});
3392: }
1.293 ! www 3393: $r->print('<tr bgcolor="'.$bgcolor.'"><td rowspan="'.$count.'">'.$time.'</td>
1.290 www 3394: <td rowspan="'.$count.'">'.$about_me_link.
3395: '<br /><tt>'.$parmlog{$id.'_exe_uname'}.
3396: ':'.$parmlog{$id.'_exe_udom'}.'</tt>'.
3397: $send_msg_link.'</td>');
3398: my $makenewrow=0;
3399: my %istype=();
1.293 ! www 3400: foreach my $changed (reverse(sort(@changes))) {
! 3401: my $value=$parmlog{$id.'_logentry'}->{$changed};
1.291 www 3402: my ($realm,$section,$parmname,$part,$typeflag,$what,$middle,$uname,$udom,$issection)=
1.293 ! www 3403: &components($changed,$parmlog{$id.'_uname'},$parmlog{$id.'_udom'});
1.290 www 3404: if ($typeflag) { $istype{$parmname}=$value; }
1.293 ! www 3405: if ($makenewrow) { $r->print('<tr bgcolor="'.$bgcolor.'">'); } else { $makenewrow=1; }
1.290 www 3406: $r->print('<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 3407: &standard_parameter_names($parmname).'</td><td>'.
3408: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>');
1.291 www 3409: my $stillactive=0;
1.290 www 3410: if ($parmlog{$id.'_deleteflag'}) {
3411: $r->print(&mt('Deleted'));
1.288 albertel 3412: } else {
1.290 www 3413: if ($typeflag) {
1.292 www 3414: $r->print(&mt('Type: [_1]',&standard_parameter_names($value)));
1.290 www 3415: } else {
1.291 www 3416: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
3417: $uname,$udom,$issection,$issection,$courseopt);
3418: if (&isdateparm($istype{$parmname})) {
3419: $r->print(&Apache::lonlocal::locallocaltime($value));
3420: } else {
3421: $r->print($value);
3422: }
3423: if ($value ne $all[$level]) {
3424: $r->print('<br /><font color="red">'.&mt('Not active anymore').'</font>');
3425: } else {
3426: $stillactive=1;
3427: }
1.290 www 3428: }
1.288 albertel 3429: }
1.291 www 3430: $r->print('</td>');
3431: if ($stillactive) {
1.292 www 3432: if (($uname) && ($udom)) {
3433: $r->print('<td>Notify Link</td>');
3434: } else {
3435: $r->print('<td>Blog Link</td>');
3436: }
1.291 www 3437: } else {
3438: $r->print('<td> </td>');
3439: }
3440: $r->print('</tr>');
1.288 albertel 3441: }
1.286 www 3442: }
3443: $r->print('</table>');
1.284 www 3444: $r->print(&Apache::loncommon::end_page());
3445: }
3446:
1.178 raeburn 3447: ##################################################
3448: ##################################################
1.30 www 3449:
1.59 matthew 3450: =pod
3451:
1.83 bowersj2 3452: =item * handler
1.59 matthew 3453:
3454: Main handler. Calls &assessparms and &crsenv subroutines.
3455:
3456: =cut
3457: ##################################################
3458: ##################################################
1.220 www 3459: # use Data::Dumper;
3460:
1.259 banghart 3461:
1.30 www 3462: sub handler {
1.43 albertel 3463: my $r=shift;
1.30 www 3464:
1.43 albertel 3465: if ($r->header_only) {
1.126 www 3466: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 3467: $r->send_http_header;
3468: return OK;
3469: }
1.193 albertel 3470: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 3471: ['action','state',
3472: 'pres_marker',
3473: 'pres_value',
1.206 www 3474: 'pres_type',
1.243 banghart 3475: 'udom','uname','symb','serial']);
1.131 www 3476:
1.83 bowersj2 3477:
1.193 albertel 3478: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 3479: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
3480: text=>"Parameter Manager",
1.204 www 3481: faq=>10,
1.194 albertel 3482: bug=>'Instructor Interface'});
1.203 www 3483:
1.30 www 3484: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 3485: my $parm_permission =
3486: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 3487: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 3488: $env{'request.course.sec'}));
1.194 albertel 3489: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 3490:
3491: # Start Page
1.126 www 3492: &Apache::loncommon::content_type($r,'text/html');
1.106 www 3493: $r->send_http_header;
1.30 www 3494:
1.203 www 3495:
3496: # id numbers can change on re-ordering of folders
3497:
3498: &resetsymbcache();
3499:
1.193 albertel 3500: #
3501: # Main switch on form.action and form.state, as appropriate
3502: #
3503: # Check first if coming from someone else headed directly for
3504: # the table mode
3505: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
3506: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
3507: &assessparms($r);
3508:
3509: } elsif (! exists($env{'form.action'})) {
3510: $r->print(&header());
1.194 albertel 3511: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
3512: 'Parameter Manager'));
1.193 albertel 3513: &print_main_menu($r,$parm_permission);
3514: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 3515: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
3516: text=>"Course Environment"});
1.193 albertel 3517: &crsenv($r);
3518: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 3519: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3520: text=>"Overview Mode"});
1.121 www 3521: &overview($r);
1.259 banghart 3522: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
3523: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
3524: text=>"Restrict Metadata"});
3525: &setrestrictmeta($r);
1.208 www 3526: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
3527: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3528: text=>"Overview Mode"});
3529: &newoverview($r);
1.220 www 3530: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
3531: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
3532: text=>"Set Defaults"});
3533: &defaultsetter($r);
3534: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 3535: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 3536: text=>"Table Mode",
3537: help => 'Course_Setting_Parameters'});
1.121 www 3538: &assessparms($r);
1.284 www 3539: } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) {
3540: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.292 www 3541: text=>"Parameter Change Log"});
1.285 albertel 3542: &parm_change_log($r);
1.284 www 3543: }
1.43 albertel 3544: } else {
1.1 www 3545: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 3546: $env{'user.error.msg'}=
1.43 albertel 3547: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
3548: return HTTP_NOT_ACCEPTABLE;
3549: }
3550: return OK;
1.1 www 3551: }
3552:
3553: 1;
3554: __END__
3555:
1.59 matthew 3556: =pod
1.38 harris41 3557:
3558: =back
3559:
3560: =cut
1.1 www 3561:
3562:
3563:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>