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