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