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