Annotation of loncom/interface/lonparmset.pm, revision 1.413.6.1
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.413.6.1! raeburn 4: # $Id: lonparmset.pm,v 1.413 2008/10/23 14:26:17 bisitz 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.6.1! 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.6.1! 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.6.1! 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 = &mt($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.6.1! 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.6.1! raeburn 1143: $r->print(' checked="checked"');
1.208 www 1144: }
1.413.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.6.1! 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.413.6.1! raeburn 3001: my $parmitem = &standard_parameter_names($name);
1.295 albertel 3002: $r->print(&tablestart().
3003: &Apache::loncommon::start_data_table_row().
1.413.6.1! raeburn 3004: '<td><b>'.&mt($parmitem).
1.293 www 3005: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 3006: $thiskey.'" /></td><td>');
1.145 www 3007: $foundkeys++;
1.213 www 3008: if (&isdateparm($thistype)) {
1.123 www 3009: my $jskey='key_'.$pointer;
3010: $pointer++;
3011: $r->print(
1.232 albertel 3012: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 3013: $jskey,
1.219 www 3014: $$resourcedata{$thiskey},
1.325 www 3015: '',1,'','').
1.277 www 3016: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3017: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3018: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3019: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 3020: );
1.385 albertel 3021: } elsif ($thistype eq 'date_interval') {
3022: $r->print(&date_interval_selector($thiskey,
3023: $$resourcedata{$thiskey}));
1.383 albertel 3024: } elsif ($thistype =~ m/^string/) {
3025: $r->print(&string_selector($thistype,$thiskey,
3026: $$resourcedata{$thiskey}));
1.123 www 3027: } else {
1.383 albertel 3028: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 3029: }
1.211 www 3030: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
1.413.6.1! raeburn 3031: $thistype.'" />');
1.295 albertel 3032: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 3033: }
1.121 www 3034: }
1.208 www 3035: return $foundkeys;
3036: }
3037:
1.385 albertel 3038:
3039: sub date_interval_selector {
3040: my ($thiskey, $showval) = @_;
3041: my $result;
3042: foreach my $which (['days', 86400, 31],
3043: ['hours', 3600, 23],
3044: ['minutes', 60, 59],
3045: ['seconds', 1, 59]) {
3046: my ($name, $factor, $max) = @{ $which };
3047: my $amount = int($showval/$factor);
3048: $showval %= $factor;
3049: my %select = ((map {$_ => $_} (0..$max)),
3050: 'select_form_order' => [0..$max]);
3051: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
3052: %select);
3053: $result .= ' '.&mt($name);
3054: }
3055: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3056: return $result;
3057:
3058: }
3059:
3060: sub get_date_interval_from_form {
3061: my ($key) = @_;
3062: my $seconds = 0;
3063: foreach my $which (['days', 86400],
3064: ['hours', 3600],
3065: ['minutes', 60],
3066: ['seconds', 1]) {
3067: my ($name, $factor) = @{ $which };
3068: if (defined($env{'form.'.$name.'_'.$key})) {
3069: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3070: }
3071: }
3072: return $seconds;
3073: }
3074:
3075:
1.383 albertel 3076: sub default_selector {
3077: my ($thiskey, $showval) = @_;
1.385 albertel 3078: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3079: }
3080:
3081: my %strings =
3082: (
3083: 'string_yesno'
3084: => [[ 'yes', 'Yes' ],
3085: [ 'no', 'No' ]],
3086: 'string_problemstatus'
3087: => [[ 'yes', 'Yes' ],
1.394 www 3088: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3089: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3090: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3091: );
3092:
3093:
3094: sub string_selector {
3095: my ($thistype, $thiskey, $showval) = @_;
3096:
3097: if (!exists($strings{$thistype})) {
3098: return &default_selector($thiskey,$showval);
3099: }
3100:
3101: my $result;
3102: foreach my $possibilities (@{ $strings{$thistype} }) {
3103: my ($name, $description) = @{ $possibilities };
3104: $result .= '<label><input type="radio" name="set_'.$thiskey.
3105: '" value="'.$name.'"';
3106: if ($showval eq $name) {
3107: $result .= ' checked="checked"';
3108: }
3109: $result .= ' />'.&mt($description).'</label> ';
3110: }
3111: return $result;
3112: }
3113:
1.389 www 3114: #
3115: # Shift all start and end dates by $shift
3116: #
3117:
3118: sub dateshift {
3119: my ($shift)=@_;
3120: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3121: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3122: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3123: # ugly retro fix for broken version of types
3124: foreach my $key (keys %data) {
3125: if ($key=~/\wtype$/) {
3126: my $newkey=$key;
3127: $newkey=~s/type$/\.type/;
3128: $data{$newkey}=$data{$key};
3129: delete $data{$key};
3130: }
3131: }
1.391 www 3132: my %storecontent=();
1.389 www 3133: # go through all parameters and look for dates
3134: foreach my $key (keys %data) {
3135: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3136: my $newdate=$data{$key}+$shift;
1.391 www 3137: $storecontent{$key}=$newdate;
1.389 www 3138: }
3139: }
1.391 www 3140: my $reply=&Apache::lonnet::cput
3141: ('resourcedata',\%storecontent,$dom,$crs);
3142: if ($reply eq 'ok') {
3143: &log_parmset(\%storecontent);
3144: }
3145: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3146: return $reply;
1.389 www 3147: }
3148:
1.208 www 3149: sub newoverview {
1.280 albertel 3150: my ($r) = @_;
3151:
1.208 www 3152: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3153: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3154: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3155: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3156: $r->print(<<ENDOVER);
1.280 albertel 3157: $start_page
1.208 www 3158: $breadcrumbs
1.232 albertel 3159: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3160: ENDOVER
1.211 www 3161: my @ids=();
3162: my %typep=();
3163: my %keyp=();
3164: my %allparms=();
3165: my %allparts=();
3166: my %allmaps=();
3167: my %mapp=();
3168: my %symbp=();
3169: my %maptitles=();
3170: my %uris=();
3171: my %keyorder=&standardkeyorder();
3172: my %defkeytype=();
3173:
3174: my %alllevs=();
3175: $alllevs{'Resource Level'}='full';
1.215 www 3176: $alllevs{'Map/Folder Level'}='map';
1.211 www 3177: $alllevs{'Course Level'}='general';
3178:
3179: my $csec=$env{'form.csec'};
1.269 raeburn 3180: my $cgroup=$env{'form.cgroup'};
1.211 www 3181:
3182: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3183: my $pschp=$env{'form.pschp'};
3184: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3185: if (!@psprt) { $psprt[0]='0'; }
3186:
3187: my @selected_sections =
3188: &Apache::loncommon::get_env_multiple('form.Section');
3189: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3190: foreach my $sec (@selected_sections) {
3191: if ($sec eq 'all') {
1.211 www 3192: @selected_sections = ('all');
3193: }
3194: }
1.269 raeburn 3195: my @selected_groups =
3196: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3197:
3198: my $pssymb='';
3199: my $parmlev='';
3200:
3201: unless ($env{'form.parmlev'}) {
3202: $parmlev = 'map';
3203: } else {
3204: $parmlev = $env{'form.parmlev'};
3205: }
3206:
3207: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3208: \%mapp, \%symbp,\%maptitles,\%uris,
3209: \%keyorder,\%defkeytype);
3210:
1.374 albertel 3211: if (grep {$_ eq 'all'} (@psprt)) {
3212: @psprt = keys(%allparts);
3213: }
1.211 www 3214: # Menu to select levels, etc
3215:
1.317 albertel 3216: $r->print('<table id="LC_parm_overview_scope">
3217: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3218: &levelmenu($r,\%alllevs,$parmlev);
3219: if ($parmlev ne 'general') {
1.317 albertel 3220: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3221: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3222: $r->print('</td>');
3223: }
3224: $r->print('</td></tr></table>');
3225:
1.317 albertel 3226: $r->print('<table id="LC_parm_overview_controls">
3227: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3228: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3229: $r->print('</td><td class="LC_parm_overview_restrictions">
3230: <table class="LC_parm_overview_restrictions">'.
3231: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3232: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3233: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3234: $r->print('</td><td>');
1.211 www 3235: §ionmenu($r,\@selected_sections);
1.317 albertel 3236: $r->print('</td><td>');
1.269 raeburn 3237: &groupmenu($r,\@selected_groups);
3238: $r->print('</td></tr></table>');
1.214 www 3239: $r->print('</td></tr></table>');
3240:
3241: my $sortorder=$env{'form.sortorder'};
3242: unless ($sortorder) { $sortorder='realmstudent'; }
3243: &sortmenu($r,$sortorder);
3244:
3245: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3246:
3247: # Build the list data hash from the specified parms
3248:
3249: my $listdata;
3250: %{$listdata}=();
3251:
3252: foreach my $cat (@pscat) {
1.269 raeburn 3253: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3254: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3255: }
3256:
1.212 www 3257: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3258:
1.212 www 3259: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3260:
3261: # Read modified data
3262:
3263: my $resourcedata=&readdata($crs,$dom);
3264:
3265: # List data
3266:
1.214 www 3267: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3268: }
3269: $r->print(&tableend().
1.365 albertel 3270: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3271: '</form>'.&Apache::loncommon::end_page());
1.208 www 3272: }
3273:
1.269 raeburn 3274: sub secgroup_lister {
3275: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3276: foreach my $item (@{$selections}) {
3277: foreach my $part (@{$psprt}) {
3278: my $rootparmkey=$env{'request.course.id'};
3279: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3280: $rootparmkey.='.['.$item.']';
3281: }
3282: if ($parmlev eq 'general') {
3283: # course-level parameter
3284: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3285: $$listdata{$newparmkey}=1;
3286: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3287: } elsif ($parmlev eq 'map') {
3288: # map-level parameter
3289: foreach my $mapid (keys %{$allmaps}) {
3290: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3291: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3292: $$listdata{$newparmkey}=1;
3293: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3294: }
3295: } else {
3296: # resource-level parameter
3297: foreach my $rid (@{$ids}) {
3298: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3299: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3300: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3301: $$listdata{$newparmkey}=1;
3302: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3303: }
3304: }
3305: }
3306: }
3307: }
3308:
1.208 www 3309: sub overview {
1.280 albertel 3310: my ($r) = @_;
1.208 www 3311: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3312: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3313:
3314: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3315: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3316: $r->print(<<ENDOVER);
1.280 albertel 3317: $start_page
1.208 www 3318: $breadcrumbs
1.232 albertel 3319: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3320: ENDOVER
3321: # Store modified
3322:
3323: &storedata($r,$crs,$dom);
3324:
3325: # Read modified data
3326:
3327: my $resourcedata=&readdata($crs,$dom);
3328:
1.214 www 3329:
3330: my $sortorder=$env{'form.sortorder'};
3331: unless ($sortorder) { $sortorder='realmstudent'; }
3332: &sortmenu($r,$sortorder);
3333:
1.208 www 3334: # List data
3335:
1.214 www 3336: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3337:
1.145 www 3338: $r->print(&tableend().'<p>'.
1.280 albertel 3339: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
3340: &Apache::loncommon::end_page());
1.120 www 3341: }
1.121 www 3342:
1.333 albertel 3343: sub clean_parameters {
3344: my ($r) = @_;
3345: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3346: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3347:
3348: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3349: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3350: $r->print(<<ENDOVER);
3351: $start_page
3352: $breadcrumbs
3353: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3354: ENDOVER
3355: # Store modified
3356:
3357: &storedata($r,$crs,$dom);
3358:
3359: # Read modified data
3360:
3361: my $resourcedata=&readdata($crs,$dom);
3362:
3363: # List data
3364:
3365: $r->print('<h3>'.
3366: &mt('These parameters refer to resources that do not exist.').
3367: '</h3>'.
1.413.6.1! raeburn 3368: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
1.333 albertel 3369: '<br />');
3370: $r->print(&Apache::loncommon::start_data_table().
3371: '<tr>'.
3372: '<th>'.&mt('Delete').'</th>'.
3373: '<th>'.&mt('Parameter').'</th>'.
3374: '</tr>');
3375: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3376: next if (!exists($resourcedata->{$thiskey.'.type'})
3377: && $thiskey=~/\.type$/);
3378: my %data = &parse_key($thiskey);
1.383 albertel 3379: if (1) { #exists($data{'realm_exists'})
3380: #&& !$data{'realm_exists'}) {
1.333 albertel 3381: $r->print(&Apache::loncommon::start_data_table_row().
3382: '<tr>'.
3383: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3384:
3385: $r->print('<td>');
1.362 albertel 3386: my $display_value = $resourcedata->{$thiskey};
3387: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3388: $display_value =
3389: &Apache::lonlocal::locallocaltime($display_value);
3390: }
1.413.6.1! raeburn 3391: my $parmitem = &standard_parameter_names($data{'parameter_name'});
! 3392: $parmitem = &mt($parmitem);
1.333 albertel 3393: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
1.413.6.1! raeburn 3394: $parmitem,$resourcedata->{$thiskey}));
1.333 albertel 3395: $r->print('<br />');
3396: if ($data{'scope_type'} eq 'all') {
3397: $r->print(&mt('All users'));
3398: } elsif ($data{'scope_type'} eq 'user') {
3399: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3400: } elsif ($data{'scope_type'} eq 'section') {
3401: $r->print(&mt('Section: [_1]',$data{'scope'}));
3402: } elsif ($data{'scope_type'} eq 'group') {
3403: $r->print(&mt('Group: [_1]',$data{'scope'}));
3404: }
3405: $r->print('<br />');
3406: if ($data{'realm_type'} eq 'all') {
3407: $r->print(&mt('All Resources'));
3408: } elsif ($data{'realm_type'} eq 'folder') {
3409: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3410: } elsif ($data{'realm_type'} eq 'symb') {
3411: my ($map,$resid,$url) =
3412: &Apache::lonnet::decode_symb($data{'realm'});
3413: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3414: $url,$resid,$map));
3415: }
1.362 albertel 3416: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3417: $r->print('</td></tr>');
3418:
3419: }
3420: }
3421: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.413.6.1! raeburn 3422: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.333 albertel 3423: '</p></form>'.
3424: &Apache::loncommon::end_page());
3425: }
3426:
1.390 www 3427: sub date_shift_one {
3428: my ($r) = @_;
3429: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3430: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3431:
3432: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3433: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3434: $r->print(<<ENDOVER);
3435: $start_page
3436: $breadcrumbs
3437: ENDOVER
3438: $r->print('<form name="shiftform" method="post">'.
3439: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3440: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3441: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3442: &Apache::lonhtmlcommon::date_setter('shiftform',
3443: 'timeshifted',
3444: $env{'form.timebase'},,
3445: '').
3446: '</td></tr></table>'.
3447: '<input type="hidden" name="action" value="dateshift2" />'.
3448: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3449: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3450: $r->print(&Apache::loncommon::end_page());
3451: }
3452:
3453: sub date_shift_two {
3454: my ($r) = @_;
3455: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3456: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3457: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3458: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3459: $r->print(<<ENDOVER);
3460: $start_page
3461: $breadcrumbs
3462: ENDOVER
3463: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3464: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3465: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3466: &Apache::lonlocal::locallocaltime($timeshifted)));
3467: my $delta=$timeshifted-$env{'form.timebase'};
3468: &dateshift($delta);
3469: $r->print(&Apache::loncommon::end_page());
3470: }
3471:
1.333 albertel 3472: sub parse_key {
3473: my ($key) = @_;
3474: my %data;
3475: my ($middle,$part,$name)=
3476: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3477: $data{'scope_type'} = 'all';
3478: if ($middle=~/^\[(.*)\]/) {
3479: $data{'scope'} = $1;
1.350 albertel 3480: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3481: $data{'scope_type'} = 'user';
3482: $data{'scope'} = [$1,$2];
3483: } else {
3484: #FIXME check for group scope
3485: $data{'scope_type'} = 'section';
3486: }
3487: $middle=~s/^\[(.*)\]//;
3488: }
3489: $middle=~s/\.+$//;
3490: $middle=~s/^\.+//;
3491: $data{'realm_type'}='all';
3492: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3493: $data{'realm'} = $1;
3494: $data{'realm_type'} = 'folder';
3495: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3496: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3497: } elsif ($middle) {
3498: $data{'realm'} = $middle;
3499: $data{'realm_type'} = 'symb';
3500: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3501: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3502: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3503: }
3504:
3505: $data{'parameter_part'} = $part;
3506: $data{'parameter_name'} = $name;
3507:
3508: return %data;
3509: }
3510:
1.59 matthew 3511: ##################################################
3512: ##################################################
1.333 albertel 3513:
1.178 raeburn 3514: =pod
1.239 raeburn 3515:
3516: =item check_cloners
3517:
3518: Checks if new users included in list of allowed cloners
3519: are valid users. Replaces supplied list with
3520: cleaned list containing only users with valid usernames
3521: and domains.
3522:
3523: Inputs: $clonelist, $oldcloner
3524: where $clonelist is ref to array of requested cloners,
3525: and $oldcloner is ref to array of currently allowed
3526: cloners.
3527:
3528: Returns: string - comma separated list of requested
3529: cloners (username:domain) who do not exist in system.
3530:
3531: =item change_clone
3532:
1.178 raeburn 3533: Modifies the list of courses a user can clone (stored
1.239 raeburn 3534: in the user's environment.db file), called when a
1.178 raeburn 3535: change is made to the list of users allowed to clone
3536: a course.
1.239 raeburn 3537:
1.178 raeburn 3538: Inputs: $action,$cloner
3539: where $action is add or drop, and $cloner is identity of
3540: user for whom cloning ability is to be changed in course.
3541:
3542: =cut
1.380 albertel 3543:
1.178 raeburn 3544: ##################################################
3545: ##################################################
3546:
1.239 raeburn 3547: sub extract_cloners {
3548: my ($clonelist,$allowclone) = @_;
3549: if ($clonelist =~ /,/) {
1.380 albertel 3550: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3551: } else {
3552: $$allowclone[0] = $clonelist;
3553: }
3554: }
3555:
3556: sub check_cloners {
3557: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3558: my ($clean_clonelist,%disallowed);
1.239 raeburn 3559: my @allowclone = ();
3560: &extract_cloners($$clonelist,\@allowclone);
3561: foreach my $currclone (@allowclone) {
1.380 albertel 3562: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3563: if ($currclone eq '*') {
3564: $clean_clonelist .= $currclone.',';
3565: } else {
3566: my ($uname,$udom) = split(/:/,$currclone);
3567: if ($uname eq '*') {
3568: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3569: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3570: $disallowed{'domain'} .= $currclone.',';
3571: } else {
3572: $clean_clonelist .= $currclone.',';
3573: }
3574: } else {
3575: $disallowed{'format'} .= $currclone.',';
3576: }
3577: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3578: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3579: } else {
1.379 raeburn 3580: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3581: $disallowed{'newuser'} .= $currclone.',';
3582: } else {
3583: $clean_clonelist .= $currclone.',';
3584: }
1.239 raeburn 3585: }
3586: }
3587: } else {
3588: $clean_clonelist .= $currclone.',';
3589: }
3590: }
1.379 raeburn 3591: foreach my $key (keys(%disallowed)) {
3592: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3593: }
3594: if ($clean_clonelist) {
3595: $clean_clonelist =~ s/,$//;
3596: }
3597: $$clonelist = $clean_clonelist;
1.379 raeburn 3598: return %disallowed;
3599: }
1.178 raeburn 3600:
3601: sub change_clone {
3602: my ($clonelist,$oldcloner) = @_;
3603: my ($uname,$udom);
1.190 albertel 3604: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3605: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3606: my $clone_crs = $cnum.':'.$cdom;
3607:
3608: if ($cnum && $cdom) {
1.239 raeburn 3609: my @allowclone;
3610: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 3611: foreach my $currclone (@allowclone) {
1.380 albertel 3612: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 3613: if ($currclone ne '*') {
1.380 albertel 3614: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 3615: if ($uname && $udom && $uname ne '*') {
3616: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3617: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3618: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3619: if ($currclonecrs{'cloneable'} eq '') {
3620: $currclonecrs{'cloneable'} = $clone_crs;
3621: } else {
3622: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3623: }
3624: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 3625: }
3626: }
3627: }
3628: }
3629: }
3630: }
3631: foreach my $oldclone (@$oldcloner) {
1.380 albertel 3632: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 3633: if ($oldclone ne '*') {
1.380 albertel 3634: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 3635: if ($uname && $udom && $uname ne '*' ) {
3636: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3637: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3638: my %newclonecrs = ();
3639: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3640: if ($currclonecrs{'cloneable'} =~ /,/) {
3641: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3642: foreach my $crs (@currclonecrs) {
3643: if ($crs ne $clone_crs) {
3644: $newclonecrs{'cloneable'} .= $crs.',';
3645: }
1.178 raeburn 3646: }
1.379 raeburn 3647: $newclonecrs{'cloneable'} =~ s/,$//;
3648: } else {
3649: $newclonecrs{'cloneable'} = '';
1.178 raeburn 3650: }
1.379 raeburn 3651: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 3652: }
3653: }
3654: }
3655: }
3656: }
3657: }
3658: }
3659: }
3660:
1.193 albertel 3661:
3662: ##################################################
3663: ##################################################
3664:
3665: =pod
3666:
3667: =item * header
3668:
3669: Output html header for page
3670:
3671: =cut
3672:
3673: ##################################################
3674: ##################################################
3675: sub header {
1.280 albertel 3676: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 3677: }
3678: ##################################################
3679: ##################################################
3680: sub print_main_menu {
3681: my ($r,$parm_permission)=@_;
3682: #
3683: $r->print(<<ENDMAINFORMHEAD);
3684: <form method="post" enctype="multipart/form-data"
3685: action="/adm/parmset" name="studentform">
3686: ENDMAINFORMHEAD
3687: #
1.195 albertel 3688: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3689: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3690: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3691: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 3692:
1.193 albertel 3693: my @menu =
1.322 www 3694: ( { divider=>'Settings for Your Course',
3695: },
1.323 albertel 3696: { text => 'Set Course Environment',
1.204 www 3697: action => 'crsenv',
1.193 albertel 3698: permission => $parm_permission,
1.324 www 3699: help => 'Course_Environment',
1.193 albertel 3700: },
1.255 banghart 3701: { text => 'Set Portfolio Metadata',
1.259 banghart 3702: action => 'setrestrictmeta',
1.240 banghart 3703: permission => $parm_permission,
3704: },
1.271 www 3705: { text => 'Manage Course Slots',
1.268 albertel 3706: url => '/adm/slotrequest?command=showslots',
3707: permission => $vgr,
3708: },
1.366 albertel 3709: { text => 'Reset Student Access Times',
3710: url => '/adm/helper/resettimes.helper',
3711: permission => $mgr,
3712: },
3713:
1.322 www 3714: { text => 'Set Parameter Setting Default Actions',
3715: action => 'setdefaults',
3716: permission => $parm_permission,
3717: },
3718: { divider => 'New and Existing Parameter Settings for Your Resources',
1.268 albertel 3719: },
1.216 www 3720: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3721: url => '/adm/helper/parameter.helper',
3722: permission => $parm_permission,
1.324 www 3723: help => 'Parameter_Helper',
1.193 albertel 3724: },
1.322 www 3725: { text => 'Set/Modify Resource Parameters - Overview Mode',
1.208 www 3726: action => 'newoverview',
3727: permission => $parm_permission,
1.324 www 3728: help => 'Parameter_Overview',
1.193 albertel 3729: },
1.216 www 3730: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3731: action => 'settable',
3732: permission => $parm_permission,
1.324 www 3733: help => 'Table_Mode',
1.193 albertel 3734: },
1.322 www 3735: { divider => 'Existing Parameter Settings for Your Resources',
3736: },
3737: { text => 'Modify Resource Parameters - Overview Mode',
3738: action => 'setoverview',
1.220 www 3739: permission => $parm_permission,
1.324 www 3740: help => 'Parameter_Overview',
1.322 www 3741: },
1.292 www 3742: { text => 'Parameter Change Log and Course Blog Posting/User Notification',
1.284 www 3743: action => 'parameterchangelog',
3744: permission => $parm_permission,
1.220 www 3745: },
1.193 albertel 3746: );
3747: my $menu_html = '';
3748: foreach my $menu_item (@menu) {
1.268 albertel 3749: if ($menu_item->{'divider'}) {
1.322 www 3750: $menu_html .= '<h3>'.&mt($menu_item->{'divider'}).'</h3>';
1.268 albertel 3751: next;
3752: }
1.193 albertel 3753: next if (! $menu_item->{'permission'});
3754: $menu_html.='<p>';
1.316 albertel 3755: $menu_html.='<span class="LC_parm_menu_item">';
1.193 albertel 3756: if (exists($menu_item->{'url'})) {
3757: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3758: } else {
3759: $menu_html.=
3760: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3761: }
1.316 albertel 3762: $menu_html.= &mt($menu_item->{'text'}).'</a></span>';
1.193 albertel 3763: if (exists($menu_item->{'help'})) {
3764: $menu_html.=
3765: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3766: }
3767: $menu_html.='</p>'.$/;
3768: }
3769: $r->print($menu_html);
3770: return;
3771: }
1.255 banghart 3772: ### Set portfolio metadata
1.252 banghart 3773: sub output_row {
1.347 banghart 3774: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3775: my $output;
1.263 banghart 3776: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3777: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3778: if (!defined($options)) {
1.254 banghart 3779: $options = 'active,stuadd';
1.261 banghart 3780: $values = '';
1.252 banghart 3781: }
1.337 banghart 3782: if (!($options =~ /deleted/)) {
3783: my @options= ( ['active', 'Show to student'],
1.351 banghart 3784: ['stuadd', 'Provide text area for students to type catalog information'],
3785: ['choices','Provide choices for students to select from']);
3786: # ['onlyone','Student may select only one choice']);
1.337 banghart 3787: if ($added_flag) {
3788: push @options,['deleted', 'Delete Metadata Field'];
3789: }
1.351 banghart 3790: $output = &Apache::loncommon::start_data_table_row();
3791: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
3792: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3793: foreach my $opt (@options) {
3794: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 3795: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 3796: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
3797: <input type="checkbox" name="'.
3798: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3799: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 3800: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3801: }
1.351 banghart 3802: $output .= &Apache::loncommon::continue_data_table_row();
3803: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
3804: $output .= &Apache::loncommon::end_data_table_row();
3805: my $multiple_checked;
3806: my $single_checked;
3807: if ($options =~ m/onlyone/) {
1.413.6.1! raeburn 3808: $multiple_checked = '';
! 3809: $single_checked = ' checked="checked"';
1.351 banghart 3810: } else {
1.413.6.1! raeburn 3811: $multiple_checked = ' checked="checked"';
! 3812: $single_checked = '';
1.351 banghart 3813: }
3814: $output .= &Apache::loncommon::continue_data_table_row();
3815: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.413.6.1! raeburn 3816: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
! 3817: '.&mt('Student may select multiple choices from list').'</span></td>';
1.351 banghart 3818: $output .= &Apache::loncommon::end_data_table_row();
3819: $output .= &Apache::loncommon::continue_data_table_row();
3820: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
3821: <input type="radio" name="'.$field_name.'_onlyone" value="single" '.$single_checked.'/>
1.413.6.1! raeburn 3822: '.&mt('Student may select only one choice from list').'</span></td>';
1.351 banghart 3823: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3824: }
3825: return ($output);
3826: }
1.340 banghart 3827: sub order_meta_fields {
3828: my ($r)=@_;
3829: my $idx = 1;
3830: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3831: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3832: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.345 banghart 3833: &Apache::lonhtmlcommon::add_breadcrumb
3834: ({href=>"/adm/parmset?action=setrestrictmeta",
3835: text=>"Restrict Metadata"},
3836: {text=>"Order Metadata"});
3837: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 3838: if ($env{'form.storeorder'}) {
3839: my $newpos = $env{'form.newpos'} - 1;
3840: my $currentpos = $env{'form.currentpos'} - 1;
3841: my @neworder = ();
3842: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3843: my $i;
1.341 banghart 3844: if ($newpos > $currentpos) {
1.340 banghart 3845: # moving stuff up
3846: for ($i=0;$i<$currentpos;$i++) {
3847: $neworder[$i]=$oldorder[$i];
3848: }
3849: for ($i=$currentpos;$i<$newpos;$i++) {
3850: $neworder[$i]=$oldorder[$i+1];
3851: }
3852: $neworder[$newpos]=$oldorder[$currentpos];
3853: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
3854: $neworder[$i]=$oldorder[$i];
3855: }
3856: } else {
3857: # moving stuff down
3858: for ($i=0;$i<$newpos;$i++) {
3859: $neworder[$i]=$oldorder[$i];
3860: }
3861: $neworder[$newpos]=$oldorder[$currentpos];
3862: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3863: $neworder[$i]=$oldorder[$i-1];
3864: }
3865: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3866: $neworder[$i]=$oldorder[$i];
3867: }
3868: }
3869: my $ordered_fields = join ",", @neworder;
1.343 banghart 3870: my $put_result = &Apache::lonnet::put('environment',
3871: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 3872: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3873: }
1.357 raeburn 3874: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3875: my $ordered_fields;
1.340 banghart 3876: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3877: if (!@fields_in_order) {
3878: # no order found, pick sorted order then create metadata.addedorder key.
3879: foreach my $key (sort keys %$fields) {
3880: push @fields_in_order, $key;
1.341 banghart 3881: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3882: }
1.341 banghart 3883: my $put_result = &Apache::lonnet::put('environment',
3884: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3885: }
1.340 banghart 3886: $r->print('<table>');
3887: my $num_fields = scalar(@fields_in_order);
3888: foreach my $key (@fields_in_order) {
3889: $r->print('<tr><td>');
3890: $r->print('<form method="post" action="">');
3891: $r->print('<select name="newpos" onChange="this.form.submit()">');
3892: for (my $i = 1;$i le $num_fields;$i ++) {
3893: if ($i eq $idx) {
3894: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3895: } else {
3896: $r->print('<option value="'.$i.'">'.$i.'</option>');
3897: }
3898: }
3899: $r->print('</select></td><td>');
3900: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3901: $r->print('<input type="hidden" name="storeorder" value="true" />');
3902: $r->print('</form>');
3903: $r->print($$fields{$key}.'</td></tr>');
3904: $idx ++;
3905: }
3906: $r->print('</table>');
3907: return 'ok';
3908: }
1.359 banghart 3909: sub continue {
3910: my $output;
3911: $output .= '<form action="" method="post">';
3912: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3913: $output .= '<input type="submit" value="Continue" />';
3914: return ($output);
3915: }
1.334 banghart 3916: sub addmetafield {
3917: my ($r)=@_;
3918: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3919: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 3920: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3921: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 3922: if (exists($env{'form.undelete'})) {
1.358 banghart 3923: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 3924: foreach my $meta_field(@meta_fields) {
3925: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
3926: $options =~ s/deleted//;
3927: $options =~ s/,,/,/;
3928: my $put_result = &Apache::lonnet::put('environment',
3929: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
3930:
3931: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
3932: }
1.359 banghart 3933: $r->print(&continue());
1.339 banghart 3934: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 3935: my $meta_field = $env{'form.fieldname'};
3936: my $display_field = $env{'form.fieldname'};
3937: $meta_field =~ s/\W/_/g;
1.338 banghart 3938: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 3939: my $put_result = &Apache::lonnet::put('environment',
3940: {'metadata.'.$meta_field.'.values'=>"",
3941: 'metadata.'.$meta_field.'.added'=>"$display_field",
3942: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 3943: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
3944: $r->print(&continue());
1.335 banghart 3945: } else {
1.357 raeburn 3946: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 3947: if ($fields) {
3948: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
3949: $r->print('<form method="post" action="">');
3950: foreach my $key(keys(%$fields)) {
1.358 banghart 3951: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 3952: }
3953: $r->print('<input type="submit" name="undelete" value="Undelete" />');
3954: $r->print('</form>');
3955: }
3956: $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 3957: $r->print('<input type="text" name="fieldname" /><br />');
3958: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 3959: }
1.361 albertel 3960: $r->print('</form>');
1.334 banghart 3961: }
1.259 banghart 3962: sub setrestrictmeta {
1.240 banghart 3963: my ($r)=@_;
1.242 banghart 3964: my $next_meta;
1.244 banghart 3965: my $output;
1.245 banghart 3966: my $item_num;
1.246 banghart 3967: my $put_result;
1.280 albertel 3968: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 3969: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 3970: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3971: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3972: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3973: my $save_field = '';
1.259 banghart 3974: if ($env{'form.restrictmeta'}) {
1.254 banghart 3975: foreach my $field (sort(keys(%env))) {
1.252 banghart 3976: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3977: my $options;
1.252 banghart 3978: my $meta_field = $1;
3979: my $meta_key = $2;
1.253 banghart 3980: if ($save_field ne $meta_field) {
1.252 banghart 3981: $save_field = $meta_field;
1.253 banghart 3982: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3983: $options.='stuadd,';
3984: }
1.351 banghart 3985: if ($env{'form.'.$meta_field.'_choices'}) {
3986: $options.='choices,';
3987: }
3988: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 3989: $options.='onlyone,';
3990: }
3991: if ($env{'form.'.$meta_field.'_active'}) {
3992: $options.='active,';
1.253 banghart 3993: }
1.337 banghart 3994: if ($env{'form.'.$meta_field.'_deleted'}) {
3995: $options.='deleted,';
3996: }
1.259 banghart 3997: my $name = $save_field;
1.253 banghart 3998: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3999: {'metadata.'.$meta_field.'.options'=>$options,
4000: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4001: },$dom,$crs);
1.252 banghart 4002: }
4003: }
4004: }
4005: }
1.296 albertel 4006: &Apache::lonnet::coursedescription($env{'request.course.id'},
4007: {'freshen_cache' => 1});
1.335 banghart 4008: # Get the default metadata fields
1.258 albertel 4009: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4010: # Now get possible added metadata fields
1.357 raeburn 4011: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4012: my $row_alt = 1;
1.347 banghart 4013: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4014: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4015: if ($field ne 'courserestricted') {
1.346 banghart 4016: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 4017: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 4018: }
1.255 banghart 4019: }
1.351 banghart 4020: my $buttons = (<<ENDButtons);
4021: <input type="submit" name="restrictmeta" value="Save" />
4022: </form><br />
4023: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4024: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4025: </form>
4026: <br />
4027: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4028: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4029: ENDButtons
1.337 banghart 4030: my $added_flag = 1;
1.335 banghart 4031: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4032: $row_alt = $row_alt ? 0 : 1;
4033: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4034: }
1.347 banghart 4035: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 4036: $r->print(<<ENDenv);
1.259 banghart 4037: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4038: $output
1.351 banghart 4039: $buttons
1.340 banghart 4040: </form>
1.244 banghart 4041: ENDenv
1.280 albertel 4042: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4043: return 'ok';
4044: }
1.220 www 4045: ##################################################
1.335 banghart 4046: sub get_added_meta_fieldnames {
1.357 raeburn 4047: my ($cid) = @_;
1.335 banghart 4048: my %fields;
4049: foreach my $key(%env) {
1.357 raeburn 4050: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4051: my $field_name = $1;
4052: my ($display_field_name) = $env{$key};
4053: $fields{$field_name} = $display_field_name;
4054: }
4055: }
4056: return \%fields;
4057: }
1.339 banghart 4058: sub get_deleted_meta_fieldnames {
1.357 raeburn 4059: my ($cid) = @_;
1.339 banghart 4060: my %fields;
4061: foreach my $key(%env) {
1.357 raeburn 4062: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4063: my $field_name = $1;
4064: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4065: my ($display_field_name) = $env{$key};
4066: $fields{$field_name} = $display_field_name;
4067: }
4068: }
4069: }
4070: return \%fields;
4071: }
1.220 www 4072: sub defaultsetter {
1.280 albertel 4073: my ($r) = @_;
4074:
4075: my $start_page =
4076: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4077: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4078: $r->print(<<ENDDEFHEAD);
1.280 albertel 4079: $start_page
1.220 www 4080: $breadcrumbs
4081: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4082: ENDDEFHEAD
1.280 albertel 4083:
4084: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4085: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4086: my @ids=();
4087: my %typep=();
4088: my %keyp=();
4089: my %allparms=();
4090: my %allparts=();
4091: my %allmaps=();
4092: my %mapp=();
4093: my %symbp=();
4094: my %maptitles=();
4095: my %uris=();
4096: my %keyorder=&standardkeyorder();
4097: my %defkeytype=();
4098:
4099: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4100: \%mapp, \%symbp,\%maptitles,\%uris,
4101: \%keyorder,\%defkeytype);
1.224 www 4102: if ($env{'form.storerules'}) {
4103: my %newrules=();
4104: my @delrules=();
1.226 www 4105: my %triggers=();
1.225 albertel 4106: foreach my $key (keys(%env)) {
4107: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4108: my $tempkey=$1;
1.226 www 4109: my $action=$env{$key};
4110: if ($action) {
4111: $newrules{$tempkey.'_action'}=$action;
4112: if ($action ne 'default') {
4113: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4114: $triggers{$whichparm}.=$tempkey.':';
4115: }
4116: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4117: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4118: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4119: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4120: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4121: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4122: } else {
4123: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4124: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4125: }
4126: } else {
1.225 albertel 4127: push(@delrules,$tempkey.'_action');
1.226 www 4128: push(@delrules,$tempkey.'_type');
1.225 albertel 4129: push(@delrules,$tempkey.'_hours');
4130: push(@delrules,$tempkey.'_min');
4131: push(@delrules,$tempkey.'_sec');
4132: push(@delrules,$tempkey.'_value');
1.224 www 4133: }
4134: }
4135: }
1.226 www 4136: foreach my $key (keys %allparms) {
4137: $newrules{$key.'_triggers'}=$triggers{$key};
4138: }
1.224 www 4139: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4140: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4141: &resetrulescache();
4142: }
1.227 www 4143: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4144: 'hours' => 'Hours',
1.221 www 4145: 'min' => 'Minutes',
4146: 'sec' => 'Seconds',
4147: 'yes' => 'Yes',
4148: 'no' => 'No');
1.222 www 4149: my @standardoptions=('','default');
4150: my @standarddisplay=('',&mt('Default value when manually setting'));
4151: my @dateoptions=('','default');
4152: my @datedisplay=('',&mt('Default value when manually setting'));
4153: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4154: unless ($tempkey) { next; }
4155: push @standardoptions,'when_setting_'.$tempkey;
4156: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4157: if (&isdateparm($defkeytype{$tempkey})) {
4158: push @dateoptions,'later_than_'.$tempkey;
4159: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4160: push @dateoptions,'earlier_than_'.$tempkey;
4161: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4162: }
4163: }
1.231 www 4164: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4165: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4166: $r->print("\n".&Apache::loncommon::start_data_table().
4167: &Apache::loncommon::start_data_table_header_row().
4168: "<th>".&mt('Rule for parameter').'</th><th>'.
4169: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4170: &Apache::loncommon::end_data_table_header_row());
1.221 www 4171: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4172: unless ($tempkey) { next; }
1.318 albertel 4173: $r->print("\n".&Apache::loncommon::start_data_table_row().
4174: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4175: my $action=&rulescache($tempkey.'_action');
4176: $r->print('<select name="'.$tempkey.'_action">');
4177: if (&isdateparm($defkeytype{$tempkey})) {
4178: for (my $i=0;$i<=$#dateoptions;$i++) {
4179: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4180: $r->print("\n<option value='$dateoptions[$i]'".
4181: ($dateoptions[$i] eq $action?' selected="selected"':'').
4182: ">$datedisplay[$i]</option>");
4183: }
4184: } else {
4185: for (my $i=0;$i<=$#standardoptions;$i++) {
4186: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4187: $r->print("\n<option value='$standardoptions[$i]'".
4188: ($standardoptions[$i] eq $action?' selected="selected"':'').
4189: ">$standarddisplay[$i]</option>");
4190: }
4191: }
4192: $r->print('</select>');
1.227 www 4193: unless (&isdateparm($defkeytype{$tempkey})) {
4194: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4195: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4196: }
1.222 www 4197: $r->print("\n</td><td>\n");
4198:
1.221 www 4199: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4200: my $days=&rulescache($tempkey.'_days');
1.222 www 4201: my $hours=&rulescache($tempkey.'_hours');
4202: my $min=&rulescache($tempkey.'_min');
4203: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4204: $r->print(<<ENDINPUTDATE);
1.227 www 4205: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4206: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4207: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4208: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4209: ENDINPUTDATE
4210: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4211: my $yeschecked='';
4212: my $nochecked='';
4213: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4214: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4215:
1.221 www 4216: $r->print(<<ENDYESNO);
1.224 www 4217: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4218: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4219: ENDYESNO
4220: } else {
1.224 www 4221: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4222: }
1.318 albertel 4223: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4224: }
1.318 albertel 4225: $r->print(&Apache::loncommon::end_data_table().
4226: "\n<input type='submit' name='storerules' value='".
1.365 albertel 4227: &mt('Save Rules')."' /></form>\n".
1.280 albertel 4228: &Apache::loncommon::end_page());
1.220 www 4229: return;
4230: }
1.193 albertel 4231:
1.290 www 4232: sub components {
1.330 albertel 4233: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4234:
4235: if ($typeflag) {
1.290 www 4236: $key=~s/\.type$//;
4237: }
1.330 albertel 4238:
4239: my ($middle,$part,$name)=
4240: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4241: my $issection;
1.330 albertel 4242:
1.290 www 4243: my $section=&mt('All Students');
4244: if ($middle=~/^\[(.*)\]/) {
1.291 www 4245: $issection=$1;
4246: $section=&mt('Group/Section').': '.$issection;
1.290 www 4247: $middle=~s/^\[(.*)\]//;
4248: }
4249: $middle=~s/\.+$//;
4250: $middle=~s/^\.+//;
1.291 www 4251: if ($uname) {
4252: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4253: $issection='';
4254: }
1.316 albertel 4255: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4256: my $realmdescription=&mt('all resources');
1.290 www 4257: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4258: $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 4259: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4260: } elsif ($middle) {
1.290 www 4261: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4262: $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 4263: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4264: }
1.291 www 4265: my $what=$part.'.'.$name;
1.330 albertel 4266: return ($realm,$section,$name,$part,
1.304 www 4267: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4268: }
1.293 www 4269:
1.328 albertel 4270: my %standard_parms;
4271: sub load_parameter_names {
4272: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4273: while (my $configline=<$config>) {
4274: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4275: chomp($configline);
4276: my ($short,$plain)=split(/:/,$configline);
4277: my (undef,$name,$type)=split(/\&/,$short,3);
4278: if ($type eq 'display') {
4279: $standard_parms{$name} = $plain;
4280: }
4281: }
4282: close($config);
4283: $standard_parms{'int_pos'} = 'Positive Integer';
4284: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4285: }
4286:
1.292 www 4287: sub standard_parameter_names {
4288: my ($name)=@_;
1.328 albertel 4289: if (!%standard_parms) {
4290: &load_parameter_names();
4291: }
1.292 www 4292: if ($standard_parms{$name}) {
4293: return $standard_parms{$name};
4294: } else {
4295: return $name;
4296: }
4297: }
1.290 www 4298:
1.309 www 4299: #
4300: # Parameter Change Log
4301: #
4302:
4303:
1.285 albertel 4304: sub parm_change_log {
1.284 www 4305: my ($r)=@_;
1.327 albertel 4306: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4307: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4308:
1.286 www 4309: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4310: $env{'course.'.$env{'request.course.id'}.'.domain'},
4311: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4312:
1.301 www 4313: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4314:
1.327 albertel 4315: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4316: method="post" name="parameterlog">');
1.311 albertel 4317:
4318: my %saveable_parameters = ('show' => 'scalar',);
4319: &Apache::loncommon::store_course_settings('parameter_log',
4320: \%saveable_parameters);
4321: &Apache::loncommon::restore_course_settings('parameter_log',
4322: \%saveable_parameters);
1.348 www 4323: $r->print(&Apache::loncommon::display_filter().
1.326 www 4324: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4325: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4326: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4327:
1.291 www 4328: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4329: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4330: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4331: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4332: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4333: &Apache::loncommon::end_data_table_header_row());
1.309 www 4334: my $shown=0;
1.349 www 4335: my $folder='';
4336: if ($env{'form.displayfilter'} eq 'currentfolder') {
4337: my $last='';
4338: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4339: &GDBM_READER(),0640)) {
4340: $last=$hash{'last_known'};
4341: untie(%hash);
4342: }
4343: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4344: }
1.356 albertel 4345: foreach my $id (sort
4346: {
4347: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4348: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4349: }
4350: my $aid = (split('00000',$a))[-1];
4351: my $bid = (split('00000',$b))[-1];
4352: return $bid<=>$aid;
4353: } (keys(%parmlog))) {
1.294 www 4354: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4355: my $count = 0;
1.288 albertel 4356: my $time =
1.294 www 4357: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4358: my $plainname =
1.294 www 4359: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4360: $parmlog{$id}{'exe_udom'});
1.288 albertel 4361: my $about_me_link =
1.289 www 4362: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4363: $parmlog{$id}{'exe_uname'},
4364: $parmlog{$id}{'exe_udom'});
1.293 www 4365: my $send_msg_link='';
1.294 www 4366: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4367: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4368: $send_msg_link ='<br />'.
1.288 albertel 4369: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4370: $parmlog{$id}{'exe_uname'},
4371: $parmlog{$id}{'exe_udom'});
1.288 albertel 4372: }
1.301 www 4373: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4374: my $makenewrow=0;
4375: my %istype=();
1.332 albertel 4376: my $output;
1.293 www 4377: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4378: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4379: my $typeflag = ($changed =~/\.type$/ &&
4380: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4381: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4382: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4383: if ($env{'form.displayfilter'} eq 'currentfolder') {
4384: if ($folder) {
4385: if ($middle!~/^\Q$folder\E/) { next; }
4386: }
4387: }
1.326 www 4388: if ($typeflag) {
1.329 albertel 4389: $istype{$parmname}=$value;
1.326 www 4390: if (!$env{'form.includetypes'}) { next; }
4391: }
1.332 albertel 4392: $count++;
4393: if ($makenewrow) {
4394: $output .= $row_start;
4395: } else {
4396: $makenewrow=1;
4397: }
1.413.6.1! raeburn 4398: my $parmitem = &standard_parameter_names($parmname);
1.332 albertel 4399: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.413.6.1! raeburn 4400: &mt($parmitem).'</td><td>'.
1.332 albertel 4401: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4402: my $stillactive=0;
1.332 albertel 4403: if ($parmlog{$id}{'delflag'}) {
4404: $output .= &mt('Deleted');
1.288 albertel 4405: } else {
1.290 www 4406: if ($typeflag) {
1.413.6.1! raeburn 4407: my $parmitem = &standard_parameter_names($value);
! 4408: $parmitem = &mt($parmitem);
! 4409: $output .= &mt('Type: [_1]',$parmitem);
1.290 www 4410: } else {
1.291 www 4411: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4412: $uname,$udom,$issection,$issection,$courseopt);
4413: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4414: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4415: } else {
1.332 albertel 4416: $output .= $value;
1.291 www 4417: }
4418: if ($value ne $all[$level]) {
1.332 albertel 4419: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4420: } else {
4421: $stillactive=1;
4422: }
1.290 www 4423: }
1.288 albertel 4424: }
1.332 albertel 4425: $output .= '</td><td>';
1.291 www 4426: if ($stillactive) {
1.413.6.1! raeburn 4427: my $parmitem = &standard_parameter_names($parmname);
! 4428: $parmitem = &mt($parmitem);
! 4429: my $title=&mt('Changed [_1]',$parmitem);
! 4430: my $description=&mt('Changed [_1] for [_2] to [_3]',
! 4431: $parmitem,$realmdescription,
1.304 www 4432: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4433: if (($uname) && ($udom)) {
1.332 albertel 4434: $output .=
4435: &Apache::loncommon::messagewrapper('Notify User',
4436: $uname,$udom,$title,
4437: $description);
1.292 www 4438: } else {
1.332 albertel 4439: $output .=
4440: &Apache::lonrss::course_blog_link($id,$title,
4441: $description);
1.292 www 4442: }
1.291 www 4443: }
1.332 albertel 4444: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4445: }
1.349 www 4446: if ($env{'form.displayfilter'} eq 'containing') {
4447: my $wholeentry=$about_me_link.':'.
4448: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4449: $output;
4450: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4451: }
4452: if ($count) {
4453: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4454: <td rowspan="'.$count.'">'.$about_me_link.
4455: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4456: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4457: $send_msg_link.'</td>'.$output);
1.349 www 4458: $shown++;
4459: }
1.311 albertel 4460: if (!($env{'form.show'} eq &mt('all')
4461: || $shown<=$env{'form.show'})) { last; }
1.286 www 4462: }
1.301 www 4463: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4464: $r->print(&Apache::loncommon::end_page());
4465: }
4466:
1.355 albertel 4467: sub check_for_course_info {
4468: my $navmap = Apache::lonnavmaps::navmap->new();
4469: return 1 if ($navmap);
4470: return 0;
4471: }
4472:
1.178 raeburn 4473: ##################################################
4474: ##################################################
1.30 www 4475:
1.59 matthew 4476: =pod
4477:
1.83 bowersj2 4478: =item * handler
1.59 matthew 4479:
4480: Main handler. Calls &assessparms and &crsenv subroutines.
4481:
4482: =cut
1.376 albertel 4483:
1.59 matthew 4484: ##################################################
4485: ##################################################
1.259 banghart 4486:
1.30 www 4487: sub handler {
1.43 albertel 4488: my $r=shift;
1.30 www 4489:
1.376 albertel 4490: &reset_caches();
4491:
1.43 albertel 4492: if ($r->header_only) {
1.126 www 4493: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 4494: $r->send_http_header;
4495: return OK;
4496: }
1.193 albertel 4497: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4498: ['action','state',
4499: 'pres_marker',
4500: 'pres_value',
1.206 www 4501: 'pres_type',
1.390 www 4502: 'udom','uname','symb','serial','timebase']);
1.131 www 4503:
1.83 bowersj2 4504:
1.193 albertel 4505: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4506: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4507: text=>"Parameter Manager",
1.204 www 4508: faq=>10,
1.324 www 4509: bug=>'Instructor Interface',
4510: help => 'Parameter_Manager'});
1.203 www 4511:
1.30 www 4512: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4513: my $parm_permission =
4514: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4515: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4516: $env{'request.course.sec'}));
1.355 albertel 4517: my $exists = &check_for_course_info();
4518:
4519: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4520:
4521: # Start Page
1.126 www 4522: &Apache::loncommon::content_type($r,'text/html');
1.106 www 4523: $r->send_http_header;
1.30 www 4524:
1.203 www 4525:
1.193 albertel 4526: #
4527: # Main switch on form.action and form.state, as appropriate
4528: #
4529: # Check first if coming from someone else headed directly for
4530: # the table mode
4531: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
4532: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
1.324 www 4533: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
4534: text=>"Problem Parameters"});
1.193 albertel 4535: &assessparms($r);
4536:
4537: } elsif (! exists($env{'form.action'})) {
4538: $r->print(&header());
1.298 albertel 4539: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 4540: &print_main_menu($r,$parm_permission);
4541: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 4542: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
4543: text=>"Course Environment"});
1.193 albertel 4544: &crsenv($r);
4545: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 4546: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4547: text=>"Overview Mode"});
1.121 www 4548: &overview($r);
1.334 banghart 4549: } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) {
4550: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4551: text=>"Add Metadata Field"});
4552: &addmetafield($r);
1.340 banghart 4553: } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) {
4554: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4555: text=>"Add Metadata Field"});
4556: &order_meta_fields($r);
1.259 banghart 4557: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
4558: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4559: text=>"Restrict Metadata"});
4560: &setrestrictmeta($r);
1.208 www 4561: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
4562: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4563: text=>"Overview Mode"});
4564: &newoverview($r);
1.220 www 4565: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
4566: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4567: text=>"Set Defaults"});
4568: &defaultsetter($r);
4569: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 4570: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 4571: text=>"Table Mode",
4572: help => 'Course_Setting_Parameters'});
1.121 www 4573: &assessparms($r);
1.284 www 4574: } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) {
4575: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.292 www 4576: text=>"Parameter Change Log"});
1.285 albertel 4577: &parm_change_log($r);
1.333 albertel 4578: } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) {
4579: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
4580: text=>"Clean Parameters"});
4581: &clean_parameters($r);
1.390 www 4582: } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
4583: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4584: text=>"Shifting Dates"});
1.390 www 4585: &date_shift_one($r);
4586: } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) {
4587: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4588: text=>"Shifting Dates"});
1.390 www 4589: &date_shift_two($r);
1.403 raeburn 4590: } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
4591: &assign_course_categories($r);
4592: }
1.43 albertel 4593: } else {
1.1 www 4594: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 4595: if ($exists) {
4596: $env{'user.error.msg'}=
4597: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4598: } else {
4599: $env{'user.error.msg'}=
4600: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4601: }
1.43 albertel 4602: return HTTP_NOT_ACCEPTABLE;
4603: }
1.376 albertel 4604: &reset_caches();
4605:
1.43 albertel 4606: return OK;
1.1 www 4607: }
4608:
4609: 1;
4610: __END__
4611:
1.59 matthew 4612: =pod
1.38 harris41 4613:
4614: =back
4615:
4616: =cut
1.1 www 4617:
4618:
4619:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>