Annotation of loncom/interface/lonparmset.pm, revision 1.413.6.2
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.413.6.2! raeburn 4: # $Id: lonparmset.pm,v 1.413.6.1 2009/09/15 02:21:20 raeburn Exp $
1.40 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.59 matthew 28: ###################################################################
29: ###################################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: lonparmset - Handler to set parameters for assessments and course
36:
37: =head1 SYNOPSIS
38:
39: lonparmset provides an interface to setting course parameters.
40:
41: =head1 DESCRIPTION
42:
43: This module sets coursewide and assessment parameters.
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over 4
48:
49: =cut
50:
51: ###################################################################
52: ###################################################################
1.1 www 53:
54: package Apache::lonparmset;
55:
56: use strict;
57: use Apache::lonnet;
58: use Apache::Constants qw(:common :http REDIRECT);
1.88 matthew 59: use Apache::lonhtmlcommon();
1.36 albertel 60: use Apache::loncommon;
1.1 www 61: use GDBM_File;
1.57 albertel 62: use Apache::lonhomework;
63: use Apache::lonxml;
1.130 www 64: use Apache::lonlocal;
1.197 www 65: use Apache::lonnavmaps;
1.307 raeburn 66: use Apache::longroup;
1.303 www 67: use Apache::lonrss;
1.350 albertel 68: use LONCAPA qw(:DEFAULT :match);
1.1 www 69:
1.198 www 70:
1.59 matthew 71: ##################################################
72: ##################################################
73:
74: =pod
75:
76: =item parmval
77:
78: Figure out a cascading parameter.
79:
1.71 albertel 80: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 81: $id - a bighash Id number
1.71 albertel 82: $def - the resource's default value 'stupid emacs
83:
1.269 raeburn 84: Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels
1.71 albertel 85:
1.306 albertel 86: 14- General Course
87: 13- Map or Folder level in course
1.269 raeburn 88: 12- resource default
89: 11- map default
1.306 albertel 90: 10- resource level in course
1.269 raeburn 91: 9 - General for section
92: 8 - Map or Folder level for section
93: 7 - resource level in section
94: 6 - General for group
95: 5 - Map or Folder level for group
96: 4 - resource level in group
1.71 albertel 97: 3 - General for specific student
1.82 www 98: 2 - Map or Folder level for specific student
1.71 albertel 99: 1 - resource level for specific student
1.2 www 100:
1.59 matthew 101: =cut
102:
103: ##################################################
1.2 www 104: sub parmval {
1.275 raeburn 105: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
106: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
107: $cgroup,$courseopt);
1.201 www 108: }
109:
110: sub parmval_by_symb {
1.275 raeburn 111: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.200 www 112:
1.352 albertel 113: my $useropt;
114: if ($uname ne '' && $udom ne '') {
115: $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
116: }
1.200 www 117:
1.8 www 118: my $result='';
1.44 albertel 119: my @outpar=();
1.2 www 120: # ----------------------------------------------------- Cascading lookup scheme
1.201 www 121: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 122: $map = &Apache::lonnet::deversion($map);
1.10 www 123:
1.201 www 124: my $symbparm=$symb.'.'.$what;
125: my $mapparm=$map.'___(all).'.$what;
1.10 www 126:
1.269 raeburn 127: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
128: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
129: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
130:
1.190 albertel 131: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
132: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
133: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
134:
135: my $courselevel=$env{'request.course.id'}.'.'.$what;
136: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
137: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 138:
1.11 www 139:
1.182 albertel 140: # --------------------------------------------------------- first, check course
1.11 www 141:
1.200 www 142: if (defined($$courseopt{$courselevel})) {
1.269 raeburn 143: $outpar[14]=$$courseopt{$courselevel};
144: $result=14;
1.43 albertel 145: }
1.11 www 146:
1.200 www 147: if (defined($$courseopt{$courselevelm})) {
1.269 raeburn 148: $outpar[13]=$$courseopt{$courselevelm};
149: $result=13;
1.43 albertel 150: }
1.11 www 151:
1.182 albertel 152: # ------------------------------------------------------- second, check default
153:
1.269 raeburn 154: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 155:
156: # ------------------------------------------------------ third, check map parms
157:
1.376 albertel 158: my $thisparm=&parmhash($symbparm);
1.269 raeburn 159: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 160:
1.200 www 161: if (defined($$courseopt{$courselevelr})) {
1.269 raeburn 162: $outpar[10]=$$courseopt{$courselevelr};
163: $result=10;
1.43 albertel 164: }
1.11 www 165:
1.182 albertel 166: # ------------------------------------------------------ fourth, back to course
1.352 albertel 167: if ($csec ne '') {
1.200 www 168: if (defined($$courseopt{$seclevel})) {
1.269 raeburn 169: $outpar[9]=$$courseopt{$seclevel};
170: $result=9;
1.43 albertel 171: }
1.200 www 172: if (defined($$courseopt{$seclevelm})) {
1.269 raeburn 173: $outpar[8]=$$courseopt{$seclevelm};
174: $result=8;
1.43 albertel 175: }
176:
1.200 www 177: if (defined($$courseopt{$seclevelr})) {
1.269 raeburn 178: $outpar[7]=$$courseopt{$seclevelr};
179: $result=7;
1.43 albertel 180: }
181: }
1.275 raeburn 182: # ------------------------------------------------------ fifth, check course group
1.352 albertel 183: if ($cgroup ne '') {
1.269 raeburn 184: if (defined($$courseopt{$grplevel})) {
185: $outpar[6]=$$courseopt{$grplevel};
186: $result=6;
187: }
188: if (defined($$courseopt{$grplevelm})) {
189: $outpar[5]=$$courseopt{$grplevelm};
190: $result=5;
191: }
192: if (defined($$courseopt{$grplevelr})) {
193: $outpar[4]=$$courseopt{$grplevelr};
194: $result=4;
195: }
196: }
1.11 www 197:
1.182 albertel 198: # ---------------------------------------------------------- fifth, check user
1.11 www 199:
1.352 albertel 200: if ($uname ne '') {
1.200 www 201: if (defined($$useropt{$courselevel})) {
202: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 203: $result=3;
204: }
1.10 www 205:
1.200 www 206: if (defined($$useropt{$courselevelm})) {
207: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 208: $result=2;
209: }
1.2 www 210:
1.200 www 211: if (defined($$useropt{$courselevelr})) {
212: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 213: $result=1;
214: }
215: }
1.44 albertel 216: return ($result,@outpar);
1.2 www 217: }
218:
1.198 www 219:
220:
1.376 albertel 221: # --- Caches local to lonparmset
222:
223:
224: sub reset_caches {
225: &resetparmhash();
226: &resetsymbcache();
227: &resetrulescache();
1.203 www 228: }
229:
1.376 albertel 230: {
231: my $parmhashid;
232: my %parmhash;
233: sub resetparmhash {
234: undef($parmhashid);
235: undef(%parmhash);
236: }
237:
238: sub cacheparmhash {
239: if ($parmhashid eq $env{'request.course.fn'}) { return; }
240: my %parmhashfile;
241: if (tie(%parmhashfile,'GDBM_File',
242: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
243: %parmhash=%parmhashfile;
244: untie(%parmhashfile);
245: $parmhashid=$env{'request.course.fn'};
246: }
1.201 www 247: }
1.376 albertel 248:
249: sub parmhash {
250: my ($id) = @_;
251: &cacheparmhash();
252: return $parmhash{$id};
253: }
254: }
255:
256: {
257: my $symbsid;
258: my %symbs;
259: sub resetsymbcache {
260: undef($symbsid);
261: undef(%symbs);
262: }
263:
264: sub symbcache {
265: my $id=shift;
266: if ($symbsid ne $env{'request.course.id'}) {
267: undef(%symbs);
268: }
269: if (!$symbs{$id}) {
270: my $navmap = Apache::lonnavmaps::navmap->new();
271: if ($id=~/\./) {
272: my $resource=$navmap->getById($id);
273: $symbs{$id}=$resource->symb();
274: } else {
275: my $resource=$navmap->getByMapPc($id);
276: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
277: }
278: $symbsid=$env{'request.course.id'};
1.201 www 279: }
1.376 albertel 280: return $symbs{$id};
1.201 www 281: }
1.376 albertel 282: }
1.201 www 283:
1.376 albertel 284: {
285: my $rulesid;
286: my %rules;
287: sub resetrulescache {
288: undef($rulesid);
289: undef(%rules);
290: }
291:
292: sub rulescache {
293: my $id=shift;
294: if ($rulesid ne $env{'request.course.id'}
295: && !defined($rules{$id})) {
296: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
297: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
298: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
299: $rulesid=$env{'request.course.id'};
300: }
301: return $rules{$id};
1.221 www 302: }
303: }
304:
1.229 www 305: sub preset_defaults {
306: my $type=shift;
307: if (&rulescache($type.'_action') eq 'default') {
308: # yes, there is something
309: return (&rulescache($type.'_hours'),
310: &rulescache($type.'_min'),
311: &rulescache($type.'_sec'),
312: &rulescache($type.'_value'));
313: } else {
314: # nothing there or something else
315: return ('','','','','');
316: }
317: }
318:
1.186 www 319: ##################################################
1.277 www 320:
321: sub date_sanity_info {
322: my $checkdate=shift;
323: unless ($checkdate) { return ''; }
324: my $result='';
325: my $crsprefix='course.'.$env{'request.course.id'}.'.';
326: if ($env{$crsprefix.'default_enrollment_end_date'}) {
327: if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
1.413 bisitz 328: $result.='<div class="LC_warning">'
329: .&mt('After course enrollment end!')
330: .'</div>';
1.277 www 331: }
332: }
333: if ($env{$crsprefix.'default_enrollment_start_date'}) {
334: if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
1.413 bisitz 335: $result.='<div class="LC_warning">'
336: .&mt('Before course enrollment start!')
337: .'</div>';
1.277 www 338: }
339: }
1.413 bisitz 340: # Preparation for additional warnings about dates in the past/future.
341: # An improved, more context sensitive version is recommended,
342: # e.g. warn for due and answer dates which are defined before the corresponding open date, etc.
343: # if ($checkdate<time) {
344: # $result.='<div class="LC_info">'
345: # .'('.&mt('in the past').')'
346: # .'</div>';
347: # }
348: # if ($checkdate>time) {
349: # $result.='<div class="LC_info">'
350: # .'('.&mt('in the future').')'
351: # .'</div>';
352: # }
1.277 www 353: return $result;
354: }
355: ##################################################
1.186 www 356: ##################################################
357: #
1.197 www 358: # Store a parameter by ID
1.186 www 359: #
360: # Takes
361: # - resource id
362: # - name of parameter
363: # - level
364: # - new value
365: # - new type
1.187 www 366: # - username
367: # - userdomain
368:
1.186 www 369: sub storeparm {
1.269 raeburn 370: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 raeburn 371: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 372: }
373:
374: #
375: # Store a parameter by symb
376: #
377: # Takes
378: # - symb
379: # - name of parameter
380: # - level
381: # - new value
382: # - new type
383: # - username
384: # - userdomain
1.226 www 385: my %recstack;
1.197 www 386: sub storeparm_by_symb {
1.275 raeburn 387: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 388: unless ($recflag) {
389: # first time call
390: %recstack=();
391: $recflag=1;
392: }
393: # store parameter
394: &storeparm_by_symb_inner
1.269 raeburn 395: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 396: # don't do anything if parameter was reset
397: unless ($nval) { return; }
1.226 www 398: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
399: # remember that this was set
400: $recstack{$parm}=1;
401: # what does this trigger?
402: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
403: # don't backfire
404: unless ((!$triggered) || ($recstack{$triggered})) {
405: my $action=&rulescache($triggered.'_action');
406: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
407: # set triggered parameter on same level
408: my $newspnam=$prefix.$triggered;
1.227 www 409: my $newvalue='';
1.228 www 410: my $active=1;
411: if ($action=~/^when\_setting/) {
412: # are there restrictions?
413: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
414: $active=0;
415: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
416: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
417: }
418: }
419: $newvalue=&rulescache($triggered.'_value');
1.227 www 420: } else {
421: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
1.228 www 422: if ($action=~/^later\_than/) {
423: $newvalue=$nval+$totalsecs;
424: } else {
425: $newvalue=$nval-$totalsecs;
426: }
427: }
428: if ($active) {
429: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
1.275 raeburn 430: $uname,$udom,$csec,$recflag,$cgroup);
1.227 www 431: }
1.226 www 432: }
433: }
434: return '';
435: }
436:
1.293 www 437: sub log_parmset {
438: return &Apache::lonnet::instructor_log('parameterlog',@_);
1.284 www 439: }
440:
1.226 www 441: sub storeparm_by_symb_inner {
1.197 www 442: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 443: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 444: # ---------------------------------------------------------- Construct prefixes
1.186 www 445: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 446: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 447: $map = &Apache::lonnet::deversion($map);
448:
1.197 www 449: my $symbparm=$symb.'.'.$spnam;
450: my $mapparm=$map.'___(all).'.$spnam;
451:
1.269 raeburn 452: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
453: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
454: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
455:
1.190 albertel 456: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
457: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
458: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 459:
1.190 albertel 460: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
461: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
462: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 463:
464: my $storeunder='';
1.269 raeburn 465: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
466: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
467: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
468: if ($snum==9) { $storeunder=$seclevel; }
469: if ($snum==8) { $storeunder=$seclevelm; }
470: if ($snum==7) { $storeunder=$seclevelr; }
471: if ($snum==6) { $storeunder=$grplevel; }
472: if ($snum==5) { $storeunder=$grplevelm; }
473: if ($snum==4) { $storeunder=$grplevelr; }
474:
1.186 www 475:
476: my $delete;
477: if ($nval eq '') { $delete=1;}
478: my %storecontent = ($storeunder => $nval,
479: $storeunder.'.type' => $ntype);
480: my $reply='';
481: if ($snum>3) {
482: # ---------------------------------------------------------------- Store Course
483: #
1.200 www 484: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
485: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 486: # Expire sheets
487: &Apache::lonnet::expirespread('','','studentcalc');
1.269 raeburn 488: if (($snum==10) || ($snum==7) || ($snum==4)) {
1.197 www 489: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.269 raeburn 490: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
1.197 www 491: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 492: } else {
493: &Apache::lonnet::expirespread('','','assesscalc');
494: }
495: # Store parameter
496: if ($delete) {
497: $reply=&Apache::lonnet::del
1.200 www 498: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.290 www 499: &log_parmset(\%storecontent,1);
1.186 www 500: } else {
501: $reply=&Apache::lonnet::cput
1.200 www 502: ('resourcedata',\%storecontent,$cdom,$cnum);
1.290 www 503: &log_parmset(\%storecontent);
1.186 www 504: }
1.200 www 505: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 506: } else {
507: # ------------------------------------------------------------------ Store User
508: #
509: # Expire sheets
510: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
511: if ($snum==1) {
512: &Apache::lonnet::expirespread
1.197 www 513: ($uname,$udom,'assesscalc',$symb);
1.186 www 514: } elsif ($snum==2) {
515: &Apache::lonnet::expirespread
1.197 www 516: ($uname,$udom,'assesscalc',$map);
1.186 www 517: } else {
518: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
519: }
520: # Store parameter
521: if ($delete) {
522: $reply=&Apache::lonnet::del
523: ('resourcedata',[keys(%storecontent)],$udom,$uname);
1.290 www 524: &log_parmset(\%storecontent,1,$uname,$udom);
1.186 www 525: } else {
526: $reply=&Apache::lonnet::cput
527: ('resourcedata',\%storecontent,$udom,$uname);
1.290 www 528: &log_parmset(\%storecontent,0,$uname,$udom);
1.186 www 529: }
1.191 albertel 530: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 531: }
532:
533: if ($reply=~/^error\:(.*)/) {
1.314 albertel 534: return "<span class=\"LC_error\">Write Error: $1</span>";
1.186 www 535: }
536: return '';
537: }
538:
1.59 matthew 539: ##################################################
540: ##################################################
541:
542: =pod
543:
544: =item valout
545:
546: Format a value for output.
547:
1.320 www 548: Inputs: $value, $type, $editable
1.59 matthew 549:
550: Returns: $value, formatted for output. If $type indicates it is a date,
551: localtime($value) is returned.
1.320 www 552: $editable will return an icon to click on
1.9 www 553:
1.59 matthew 554: =cut
555:
556: ##################################################
557: ##################################################
1.9 www 558: sub valout {
1.320 www 559: my ($value,$type,$editable)=@_;
1.59 matthew 560: my $result = '';
561: # Values of zero are valid.
562: if (! $value && $value ne '0') {
1.320 www 563: if ($editable) {
1.324 www 564: $result = '<span class="LC_clickhere">*</span>';
1.320 www 565: } else {
566: $result=' ';
567: }
1.59 matthew 568: } else {
1.66 www 569: if ($type eq 'date_interval') {
570: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
1.413 bisitz 571: my @timer;
1.66 www 572: $year=$year-70;
573: $mday--;
574: if ($year) {
1.413 bisitz 575: # $result.=&mt('[quant,_1,yr]',$year).' ';
576: push(@timer,&mt('[quant,_1,yr]',$year));
1.66 www 577: }
578: if ($mon) {
1.413 bisitz 579: # $result.=&mt('[quant,_1,mth]',$mon).' ';
580: push(@timer,&mt('[quant,_1,mth]',$mon));
1.66 www 581: }
582: if ($mday) {
1.413 bisitz 583: # $result.=&mt('[quant,_1,day]',$mday).' ';
584: push(@timer,&mt('[quant,_1,day]',$mday));
1.66 www 585: }
586: if ($hour) {
1.413 bisitz 587: # $result.=&mt('[quant,_1,hr]',$hour).' ';
588: push(@timer,&mt('[quant,_1,hr]',$hour));
1.66 www 589: }
590: if ($min) {
1.413 bisitz 591: # $result.=&mt('[quant,_1,min]',$min).' ';
592: push(@timer,&mt('[quant,_1,min]',$min));
1.66 www 593: }
594: if ($sec) {
1.413 bisitz 595: # $result.=&mt('[quant,_1,sec]',$sec).' ';
596: push(@timer,&mt('[quant,_1,sec]',$sec));
1.66 www 597: }
1.413 bisitz 598: # $result=~s/\s+$//;
599: if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable
600: push(@timer,&mt('[quant,_1,sec]',0));
601: }
602: $result.=join(", ",@timer);
1.213 www 603: } elsif (&isdateparm($type)) {
1.361 albertel 604: $result = &Apache::lonlocal::locallocaltime($value).
605: &date_sanity_info($value);
1.59 matthew 606: } else {
607: $result = $value;
1.378 albertel 608: $result = &HTML::Entities::encode($result,'"<>&');
1.59 matthew 609: }
610: }
611: return $result;
1.9 www 612: }
613:
1.59 matthew 614: ##################################################
615: ##################################################
616:
617: =pod
1.5 www 618:
1.59 matthew 619: =item plink
620:
621: Produces a link anchor.
622:
623: Inputs: $type,$dis,$value,$marker,$return,$call
624:
625: Returns: scalar with html code for a link which will envoke the
626: javascript function 'pjump'.
627:
628: =cut
629:
630: ##################################################
631: ##################################################
1.5 www 632: sub plink {
633: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 634: my $winvalue=$value;
635: unless ($winvalue) {
1.213 www 636: if (&isdateparm($type)) {
1.190 albertel 637: $winvalue=$env{'form.recent_'.$type};
1.23 www 638: } else {
1.190 albertel 639: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 640: }
641: }
1.229 www 642: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
643: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
644: unless (defined($winvalue)) { $winvalue=$val; }
1.378 albertel 645: my $valout = &valout($value,$type,1);
1.413.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);
1.413.6.2! raeburn 2123: my $crstype = &Apache::loncommon::course_type();
1.392 raeburn 2124:
1.105 matthew 2125: #
2126: # Go through list of changes
1.190 albertel 2127: foreach (keys %env) {
1.105 matthew 2128: next if ($_!~/^form\.(.+)\_setparmval$/);
2129: my $name = $1;
1.190 albertel 2130: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 2131: if ($name eq 'newp') {
1.190 albertel 2132: $name = $env{'form.newp_name'};
1.413.6.2! raeburn 2133: } elsif ($name =~ /^rolenames_([^_]+)$/) {
! 2134: $name = $1.'.plaintext';
! 2135: my $standardtitle =
! 2136: &Apache::lonnet::plaintext($1,$crstype,$env{'request.course.id'},1);
! 2137: my %adv_roles =
! 2138: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
! 2139: if ($value ne '') {
! 2140: foreach my $role (keys(%adv_roles)) {
! 2141: if ($role =~ m{^cr/$match_domain/$match_name/\Q$value\E$}) {
! 2142: $setoutput.= '<span class="LC_error">'.
! 2143: &mt('Requested replacement title for [_1] role is already used as the name of a custom role ([_2]).',$standardtitle,$value).
! 2144: '</span><br />';
! 2145: undef($value);
! 2146: }
! 2147: }
! 2148: }
1.105 matthew 2149: }
2150: if ($name eq 'url') {
2151: $value=~s/^\/res\///;
2152: my $bkuptime=time;
2153: my @tmp = &Apache::lonnet::get
2154: ('environment',['url'],$dom,$crs);
1.130 www 2155: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2156: &Apache::lonnet::put
2157: ('environment',
2158: {'top level map backup '.$bkuptime => $tmp[1] },
2159: $dom,$crs).
1.336 albertel 2160: '<br />';
1.105 matthew 2161: }
2162: #
2163: # Deal with modified default spreadsheets
2164: if ($name =~ /^spreadsheet_default_(classcalc|
2165: studentcalc|
2166: assesscalc)$/x) {
2167: my $sheettype = $1;
2168: if ($sheettype eq 'classcalc') {
2169: # no need to do anything since viewing the sheet will
2170: # cause it to be updated.
2171: } elsif ($sheettype eq 'studentcalc') {
2172: # expire all the student spreadsheets
2173: &Apache::lonnet::expirespread('','','studentcalc');
2174: } else {
2175: # expire all the assessment spreadsheets
2176: # this includes non-default spreadsheets, but better to
2177: # be safe than sorry.
2178: &Apache::lonnet::expirespread('','','assesscalc');
2179: # expire all the student spreadsheets
2180: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2181: }
1.105 matthew 2182: }
2183: #
1.107 matthew 2184: # Deal with the enrollment dates
2185: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2186: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2187: }
1.364 albertel 2188: #
2189: # Deal with the emails
2190: if ($name =~ /\.email$/) {
1.371 albertel 2191: foreach my $specifier (split(',',$value)) {
2192: my ($user,$sections_or_groups)=
2193: ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
2194: if (!$sections_or_groups) {
2195: $user = $specifier;
2196: }
2197: my ($name,$domain) = split(':',$user);
2198: if (!defined($user) || !defined($domain)) {
2199: $setoutput.= '<br /> <span class="LC_error">'.
2200: &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user).
2201: '</span>';
2202: undef($value);
2203: } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
2204: $setoutput.= '<br /> <span class="LC_error">'.
2205: &mt("Invalid email address specified, user [_1] is unknown.",$name).
2206: '</span>';
2207: undef($value);
2208: }
1.364 albertel 2209: }
2210: }
1.178 raeburn 2211: # Get existing cloners
2212: my @oldcloner = ();
2213: if ($name eq 'cloners') {
2214: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2215: if ($clonenames{'cloners'} =~ /,/) {
2216: @oldcloner = split/,/,$clonenames{'cloners'};
2217: } else {
2218: $oldcloner[0] = $clonenames{'cloners'};
2219: }
2220: }
1.107 matthew 2221: #
1.105 matthew 2222: # Let the user know we made the changes
1.153 albertel 2223: if ($name && defined($value)) {
1.379 raeburn 2224: my %failed_cloners;
1.178 raeburn 2225: if ($name eq 'cloners') {
1.239 raeburn 2226: $value =~ s/\s//g;
1.178 raeburn 2227: $value =~ s/^,//;
2228: $value =~ s/,$//;
1.239 raeburn 2229: # check requested clones are valid users.
1.379 raeburn 2230: %failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2231: }
1.105 matthew 2232: my $put_result = &Apache::lonnet::put('environment',
2233: {$name=>$value},$dom,$crs);
2234: if ($put_result eq 'ok') {
1.392 raeburn 2235: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
2236: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2237: $setoutput .= &Apache::lonlocal::locallocaltime($value);
1.406 raeburn 2238: } elsif ($name eq 'categories') {
2239: $setoutput .= $env{'form.categories_display'};
1.392 raeburn 2240: } else {
2241: $setoutput .= $value;
2242: }
2243: $setoutput .= '</b>.<br />';
1.178 raeburn 2244: if ($name eq 'cloners') {
2245: &change_clone($value,\@oldcloner);
2246: }
1.382 raeburn 2247: # Update environment and nohist_courseids.db
1.402 raeburn 2248: if (($name eq 'description') || ($name eq 'cloners') ||
1.403 raeburn 2249: ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.392 raeburn 2250: if ($chome eq '') {
2251: %crsinfo =
2252: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
1.403 raeburn 2253: $crs,undef,undef,'.');
1.392 raeburn 2254: $chome = &Apache::lonnet::homeserver($crs,$dom);
2255: }
2256: }
1.179 raeburn 2257: if ($name eq 'description' && defined($value)) {
1.393 raeburn 2258: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
1.382 raeburn 2259: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2260: $crsinfo{$env{'request.course.id'}}{'description'} = $value;
1.392 raeburn 2261: my $putresult =
2262: &Apache::lonnet::courseidput($dom,\%crsinfo,
2263: $chome,'notime');
2264: }
2265: }
1.403 raeburn 2266: if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.402 raeburn 2267: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1.403 raeburn 2268: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
2269: $crsinfo{$env{'request.course.id'}}{$name} = $value;
1.402 raeburn 2270: my $putresult =
2271: &Apache::lonnet::courseidput($dom,\%crsinfo,
2272: $chome,'notime');
2273: }
2274: }
1.105 matthew 2275: } else {
1.130 www 2276: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2277: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2278: }
1.379 raeburn 2279: if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
2280: $setoutput.= &mt('Unable to include').': ';
2281: my @fails;
2282: my $num = 0;
2283: if (defined($failed_cloners{'format'})) {
2284: $fails[$num] .= '<b>'.$failed_cloners{'format'}.
2285: '</b>, '.&mt('reason').' - '.
2286: &mt('Invalid format');
2287: $num ++;
2288: }
2289: if (defined($failed_cloners{'domain'})) {
2290: $fails[$num] .= '<b>'.$failed_cloners{'domain'}.
2291: '</b>, '.&mt('reason').' - '.
2292: &mt('Domain does not exist');
2293: $num ++;
2294: }
2295: if (defined($failed_cloners{'newuser'})) {
2296: $fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</b>, '.&mt('reason').' - '.
2297: &mt('LON-CAPA user(s) do(es) not exist.').
2298: '.<br />'.&mt('Please ').
2299: ' <a href="/adm/createuser">'.
2300: &mt('add the user(s)').'</a>, '.
2301: &mt('and then return to the ').
2302: '<a href="/adm/parmset?action=crsenv">'.
2303: &mt('Course Parameters page').'</a> '.
2304: &mt('to add the new user(s) to the list of possible cloners');
2305: }
2306: $setoutput .= join('; ',@fails).'.<br />';
1.239 raeburn 2307: }
1.30 www 2308: }
1.38 harris41 2309: }
1.315 albertel 2310:
2311: my $start_table =&Apache::loncommon::start_data_table();
2312: my $start_header_row=&Apache::loncommon::start_data_table_header_row();
2313: my $end_header_row =&Apache::loncommon::end_data_table_header_row();
1.108 www 2314: # ------------------------- Re-init course environment entries for this session
2315:
1.302 albertel 2316: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2317: {'freshen_cache' => 1});
1.105 matthew 2318:
1.30 www 2319: # -------------------------------------------------------- Get parameters again
1.45 matthew 2320:
2321: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2322: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2323: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2324: my $output='';
1.403 raeburn 2325: my $can_categorize;
1.45 matthew 2326: if (! exists($values{'con_lost'})) {
1.30 www 2327: my %descriptions=
1.395 bisitz 2328: ('url' => '<b>'.&mt('Top Level Map').'</b><br />'.
1.46 matthew 2329: '<a href="javascript:openbrowser'.
1.47 matthew 2330: "('envform','url','sequence')\">".
1.314 albertel 2331: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1.395 bisitz 2332: &mt('Modification may make assessment data inaccessible!').
1.314 albertel 2333: '</span>',
1.140 sakharuk 2334: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2335: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2336: '</b><br />'.
1.395 bisitz 2337: '('.&mt('internal, optional').')',
2338: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br />'
2339: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'
2340: .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'
2341: .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'
2342: .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),
1.150 www 2343: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1.395 bisitz 2344: &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),
2345: 'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'
2346: .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'
2347: .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',
2348: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.
1.52 www 2349: '<a href="javascript:openbrowser'.
2350: "('envform','default_xml_style'".
1.336 albertel 2351: ",'sty')\">$SelectStyleFile</a><br />",
1.395 bisitz 2352: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'
2353: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2354: 'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',
2355: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'
2356: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2357: 'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',
2358: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'
2359: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2360: 'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',
2361: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'
2362: .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',
2363: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'
2364: .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '
2365: .&mt('Changes will not show until next login.').')',
2366: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'
2367: .'('.&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>"').')',
2368: 'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'
1.413.6.1 raeburn 2369: .'('.&mt("[_1] for link to each a listing of each student's files.",'"<tt>yes</tt>"').')',
1.395 bisitz 2370: 'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'
2371: .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',
2372: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').'</b><br />'
2373: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2374: .'("<tt>'.&mt('role,role,...').'</tt>") '
2375: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.118 matthew 2376: 'plc.users.denied' =>
1.141 sakharuk 2377: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.395 bisitz 2378: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.118 matthew 2379:
1.395 bisitz 2380: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'
2381: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')
2382: .'("<tt>'.&mt('role,role,...').'</tt>") '
2383: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2384: 'pch.users.denied' =>
1.141 sakharuk 2385: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.395 bisitz 2386: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.49 matthew 2387: 'spreadsheet_default_classcalc'
1.141 sakharuk 2388: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2389: '<a href="javascript:openbrowser'.
2390: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2391: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2392: 'spreadsheet_default_studentcalc'
1.395 bisitz 2393: => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.
1.50 matthew 2394: '<a href="javascript:openbrowser'.
2395: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2396: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2397: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2398: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2399: '<a href="javascript:openbrowser'.
2400: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2401: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2402: 'allow_limited_html_in_feedback'
1.141 sakharuk 2403: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.395 bisitz 2404: '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',
1.170 raeburn 2405: 'allow_discussion_post_editing'
1.395 bisitz 2406: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'
2407: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2408: .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'
2409: .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'
2410: .'('.&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 2411: 'rndseed'
1.395 bisitz 2412: => '<b>'.&mt('Randomization algorithm used').'</b><br />'
2413: .'<span class="LC_error">'
2414: .&mt('Modifying this will make problems have different numbers and answers!')
2415: .'</span>',
1.151 albertel 2416: 'receiptalg'
2417: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2418: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2419: 'suppress_tries'
1.272 albertel 2420: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.395 bisitz 2421: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.113 sakharuk 2422: 'problem_stream_switch'
1.141 sakharuk 2423: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.395 bisitz 2424: ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',
1.161 sakharuk 2425: 'default_paper_size'
2426: => '<b>'.&mt('Default paper type').'</b><br />'.
2427: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2428: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2429: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.319 foxr 2430: 'print_header_format'
1.395 bisitz 2431: => ' <b>'.&mt('Print header format').'</b><br />'
2432: .&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 2433: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2434: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.395 bisitz 2435: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'
2436: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',
1.140 sakharuk 2437: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2438: 'disable_receipt_display'
1.141 sakharuk 2439: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2440: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.313 albertel 2441: 'task_messages'
1.395 bisitz 2442: => '<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 2443: 'disablesigfigs'
2444: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2445: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2446: 'disableexampointprint'
2447: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2448: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2449: 'externalsyllabus'
1.279 www 2450: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2451: 'tthoptions'
1.367 albertel 2452: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>',
2453:
2454: 'texengine'
1.395 bisitz 2455: => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'
1.413.6.1 raeburn 2456: .'('.&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 2457: 'timezone'
1.400 raeburn 2458: => '<b>'.&mt('Timezone in which the course takes place').'</b>',
1.392 raeburn 2459:
1.400 raeburn 2460: 'suppress_embed_prompt'
2461: => '<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 2462: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.403 raeburn 2463: 'hidefromcat'
1.402 raeburn 2464: => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
2465: ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',
1.403 raeburn 2466: 'categories'
2467: => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
2468: &mt('Display Categories').'</a>',
1.409 raeburn 2469: 'datelocale'
2470: => '<b>'.&mt('Locale used for course calendar').'</b>',
1.413.6.2! raeburn 2471: 'rolenames'
! 2472: => '<b>'.&mt('Replacement titles for standard course roles').'</b><br />'.
! 2473: '('.&mt('To replace the standard title for a course role, enter the title you wish to use, otherwise leave blank.').')',
1.402 raeburn 2474: );
2475: my @Display_Order = ('url','description','courseid','cloners');
1.403 raeburn 2476: (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
2477: if ($can_toggle_cat) {
1.402 raeburn 2478: push(@Display_Order,'hidefromcat');
2479: }
1.403 raeburn 2480: if ($can_categorize) {
2481: push(@Display_Order,'categories');
2482: }
1.402 raeburn 2483: push (@Display_Order,('grading',
1.278 www 2484: 'externalsyllabus',
1.107 matthew 2485: 'default_xml_style','pageseparators',
1.402 raeburn 2486: 'question.email','question.email.text','comment.email',
2487: 'comment.email.text','policy.email','policy.email.text',
1.169 matthew 2488: 'student_classlist_view',
1.372 raeburn 2489: 'student_classlist_opt_in',
2490: 'student_classlist_portfiles',
1.118 matthew 2491: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2492: 'pch.roles.denied','pch.users.denied',
2493: 'allow_limited_html_in_feedback',
1.170 raeburn 2494: 'allow_discussion_post_editing',
1.108 www 2495: 'languages',
1.397 www 2496: 'timezone',
1.409 raeburn 2497: 'datelocale',
1.413.6.2! raeburn 2498: 'rolenames',
1.150 www 2499: 'nothideprivileged',
1.107 matthew 2500: 'rndseed',
1.151 albertel 2501: 'receiptalg',
1.107 matthew 2502: 'problem_stream_switch',
1.164 sakharuk 2503: 'suppress_tries',
1.400 raeburn 2504: 'suppress_embed_prompt',
1.161 sakharuk 2505: 'default_paper_size',
1.319 foxr 2506: 'print_header_format',
1.115 www 2507: 'disable_receipt_display',
1.107 matthew 2508: 'spreadsheet_default_classcalc',
2509: 'spreadsheet_default_studentcalc',
2510: 'spreadsheet_default_assesscalc',
2511: 'hideemptyrows',
2512: 'default_enrollment_start_date',
2513: 'default_enrollment_end_date',
1.163 albertel 2514: 'tthoptions',
1.367 albertel 2515: 'texengine',
1.251 albertel 2516: 'disablesigfigs',
1.313 albertel 2517: 'disableexampointprint',
1.402 raeburn 2518: 'task_messages','task_grading'));
1.107 matthew 2519: foreach my $parameter (sort(keys(%values))) {
1.405 raeburn 2520: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
1.413.6.2! raeburn 2521: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) ||
! 2522: ($parameter eq 'type') ||
! 2523: ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
1.142 raeburn 2524: if (! $descriptions{$parameter}) {
2525: $descriptions{$parameter}=$parameter;
2526: push(@Display_Order,$parameter);
2527: }
2528: }
1.43 albertel 2529: }
1.315 albertel 2530:
1.107 matthew 2531: foreach my $parameter (@Display_Order) {
2532: my $description = $descriptions{$parameter};
1.51 matthew 2533: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2534: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2535: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2536: '.checked=true;"';
1.315 albertel 2537: $output .= &Apache::loncommon::start_data_table_row().
2538: '<td>'.$description.'</td>';
1.107 matthew 2539: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2540: $output .= '<td>'.
2541: &Apache::lonhtmlcommon::date_setter('envform',
2542: $parameter.'_value',
2543: $values{$parameter},
2544: $onchange).
2545: '</td>';
1.398 www 2546: } elsif ($parameter eq 'timezone') {
1.399 raeburn 2547: my $includeempty = 1;
2548: my $timezone = &Apache::lonlocal::gettimezone();
1.398 www 2549: $output .= '<td>'.
2550: &Apache::loncommon::select_timezone($parameter.'_value',
1.399 raeburn 2551: $timezone,
2552: $onchange,$includeempty).'</td>';
1.409 raeburn 2553: } elsif ($parameter eq 'datelocale') {
2554: my $includeempty = 1;
2555: my $locale_obj = &Apache::lonlocal::getdatelocale();
2556: my $currdatelocale;
2557: if (ref($locale_obj)) {
2558: $currdatelocale = $locale_obj->id();
2559: }
2560: $output .= '<td>'.
2561: &Apache::loncommon::select_datelocale($parameter.'_value',
2562: $currdatelocale,
1.413.6.2! raeburn 2563: $onchange,$includeempty).'</td>';
! 2564: } elsif ($parameter eq 'rolenames') {
! 2565: $output.= '<td><table>';
! 2566: foreach my $role ('cc','in','ta','ep','ad','st') {
! 2567: my $onchange = 'onFocus="javascript:window.document.forms'.
! 2568: "['envform'].elements['".
! 2569: $parameter.'_'.$role."_setparmval']".
! 2570: '.checked=true;"';
! 2571:
! 2572: $output.= '<tr><td>'.&Apache::lonnet::plaintext($role,$crstype,undef,1).
! 2573: '</td><td>'.
! 2574: &Apache::lonhtmlcommon::textbox($parameter.'_'.$role.'_value',
! 2575: $values{$role.'.plaintext'},
! 2576: 15,$onchange).
! 2577: '</td></tr>';
! 2578: }
! 2579: $output .= '</table></td><td><table>';
! 2580: foreach my $role ('cc','in','ta','ep','ad','st') {
! 2581: $output .= '<tr><td>'.&Apache::lonhtmlcommon::checkbox($parameter.'_'.$role.'_setparmval').
! 2582: '</td></tr>';
! 2583: }
! 2584: $output .= '</table></td>';
1.406 raeburn 2585: } elsif ($parameter eq 'categories') {
2586: my $catdisplay;
2587: if ($values{'categories'} ne '') {
2588: my @curritems = split(/\&/,$values{'categories'});
2589: foreach my $item (@curritems) {
2590: my ($name,$parent,$pos) = split(/:/,$item);
2591: $catdisplay .= &unescape($name).'&';
2592: }
2593: $catdisplay =~ s/\&$//;
2594: }
2595: $output .= '<td>'.
2596: '<input type="hidden" name="categories_value" value="'.
2597: $values{'categories'}.'" />'.
2598: '<input type="textbox" name="categories_display" value="'.
2599: $catdisplay.'" readonly="readonly" size="40" /></td>';
1.107 matthew 2600: } else {
2601: $output .= '<td>'.
2602: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2603: $values{$parameter},
2604: 40,$onchange).'</td>';
2605: }
1.413.6.2! raeburn 2606: unless ($parameter eq 'rolenames') {
! 2607: $output .= '<td>'.
! 2608: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
! 2609: '</td>';
! 2610: }
1.315 albertel 2611: $output .= &Apache::loncommon::end_data_table_row()."\n";
1.51 matthew 2612: }
1.69 www 2613: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2614: '[\'envform\'].elements[\'newp_setparmval\']'.
2615: '.checked=true;"';
1.315 albertel 2616: $output.=&Apache::loncommon::start_data_table_row().
2617: '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2618: '<input type="text" size=40 name="newp_name" '.
2619: $onchange.' /></td><td>'.
2620: '<input type="text" size=40 name="newp_value" '.
2621: $onchange.' /></td><td>'.
1.315 albertel 2622: '<input type="checkbox" name="newp_setparmval" /></td>'.
2623: &Apache::loncommon::end_data_table_row()."\n";
1.43 albertel 2624: }
1.157 sakharuk 2625: my %lt=&Apache::lonlocal::texthash(
2626: 'par' => 'Parameter',
2627: 'val' => 'Value',
1.395 bisitz 2628: 'set' => 'Set?',
2629: 'sav' => 'Save'
1.157 sakharuk 2630: );
2631:
1.140 sakharuk 2632: my $Parameter=&mt('Parameter');
2633: my $Value=&mt('Value');
1.141 sakharuk 2634: my $Set=&mt('Set');
1.403 raeburn 2635: my ($jscript,$categorize_js);
2636: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
2637: if ($can_categorize) {
2638: $categorize_js = <<ENDSCRIPT;
2639: function catsbrowser() {
2640: var catswin = null;
2641: var url = '/adm/parmset?action=categorizecourse';
2642: if (!catswin || catswin.closed) {
2643: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2644: } else {
2645: catswin.focus();
2646: }
2647: }
2648: ENDSCRIPT
2649: }
2650: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
2651: $browse_js."\n".$categorize_js."\n".'</script>';
1.280 albertel 2652: my $start_page =
1.323 albertel 2653: &Apache::loncommon::start_page('Set Course Environment',
1.403 raeburn 2654: $jscript);
1.280 albertel 2655: my $end_page =
2656: &Apache::loncommon::end_page();
1.315 albertel 2657: my $end_table=&Apache::loncommon::end_data_table();
1.280 albertel 2658: $r->print(<<ENDENV);
2659: $start_page
1.193 albertel 2660: $breadcrumbs
2661: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2662: $setoutput
1.395 bisitz 2663: <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>
1.315 albertel 2664: $start_table
2665: $start_header_row
1.395 bisitz 2666: <th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
1.315 albertel 2667: $end_header_row
1.30 www 2668: $output
1.315 albertel 2669: $end_table
1.395 bisitz 2670: <input type="submit" name="crsenv" value="$lt{'sav'}" />
1.30 www 2671: </form>
1.280 albertel 2672: $end_page
2673: ENDENV
1.30 www 2674: }
1.402 raeburn 2675:
1.403 raeburn 2676: sub can_modify_catsettings {
1.402 raeburn 2677: my ($dom) = @_;
2678: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.403 raeburn 2679: my ($can_toggle_cat,$can_categorize);
1.402 raeburn 2680: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2681: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2682: $can_toggle_cat = 1;
2683: }
1.403 raeburn 2684: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2685: $can_categorize = 1;
2686: }
2687: }
2688: return ($can_toggle_cat,$can_categorize);
2689: }
2690:
2691: sub assign_course_categories {
2692: my ($r) = @_;
2693: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2694: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2695: my $hascats = 0;
2696: my $cathash;
2697: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2698: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2699: $cathash = $domconf{'coursecategories'}{'cats'};
2700: if (ref($cathash) eq 'HASH') {
2701: $hascats = 1;
2702: }
1.402 raeburn 2703: }
1.403 raeburn 2704: my $catwin_js;
2705: if ($hascats) {
2706: my $alert = &mt('Use \"Save\" in the main window to save course categories');
2707: $catwin_js = <<ENDSCRIPT;
2708: <script type="text/javascript">
2709:
2710: function updateCategories() {
2711: var newcategories = '';
1.406 raeburn 2712: var unescapedcats = '';
1.403 raeburn 2713: if (document.chgcats.usecategory.length) {
2714: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2715: if (document.chgcats.usecategory[i].checked == true) {
2716: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1.406 raeburn 2717: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1.403 raeburn 2718: }
2719: }
2720: if (newcategories.length > 0) {
2721: newcategories = newcategories.slice(0,-1);
2722: }
1.406 raeburn 2723: if (unescapedcats.length > 0) {
1.408 raeburn 2724: unescapedcats = unescapedcats.slice(0,-3);
1.406 raeburn 2725: }
1.403 raeburn 2726: } else {
2727: if (document.chgcats.usecategory.checked == true) {
2728: newcategories = document.chgcats.usecategory.value;
1.406 raeburn 2729: unescapedcats = document.chgcats.catname.value;
1.403 raeburn 2730: }
2731: }
2732: opener.document.envform.categories_value.value = newcategories;
1.406 raeburn 2733: opener.document.envform.categories_display.value = unescapedcats;
1.403 raeburn 2734: opener.document.envform.categories_setparmval.checked = true;
2735: alert("$alert");
2736: self.close();
2737: return;
2738: }
2739:
2740: </script>
2741: ENDSCRIPT
2742: } else {
2743: my $onload;
2744: }
2745: my $start_page =
2746: &Apache::loncommon::start_page('Course Categories',$catwin_js,
2747: {'only_body' => 1,});
2748: my $end_page = &Apache::loncommon::end_page();
2749: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
2750: if ($hascats) {
2751: my %currsettings =
2752: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2753: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
2754: '<form name="chgcats" action="/adm/parmset" method="post">'."\n"
2755: .&Apache::loncommon::assign_categories_table($cathash,
2756: $currsettings{'categories'})."\n"
2757: .'<br /><input type="button" name="changes" value="'
2758: .&mt('Copy to main window').'" '
2759: .'onclick="javascript:updateCategories()" /></form><br />';
2760: } else {
2761: $categoriesform .= &mt('No categories defined for this domain');
2762: }
2763: $r->print($start_page.$categoriesform.$end_page);
2764: return;
1.402 raeburn 2765: }
2766:
1.120 www 2767: ##################################################
1.207 www 2768: # Overview mode
2769: ##################################################
1.124 www 2770: my $tableopen;
2771:
2772: sub tablestart {
2773: if ($tableopen) {
2774: return '';
2775: } else {
2776: $tableopen=1;
1.295 albertel 2777: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 2778: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2779: }
2780: }
2781:
2782: sub tableend {
2783: if ($tableopen) {
2784: $tableopen=0;
1.295 albertel 2785: return &Apache::loncommon::end_data_table();
1.124 www 2786: } else {
2787: return'';
2788: }
2789: }
2790:
1.207 www 2791: sub readdata {
2792: my ($crs,$dom)=@_;
2793: # Read coursedata
2794: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2795: # Read userdata
2796:
2797: my $classlist=&Apache::loncoursedata::get_classlist();
2798: foreach (keys %$classlist) {
1.350 albertel 2799: if ($_=~/^($match_username)\:($match_domain)$/) {
1.207 www 2800: my ($tuname,$tudom)=($1,$2);
2801: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2802: foreach my $userkey (keys %{$useropt}) {
2803: if ($userkey=~/^$env{'request.course.id'}/) {
2804: my $newkey=$userkey;
2805: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2806: $$resourcedata{$newkey}=$$useropt{$userkey};
2807: }
2808: }
2809: }
2810: }
2811: return $resourcedata;
2812: }
2813:
2814:
1.124 www 2815: # Setting
1.208 www 2816:
2817: sub storedata {
2818: my ($r,$crs,$dom)=@_;
1.207 www 2819: # Set userlevel immediately
2820: # Do an intermediate store of course level
2821: my $olddata=&readdata($crs,$dom);
1.124 www 2822: my %newdata=();
2823: undef %newdata;
2824: my @deldata=();
2825: undef @deldata;
1.190 albertel 2826: foreach (keys %env) {
1.124 www 2827: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2828: my $cmd=$1;
2829: my $thiskey=$2;
1.207 www 2830: my ($tuname,$tudom)=&extractuser($thiskey);
2831: my $tkey=$thiskey;
2832: if ($tuname) {
2833: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2834: }
1.385 albertel 2835: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.384 albertel 2836: my ($data, $typeof, $text);
2837: if ($cmd eq 'set') {
2838: $data=$env{$_};
2839: $typeof=$env{'form.typeof_'.$thiskey};
2840: $text = &mt('Saved modified parameter for');
2841: } elsif ($cmd eq 'datepointer') {
2842: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
2843: $typeof=$env{'form.typeof_'.$thiskey};
2844: $text = &mt('Saved modified date for');
1.385 albertel 2845: } elsif ($cmd eq 'dateinterval') {
2846: $data=&get_date_interval_from_form($thiskey);
2847: $typeof=$env{'form.typeof_'.$thiskey};
2848: $text = &mt('Saved modified date for');
1.384 albertel 2849: }
2850: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 2851: if ($tuname) {
1.212 www 2852: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2853: $tkey.'.type' => $typeof},
2854: $tudom,$tuname) eq 'ok') {
1.290 www 2855: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.384 albertel 2856: $r->print('<br />'.$text.' '.
1.207 www 2857: &Apache::loncommon::plainname($tuname,$tudom));
2858: } else {
1.314 albertel 2859: $r->print('<div class="LC_error">'.
1.365 albertel 2860: &mt('Error saving parameters').'</div>');
1.207 www 2861: }
2862: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2863: } else {
2864: $newdata{$thiskey}=$data;
1.212 www 2865: $newdata{$thiskey.'.type'}=$typeof;
2866: }
1.207 www 2867: }
1.124 www 2868: } elsif ($cmd eq 'del') {
1.207 www 2869: if ($tuname) {
2870: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 2871: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 2872: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2873: } else {
1.314 albertel 2874: $r->print('<div class="LC_error">'.
2875: &mt('Error deleting parameters').'</div>');
1.207 www 2876: }
2877: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2878: } else {
1.333 albertel 2879: push (@deldata,$thiskey,$thiskey.'.type');
1.207 www 2880: }
1.124 www 2881: }
2882: }
2883: }
1.207 www 2884: # Store all course level
1.144 www 2885: my $delentries=$#deldata+1;
2886: my @newdatakeys=keys %newdata;
2887: my $putentries=$#newdatakeys+1;
2888: if ($delentries) {
2889: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 2890: my %loghash=map { $_ => '' } @deldata;
2891: &log_parmset(\%loghash,1);
1.144 www 2892: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2893: } else {
1.314 albertel 2894: $r->print('<div class="LC_error">'.
2895: &mt('Error deleting parameters').'</div>');
1.144 www 2896: }
1.205 www 2897: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2898: }
2899: if ($putentries) {
2900: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 2901: &log_parmset(\%newdata,0);
1.365 albertel 2902: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2903: } else {
1.314 albertel 2904: $r->print('<div class="LC_error">'.
1.365 albertel 2905: &mt('Error saving parameters').'</div>');
1.144 www 2906: }
1.205 www 2907: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2908: }
1.208 www 2909: }
1.207 www 2910:
1.208 www 2911: sub extractuser {
2912: my $key=shift;
1.350 albertel 2913: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 2914: }
1.206 www 2915:
1.381 albertel 2916: sub parse_listdata_key {
2917: my ($key,$listdata) = @_;
2918: # split into student/section affected, and
2919: # the realm (folder/resource part and parameter
2920: my ($student,$realm) =
2921: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
2922: # if course wide student would be undefined
2923: if (!defined($student)) {
2924: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2925: }
2926: # strip off the .type if it's not the Question type parameter
2927: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
2928: $realm=~s/\.type//;
2929: }
2930: # split into resource+part and parameter name
1.388 albertel 2931: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
2932: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 2933: return ($student,$res,$part,$parm);
2934: }
2935:
1.208 www 2936: sub listdata {
1.214 www 2937: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2938: # Start list output
1.206 www 2939:
1.122 www 2940: my $oldsection='';
2941: my $oldrealm='';
2942: my $oldpart='';
1.123 www 2943: my $pointer=0;
1.124 www 2944: $tableopen=0;
1.145 www 2945: my $foundkeys=0;
1.248 albertel 2946: my %keyorder=&standardkeyorder();
1.381 albertel 2947:
1.214 www 2948: foreach my $thiskey (sort {
1.381 albertel 2949: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
2950: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
2951:
2952: # get the numerical order for the param
2953: $aparm=$keyorder{'parameter_0_'.$aparm};
2954: $bparm=$keyorder{'parameter_0_'.$bparm};
2955:
2956: my $result=0;
2957:
1.214 www 2958: if ($sortorder eq 'realmstudent') {
1.381 albertel 2959: if ($ares ne $bres ) {
2960: $result = ($ares cmp $bres);
2961: } elsif ($astudent ne $bstudent) {
2962: $result = ($astudent cmp $bstudent);
2963: } elsif ($apart ne $bpart ) {
2964: $result = ($apart cmp $bpart);
1.237 albertel 2965: }
1.381 albertel 2966: } else {
2967: if ($astudent ne $bstudent) {
2968: $result = ($astudent cmp $bstudent);
2969: } elsif ($ares ne $bres ) {
2970: $result = ($ares cmp $bres);
2971: } elsif ($apart ne $bpart ) {
2972: $result = ($apart cmp $bpart);
1.247 albertel 2973: }
1.381 albertel 2974: }
2975:
2976: if (!$result) {
2977: if (defined($aparm) && defined($bparm)) {
2978: $result = ($aparm <=> $bparm);
2979: } elsif (defined($aparm)) {
2980: $result = -1;
2981: } elsif (defined($bparm)) {
2982: $result = 1;
1.248 albertel 2983: }
1.214 www 2984: }
1.381 albertel 2985:
2986: $result;
1.214 www 2987: } keys %{$listdata}) {
1.381 albertel 2988:
1.211 www 2989: if ($$listdata{$thiskey.'.type'}) {
2990: my $thistype=$$listdata{$thiskey.'.type'};
2991: if ($$resourcedata{$thiskey.'.type'}) {
2992: $thistype=$$resourcedata{$thiskey.'.type'};
2993: }
1.207 www 2994: my ($middle,$part,$name)=
2995: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2996: my $section=&mt('All Students');
1.207 www 2997: if ($middle=~/^\[(.*)\]/) {
1.206 www 2998: my $issection=$1;
1.350 albertel 2999: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
1.206 www 3000: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
3001: } else {
3002: $section=&mt('Group/Section').': '.$issection;
3003: }
1.207 www 3004: $middle=~s/^\[(.*)\]//;
1.122 www 3005: }
1.207 www 3006: $middle=~s/\.+$//;
3007: $middle=~s/^\.+//;
1.316 albertel 3008: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.122 www 3009: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 3010: $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 3011: } elsif ($middle) {
1.174 albertel 3012: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 3013: $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 3014: }
1.214 www 3015: if ($sortorder eq 'realmstudent') {
3016: if ($realm ne $oldrealm) {
3017: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3018: $oldrealm=$realm;
3019: $oldsection='';
3020: }
3021: if ($section ne $oldsection) {
3022: $r->print(&tableend()."\n<h2>$section</h2>");
3023: $oldsection=$section;
3024: $oldpart='';
3025: }
3026: } else {
3027: if ($section ne $oldsection) {
3028: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3029: $oldsection=$section;
3030: $oldrealm='';
3031: }
3032: if ($realm ne $oldrealm) {
3033: $r->print(&tableend()."\n<h2>$realm</h2>");
3034: $oldrealm=$realm;
3035: $oldpart='';
3036: }
1.122 www 3037: }
3038: if ($part ne $oldpart) {
1.124 www 3039: $r->print(&tableend().
1.413.6.1 raeburn 3040: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
1.122 www 3041: $oldpart=$part;
3042: }
1.123 www 3043: #
3044: # Ready to print
3045: #
1.413.6.1 raeburn 3046: my $parmitem = &standard_parameter_names($name);
1.295 albertel 3047: $r->print(&tablestart().
3048: &Apache::loncommon::start_data_table_row().
1.413.6.1 raeburn 3049: '<td><b>'.&mt($parmitem).
1.293 www 3050: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 3051: $thiskey.'" /></td><td>');
1.145 www 3052: $foundkeys++;
1.213 www 3053: if (&isdateparm($thistype)) {
1.123 www 3054: my $jskey='key_'.$pointer;
3055: $pointer++;
3056: $r->print(
1.232 albertel 3057: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 3058: $jskey,
1.219 www 3059: $$resourcedata{$thiskey},
1.325 www 3060: '',1,'','').
1.277 www 3061: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3062: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3063: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3064: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 3065: );
1.385 albertel 3066: } elsif ($thistype eq 'date_interval') {
3067: $r->print(&date_interval_selector($thiskey,
3068: $$resourcedata{$thiskey}));
1.383 albertel 3069: } elsif ($thistype =~ m/^string/) {
3070: $r->print(&string_selector($thistype,$thiskey,
3071: $$resourcedata{$thiskey}));
1.123 www 3072: } else {
1.383 albertel 3073: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 3074: }
1.211 www 3075: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
1.413.6.1 raeburn 3076: $thistype.'" />');
1.295 albertel 3077: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 3078: }
1.121 www 3079: }
1.208 www 3080: return $foundkeys;
3081: }
3082:
1.385 albertel 3083:
3084: sub date_interval_selector {
3085: my ($thiskey, $showval) = @_;
3086: my $result;
3087: foreach my $which (['days', 86400, 31],
3088: ['hours', 3600, 23],
3089: ['minutes', 60, 59],
3090: ['seconds', 1, 59]) {
3091: my ($name, $factor, $max) = @{ $which };
3092: my $amount = int($showval/$factor);
3093: $showval %= $factor;
3094: my %select = ((map {$_ => $_} (0..$max)),
3095: 'select_form_order' => [0..$max]);
3096: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
3097: %select);
3098: $result .= ' '.&mt($name);
3099: }
3100: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3101: return $result;
3102:
3103: }
3104:
3105: sub get_date_interval_from_form {
3106: my ($key) = @_;
3107: my $seconds = 0;
3108: foreach my $which (['days', 86400],
3109: ['hours', 3600],
3110: ['minutes', 60],
3111: ['seconds', 1]) {
3112: my ($name, $factor) = @{ $which };
3113: if (defined($env{'form.'.$name.'_'.$key})) {
3114: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3115: }
3116: }
3117: return $seconds;
3118: }
3119:
3120:
1.383 albertel 3121: sub default_selector {
3122: my ($thiskey, $showval) = @_;
1.385 albertel 3123: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3124: }
3125:
3126: my %strings =
3127: (
3128: 'string_yesno'
3129: => [[ 'yes', 'Yes' ],
3130: [ 'no', 'No' ]],
3131: 'string_problemstatus'
3132: => [[ 'yes', 'Yes' ],
1.394 www 3133: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3134: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3135: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3136: );
3137:
3138:
3139: sub string_selector {
3140: my ($thistype, $thiskey, $showval) = @_;
3141:
3142: if (!exists($strings{$thistype})) {
3143: return &default_selector($thiskey,$showval);
3144: }
3145:
3146: my $result;
3147: foreach my $possibilities (@{ $strings{$thistype} }) {
3148: my ($name, $description) = @{ $possibilities };
3149: $result .= '<label><input type="radio" name="set_'.$thiskey.
3150: '" value="'.$name.'"';
3151: if ($showval eq $name) {
3152: $result .= ' checked="checked"';
3153: }
3154: $result .= ' />'.&mt($description).'</label> ';
3155: }
3156: return $result;
3157: }
3158:
1.389 www 3159: #
3160: # Shift all start and end dates by $shift
3161: #
3162:
3163: sub dateshift {
3164: my ($shift)=@_;
3165: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3166: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3167: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3168: # ugly retro fix for broken version of types
3169: foreach my $key (keys %data) {
3170: if ($key=~/\wtype$/) {
3171: my $newkey=$key;
3172: $newkey=~s/type$/\.type/;
3173: $data{$newkey}=$data{$key};
3174: delete $data{$key};
3175: }
3176: }
1.391 www 3177: my %storecontent=();
1.389 www 3178: # go through all parameters and look for dates
3179: foreach my $key (keys %data) {
3180: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3181: my $newdate=$data{$key}+$shift;
1.391 www 3182: $storecontent{$key}=$newdate;
1.389 www 3183: }
3184: }
1.391 www 3185: my $reply=&Apache::lonnet::cput
3186: ('resourcedata',\%storecontent,$dom,$crs);
3187: if ($reply eq 'ok') {
3188: &log_parmset(\%storecontent);
3189: }
3190: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3191: return $reply;
1.389 www 3192: }
3193:
1.208 www 3194: sub newoverview {
1.280 albertel 3195: my ($r) = @_;
3196:
1.208 www 3197: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3198: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3199: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3200: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3201: $r->print(<<ENDOVER);
1.280 albertel 3202: $start_page
1.208 www 3203: $breadcrumbs
1.232 albertel 3204: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3205: ENDOVER
1.211 www 3206: my @ids=();
3207: my %typep=();
3208: my %keyp=();
3209: my %allparms=();
3210: my %allparts=();
3211: my %allmaps=();
3212: my %mapp=();
3213: my %symbp=();
3214: my %maptitles=();
3215: my %uris=();
3216: my %keyorder=&standardkeyorder();
3217: my %defkeytype=();
3218:
3219: my %alllevs=();
3220: $alllevs{'Resource Level'}='full';
1.215 www 3221: $alllevs{'Map/Folder Level'}='map';
1.211 www 3222: $alllevs{'Course Level'}='general';
3223:
3224: my $csec=$env{'form.csec'};
1.269 raeburn 3225: my $cgroup=$env{'form.cgroup'};
1.211 www 3226:
3227: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3228: my $pschp=$env{'form.pschp'};
3229: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3230: if (!@psprt) { $psprt[0]='0'; }
3231:
3232: my @selected_sections =
3233: &Apache::loncommon::get_env_multiple('form.Section');
3234: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3235: foreach my $sec (@selected_sections) {
3236: if ($sec eq 'all') {
1.211 www 3237: @selected_sections = ('all');
3238: }
3239: }
1.269 raeburn 3240: my @selected_groups =
3241: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3242:
3243: my $pssymb='';
3244: my $parmlev='';
3245:
3246: unless ($env{'form.parmlev'}) {
3247: $parmlev = 'map';
3248: } else {
3249: $parmlev = $env{'form.parmlev'};
3250: }
3251:
3252: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3253: \%mapp, \%symbp,\%maptitles,\%uris,
3254: \%keyorder,\%defkeytype);
3255:
1.374 albertel 3256: if (grep {$_ eq 'all'} (@psprt)) {
3257: @psprt = keys(%allparts);
3258: }
1.211 www 3259: # Menu to select levels, etc
3260:
1.317 albertel 3261: $r->print('<table id="LC_parm_overview_scope">
3262: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3263: &levelmenu($r,\%alllevs,$parmlev);
3264: if ($parmlev ne 'general') {
1.317 albertel 3265: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3266: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3267: $r->print('</td>');
3268: }
3269: $r->print('</td></tr></table>');
3270:
1.317 albertel 3271: $r->print('<table id="LC_parm_overview_controls">
3272: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3273: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3274: $r->print('</td><td class="LC_parm_overview_restrictions">
3275: <table class="LC_parm_overview_restrictions">'.
3276: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3277: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3278: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3279: $r->print('</td><td>');
1.211 www 3280: §ionmenu($r,\@selected_sections);
1.317 albertel 3281: $r->print('</td><td>');
1.269 raeburn 3282: &groupmenu($r,\@selected_groups);
3283: $r->print('</td></tr></table>');
1.214 www 3284: $r->print('</td></tr></table>');
3285:
3286: my $sortorder=$env{'form.sortorder'};
3287: unless ($sortorder) { $sortorder='realmstudent'; }
3288: &sortmenu($r,$sortorder);
3289:
3290: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3291:
3292: # Build the list data hash from the specified parms
3293:
3294: my $listdata;
3295: %{$listdata}=();
3296:
3297: foreach my $cat (@pscat) {
1.269 raeburn 3298: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3299: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3300: }
3301:
1.212 www 3302: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3303:
1.212 www 3304: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3305:
3306: # Read modified data
3307:
3308: my $resourcedata=&readdata($crs,$dom);
3309:
3310: # List data
3311:
1.214 www 3312: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3313: }
3314: $r->print(&tableend().
1.365 albertel 3315: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3316: '</form>'.&Apache::loncommon::end_page());
1.208 www 3317: }
3318:
1.269 raeburn 3319: sub secgroup_lister {
3320: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3321: foreach my $item (@{$selections}) {
3322: foreach my $part (@{$psprt}) {
3323: my $rootparmkey=$env{'request.course.id'};
3324: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3325: $rootparmkey.='.['.$item.']';
3326: }
3327: if ($parmlev eq 'general') {
3328: # course-level parameter
3329: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3330: $$listdata{$newparmkey}=1;
3331: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3332: } elsif ($parmlev eq 'map') {
3333: # map-level parameter
3334: foreach my $mapid (keys %{$allmaps}) {
3335: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3336: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3337: $$listdata{$newparmkey}=1;
3338: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3339: }
3340: } else {
3341: # resource-level parameter
3342: foreach my $rid (@{$ids}) {
3343: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3344: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3345: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3346: $$listdata{$newparmkey}=1;
3347: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3348: }
3349: }
3350: }
3351: }
3352: }
3353:
1.208 www 3354: sub overview {
1.280 albertel 3355: my ($r) = @_;
1.208 www 3356: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3357: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3358:
3359: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3360: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3361: $r->print(<<ENDOVER);
1.280 albertel 3362: $start_page
1.208 www 3363: $breadcrumbs
1.232 albertel 3364: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3365: ENDOVER
3366: # Store modified
3367:
3368: &storedata($r,$crs,$dom);
3369:
3370: # Read modified data
3371:
3372: my $resourcedata=&readdata($crs,$dom);
3373:
1.214 www 3374:
3375: my $sortorder=$env{'form.sortorder'};
3376: unless ($sortorder) { $sortorder='realmstudent'; }
3377: &sortmenu($r,$sortorder);
3378:
1.208 www 3379: # List data
3380:
1.214 www 3381: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3382:
1.145 www 3383: $r->print(&tableend().'<p>'.
1.280 albertel 3384: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
3385: &Apache::loncommon::end_page());
1.120 www 3386: }
1.121 www 3387:
1.333 albertel 3388: sub clean_parameters {
3389: my ($r) = @_;
3390: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3391: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3392:
3393: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3394: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3395: $r->print(<<ENDOVER);
3396: $start_page
3397: $breadcrumbs
3398: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3399: ENDOVER
3400: # Store modified
3401:
3402: &storedata($r,$crs,$dom);
3403:
3404: # Read modified data
3405:
3406: my $resourcedata=&readdata($crs,$dom);
3407:
3408: # List data
3409:
3410: $r->print('<h3>'.
3411: &mt('These parameters refer to resources that do not exist.').
3412: '</h3>'.
1.413.6.1 raeburn 3413: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
1.333 albertel 3414: '<br />');
3415: $r->print(&Apache::loncommon::start_data_table().
3416: '<tr>'.
3417: '<th>'.&mt('Delete').'</th>'.
3418: '<th>'.&mt('Parameter').'</th>'.
3419: '</tr>');
3420: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3421: next if (!exists($resourcedata->{$thiskey.'.type'})
3422: && $thiskey=~/\.type$/);
3423: my %data = &parse_key($thiskey);
1.383 albertel 3424: if (1) { #exists($data{'realm_exists'})
3425: #&& !$data{'realm_exists'}) {
1.333 albertel 3426: $r->print(&Apache::loncommon::start_data_table_row().
3427: '<tr>'.
3428: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3429:
3430: $r->print('<td>');
1.362 albertel 3431: my $display_value = $resourcedata->{$thiskey};
3432: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3433: $display_value =
3434: &Apache::lonlocal::locallocaltime($display_value);
3435: }
1.413.6.1 raeburn 3436: my $parmitem = &standard_parameter_names($data{'parameter_name'});
3437: $parmitem = &mt($parmitem);
1.333 albertel 3438: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
1.413.6.1 raeburn 3439: $parmitem,$resourcedata->{$thiskey}));
1.333 albertel 3440: $r->print('<br />');
3441: if ($data{'scope_type'} eq 'all') {
3442: $r->print(&mt('All users'));
3443: } elsif ($data{'scope_type'} eq 'user') {
3444: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3445: } elsif ($data{'scope_type'} eq 'section') {
3446: $r->print(&mt('Section: [_1]',$data{'scope'}));
3447: } elsif ($data{'scope_type'} eq 'group') {
3448: $r->print(&mt('Group: [_1]',$data{'scope'}));
3449: }
3450: $r->print('<br />');
3451: if ($data{'realm_type'} eq 'all') {
3452: $r->print(&mt('All Resources'));
3453: } elsif ($data{'realm_type'} eq 'folder') {
3454: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3455: } elsif ($data{'realm_type'} eq 'symb') {
3456: my ($map,$resid,$url) =
3457: &Apache::lonnet::decode_symb($data{'realm'});
3458: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3459: $url,$resid,$map));
3460: }
1.362 albertel 3461: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3462: $r->print('</td></tr>');
3463:
3464: }
3465: }
3466: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.413.6.1 raeburn 3467: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.333 albertel 3468: '</p></form>'.
3469: &Apache::loncommon::end_page());
3470: }
3471:
1.390 www 3472: sub date_shift_one {
3473: my ($r) = @_;
3474: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3475: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3476:
3477: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3478: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3479: $r->print(<<ENDOVER);
3480: $start_page
3481: $breadcrumbs
3482: ENDOVER
3483: $r->print('<form name="shiftform" method="post">'.
3484: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3485: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3486: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3487: &Apache::lonhtmlcommon::date_setter('shiftform',
3488: 'timeshifted',
3489: $env{'form.timebase'},,
3490: '').
3491: '</td></tr></table>'.
3492: '<input type="hidden" name="action" value="dateshift2" />'.
3493: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3494: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3495: $r->print(&Apache::loncommon::end_page());
3496: }
3497:
3498: sub date_shift_two {
3499: my ($r) = @_;
3500: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3501: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3502: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3503: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3504: $r->print(<<ENDOVER);
3505: $start_page
3506: $breadcrumbs
3507: ENDOVER
3508: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3509: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3510: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3511: &Apache::lonlocal::locallocaltime($timeshifted)));
3512: my $delta=$timeshifted-$env{'form.timebase'};
3513: &dateshift($delta);
3514: $r->print(&Apache::loncommon::end_page());
3515: }
3516:
1.333 albertel 3517: sub parse_key {
3518: my ($key) = @_;
3519: my %data;
3520: my ($middle,$part,$name)=
3521: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3522: $data{'scope_type'} = 'all';
3523: if ($middle=~/^\[(.*)\]/) {
3524: $data{'scope'} = $1;
1.350 albertel 3525: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3526: $data{'scope_type'} = 'user';
3527: $data{'scope'} = [$1,$2];
3528: } else {
3529: #FIXME check for group scope
3530: $data{'scope_type'} = 'section';
3531: }
3532: $middle=~s/^\[(.*)\]//;
3533: }
3534: $middle=~s/\.+$//;
3535: $middle=~s/^\.+//;
3536: $data{'realm_type'}='all';
3537: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3538: $data{'realm'} = $1;
3539: $data{'realm_type'} = 'folder';
3540: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3541: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3542: } elsif ($middle) {
3543: $data{'realm'} = $middle;
3544: $data{'realm_type'} = 'symb';
3545: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3546: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3547: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3548: }
3549:
3550: $data{'parameter_part'} = $part;
3551: $data{'parameter_name'} = $name;
3552:
3553: return %data;
3554: }
3555:
1.59 matthew 3556: ##################################################
3557: ##################################################
1.333 albertel 3558:
1.178 raeburn 3559: =pod
1.239 raeburn 3560:
3561: =item check_cloners
3562:
3563: Checks if new users included in list of allowed cloners
3564: are valid users. Replaces supplied list with
3565: cleaned list containing only users with valid usernames
3566: and domains.
3567:
3568: Inputs: $clonelist, $oldcloner
3569: where $clonelist is ref to array of requested cloners,
3570: and $oldcloner is ref to array of currently allowed
3571: cloners.
3572:
3573: Returns: string - comma separated list of requested
3574: cloners (username:domain) who do not exist in system.
3575:
3576: =item change_clone
3577:
1.178 raeburn 3578: Modifies the list of courses a user can clone (stored
1.239 raeburn 3579: in the user's environment.db file), called when a
1.178 raeburn 3580: change is made to the list of users allowed to clone
3581: a course.
1.239 raeburn 3582:
1.178 raeburn 3583: Inputs: $action,$cloner
3584: where $action is add or drop, and $cloner is identity of
3585: user for whom cloning ability is to be changed in course.
3586:
3587: =cut
1.380 albertel 3588:
1.178 raeburn 3589: ##################################################
3590: ##################################################
3591:
1.239 raeburn 3592: sub extract_cloners {
3593: my ($clonelist,$allowclone) = @_;
3594: if ($clonelist =~ /,/) {
1.380 albertel 3595: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3596: } else {
3597: $$allowclone[0] = $clonelist;
3598: }
3599: }
3600:
3601: sub check_cloners {
3602: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3603: my ($clean_clonelist,%disallowed);
1.239 raeburn 3604: my @allowclone = ();
3605: &extract_cloners($$clonelist,\@allowclone);
3606: foreach my $currclone (@allowclone) {
1.380 albertel 3607: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3608: if ($currclone eq '*') {
3609: $clean_clonelist .= $currclone.',';
3610: } else {
3611: my ($uname,$udom) = split(/:/,$currclone);
3612: if ($uname eq '*') {
3613: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3614: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3615: $disallowed{'domain'} .= $currclone.',';
3616: } else {
3617: $clean_clonelist .= $currclone.',';
3618: }
3619: } else {
3620: $disallowed{'format'} .= $currclone.',';
3621: }
3622: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3623: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3624: } else {
1.379 raeburn 3625: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3626: $disallowed{'newuser'} .= $currclone.',';
3627: } else {
3628: $clean_clonelist .= $currclone.',';
3629: }
1.239 raeburn 3630: }
3631: }
3632: } else {
3633: $clean_clonelist .= $currclone.',';
3634: }
3635: }
1.379 raeburn 3636: foreach my $key (keys(%disallowed)) {
3637: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3638: }
3639: if ($clean_clonelist) {
3640: $clean_clonelist =~ s/,$//;
3641: }
3642: $$clonelist = $clean_clonelist;
1.379 raeburn 3643: return %disallowed;
3644: }
1.178 raeburn 3645:
3646: sub change_clone {
3647: my ($clonelist,$oldcloner) = @_;
3648: my ($uname,$udom);
1.190 albertel 3649: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3650: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3651: my $clone_crs = $cnum.':'.$cdom;
3652:
3653: if ($cnum && $cdom) {
1.239 raeburn 3654: my @allowclone;
3655: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 3656: foreach my $currclone (@allowclone) {
1.380 albertel 3657: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 3658: if ($currclone ne '*') {
1.380 albertel 3659: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 3660: if ($uname && $udom && $uname ne '*') {
3661: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3662: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3663: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3664: if ($currclonecrs{'cloneable'} eq '') {
3665: $currclonecrs{'cloneable'} = $clone_crs;
3666: } else {
3667: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3668: }
3669: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 3670: }
3671: }
3672: }
3673: }
3674: }
3675: }
3676: foreach my $oldclone (@$oldcloner) {
1.380 albertel 3677: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 3678: if ($oldclone ne '*') {
1.380 albertel 3679: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 3680: if ($uname && $udom && $uname ne '*' ) {
3681: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3682: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3683: my %newclonecrs = ();
3684: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3685: if ($currclonecrs{'cloneable'} =~ /,/) {
3686: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3687: foreach my $crs (@currclonecrs) {
3688: if ($crs ne $clone_crs) {
3689: $newclonecrs{'cloneable'} .= $crs.',';
3690: }
1.178 raeburn 3691: }
1.379 raeburn 3692: $newclonecrs{'cloneable'} =~ s/,$//;
3693: } else {
3694: $newclonecrs{'cloneable'} = '';
1.178 raeburn 3695: }
1.379 raeburn 3696: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 3697: }
3698: }
3699: }
3700: }
3701: }
3702: }
3703: }
3704: }
3705:
1.193 albertel 3706:
3707: ##################################################
3708: ##################################################
3709:
3710: =pod
3711:
3712: =item * header
3713:
3714: Output html header for page
3715:
3716: =cut
3717:
3718: ##################################################
3719: ##################################################
3720: sub header {
1.280 albertel 3721: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 3722: }
3723: ##################################################
3724: ##################################################
3725: sub print_main_menu {
3726: my ($r,$parm_permission)=@_;
3727: #
3728: $r->print(<<ENDMAINFORMHEAD);
3729: <form method="post" enctype="multipart/form-data"
3730: action="/adm/parmset" name="studentform">
3731: ENDMAINFORMHEAD
3732: #
1.195 albertel 3733: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3734: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3735: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3736: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 3737:
1.193 albertel 3738: my @menu =
1.322 www 3739: ( { divider=>'Settings for Your Course',
3740: },
1.323 albertel 3741: { text => 'Set Course Environment',
1.204 www 3742: action => 'crsenv',
1.193 albertel 3743: permission => $parm_permission,
1.324 www 3744: help => 'Course_Environment',
1.193 albertel 3745: },
1.255 banghart 3746: { text => 'Set Portfolio Metadata',
1.259 banghart 3747: action => 'setrestrictmeta',
1.240 banghart 3748: permission => $parm_permission,
3749: },
1.271 www 3750: { text => 'Manage Course Slots',
1.268 albertel 3751: url => '/adm/slotrequest?command=showslots',
3752: permission => $vgr,
3753: },
1.366 albertel 3754: { text => 'Reset Student Access Times',
3755: url => '/adm/helper/resettimes.helper',
3756: permission => $mgr,
3757: },
3758:
1.322 www 3759: { text => 'Set Parameter Setting Default Actions',
3760: action => 'setdefaults',
3761: permission => $parm_permission,
3762: },
3763: { divider => 'New and Existing Parameter Settings for Your Resources',
1.268 albertel 3764: },
1.216 www 3765: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3766: url => '/adm/helper/parameter.helper',
3767: permission => $parm_permission,
1.324 www 3768: help => 'Parameter_Helper',
1.193 albertel 3769: },
1.322 www 3770: { text => 'Set/Modify Resource Parameters - Overview Mode',
1.208 www 3771: action => 'newoverview',
3772: permission => $parm_permission,
1.324 www 3773: help => 'Parameter_Overview',
1.193 albertel 3774: },
1.216 www 3775: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3776: action => 'settable',
3777: permission => $parm_permission,
1.324 www 3778: help => 'Table_Mode',
1.193 albertel 3779: },
1.322 www 3780: { divider => 'Existing Parameter Settings for Your Resources',
3781: },
3782: { text => 'Modify Resource Parameters - Overview Mode',
3783: action => 'setoverview',
1.220 www 3784: permission => $parm_permission,
1.324 www 3785: help => 'Parameter_Overview',
1.322 www 3786: },
1.292 www 3787: { text => 'Parameter Change Log and Course Blog Posting/User Notification',
1.284 www 3788: action => 'parameterchangelog',
3789: permission => $parm_permission,
1.220 www 3790: },
1.193 albertel 3791: );
3792: my $menu_html = '';
3793: foreach my $menu_item (@menu) {
1.268 albertel 3794: if ($menu_item->{'divider'}) {
1.322 www 3795: $menu_html .= '<h3>'.&mt($menu_item->{'divider'}).'</h3>';
1.268 albertel 3796: next;
3797: }
1.193 albertel 3798: next if (! $menu_item->{'permission'});
3799: $menu_html.='<p>';
1.316 albertel 3800: $menu_html.='<span class="LC_parm_menu_item">';
1.193 albertel 3801: if (exists($menu_item->{'url'})) {
3802: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3803: } else {
3804: $menu_html.=
3805: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3806: }
1.316 albertel 3807: $menu_html.= &mt($menu_item->{'text'}).'</a></span>';
1.193 albertel 3808: if (exists($menu_item->{'help'})) {
3809: $menu_html.=
3810: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3811: }
3812: $menu_html.='</p>'.$/;
3813: }
3814: $r->print($menu_html);
3815: return;
3816: }
1.255 banghart 3817: ### Set portfolio metadata
1.252 banghart 3818: sub output_row {
1.347 banghart 3819: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3820: my $output;
1.263 banghart 3821: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3822: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3823: if (!defined($options)) {
1.254 banghart 3824: $options = 'active,stuadd';
1.261 banghart 3825: $values = '';
1.252 banghart 3826: }
1.337 banghart 3827: if (!($options =~ /deleted/)) {
3828: my @options= ( ['active', 'Show to student'],
1.351 banghart 3829: ['stuadd', 'Provide text area for students to type catalog information'],
3830: ['choices','Provide choices for students to select from']);
3831: # ['onlyone','Student may select only one choice']);
1.337 banghart 3832: if ($added_flag) {
3833: push @options,['deleted', 'Delete Metadata Field'];
3834: }
1.351 banghart 3835: $output = &Apache::loncommon::start_data_table_row();
3836: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
3837: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3838: foreach my $opt (@options) {
3839: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 3840: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 3841: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
3842: <input type="checkbox" name="'.
3843: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3844: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 3845: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3846: }
1.351 banghart 3847: $output .= &Apache::loncommon::continue_data_table_row();
3848: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
3849: $output .= &Apache::loncommon::end_data_table_row();
3850: my $multiple_checked;
3851: my $single_checked;
3852: if ($options =~ m/onlyone/) {
1.413.6.1 raeburn 3853: $multiple_checked = '';
3854: $single_checked = ' checked="checked"';
1.351 banghart 3855: } else {
1.413.6.1 raeburn 3856: $multiple_checked = ' checked="checked"';
3857: $single_checked = '';
1.351 banghart 3858: }
3859: $output .= &Apache::loncommon::continue_data_table_row();
3860: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.413.6.1 raeburn 3861: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
3862: '.&mt('Student may select multiple choices from list').'</span></td>';
1.351 banghart 3863: $output .= &Apache::loncommon::end_data_table_row();
3864: $output .= &Apache::loncommon::continue_data_table_row();
3865: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
3866: <input type="radio" name="'.$field_name.'_onlyone" value="single" '.$single_checked.'/>
1.413.6.1 raeburn 3867: '.&mt('Student may select only one choice from list').'</span></td>';
1.351 banghart 3868: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3869: }
3870: return ($output);
3871: }
1.340 banghart 3872: sub order_meta_fields {
3873: my ($r)=@_;
3874: my $idx = 1;
3875: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3876: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3877: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.345 banghart 3878: &Apache::lonhtmlcommon::add_breadcrumb
3879: ({href=>"/adm/parmset?action=setrestrictmeta",
3880: text=>"Restrict Metadata"},
3881: {text=>"Order Metadata"});
3882: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 3883: if ($env{'form.storeorder'}) {
3884: my $newpos = $env{'form.newpos'} - 1;
3885: my $currentpos = $env{'form.currentpos'} - 1;
3886: my @neworder = ();
3887: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3888: my $i;
1.341 banghart 3889: if ($newpos > $currentpos) {
1.340 banghart 3890: # moving stuff up
3891: for ($i=0;$i<$currentpos;$i++) {
3892: $neworder[$i]=$oldorder[$i];
3893: }
3894: for ($i=$currentpos;$i<$newpos;$i++) {
3895: $neworder[$i]=$oldorder[$i+1];
3896: }
3897: $neworder[$newpos]=$oldorder[$currentpos];
3898: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
3899: $neworder[$i]=$oldorder[$i];
3900: }
3901: } else {
3902: # moving stuff down
3903: for ($i=0;$i<$newpos;$i++) {
3904: $neworder[$i]=$oldorder[$i];
3905: }
3906: $neworder[$newpos]=$oldorder[$currentpos];
3907: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3908: $neworder[$i]=$oldorder[$i-1];
3909: }
3910: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3911: $neworder[$i]=$oldorder[$i];
3912: }
3913: }
3914: my $ordered_fields = join ",", @neworder;
1.343 banghart 3915: my $put_result = &Apache::lonnet::put('environment',
3916: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 3917: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3918: }
1.357 raeburn 3919: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3920: my $ordered_fields;
1.340 banghart 3921: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3922: if (!@fields_in_order) {
3923: # no order found, pick sorted order then create metadata.addedorder key.
3924: foreach my $key (sort keys %$fields) {
3925: push @fields_in_order, $key;
1.341 banghart 3926: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3927: }
1.341 banghart 3928: my $put_result = &Apache::lonnet::put('environment',
3929: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3930: }
1.340 banghart 3931: $r->print('<table>');
3932: my $num_fields = scalar(@fields_in_order);
3933: foreach my $key (@fields_in_order) {
3934: $r->print('<tr><td>');
3935: $r->print('<form method="post" action="">');
3936: $r->print('<select name="newpos" onChange="this.form.submit()">');
3937: for (my $i = 1;$i le $num_fields;$i ++) {
3938: if ($i eq $idx) {
3939: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3940: } else {
3941: $r->print('<option value="'.$i.'">'.$i.'</option>');
3942: }
3943: }
3944: $r->print('</select></td><td>');
3945: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3946: $r->print('<input type="hidden" name="storeorder" value="true" />');
3947: $r->print('</form>');
3948: $r->print($$fields{$key}.'</td></tr>');
3949: $idx ++;
3950: }
3951: $r->print('</table>');
3952: return 'ok';
3953: }
1.359 banghart 3954: sub continue {
3955: my $output;
3956: $output .= '<form action="" method="post">';
3957: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3958: $output .= '<input type="submit" value="Continue" />';
3959: return ($output);
3960: }
1.334 banghart 3961: sub addmetafield {
3962: my ($r)=@_;
3963: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3964: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 3965: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3966: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 3967: if (exists($env{'form.undelete'})) {
1.358 banghart 3968: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 3969: foreach my $meta_field(@meta_fields) {
3970: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
3971: $options =~ s/deleted//;
3972: $options =~ s/,,/,/;
3973: my $put_result = &Apache::lonnet::put('environment',
3974: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
3975:
3976: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
3977: }
1.359 banghart 3978: $r->print(&continue());
1.339 banghart 3979: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 3980: my $meta_field = $env{'form.fieldname'};
3981: my $display_field = $env{'form.fieldname'};
3982: $meta_field =~ s/\W/_/g;
1.338 banghart 3983: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 3984: my $put_result = &Apache::lonnet::put('environment',
3985: {'metadata.'.$meta_field.'.values'=>"",
3986: 'metadata.'.$meta_field.'.added'=>"$display_field",
3987: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 3988: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
3989: $r->print(&continue());
1.335 banghart 3990: } else {
1.357 raeburn 3991: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 3992: if ($fields) {
3993: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
3994: $r->print('<form method="post" action="">');
3995: foreach my $key(keys(%$fields)) {
1.358 banghart 3996: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 3997: }
3998: $r->print('<input type="submit" name="undelete" value="Undelete" />');
3999: $r->print('</form>');
4000: }
4001: $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 4002: $r->print('<input type="text" name="fieldname" /><br />');
4003: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4004: }
1.361 albertel 4005: $r->print('</form>');
1.334 banghart 4006: }
1.259 banghart 4007: sub setrestrictmeta {
1.240 banghart 4008: my ($r)=@_;
1.242 banghart 4009: my $next_meta;
1.244 banghart 4010: my $output;
1.245 banghart 4011: my $item_num;
1.246 banghart 4012: my $put_result;
1.280 albertel 4013: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4014: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4015: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4016: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4017: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4018: my $save_field = '';
1.259 banghart 4019: if ($env{'form.restrictmeta'}) {
1.254 banghart 4020: foreach my $field (sort(keys(%env))) {
1.252 banghart 4021: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4022: my $options;
1.252 banghart 4023: my $meta_field = $1;
4024: my $meta_key = $2;
1.253 banghart 4025: if ($save_field ne $meta_field) {
1.252 banghart 4026: $save_field = $meta_field;
1.253 banghart 4027: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 4028: $options.='stuadd,';
4029: }
1.351 banghart 4030: if ($env{'form.'.$meta_field.'_choices'}) {
4031: $options.='choices,';
4032: }
4033: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 4034: $options.='onlyone,';
4035: }
4036: if ($env{'form.'.$meta_field.'_active'}) {
4037: $options.='active,';
1.253 banghart 4038: }
1.337 banghart 4039: if ($env{'form.'.$meta_field.'_deleted'}) {
4040: $options.='deleted,';
4041: }
1.259 banghart 4042: my $name = $save_field;
1.253 banghart 4043: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4044: {'metadata.'.$meta_field.'.options'=>$options,
4045: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4046: },$dom,$crs);
1.252 banghart 4047: }
4048: }
4049: }
4050: }
1.296 albertel 4051: &Apache::lonnet::coursedescription($env{'request.course.id'},
4052: {'freshen_cache' => 1});
1.335 banghart 4053: # Get the default metadata fields
1.258 albertel 4054: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4055: # Now get possible added metadata fields
1.357 raeburn 4056: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4057: my $row_alt = 1;
1.347 banghart 4058: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4059: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4060: if ($field ne 'courserestricted') {
1.346 banghart 4061: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 4062: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 4063: }
1.255 banghart 4064: }
1.351 banghart 4065: my $buttons = (<<ENDButtons);
4066: <input type="submit" name="restrictmeta" value="Save" />
4067: </form><br />
4068: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4069: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4070: </form>
4071: <br />
4072: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4073: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4074: ENDButtons
1.337 banghart 4075: my $added_flag = 1;
1.335 banghart 4076: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4077: $row_alt = $row_alt ? 0 : 1;
4078: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4079: }
1.347 banghart 4080: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 4081: $r->print(<<ENDenv);
1.259 banghart 4082: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4083: $output
1.351 banghart 4084: $buttons
1.340 banghart 4085: </form>
1.244 banghart 4086: ENDenv
1.280 albertel 4087: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4088: return 'ok';
4089: }
1.220 www 4090: ##################################################
1.335 banghart 4091: sub get_added_meta_fieldnames {
1.357 raeburn 4092: my ($cid) = @_;
1.335 banghart 4093: my %fields;
4094: foreach my $key(%env) {
1.357 raeburn 4095: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4096: my $field_name = $1;
4097: my ($display_field_name) = $env{$key};
4098: $fields{$field_name} = $display_field_name;
4099: }
4100: }
4101: return \%fields;
4102: }
1.339 banghart 4103: sub get_deleted_meta_fieldnames {
1.357 raeburn 4104: my ($cid) = @_;
1.339 banghart 4105: my %fields;
4106: foreach my $key(%env) {
1.357 raeburn 4107: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4108: my $field_name = $1;
4109: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4110: my ($display_field_name) = $env{$key};
4111: $fields{$field_name} = $display_field_name;
4112: }
4113: }
4114: }
4115: return \%fields;
4116: }
1.220 www 4117: sub defaultsetter {
1.280 albertel 4118: my ($r) = @_;
4119:
4120: my $start_page =
4121: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4122: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4123: $r->print(<<ENDDEFHEAD);
1.280 albertel 4124: $start_page
1.220 www 4125: $breadcrumbs
4126: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4127: ENDDEFHEAD
1.280 albertel 4128:
4129: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4130: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4131: my @ids=();
4132: my %typep=();
4133: my %keyp=();
4134: my %allparms=();
4135: my %allparts=();
4136: my %allmaps=();
4137: my %mapp=();
4138: my %symbp=();
4139: my %maptitles=();
4140: my %uris=();
4141: my %keyorder=&standardkeyorder();
4142: my %defkeytype=();
4143:
4144: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4145: \%mapp, \%symbp,\%maptitles,\%uris,
4146: \%keyorder,\%defkeytype);
1.224 www 4147: if ($env{'form.storerules'}) {
4148: my %newrules=();
4149: my @delrules=();
1.226 www 4150: my %triggers=();
1.225 albertel 4151: foreach my $key (keys(%env)) {
4152: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4153: my $tempkey=$1;
1.226 www 4154: my $action=$env{$key};
4155: if ($action) {
4156: $newrules{$tempkey.'_action'}=$action;
4157: if ($action ne 'default') {
4158: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4159: $triggers{$whichparm}.=$tempkey.':';
4160: }
4161: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4162: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4163: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4164: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4165: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4166: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4167: } else {
4168: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4169: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4170: }
4171: } else {
1.225 albertel 4172: push(@delrules,$tempkey.'_action');
1.226 www 4173: push(@delrules,$tempkey.'_type');
1.225 albertel 4174: push(@delrules,$tempkey.'_hours');
4175: push(@delrules,$tempkey.'_min');
4176: push(@delrules,$tempkey.'_sec');
4177: push(@delrules,$tempkey.'_value');
1.224 www 4178: }
4179: }
4180: }
1.226 www 4181: foreach my $key (keys %allparms) {
4182: $newrules{$key.'_triggers'}=$triggers{$key};
4183: }
1.224 www 4184: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4185: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4186: &resetrulescache();
4187: }
1.227 www 4188: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4189: 'hours' => 'Hours',
1.221 www 4190: 'min' => 'Minutes',
4191: 'sec' => 'Seconds',
4192: 'yes' => 'Yes',
4193: 'no' => 'No');
1.222 www 4194: my @standardoptions=('','default');
4195: my @standarddisplay=('',&mt('Default value when manually setting'));
4196: my @dateoptions=('','default');
4197: my @datedisplay=('',&mt('Default value when manually setting'));
4198: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4199: unless ($tempkey) { next; }
4200: push @standardoptions,'when_setting_'.$tempkey;
4201: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4202: if (&isdateparm($defkeytype{$tempkey})) {
4203: push @dateoptions,'later_than_'.$tempkey;
4204: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4205: push @dateoptions,'earlier_than_'.$tempkey;
4206: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4207: }
4208: }
1.231 www 4209: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4210: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4211: $r->print("\n".&Apache::loncommon::start_data_table().
4212: &Apache::loncommon::start_data_table_header_row().
4213: "<th>".&mt('Rule for parameter').'</th><th>'.
4214: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4215: &Apache::loncommon::end_data_table_header_row());
1.221 www 4216: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4217: unless ($tempkey) { next; }
1.318 albertel 4218: $r->print("\n".&Apache::loncommon::start_data_table_row().
4219: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4220: my $action=&rulescache($tempkey.'_action');
4221: $r->print('<select name="'.$tempkey.'_action">');
4222: if (&isdateparm($defkeytype{$tempkey})) {
4223: for (my $i=0;$i<=$#dateoptions;$i++) {
4224: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4225: $r->print("\n<option value='$dateoptions[$i]'".
4226: ($dateoptions[$i] eq $action?' selected="selected"':'').
4227: ">$datedisplay[$i]</option>");
4228: }
4229: } else {
4230: for (my $i=0;$i<=$#standardoptions;$i++) {
4231: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4232: $r->print("\n<option value='$standardoptions[$i]'".
4233: ($standardoptions[$i] eq $action?' selected="selected"':'').
4234: ">$standarddisplay[$i]</option>");
4235: }
4236: }
4237: $r->print('</select>');
1.227 www 4238: unless (&isdateparm($defkeytype{$tempkey})) {
4239: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4240: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4241: }
1.222 www 4242: $r->print("\n</td><td>\n");
4243:
1.221 www 4244: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4245: my $days=&rulescache($tempkey.'_days');
1.222 www 4246: my $hours=&rulescache($tempkey.'_hours');
4247: my $min=&rulescache($tempkey.'_min');
4248: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4249: $r->print(<<ENDINPUTDATE);
1.227 www 4250: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4251: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4252: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4253: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4254: ENDINPUTDATE
4255: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4256: my $yeschecked='';
4257: my $nochecked='';
4258: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4259: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4260:
1.221 www 4261: $r->print(<<ENDYESNO);
1.224 www 4262: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4263: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4264: ENDYESNO
4265: } else {
1.224 www 4266: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4267: }
1.318 albertel 4268: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4269: }
1.318 albertel 4270: $r->print(&Apache::loncommon::end_data_table().
4271: "\n<input type='submit' name='storerules' value='".
1.365 albertel 4272: &mt('Save Rules')."' /></form>\n".
1.280 albertel 4273: &Apache::loncommon::end_page());
1.220 www 4274: return;
4275: }
1.193 albertel 4276:
1.290 www 4277: sub components {
1.330 albertel 4278: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4279:
4280: if ($typeflag) {
1.290 www 4281: $key=~s/\.type$//;
4282: }
1.330 albertel 4283:
4284: my ($middle,$part,$name)=
4285: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4286: my $issection;
1.330 albertel 4287:
1.290 www 4288: my $section=&mt('All Students');
4289: if ($middle=~/^\[(.*)\]/) {
1.291 www 4290: $issection=$1;
4291: $section=&mt('Group/Section').': '.$issection;
1.290 www 4292: $middle=~s/^\[(.*)\]//;
4293: }
4294: $middle=~s/\.+$//;
4295: $middle=~s/^\.+//;
1.291 www 4296: if ($uname) {
4297: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4298: $issection='';
4299: }
1.316 albertel 4300: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4301: my $realmdescription=&mt('all resources');
1.290 www 4302: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4303: $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 4304: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4305: } elsif ($middle) {
1.290 www 4306: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4307: $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 4308: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4309: }
1.291 www 4310: my $what=$part.'.'.$name;
1.330 albertel 4311: return ($realm,$section,$name,$part,
1.304 www 4312: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4313: }
1.293 www 4314:
1.328 albertel 4315: my %standard_parms;
4316: sub load_parameter_names {
4317: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4318: while (my $configline=<$config>) {
4319: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4320: chomp($configline);
4321: my ($short,$plain)=split(/:/,$configline);
4322: my (undef,$name,$type)=split(/\&/,$short,3);
4323: if ($type eq 'display') {
4324: $standard_parms{$name} = $plain;
4325: }
4326: }
4327: close($config);
4328: $standard_parms{'int_pos'} = 'Positive Integer';
4329: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4330: }
4331:
1.292 www 4332: sub standard_parameter_names {
4333: my ($name)=@_;
1.328 albertel 4334: if (!%standard_parms) {
4335: &load_parameter_names();
4336: }
1.292 www 4337: if ($standard_parms{$name}) {
4338: return $standard_parms{$name};
4339: } else {
4340: return $name;
4341: }
4342: }
1.290 www 4343:
1.309 www 4344: #
4345: # Parameter Change Log
4346: #
4347:
4348:
1.285 albertel 4349: sub parm_change_log {
1.284 www 4350: my ($r)=@_;
1.327 albertel 4351: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4352: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4353:
1.286 www 4354: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4355: $env{'course.'.$env{'request.course.id'}.'.domain'},
4356: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4357:
1.301 www 4358: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4359:
1.327 albertel 4360: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4361: method="post" name="parameterlog">');
1.311 albertel 4362:
4363: my %saveable_parameters = ('show' => 'scalar',);
4364: &Apache::loncommon::store_course_settings('parameter_log',
4365: \%saveable_parameters);
4366: &Apache::loncommon::restore_course_settings('parameter_log',
4367: \%saveable_parameters);
1.348 www 4368: $r->print(&Apache::loncommon::display_filter().
1.326 www 4369: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4370: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4371: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4372:
1.291 www 4373: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4374: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4375: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4376: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4377: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4378: &Apache::loncommon::end_data_table_header_row());
1.309 www 4379: my $shown=0;
1.349 www 4380: my $folder='';
4381: if ($env{'form.displayfilter'} eq 'currentfolder') {
4382: my $last='';
4383: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4384: &GDBM_READER(),0640)) {
4385: $last=$hash{'last_known'};
4386: untie(%hash);
4387: }
4388: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4389: }
1.356 albertel 4390: foreach my $id (sort
4391: {
4392: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4393: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4394: }
4395: my $aid = (split('00000',$a))[-1];
4396: my $bid = (split('00000',$b))[-1];
4397: return $bid<=>$aid;
4398: } (keys(%parmlog))) {
1.294 www 4399: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4400: my $count = 0;
1.288 albertel 4401: my $time =
1.294 www 4402: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4403: my $plainname =
1.294 www 4404: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4405: $parmlog{$id}{'exe_udom'});
1.288 albertel 4406: my $about_me_link =
1.289 www 4407: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4408: $parmlog{$id}{'exe_uname'},
4409: $parmlog{$id}{'exe_udom'});
1.293 www 4410: my $send_msg_link='';
1.294 www 4411: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4412: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4413: $send_msg_link ='<br />'.
1.288 albertel 4414: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4415: $parmlog{$id}{'exe_uname'},
4416: $parmlog{$id}{'exe_udom'});
1.288 albertel 4417: }
1.301 www 4418: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4419: my $makenewrow=0;
4420: my %istype=();
1.332 albertel 4421: my $output;
1.293 www 4422: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4423: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4424: my $typeflag = ($changed =~/\.type$/ &&
4425: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4426: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4427: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4428: if ($env{'form.displayfilter'} eq 'currentfolder') {
4429: if ($folder) {
4430: if ($middle!~/^\Q$folder\E/) { next; }
4431: }
4432: }
1.326 www 4433: if ($typeflag) {
1.329 albertel 4434: $istype{$parmname}=$value;
1.326 www 4435: if (!$env{'form.includetypes'}) { next; }
4436: }
1.332 albertel 4437: $count++;
4438: if ($makenewrow) {
4439: $output .= $row_start;
4440: } else {
4441: $makenewrow=1;
4442: }
1.413.6.1 raeburn 4443: my $parmitem = &standard_parameter_names($parmname);
1.332 albertel 4444: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.413.6.1 raeburn 4445: &mt($parmitem).'</td><td>'.
1.332 albertel 4446: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4447: my $stillactive=0;
1.332 albertel 4448: if ($parmlog{$id}{'delflag'}) {
4449: $output .= &mt('Deleted');
1.288 albertel 4450: } else {
1.290 www 4451: if ($typeflag) {
1.413.6.1 raeburn 4452: my $parmitem = &standard_parameter_names($value);
4453: $parmitem = &mt($parmitem);
4454: $output .= &mt('Type: [_1]',$parmitem);
1.290 www 4455: } else {
1.291 www 4456: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4457: $uname,$udom,$issection,$issection,$courseopt);
4458: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4459: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4460: } else {
1.332 albertel 4461: $output .= $value;
1.291 www 4462: }
4463: if ($value ne $all[$level]) {
1.332 albertel 4464: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4465: } else {
4466: $stillactive=1;
4467: }
1.290 www 4468: }
1.288 albertel 4469: }
1.332 albertel 4470: $output .= '</td><td>';
1.291 www 4471: if ($stillactive) {
1.413.6.1 raeburn 4472: my $parmitem = &standard_parameter_names($parmname);
4473: $parmitem = &mt($parmitem);
4474: my $title=&mt('Changed [_1]',$parmitem);
4475: my $description=&mt('Changed [_1] for [_2] to [_3]',
4476: $parmitem,$realmdescription,
1.304 www 4477: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4478: if (($uname) && ($udom)) {
1.332 albertel 4479: $output .=
4480: &Apache::loncommon::messagewrapper('Notify User',
4481: $uname,$udom,$title,
4482: $description);
1.292 www 4483: } else {
1.332 albertel 4484: $output .=
4485: &Apache::lonrss::course_blog_link($id,$title,
4486: $description);
1.292 www 4487: }
1.291 www 4488: }
1.332 albertel 4489: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4490: }
1.349 www 4491: if ($env{'form.displayfilter'} eq 'containing') {
4492: my $wholeentry=$about_me_link.':'.
4493: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4494: $output;
4495: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4496: }
4497: if ($count) {
4498: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4499: <td rowspan="'.$count.'">'.$about_me_link.
4500: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4501: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4502: $send_msg_link.'</td>'.$output);
1.349 www 4503: $shown++;
4504: }
1.311 albertel 4505: if (!($env{'form.show'} eq &mt('all')
4506: || $shown<=$env{'form.show'})) { last; }
1.286 www 4507: }
1.301 www 4508: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4509: $r->print(&Apache::loncommon::end_page());
4510: }
4511:
1.355 albertel 4512: sub check_for_course_info {
4513: my $navmap = Apache::lonnavmaps::navmap->new();
4514: return 1 if ($navmap);
4515: return 0;
4516: }
4517:
1.178 raeburn 4518: ##################################################
4519: ##################################################
1.30 www 4520:
1.59 matthew 4521: =pod
4522:
1.83 bowersj2 4523: =item * handler
1.59 matthew 4524:
4525: Main handler. Calls &assessparms and &crsenv subroutines.
4526:
4527: =cut
1.376 albertel 4528:
1.59 matthew 4529: ##################################################
4530: ##################################################
1.259 banghart 4531:
1.30 www 4532: sub handler {
1.43 albertel 4533: my $r=shift;
1.30 www 4534:
1.376 albertel 4535: &reset_caches();
4536:
1.43 albertel 4537: if ($r->header_only) {
1.126 www 4538: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 4539: $r->send_http_header;
4540: return OK;
4541: }
1.193 albertel 4542: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4543: ['action','state',
4544: 'pres_marker',
4545: 'pres_value',
1.206 www 4546: 'pres_type',
1.390 www 4547: 'udom','uname','symb','serial','timebase']);
1.131 www 4548:
1.83 bowersj2 4549:
1.193 albertel 4550: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4551: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4552: text=>"Parameter Manager",
1.204 www 4553: faq=>10,
1.324 www 4554: bug=>'Instructor Interface',
4555: help => 'Parameter_Manager'});
1.203 www 4556:
1.30 www 4557: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4558: my $parm_permission =
4559: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4560: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4561: $env{'request.course.sec'}));
1.355 albertel 4562: my $exists = &check_for_course_info();
4563:
4564: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4565:
4566: # Start Page
1.126 www 4567: &Apache::loncommon::content_type($r,'text/html');
1.106 www 4568: $r->send_http_header;
1.30 www 4569:
1.203 www 4570:
1.193 albertel 4571: #
4572: # Main switch on form.action and form.state, as appropriate
4573: #
4574: # Check first if coming from someone else headed directly for
4575: # the table mode
4576: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
4577: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
1.324 www 4578: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
4579: text=>"Problem Parameters"});
1.193 albertel 4580: &assessparms($r);
4581:
4582: } elsif (! exists($env{'form.action'})) {
4583: $r->print(&header());
1.298 albertel 4584: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 4585: &print_main_menu($r,$parm_permission);
4586: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 4587: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
4588: text=>"Course Environment"});
1.193 albertel 4589: &crsenv($r);
4590: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 4591: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4592: text=>"Overview Mode"});
1.121 www 4593: &overview($r);
1.334 banghart 4594: } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) {
4595: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4596: text=>"Add Metadata Field"});
4597: &addmetafield($r);
1.340 banghart 4598: } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) {
4599: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4600: text=>"Add Metadata Field"});
4601: &order_meta_fields($r);
1.259 banghart 4602: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
4603: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4604: text=>"Restrict Metadata"});
4605: &setrestrictmeta($r);
1.208 www 4606: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
4607: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4608: text=>"Overview Mode"});
4609: &newoverview($r);
1.220 www 4610: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
4611: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4612: text=>"Set Defaults"});
4613: &defaultsetter($r);
4614: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 4615: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 4616: text=>"Table Mode",
4617: help => 'Course_Setting_Parameters'});
1.121 www 4618: &assessparms($r);
1.284 www 4619: } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) {
4620: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.292 www 4621: text=>"Parameter Change Log"});
1.285 albertel 4622: &parm_change_log($r);
1.333 albertel 4623: } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) {
4624: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
4625: text=>"Clean Parameters"});
4626: &clean_parameters($r);
1.390 www 4627: } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
4628: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4629: text=>"Shifting Dates"});
1.390 www 4630: &date_shift_one($r);
4631: } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) {
4632: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4633: text=>"Shifting Dates"});
1.390 www 4634: &date_shift_two($r);
1.403 raeburn 4635: } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
4636: &assign_course_categories($r);
4637: }
1.43 albertel 4638: } else {
1.1 www 4639: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 4640: if ($exists) {
4641: $env{'user.error.msg'}=
4642: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4643: } else {
4644: $env{'user.error.msg'}=
4645: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4646: }
1.43 albertel 4647: return HTTP_NOT_ACCEPTABLE;
4648: }
1.376 albertel 4649: &reset_caches();
4650:
1.43 albertel 4651: return OK;
1.1 www 4652: }
4653:
4654: 1;
4655: __END__
4656:
1.59 matthew 4657: =pod
1.38 harris41 4658:
4659: =back
4660:
4661: =cut
1.1 www 4662:
4663:
4664:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>