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