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