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