Annotation of loncom/interface/lonparmset.pm, revision 1.436
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.436 ! raeburn 4: # $Id: lonparmset.pm,v 1.435 2009/02/24 18:20:49 hauer 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);
1.429 raeburn 851: my $unencmarker = $marker;
1.378 albertel 852: foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
853: \$hour, \$min, \$sec) {
854: $$item = &HTML::Entities::encode($$item,'"<>&');
855: $$item =~ s/\'/\\\'/g;
856: }
1.429 raeburn 857: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'.
1.43 albertel 858: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.229 www 859: .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
1.378 albertel 860: $valout.'</a></td></tr></table>';
1.5 www 861: }
862:
1.280 albertel 863: sub page_js {
864:
1.81 www 865: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 866: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.280 albertel 867:
868: return(<<ENDJS);
869: <script type="text/javascript">
1.44 albertel 870:
871: function pclose() {
872: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
873: "height=350,width=350,scrollbars=no,menubar=no");
874: parmwin.close();
875: }
876:
1.88 matthew 877: $pjump_def
1.44 albertel 878:
879: function psub() {
880: pclose();
881: if (document.parmform.pres_marker.value!='') {
882: document.parmform.action+='#'+document.parmform.pres_marker.value;
883: var typedef=new Array();
884: typedef=document.parmform.pres_type.value.split('_');
885: if (document.parmform.pres_type.value!='') {
886: if (typedef[0]=='date') {
887: eval('document.parmform.recent_'+
888: document.parmform.pres_type.value+
889: '.value=document.parmform.pres_value.value;');
890: } else {
891: eval('document.parmform.recent_'+typedef[0]+
892: '.value=document.parmform.pres_value.value;');
893: }
894: }
895: document.parmform.submit();
896: } else {
897: document.parmform.pres_value.value='';
898: document.parmform.pres_marker.value='';
899: }
900: }
901:
1.57 albertel 902: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
903: var options = "width=" + w + ",height=" + h + ",";
904: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
905: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
906: var newWin = window.open(url, wdwName, options);
907: newWin.focus();
908: }
1.44 albertel 909: </script>
1.81 www 910: $selscript
1.280 albertel 911: ENDJS
912:
913: }
914: sub startpage {
915: my ($r) = @_;
1.281 albertel 916:
1.282 albertel 917: my %loaditems = ('onunload' => "pclose()",
1.283 albertel 918: 'onload' => "group_or_section('cgroup')",);
1.280 albertel 919:
1.414 droeschl 920: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
921: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
922: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
923: text=>"Problem Parameters"});
924: } else {
925: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
926: text=>"Table Mode",
927: help => 'Course_Setting_Parameters'});
928: }
1.281 albertel 929: my $start_page =
930: &Apache::loncommon::start_page('Set/Modify Course Parameters',
931: &page_js(),
1.282 albertel 932: {'add_entries' => \%loaditems,});
1.280 albertel 933: my $breadcrumbs =
1.321 www 934: &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode');
1.280 albertel 935: $r->print(<<ENDHEAD);
1.281 albertel 936: $start_page
1.193 albertel 937: $breadcrumbs
938: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.419 bisitz 939: <input type="hidden" value="" name="pres_value" />
940: <input type="hidden" value="" name="pres_type" />
941: <input type="hidden" value="" name="pres_marker" />
942: <input type="hidden" value="1" name="prevvisit" />
1.44 albertel 943: ENDHEAD
944: }
945:
1.209 www 946:
1.44 albertel 947: sub print_row {
1.201 www 948: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.275 raeburn 949: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
950: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
951: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
952: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 953: # get the values for the parameter in cascading order
954: # empty levels will remain empty
1.44 albertel 955: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.275 raeburn 956: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 957: # get the type for the parameters
958: # problem: these may not be set for all levels
959: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 raeburn 960: $$name{$which}.'.type',$rid,
961: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 962: # cascade down manually
1.182 albertel 963: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 964: for (my $i=14;$i>0;$i--) {
1.66 www 965: if ($typeoutpar[$i]) {
966: $cascadetype=$typeoutpar[$i];
967: } else {
968: $typeoutpar[$i]=$cascadetype;
969: }
970: }
1.57 albertel 971: my $parm=$$display{$which};
972:
1.203 www 973: if ($parmlev eq 'full') {
1.419 bisitz 974: $r->print('<td style="background-color:'.$defbgtwo.';" align="center">'
1.57 albertel 975: .$$part{$which}.'</td>');
1.433 raeburn 976: } else {
1.57 albertel 977: $parm=~s|\[.*\]\s||g;
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.432 raeburn 1185: my ($display,$parmdis);
1186: $display = &standard_parameter_names($name);
1187: if ($display eq '') {
1188: $display= &Apache::lonnet::metadata($srcf,$key.'.display');
1189: $parmdis = $display;
1190: $parmdis =~ s/\s*\[Part.*$//g;
1191: } else {
1192: $parmdis = $display;
1193: }
1.363 albertel 1194: $$allparms{$name}=$parmdis;
1195: if (ref($defkeytype)) {
1196: $$defkeytype{$name}=
1197: &Apache::lonnet::metadata($srcf,$key.'.type');
1198: }
1199: }
1200:
1.209 www 1201: #
1202: # allparts is a hash of all parts
1203: #
1.363 albertel 1204: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.410 bisitz 1205: $$allparts{$part} = &mt('Part: [_1]',$part);
1.209 www 1206: #
1207: # Remember all keys going with this resource
1208: #
1.363 albertel 1209: if ($$keyp{$id}) {
1210: $$keyp{$id}.=','.$key;
1211: } else {
1212: $$keyp{$id}=$key;
1213: }
1.210 www 1214: #
1215: # Put in order
1216: #
1.363 albertel 1217: unless ($$keyorder{$key}) {
1218: $$keyorder{$key}=$keyordercnt;
1219: $keyordercnt++;
1220: }
1221: }
1.210 www 1222:
1.363 albertel 1223:
1224: if (!exists($$mapp{$mapid})) {
1225: $$mapp{$id}=
1226: &Apache::lonnet::declutter($resource->enclosing_map_src());
1227: $$mapp{$mapid}=$$mapp{$id};
1228: $$allmaps{$mapid}=$$mapp{$id};
1229: if ($mapid eq '1') {
1.401 bisitz 1230: $$maptitles{$mapid}=&mt('Main Course Documents');
1.363 albertel 1231: } else {
1232: $$maptitles{$mapid}=
1233: &Apache::lonnet::gettitle($$mapp{$id});
1.63 bowersj2 1234: }
1.363 albertel 1235: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1236: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.196 www 1237: } else {
1.363 albertel 1238: $$mapp{$id} = $$mapp{$mapid};
1.196 www 1239: }
1240: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
1.63 bowersj2 1241: }
1242: }
1243:
1.208 www 1244:
1245:
1.213 www 1246: sub isdateparm {
1247: my $type=shift;
1248: return (($type=~/^date/) && (!($type eq 'date_interval')));
1249: }
1250:
1.208 www 1251: sub parmmenu {
1.211 www 1252: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 1253: my $tempkey;
1254: $r->print(<<ENDSCRIPT);
1255: <script type="text/javascript">
1256: function checkall(value, checkName) {
1257: for (i=0; i<document.forms.parmform.elements.length; i++) {
1258: ele = document.forms.parmform.elements[i];
1259: if (ele.name == checkName) {
1260: document.forms.parmform.elements[i].checked=value;
1261: }
1262: }
1263: }
1.210 www 1264:
1265: function checkthis(thisvalue, checkName) {
1266: for (i=0; i<document.forms.parmform.elements.length; i++) {
1267: ele = document.forms.parmform.elements[i];
1268: if (ele.name == checkName) {
1269: if (ele.value == thisvalue) {
1270: document.forms.parmform.elements[i].checked=true;
1271: }
1272: }
1273: }
1274: }
1275:
1276: function checkdates() {
1277: checkthis('duedate','pscat');
1278: checkthis('opendate','pscat');
1279: checkthis('answerdate','pscat');
1.218 www 1280: }
1281:
1282: function checkdisset() {
1283: checkthis('discussend','pscat');
1284: checkthis('discusshide','pscat');
1285: }
1286:
1287: function checkcontdates() {
1288: checkthis('contentopen','pscat');
1289: checkthis('contentclose','pscat');
1290: }
1291:
1.210 www 1292:
1293: function checkvisi() {
1294: checkthis('hiddenresource','pscat');
1295: checkthis('encrypturl','pscat');
1296: checkthis('problemstatus','pscat');
1297: checkthis('contentopen','pscat');
1298: checkthis('opendate','pscat');
1299: }
1300:
1301: function checkparts() {
1302: checkthis('hiddenparts','pscat');
1303: checkthis('display','pscat');
1304: checkthis('ordered','pscat');
1305: }
1306:
1307: function checkstandard() {
1308: checkall(false,'pscat');
1309: checkdates();
1310: checkthis('weight','pscat');
1311: checkthis('maxtries','pscat');
1312: }
1313:
1.208 www 1314: </script>
1315: ENDSCRIPT
1.209 www 1316: $r->print();
1.422 bisitz 1317: $r->print("\n".'<table id="LC_parm_overview_parm_menu"><tr>');
1.208 www 1318: my $cnt=0;
1.211 www 1319: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.419 bisitz 1320: $r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
1.208 www 1321: $r->print('value="'.$tempkey.'"');
1322: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1.422 bisitz 1323: $r->print(' checked="checked"');
1.208 www 1324: }
1.432 raeburn 1325: $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
1326: : $tempkey)
1327: .'</label></td>');
1.209 www 1328: $cnt++;
1329: if ($cnt==3) {
1330: $r->print("</tr>\n<tr>");
1331: $cnt=0;
1332: }
1.208 www 1333: }
1.410 bisitz 1334: $r->print('</tr>'
1.422 bisitz 1335: .'<tr id="LC_parm_overview_parm_menu_selectors">'
1.410 bisitz 1336: .'<td valign="top">'
1337: .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'
1338: .'<span class="LC_nobreak">'
1339: .'• <a href="javascript:checkall(true, \'pscat\')">'.&mt('Select All').'</a>'
1340: .'</span>'
1341: .'<br />'
1342: .'<span class="LC_nobreak">'
1343: .'• <a href="javascript:checkstandard()">'.&mt('Select Common Only').'</a>'
1344: .'</span>'
1345: .'<br />'
1346: .'<span class="LC_nobreak">'
1347: .'• <a href="javascript:checkall(false, \'pscat\')">'.&mt('Unselect All').'</a>'
1348: .'</span>'
1349: .'</fieldset>'
1350: .'</td>'
1351: .'<td colspan="2" valign="top">'
1352: .'<fieldset><legend><b>'.&mt('Add Selection for...').'</b></legend>'
1353: .'<span class="LC_nobreak">'
1354: .'• <a href="javascript:checkdates()">'.&mt('Problem Dates').'</a>'
1355: .'</span>'
1356: .'<span class="LC_nobreak">'
1357: .' • <a href="javascript:checkcontdates()">'.&mt('Content Dates').'</a>'
1358: .'</span>'
1359: # .'<br />'
1360: .'<span class="LC_nobreak">'
1361: .' • <a href="javascript:checkdisset()">'.&mt('Discussion Settings').'</a>'
1362: .'</span>'
1363: .'<span class="LC_nobreak">'
1364: .' • <a href="javascript:checkvisi()">'.&mt('Visibilities').'</a>'
1365: .'</span>'
1366: # .'<br />'
1367: .'<span class="LC_nobreak">'
1368: .' • <a href="javascript:checkparts()">'.&mt('Part Parameters').'</a>'
1369: .'</span>'
1370: .'</fieldset>'
1371: .'</td>'
1372: .'</tr></table>'
1373: );
1.208 www 1374: }
1375:
1.209 www 1376: sub partmenu {
1377: my ($r,$allparts,$psprt)=@_;
1.421 bisitz 1378: $r->print('<select multiple="multiple" name="psprt" size="8">');
1.208 www 1379: $r->print('<option value="all"');
1.401 bisitz 1380: $r->print(' selected="selected"') unless (@{$psprt});
1.208 www 1381: $r->print('>'.&mt('All Parts').'</option>');
1382: my %temphash=();
1383: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1384: foreach my $tempkey (sort {
1385: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1386: } keys(%{$allparts})) {
1.208 www 1387: unless ($tempkey =~ /\./) {
1388: $r->print('<option value="'.$tempkey.'"');
1389: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1.401 bisitz 1390: $r->print(' selected="selected"');
1.208 www 1391: }
1392: $r->print('>'.$$allparts{$tempkey}.'</option>');
1393: }
1394: }
1.209 www 1395: $r->print('</select>');
1396: }
1397:
1398: sub usermenu {
1.275 raeburn 1399: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1400: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1401: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1402: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.412 bisitz 1403:
1.209 www 1404: my $sections='';
1.300 albertel 1405: my %sectionhash = &Apache::loncommon::get_sections();
1406:
1.269 raeburn 1407: my $groups;
1.307 raeburn 1408: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1409:
1.412 bisitz 1410: my $g_s_header='';
1411: my $g_s_footer='';
1412:
1.300 albertel 1413: if (%sectionhash) {
1.412 bisitz 1414: $sections=&mt('Section:').' <select name="csec"';
1.299 albertel 1415: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 1416: $sections .= qq| onchange="group_or_section('csec')" |;
1417: }
1418: $sections .= '>';
1.275 raeburn 1419: foreach my $section ('',sort keys %sectionhash) {
1420: $sections.='<option value="'.$section.'" '.
1421: ($section eq $csec?'selected="selected"':'').'>'.$section.
1422: '</option>';
1.209 www 1423: }
1424: $sections.='</select>';
1.269 raeburn 1425: }
1.412 bisitz 1426:
1.300 albertel 1427: if (%sectionhash && %grouphash && $parmlev ne 'full') {
1.412 bisitz 1428: $sections .= ' '.&mt('or').' ';
1.269 raeburn 1429: $sections .= qq|
1430: <script type="text/javascript">
1431: function group_or_section(caller) {
1432: if (caller == "cgroup") {
1433: if (document.parmform.cgroup.selectedIndex != 0) {
1434: document.parmform.csec.selectedIndex = 0;
1435: }
1436: } else {
1437: if (document.parmform.csec.selectedIndex != 0) {
1438: document.parmform.cgroup.selectedIndex = 0;
1439: }
1440: }
1441: }
1442: </script>
1443: |;
1444: } else {
1445: $sections .= qq|
1446: <script type="text/javascript">
1447: function group_or_section(caller) {
1448: return;
1449: }
1450: </script>
1451: |;
1452: }
1.299 albertel 1453:
1454: if (%grouphash) {
1.412 bisitz 1455: $groups=&mt('Group:').' <select name="cgroup"';
1.300 albertel 1456: if (%sectionhash && $env{'form.action'} eq 'settable') {
1.269 raeburn 1457: $groups .= qq| onchange="group_or_section('cgroup')" |;
1458: }
1459: $groups .= '>';
1.275 raeburn 1460: foreach my $grp ('',sort keys %grouphash) {
1461: $groups.='<option value="'.$grp.'" ';
1462: if ($grp eq $cgroup) {
1463: unless ((defined($uname)) && ($grp eq '')) {
1464: $groups .= 'selected="selected" ';
1465: }
1466: } elsif (!defined($cgroup)) {
1467: if (@{$usersgroups} == 1) {
1468: if ($grp eq $$usersgroups[0]) {
1469: $groups .= 'selected="selected" ';
1470: }
1471: }
1472: }
1473: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1474: }
1475: $groups.='</select>';
1476: }
1.412 bisitz 1477:
1478: if (%sectionhash || %grouphash) {
1479: $g_s_header='<fieldset><legend>'.&mt('Group/Section').'</legend><div>';
1480: $g_s_footer='</div></fieldset>';
1481: }
1482:
1483: $r->print('<b>'
1484: .$g_s_header
1485: .$sections
1486: .$groups
1487: .$g_s_footer
1488: .'<fieldset><legend>'.&mt('User').'</legend><div>'
1489: .&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]'
1490: ,'<input type="text" value="'.$uname.'" size="12" name="uname" />'
1491: ,'<input type="text" value="'.$id.'" size="12" name="id" /> '
1492: ,$chooseopt)
1493: .'</div></fieldset>'
1494: .'</b>'
1495: );
1.209 www 1496: }
1497:
1498: sub displaymenu {
1.211 www 1499: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1500: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1501: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1502: &parmmenu($r,$allparms,$pscat,$keyorder);
1.412 bisitz 1503: $r->print('</td><td valign="top" align="center">');
1.209 www 1504: &partmenu($r,$allparts,$psprt);
1505: $r->print('</td></tr></table>');
1506: }
1507:
1508: sub mapmenu {
1509: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1510: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1511: $r->print('<select name="pschp">');
1512: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1513: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1514: $r->print('<option value="'.$_.'"');
1.401 bisitz 1515: if (($pschp eq $_)) { $r->print(' selected="selected"'); }
1.209 www 1516: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1517: }
1518: $r->print("</select>");
1519: }
1520:
1521: sub levelmenu {
1522: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1523: $r->print('<b>'.&mt('Select Parameter Level').
1524: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1525: $r->print('<select name="parmlev">');
1526: foreach (reverse sort keys %{$alllevs}) {
1527: $r->print('<option value="'.$$alllevs{$_}.'"');
1528: if ($parmlev eq $$alllevs{$_}) {
1.401 bisitz 1529: $r->print(' selected="selected"');
1.209 www 1530: }
1.401 bisitz 1531: $r->print('>'.&mt($_).'</option>');
1.208 www 1532: }
1.209 www 1533: $r->print("</select>");
1.208 www 1534: }
1535:
1.211 www 1536:
1537: sub sectionmenu {
1538: my ($r,$selectedsections)=@_;
1.300 albertel 1539: my %sectionhash = &Apache::loncommon::get_sections();
1540: return if (!%sectionhash);
1541:
1.421 bisitz 1542: $r->print('<select name="Section" multiple="multiple" size="8">');
1.300 albertel 1543: foreach my $s ('all',sort keys %sectionhash) {
1544: $r->print(' <option value="'.$s.'"');
1545: foreach (@{$selectedsections}) {
1546: if ($s eq $_) {
1.401 bisitz 1547: $r->print(' selected="selected"');
1.300 albertel 1548: last;
1.212 www 1549: }
1550: }
1.300 albertel 1551: $r->print('>'.$s."</option>\n");
1552: }
1553: $r->print("</select>\n");
1.269 raeburn 1554: }
1555:
1556: sub groupmenu {
1557: my ($r,$selectedgroups)=@_;
1.307 raeburn 1558: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1559: return if (!%grouphash);
1560:
1.421 bisitz 1561: $r->print('<select name="Group" multiple="multiple" size="8">');
1.299 albertel 1562: foreach my $group (sort(keys(%grouphash))) {
1563: $r->print(' <option value="'.$group.'"');
1564: foreach (@{$selectedgroups}) {
1565: if ($group eq $_) {
1.401 bisitz 1566: $r->print(' selected="selected"');
1.299 albertel 1567: last;
1568: }
1569: }
1570: $r->print('>'.$group."</option>\n");
1.211 www 1571: }
1.299 albertel 1572: $r->print("</select>\n");
1.211 www 1573: }
1574:
1.269 raeburn 1575:
1.210 www 1576: sub keysplit {
1577: my $keyp=shift;
1578: return (split(/\,/,$keyp));
1579: }
1580:
1581: sub keysinorder {
1582: my ($name,$keyorder)=@_;
1583: return sort {
1584: $$keyorder{$a} <=> $$keyorder{$b};
1585: } (keys %{$name});
1586: }
1587:
1.236 albertel 1588: sub keysinorder_bytype {
1589: my ($name,$keyorder)=@_;
1590: return sort {
1591: my $ta=(split('_',$a))[-1];
1592: my $tb=(split('_',$b))[-1];
1593: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1594: return ($a cmp $b);
1595: }
1596: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1597: } (keys %{$name});
1598: }
1599:
1.211 www 1600: sub keysindisplayorder {
1601: my ($name,$keyorder)=@_;
1602: return sort {
1603: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1604: } (keys %{$name});
1605: }
1606:
1.214 www 1607: sub sortmenu {
1608: my ($r,$sortorder)=@_;
1.236 albertel 1609: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1610: if ($sortorder eq 'realmstudent') {
1.422 bisitz 1611: $r->print(' checked="checked"');
1.214 www 1612: }
1613: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1614: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1615: if ($sortorder eq 'studentrealm') {
1.422 bisitz 1616: $r->print(' checked="checked"');
1.214 www 1617: }
1.236 albertel 1618: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1619: '</label>');
1.214 www 1620: }
1621:
1.211 www 1622: sub standardkeyorder {
1623: return ('parameter_0_opendate' => 1,
1624: 'parameter_0_duedate' => 2,
1625: 'parameter_0_answerdate' => 3,
1626: 'parameter_0_interval' => 4,
1627: 'parameter_0_weight' => 5,
1628: 'parameter_0_maxtries' => 6,
1629: 'parameter_0_hinttries' => 7,
1630: 'parameter_0_contentopen' => 8,
1631: 'parameter_0_contentclose' => 9,
1632: 'parameter_0_type' => 10,
1633: 'parameter_0_problemstatus' => 11,
1634: 'parameter_0_hiddenresource' => 12,
1635: 'parameter_0_hiddenparts' => 13,
1636: 'parameter_0_display' => 14,
1637: 'parameter_0_ordered' => 15,
1638: 'parameter_0_tol' => 16,
1639: 'parameter_0_sig' => 17,
1.218 www 1640: 'parameter_0_turnoffunit' => 18,
1641: 'parameter_0_discussend' => 19,
1642: 'parameter_0_discusshide' => 20);
1.211 www 1643: }
1644:
1.59 matthew 1645:
1.30 www 1646: sub assessparms {
1.1 www 1647:
1.43 albertel 1648: my $r=shift;
1.201 www 1649:
1650: my @ids=();
1651: my %symbp=();
1652: my %mapp=();
1653: my %typep=();
1654: my %keyp=();
1655: my %uris=();
1656: my %maptitles=();
1657:
1.2 www 1658: # -------------------------------------------------------- Variable declaration
1.209 www 1659:
1.129 www 1660: my %allmaps=();
1661: my %alllevs=();
1.57 albertel 1662:
1.187 www 1663: my $uname;
1664: my $udom;
1665: my $uhome;
1666: my $csec;
1.269 raeburn 1667: my $cgroup;
1.275 raeburn 1668: my @usersgroups = ();
1.187 www 1669:
1.190 albertel 1670: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1671:
1.57 albertel 1672: $alllevs{'Resource Level'}='full';
1.215 www 1673: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1674: $alllevs{'Course Level'}='general';
1675:
1676: my %allparms;
1677: my %allparts;
1.210 www 1678: #
1679: # Order in which these parameters will be displayed
1680: #
1.211 www 1681: my %keyorder=&standardkeyorder();
1682:
1.43 albertel 1683: @ids=();
1684: %symbp=();
1685: %typep=();
1686:
1687: my $message='';
1688:
1.190 albertel 1689: $csec=$env{'form.csec'};
1.269 raeburn 1690: $cgroup=$env{'form.cgroup'};
1.188 www 1691:
1.190 albertel 1692: if ($udom=$env{'form.udom'}) {
1693: } elsif ($udom=$env{'request.role.domain'}) {
1694: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1695: } else {
1696: $udom=$r->dir_config('lonDefDomain');
1697: }
1.43 albertel 1698:
1.134 albertel 1699: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1700: my $pschp=$env{'form.pschp'};
1.134 albertel 1701: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1702: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1703:
1.43 albertel 1704: my $pssymb='';
1.57 albertel 1705: my $parmlev='';
1706:
1.190 albertel 1707: unless ($env{'form.parmlev'}) {
1.57 albertel 1708: $parmlev = 'map';
1709: } else {
1.190 albertel 1710: $parmlev = $env{'form.parmlev'};
1.57 albertel 1711: }
1.26 www 1712:
1.29 www 1713: # ----------------------------------------------- Was this started from grades?
1714:
1.190 albertel 1715: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1716: && (!$env{'form.dis'})) {
1717: my $url=$env{'form.url'};
1.194 albertel 1718: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1719: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1720: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1721: $pschp='';
1.57 albertel 1722: $parmlev = 'full';
1.190 albertel 1723: } elsif ($env{'form.symb'}) {
1724: $pssymb=$env{'form.symb'};
1.92 albertel 1725: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1726: $pschp='';
1.57 albertel 1727: $parmlev = 'full';
1.43 albertel 1728: } else {
1.190 albertel 1729: $env{'form.url'}='';
1.43 albertel 1730: }
1731:
1.190 albertel 1732: my $id=$env{'form.id'};
1.43 albertel 1733: if (($id) && ($udom)) {
1734: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1735: if ($uname) {
1736: $id='';
1737: } else {
1738: $message=
1.314 albertel 1739: '<span class="LC_error">'.&mt("Unknown ID")." '$id' ".
1740: &mt('at domain')." '$udom'</span>";
1.43 albertel 1741: }
1742: } else {
1.190 albertel 1743: $uname=$env{'form.uname'};
1.43 albertel 1744: }
1745: unless ($udom) { $uname=''; }
1746: $uhome='';
1747: if ($uname) {
1748: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1749: if ($uhome eq 'no_host') {
1750: $message=
1.314 albertel 1751: '<span class="LC_error">'.&mt("Unknown user")." '$uname' ".
1752: &mt("at domain")." '$udom'</span>";
1.43 albertel 1753: $uname='';
1.12 www 1754: } else {
1.103 albertel 1755: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1756: $env{'request.course.id'});
1.269 raeburn 1757:
1.43 albertel 1758: if ($csec eq '-1') {
1.314 albertel 1759: $message='<span class="LC_error">'.
1.133 www 1760: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1.314 albertel 1761: &mt("not in this course")."</span>";
1.43 albertel 1762: $uname='';
1.190 albertel 1763: $csec=$env{'form.csec'};
1.269 raeburn 1764: $cgroup=$env{'form.cgroup'};
1.43 albertel 1765: } else {
1766: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1767: ('firstname','middlename','lastname','generation','id'));
1.133 www 1768: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1769: $name{'firstname'}.' '.$name{'middlename'}.' '
1770: .$name{'lastname'}.' '.$name{'generation'}.
1.336 albertel 1771: "<br />\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1772: }
1.297 raeburn 1773: @usersgroups = &Apache::lonnet::get_users_groups(
1.275 raeburn 1774: $udom,$uname,$env{'request.course.id'});
1.297 raeburn 1775: if (@usersgroups > 0) {
1.306 albertel 1776: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
1.275 raeburn 1777: $cgroup = $usersgroups[0];
1.297 raeburn 1778: }
1.269 raeburn 1779: }
1.12 www 1780: }
1.43 albertel 1781: }
1.2 www 1782:
1.43 albertel 1783: unless ($csec) { $csec=''; }
1.269 raeburn 1784: unless ($cgroup) { $cgroup=''; }
1.12 www 1785:
1.14 www 1786: # --------------------------------------------------------- Get all assessments
1.210 www 1787: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1788: \%mapp, \%symbp,\%maptitles,\%uris,
1789: \%keyorder);
1.63 bowersj2 1790:
1.57 albertel 1791: $mapp{'0.0'} = '';
1792: $symbp{'0.0'} = '';
1.99 albertel 1793:
1.14 www 1794: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1795: if ($env{'form.pres_marker'}) {
1.205 www 1796: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1797: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1798: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1799: for (my $i=0;$i<=$#markers;$i++) {
1800: $message.=&storeparm(split(/\&/,$markers[$i]),
1801: $values[$i],
1802: $types[$i],
1.269 raeburn 1803: $uname,$udom,$csec,$cgroup);
1.205 www 1804: }
1.68 www 1805: # ---------------------------------------------------------------- Done storing
1.130 www 1806: $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 1807: }
1.57 albertel 1808: #----------------------------------------------- if all selected, fill in array
1.209 www 1809: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1810: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1811: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1812: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1813:
1.209 www 1814: &startpage($r);
1.57 albertel 1815:
1.44 albertel 1816: foreach ('tolerance','date_default','date_start','date_end',
1817: 'date_interval','int','float','string') {
1818: $r->print('<input type="hidden" value="'.
1.378 albertel 1819: &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
1820: '" name="recent_'.$_.'" />');
1.44 albertel 1821: }
1.57 albertel 1822:
1.44 albertel 1823: if (!$pssymb) {
1.209 www 1824: $r->print('<table border="1"><tr><td>');
1825: &levelmenu($r,\%alllevs,$parmlev);
1.424 bisitz 1826: $r->print('</td>');
1.128 albertel 1827: if ($parmlev ne 'general') {
1.209 www 1828: $r->print('<td>');
1829: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1830: $r->print('</td>');
1.128 albertel 1831: }
1.424 bisitz 1832: $r->print('</tr></table>');
1.211 www 1833: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1834: } else {
1.125 www 1835: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.312 albertel 1836: my $title = &Apache::lonnet::gettitle($pssymb);
1837: $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource).
1838: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.238 www 1839: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1840: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1841: }
1.275 raeburn 1842: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.57 albertel 1843:
1.210 www 1844: $r->print('<p>'.$message.'</p>');
1845:
1.209 www 1846: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1847:
1848: my @temp_pscat;
1849: map {
1850: my $cat = $_;
1851: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1852: } @pscat;
1853:
1854: @pscat = @temp_pscat;
1855:
1.209 www 1856: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1857: # ----------------------------------------------------------------- Start Table
1.57 albertel 1858: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1859: my $csuname=$env{'user.name'};
1860: my $csudom=$env{'user.domain'};
1.57 albertel 1861:
1.203 www 1862: if ($parmlev eq 'full') {
1.57 albertel 1863: my $coursespan=$csec?8:5;
1.275 raeburn 1864: my $userspan=3;
1.269 raeburn 1865: if ($cgroup ne '') {
1866: $coursespan += 3;
1867: }
1868:
1.419 bisitz 1869: $r->print('<p><table border="2">');
1870: $r->print('<tr><td colspan="5"></td>');
1871: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
1.57 albertel 1872: if ($uname) {
1.275 raeburn 1873: if (@usersgroups > 1) {
1874: $userspan ++;
1875: }
1876: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1877: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1878: }
1.133 www 1879: my %lt=&Apache::lonlocal::texthash(
1880: 'pie' => "Parameter in Effect",
1881: 'csv' => "Current Session Value",
1882: 'at' => 'at',
1883: 'rl' => "Resource Level",
1884: 'ic' => 'in Course',
1885: 'aut' => "Assessment URL and Title",
1.143 albertel 1886: 'type' => 'Type',
1.133 www 1887: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1888: 'part' => 'Part',
1.133 www 1889: 'pn' => 'Parameter Name',
1890: 'def' => 'default',
1891: 'femof' => 'from Enclosing Map or Folder',
1892: 'gen' => 'general',
1893: 'foremf' => 'for Enclosing Map or Folder',
1894: 'fr' => 'for Resource'
1895: );
1.57 albertel 1896: $r->print(<<ENDTABLETWO);
1.419 bisitz 1897: <th rowspan="3">$lt{'pie'}</th>
1898: <th rowspan="3">$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>
1899: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
1900: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 1901:
1.10 www 1902: ENDTABLETWO
1.57 albertel 1903: if ($csec) {
1.419 bisitz 1904: $r->print('<th colspan="3">'.
1.269 raeburn 1905: &mt("in Section")." $csec</th>");
1906: }
1907: if ($cgroup) {
1.419 bisitz 1908: $r->print('<th colspan="3">'.
1.269 raeburn 1909: &mt("in Group")." $cgroup</th>");
1.57 albertel 1910: }
1911: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1912: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1913: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1914: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1915: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1916: ENDTABLEHEADFOUR
1.57 albertel 1917:
1918: if ($csec) {
1.130 www 1919: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1920: }
1921:
1.269 raeburn 1922: if ($cgroup) {
1923: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1924: }
1925:
1.57 albertel 1926: if ($uname) {
1.275 raeburn 1927: if (@usersgroups > 1) {
1928: $r->print('<th>'.&mt('Control by other group?').'</th>');
1929: }
1.130 www 1930: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1931: }
1932:
1933: $r->print('</tr>');
1934:
1935: my $defbgone='';
1936: my $defbgtwo='';
1.269 raeburn 1937: my $defbgthree = '';
1.57 albertel 1938:
1939: foreach (@ids) {
1940:
1941: my $rid=$_;
1942: my ($inmapid)=($rid=~/\.(\d+)$/);
1943:
1.152 albertel 1944: if ((!$pssymb &&
1945: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1946: ||
1947: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1948: # ------------------------------------------------------ Entry for one resource
1.419 bisitz 1949: if ($defbgone eq '#E0E099') {
1950: $defbgone='#E0E0DD';
1.57 albertel 1951: } else {
1.419 bisitz 1952: $defbgone='#E0E099';
1.57 albertel 1953: }
1.419 bisitz 1954: if ($defbgtwo eq '#FFFF99') {
1955: $defbgtwo='#FFFFDD';
1.57 albertel 1956: } else {
1.419 bisitz 1957: $defbgtwo='#FFFF99';
1.57 albertel 1958: }
1.419 bisitz 1959: if ($defbgthree eq '#FFBB99') {
1960: $defbgthree='#FFBBDD';
1.269 raeburn 1961: } else {
1.419 bisitz 1962: $defbgthree='#FFBB99';
1.269 raeburn 1963: }
1964:
1.57 albertel 1965: my $thistitle='';
1966: my %name= ();
1967: undef %name;
1968: my %part= ();
1969: my %display=();
1970: my %type= ();
1971: my %default=();
1.196 www 1972: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1973:
1.210 www 1974: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1975: my $tempkeyp = $_;
1976: if (grep $_ eq $tempkeyp, @catmarker) {
1977: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1978: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1.433 raeburn 1979: my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
1980: if ($allparms{$name{$_}} ne '') {
1981: my $identifier;
1982: if ($parmdis =~ /(\s*\[Part.*)$/) {
1983: $identifier = $1;
1984: }
1985: $display{$_} = $allparms{$name{$_}}.$identifier;
1986: } else {
1987: $display{$_} = $parmdis;
1988: }
1.57 albertel 1989: unless ($display{$_}) { $display{$_}=''; }
1990: $display{$_}.=' ('.$name{$_}.')';
1991: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1992: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1993: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1994: }
1995: }
1996: my $totalparms=scalar keys %name;
1997: if ($totalparms>0) {
1998: my $firstrow=1;
1.274 albertel 1999: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 2000: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 2001: ' rowspan='.$totalparms.
1.419 bisitz 2002: '><tt><font size="-1">'.
1.57 albertel 2003: join(' / ',split(/\//,$uri)).
2004: '</font></tt><p><b>'.
1.154 albertel 2005: "<a href=\"javascript:openWindow('".
1.274 albertel 2006: &Apache::lonnet::clutter($uri).'?symb='.
1.308 www 2007: &escape($symbp{$rid}).
1.336 albertel 2008: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
2009: " target=\"_self\">$title");
1.57 albertel 2010:
2011: if ($thistitle) {
2012: $r->print(' ('.$thistitle.')');
2013: }
2014: $r->print('</a></b></td>');
1.419 bisitz 2015: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 2016: ' rowspan='.$totalparms.'>'.$typep{$rid}.
2017: '</td>');
2018:
1.419 bisitz 2019: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 2020: ' rowspan='.$totalparms.
1.238 www 2021: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 2022:
1.236 albertel 2023: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 2024: unless ($firstrow) {
2025: $r->print('<tr>');
2026: } else {
2027: undef $firstrow;
2028: }
1.201 www 2029: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 2030: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 2031: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 2032: $cgroup,\@usersgroups);
1.57 albertel 2033: }
2034: }
2035: }
2036: } # end foreach ids
1.43 albertel 2037: # -------------------------------------------------- End entry for one resource
1.57 albertel 2038: $r->print('</table>');
1.203 www 2039: } # end of full
1.57 albertel 2040: #--------------------------------------------------- Entry for parm level map
2041: if ($parmlev eq 'map') {
1.419 bisitz 2042: my $defbgone = '#E0E099';
2043: my $defbgtwo = '#FFFF99';
2044: my $defbgthree = '#FFBB99';
1.57 albertel 2045:
2046: my %maplist;
2047:
2048: if ($pschp eq 'all') {
2049: %maplist = %allmaps;
2050: } else {
2051: %maplist = ($pschp => $mapp{$pschp});
2052: }
2053:
2054: #-------------------------------------------- for each map, gather information
2055: my $mapid;
1.60 albertel 2056: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
2057: my $maptitle = $maplist{$mapid};
1.57 albertel 2058:
2059: #----------------------- loop through ids and get all parameter types for map
2060: #----------------------------------------- and associated information
2061: my %name = ();
2062: my %part = ();
2063: my %display = ();
2064: my %type = ();
2065: my %default = ();
2066: my $map = 0;
2067:
2068: # $r->print("Catmarker: @catmarker<br />\n");
2069:
2070: foreach (@ids) {
2071: ($map)=(/([\d]*?)\./);
2072: my $rid = $_;
2073:
2074: # $r->print("$mapid:$map: $rid <br /> \n");
2075:
2076: if ($map eq $mapid) {
1.196 www 2077: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2078: # $r->print("Keys: $keyp{$rid} <br />\n");
2079:
2080: #--------------------------------------------------------------------
2081: # @catmarker contains list of all possible parameters including part #s
2082: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2083: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2084: # When storing information, store as part 0
2085: # When requesting information, request from full part
2086: #-------------------------------------------------------------------
1.210 www 2087: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2088: my $tempkeyp = $_;
2089: my $fullkeyp = $tempkeyp;
1.73 albertel 2090: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 2091:
2092: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2093: $part{$tempkeyp}="0";
2094: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1.433 raeburn 2095: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2096: if ($allparms{$name{$tempkeyp}} ne '') {
2097: my $identifier;
2098: if ($parmdis =~ /(\s*\[Part.*)$/) {
2099: $identifier = $1;
2100: }
2101: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2102: } else {
2103: $display{$tempkeyp} = $parmdis;
2104: }
1.57 albertel 2105: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2106: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 2107: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 2108: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2109: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2110: }
2111: } # end loop through keys
2112: }
2113: } # end loop through ids
2114:
2115: #---------------------------------------------------- print header information
1.133 www 2116: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 2117: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 2118: my $tmp="";
1.57 albertel 2119: if ($uname) {
1.267 albertel 2120: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 2121: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
2122: &mt('in')." \n";
1.57 albertel 2123: } else {
1.401 bisitz 2124: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 2125: }
1.269 raeburn 2126: if ($cgroup) {
1.401 bisitz 2127: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
2128: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2129: $csec = '';
2130: } elsif ($csec) {
1.401 bisitz 2131: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
2132: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2133: }
1.401 bisitz 2134: $r->print('<div align="center"><h4>'
2135: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 2136: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 2137: ,$tmp
2138: ,'<font color="red"><i>'.$coursename.'</i></font>'
2139: )
2140: ."<br /></h4>\n"
1.422 bisitz 2141: );
1.57 albertel 2142: #---------------------------------------------------------------- print table
1.419 bisitz 2143: $r->print('<p>'.&Apache::loncommon::start_data_table()
2144: .&Apache::loncommon::start_data_table_header_row()
2145: .'<th>'.&mt('Parameter Name').'</th>'
2146: .'<th>'.&mt('Default Value').'</th>'
2147: .'<th>'.&mt('Parameter in Effect').'</th>'
2148: .&Apache::loncommon::end_data_table_header_row()
2149: );
1.57 albertel 2150:
1.210 www 2151: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2152: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2153: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2154: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2155: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2156: }
1.422 bisitz 2157: $r->print(&Apache::loncommon::end_data_table().'</p>'
2158: .'</div>'
2159: );
1.57 albertel 2160: } # end each map
2161: } # end of $parmlev eq map
2162: #--------------------------------- Entry for parm level general (Course level)
2163: if ($parmlev eq 'general') {
1.419 bisitz 2164: my $defbgone = '#E0E099';
2165: my $defbgtwo = '#FFFF99';
2166: my $defbgthree = '#FFBB99';
1.57 albertel 2167:
2168: #-------------------------------------------- for each map, gather information
2169: my $mapid="0.0";
2170: #----------------------- loop through ids and get all parameter types for map
2171: #----------------------------------------- and associated information
2172: my %name = ();
2173: my %part = ();
2174: my %display = ();
2175: my %type = ();
2176: my %default = ();
2177:
2178: foreach (@ids) {
2179: my $rid = $_;
2180:
1.196 www 2181: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2182:
2183: #--------------------------------------------------------------------
2184: # @catmarker contains list of all possible parameters including part #s
2185: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2186: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2187: # When storing information, store as part 0
2188: # When requesting information, request from full part
2189: #-------------------------------------------------------------------
1.210 www 2190: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2191: my $tempkeyp = $_;
2192: my $fullkeyp = $tempkeyp;
1.73 albertel 2193: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 2194: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2195: $part{$tempkeyp}="0";
2196: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1.433 raeburn 2197: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2198: if ($allparms{$name{$tempkeyp}} ne '') {
2199: my $identifier;
2200: if ($parmdis =~ /(\s*\[Part.*)$/) {
2201: $identifier = $1;
2202: }
2203: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2204: } else {
2205: $display{$tempkeyp} = $parmdis;
2206: }
1.57 albertel 2207: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2208: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 2209: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 2210: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2211: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2212: }
2213: } # end loop through keys
2214: } # end loop through ids
2215:
2216: #---------------------------------------------------- print header information
1.133 www 2217: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 2218: $r->print(<<ENDMAPONE);
1.419 bisitz 2219: <center>
2220: <h4>$setdef
1.135 albertel 2221: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 2222: ENDMAPONE
2223: if ($uname) {
1.267 albertel 2224: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2225: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2226: } else {
1.135 albertel 2227: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2228: }
2229:
1.135 albertel 2230: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2231: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2232: $r->print("</h4>\n");
1.57 albertel 2233: #---------------------------------------------------------------- print table
1.419 bisitz 2234: $r->print('<p>'.&Apache::loncommon::start_data_table()
2235: .&Apache::loncommon::start_data_table_header_row()
2236: .'<th>'.&mt('Parameter Name').'</th>'
2237: .'<th>'.&mt('Default Value').'</th>'
2238: .'<th>'.&mt('Parameter in Effect').'</th>'
2239: .&Apache::loncommon::end_data_table_header_row()
2240: );
1.57 albertel 2241:
1.210 www 2242: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2243: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2244: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2245: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2246: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2247: }
1.419 bisitz 2248: $r->print(&Apache::loncommon::end_data_table()
2249: .'</p>'
2250: .'</center>'
2251: );
1.57 albertel 2252: } # end of $parmlev eq general
1.43 albertel 2253: }
1.280 albertel 2254: $r->print('</form>'.&Apache::loncommon::end_page());
1.57 albertel 2255: } # end sub assessparms
1.30 www 2256:
1.59 matthew 2257:
2258:
1.30 www 2259: sub crsenv {
2260: my $r=shift;
2261: my $setoutput='';
1.280 albertel 2262:
1.414 droeschl 2263: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
2264: text=>"Course Environment"});
1.298 albertel 2265: my $breadcrumbs =
2266: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
1.190 albertel 2267: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2268: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 2269:
1.392 raeburn 2270: my (%crsinfo,$chome);
1.436 ! raeburn 2271: my $crstype = &Apache::loncommon::course_type();
1.392 raeburn 2272:
1.105 matthew 2273: #
2274: # Go through list of changes
1.190 albertel 2275: foreach (keys %env) {
1.105 matthew 2276: next if ($_!~/^form\.(.+)\_setparmval$/);
2277: my $name = $1;
1.190 albertel 2278: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 2279: if ($name eq 'newp') {
1.190 albertel 2280: $name = $env{'form.newp_name'};
1.105 matthew 2281: }
1.436 ! raeburn 2282: if ($name =~ /^rolenames_([^_]+)$/) {
! 2283: $name = $1.'.plaintext';
! 2284: my $standardtitle =
! 2285: &Apache::lonnet::plaintext($1,$crstype,$env{'request.course.id'},1);
! 2286: my %adv_roles =
! 2287: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
! 2288: if ($value ne '') {
! 2289: foreach my $role (keys(%adv_roles)) {
! 2290: if ($role =~ m{^cr/$match_domain/$match_name/\Q$value\E$}) {
! 2291: $setoutput.= '<span class="LC_error">'.
! 2292: &mt('Requested replacement title for [_1] role is already used as the name of a custom role ([_2]).',$standardtitle,$value).
! 2293: '</span><br />';
! 2294: undef($value);
! 2295: }
! 2296: }
! 2297: }
! 2298: }
1.105 matthew 2299: if ($name eq 'url') {
2300: $value=~s/^\/res\///;
2301: my $bkuptime=time;
2302: my @tmp = &Apache::lonnet::get
2303: ('environment',['url'],$dom,$crs);
1.130 www 2304: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2305: &Apache::lonnet::put
2306: ('environment',
2307: {'top level map backup '.$bkuptime => $tmp[1] },
2308: $dom,$crs).
1.336 albertel 2309: '<br />';
1.105 matthew 2310: }
2311: #
2312: # Deal with modified default spreadsheets
2313: if ($name =~ /^spreadsheet_default_(classcalc|
2314: studentcalc|
2315: assesscalc)$/x) {
2316: my $sheettype = $1;
2317: if ($sheettype eq 'classcalc') {
2318: # no need to do anything since viewing the sheet will
2319: # cause it to be updated.
2320: } elsif ($sheettype eq 'studentcalc') {
2321: # expire all the student spreadsheets
2322: &Apache::lonnet::expirespread('','','studentcalc');
2323: } else {
2324: # expire all the assessment spreadsheets
2325: # this includes non-default spreadsheets, but better to
2326: # be safe than sorry.
2327: &Apache::lonnet::expirespread('','','assesscalc');
2328: # expire all the student spreadsheets
2329: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2330: }
1.105 matthew 2331: }
2332: #
1.107 matthew 2333: # Deal with the enrollment dates
2334: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2335: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2336: }
1.364 albertel 2337: #
2338: # Deal with the emails
2339: if ($name =~ /\.email$/) {
1.371 albertel 2340: foreach my $specifier (split(',',$value)) {
2341: my ($user,$sections_or_groups)=
2342: ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
2343: if (!$sections_or_groups) {
2344: $user = $specifier;
2345: }
2346: my ($name,$domain) = split(':',$user);
2347: if (!defined($user) || !defined($domain)) {
2348: $setoutput.= '<br /> <span class="LC_error">'.
1.425 schafran 2349: &mt("Invalid e-mail address specified, address must be of the form username:domain what was specified was ([_1])",$user).
1.371 albertel 2350: '</span>';
2351: undef($value);
2352: } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
2353: $setoutput.= '<br /> <span class="LC_error">'.
1.425 schafran 2354: &mt("Invalid e-mail address specified, user [_1] is unknown.",$name).
1.371 albertel 2355: '</span>';
2356: undef($value);
2357: }
1.364 albertel 2358: }
2359: }
1.178 raeburn 2360: # Get existing cloners
2361: my @oldcloner = ();
2362: if ($name eq 'cloners') {
2363: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2364: if ($clonenames{'cloners'} =~ /,/) {
2365: @oldcloner = split/,/,$clonenames{'cloners'};
2366: } else {
2367: $oldcloner[0] = $clonenames{'cloners'};
2368: }
2369: }
1.107 matthew 2370: #
1.105 matthew 2371: # Let the user know we made the changes
1.153 albertel 2372: if ($name && defined($value)) {
1.379 raeburn 2373: my %failed_cloners;
1.178 raeburn 2374: if ($name eq 'cloners') {
1.239 raeburn 2375: $value =~ s/\s//g;
1.178 raeburn 2376: $value =~ s/^,//;
2377: $value =~ s/,$//;
1.239 raeburn 2378: # check requested clones are valid users.
1.379 raeburn 2379: %failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2380: }
1.105 matthew 2381: my $put_result = &Apache::lonnet::put('environment',
2382: {$name=>$value},$dom,$crs);
2383: if ($put_result eq 'ok') {
1.392 raeburn 2384: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
2385: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2386: $setoutput .= &Apache::lonlocal::locallocaltime($value);
1.406 raeburn 2387: } elsif ($name eq 'categories') {
2388: $setoutput .= $env{'form.categories_display'};
1.392 raeburn 2389: } else {
2390: $setoutput .= $value;
2391: }
2392: $setoutput .= '</b>.<br />';
1.178 raeburn 2393: if ($name eq 'cloners') {
2394: &change_clone($value,\@oldcloner);
2395: }
1.382 raeburn 2396: # Update environment and nohist_courseids.db
1.402 raeburn 2397: if (($name eq 'description') || ($name eq 'cloners') ||
1.403 raeburn 2398: ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.392 raeburn 2399: if ($chome eq '') {
2400: %crsinfo =
2401: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
1.403 raeburn 2402: $crs,undef,undef,'.');
1.392 raeburn 2403: $chome = &Apache::lonnet::homeserver($crs,$dom);
2404: }
2405: }
1.179 raeburn 2406: if ($name eq 'description' && defined($value)) {
1.393 raeburn 2407: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
1.382 raeburn 2408: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2409: $crsinfo{$env{'request.course.id'}}{'description'} = $value;
1.392 raeburn 2410: my $putresult =
2411: &Apache::lonnet::courseidput($dom,\%crsinfo,
2412: $chome,'notime');
2413: }
2414: }
1.403 raeburn 2415: if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.402 raeburn 2416: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1.403 raeburn 2417: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
2418: $crsinfo{$env{'request.course.id'}}{$name} = $value;
1.402 raeburn 2419: my $putresult =
2420: &Apache::lonnet::courseidput($dom,\%crsinfo,
2421: $chome,'notime');
2422: }
2423: }
1.105 matthew 2424: } else {
1.130 www 2425: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2426: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2427: }
1.379 raeburn 2428: if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
2429: $setoutput.= &mt('Unable to include').': ';
2430: my @fails;
2431: my $num = 0;
2432: if (defined($failed_cloners{'format'})) {
2433: $fails[$num] .= '<b>'.$failed_cloners{'format'}.
2434: '</b>, '.&mt('reason').' - '.
2435: &mt('Invalid format');
2436: $num ++;
2437: }
2438: if (defined($failed_cloners{'domain'})) {
2439: $fails[$num] .= '<b>'.$failed_cloners{'domain'}.
2440: '</b>, '.&mt('reason').' - '.
2441: &mt('Domain does not exist');
2442: $num ++;
2443: }
2444: if (defined($failed_cloners{'newuser'})) {
2445: $fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</b>, '.&mt('reason').' - '.
2446: &mt('LON-CAPA user(s) do(es) not exist.').
2447: '.<br />'.&mt('Please ').
2448: ' <a href="/adm/createuser">'.
2449: &mt('add the user(s)').'</a>, '.
2450: &mt('and then return to the ').
2451: '<a href="/adm/parmset?action=crsenv">'.
2452: &mt('Course Parameters page').'</a> '.
2453: &mt('to add the new user(s) to the list of possible cloners');
2454: }
2455: $setoutput .= join('; ',@fails).'.<br />';
1.239 raeburn 2456: }
1.30 www 2457: }
1.38 harris41 2458: }
1.315 albertel 2459:
2460: my $start_table =&Apache::loncommon::start_data_table();
2461: my $start_header_row=&Apache::loncommon::start_data_table_header_row();
2462: my $end_header_row =&Apache::loncommon::end_data_table_header_row();
1.108 www 2463: # ------------------------- Re-init course environment entries for this session
2464:
1.302 albertel 2465: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2466: {'freshen_cache' => 1});
1.105 matthew 2467:
1.30 www 2468: # -------------------------------------------------------- Get parameters again
1.45 matthew 2469:
2470: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2471: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2472: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2473: my $output='';
1.403 raeburn 2474: my $can_categorize;
1.45 matthew 2475: if (! exists($values{'con_lost'})) {
1.30 www 2476: my %descriptions=
1.395 bisitz 2477: ('url' => '<b>'.&mt('Top Level Map').'</b><br />'.
1.46 matthew 2478: '<a href="javascript:openbrowser'.
1.47 matthew 2479: "('envform','url','sequence')\">".
1.314 albertel 2480: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1.395 bisitz 2481: &mt('Modification may make assessment data inaccessible!').
1.314 albertel 2482: '</span>',
1.140 sakharuk 2483: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2484: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2485: '</b><br />'.
1.395 bisitz 2486: '('.&mt('internal, optional').')',
2487: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br />'
2488: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'
2489: .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'
2490: .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'
2491: .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),
1.150 www 2492: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1.395 bisitz 2493: &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),
2494: 'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'
2495: .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'
2496: .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',
2497: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.
1.52 www 2498: '<a href="javascript:openbrowser'.
2499: "('envform','default_xml_style'".
1.336 albertel 2500: ",'sty')\">$SelectStyleFile</a><br />",
1.395 bisitz 2501: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'
2502: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2503: 'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',
2504: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'
2505: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2506: 'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',
2507: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'
2508: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2509: 'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',
2510: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'
2511: .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',
2512: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'
2513: .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '
2514: .&mt('Changes will not show until next login.').')',
2515: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'
2516: .'('.&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>"').')',
2517: 'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'
1.420 bisitz 2518: .'('.&mt("[_1] for link to each a listing of each student's files.",'"<tt>yes</tt>"').')',
1.395 bisitz 2519: 'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'
2520: .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',
1.435 hauer 2521: 'plc.roles.denied'=> '<b>'.&mt('Disallow chat room use for Roles').'</b><br />'
1.395 bisitz 2522: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2523: .'("<tt>'.&mt('role,role,...').'</tt>") '
2524: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.118 matthew 2525: 'plc.users.denied' =>
1.435 hauer 2526: '<b>'.&mt('Disallow chat room use for Users').'</b><br />'.
1.395 bisitz 2527: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.118 matthew 2528:
1.395 bisitz 2529: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'
2530: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')
2531: .'("<tt>'.&mt('role,role,...').'</tt>") '
2532: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2533: 'pch.users.denied' =>
1.141 sakharuk 2534: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.395 bisitz 2535: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.49 matthew 2536: 'spreadsheet_default_classcalc'
1.141 sakharuk 2537: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2538: '<a href="javascript:openbrowser'.
2539: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2540: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2541: 'spreadsheet_default_studentcalc'
1.395 bisitz 2542: => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.
1.50 matthew 2543: '<a href="javascript:openbrowser'.
2544: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2545: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2546: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2547: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2548: '<a href="javascript:openbrowser'.
2549: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2550: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2551: 'allow_limited_html_in_feedback'
1.141 sakharuk 2552: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.395 bisitz 2553: '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',
1.170 raeburn 2554: 'allow_discussion_post_editing'
1.395 bisitz 2555: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'
2556: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2557: .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'
2558: .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'
2559: .'('.&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 2560: 'rndseed'
1.395 bisitz 2561: => '<b>'.&mt('Randomization algorithm used').'</b><br />'
2562: .'<span class="LC_error">'
2563: .&mt('Modifying this will make problems have different numbers and answers!')
2564: .'</span>',
1.151 albertel 2565: 'receiptalg'
2566: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2567: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2568: 'suppress_tries'
1.272 albertel 2569: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.395 bisitz 2570: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.113 sakharuk 2571: 'problem_stream_switch'
1.141 sakharuk 2572: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.395 bisitz 2573: ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',
1.161 sakharuk 2574: 'default_paper_size'
2575: => '<b>'.&mt('Default paper type').'</b><br />'.
2576: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2577: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2578: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.319 foxr 2579: 'print_header_format'
1.395 bisitz 2580: => ' <b>'.&mt('Print header format').'</b><br />'
2581: .&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 2582: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2583: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.395 bisitz 2584: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'
2585: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',
1.140 sakharuk 2586: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2587: 'disable_receipt_display'
1.141 sakharuk 2588: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2589: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.313 albertel 2590: 'task_messages'
1.395 bisitz 2591: => '<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 2592: 'disablesigfigs'
2593: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2594: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2595: 'disableexampointprint'
2596: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2597: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2598: 'externalsyllabus'
1.279 www 2599: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2600: 'tthoptions'
1.434 biermanm 2601: => '<b>'.&mt('Default set of options to pass to tth/m when converting TeX').'</b>',
1.367 albertel 2602:
2603: 'texengine'
1.395 bisitz 2604: => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'
1.420 bisitz 2605: .'('.&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 2606: 'timezone'
1.400 raeburn 2607: => '<b>'.&mt('Timezone in which the course takes place').'</b>',
1.392 raeburn 2608:
1.400 raeburn 2609: 'suppress_embed_prompt'
2610: => '<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 2611: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.403 raeburn 2612: 'hidefromcat'
1.402 raeburn 2613: => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
2614: ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',
1.403 raeburn 2615: 'categories'
2616: => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
2617: &mt('Display Categories').'</a>',
1.409 raeburn 2618: 'datelocale'
2619: => '<b>'.&mt('Locale used for course calendar').'</b>',
1.436 ! raeburn 2620: 'rolenames'
! 2621: => '<b>'.&mt('Replacement titles for standard course roles').'</b><br />'.
! 2622: '('.&mt('To replace the standard title for a course role, enter the title you wish to use, otherwise leave blank.').')',
1.402 raeburn 2623: );
2624: my @Display_Order = ('url','description','courseid','cloners');
1.403 raeburn 2625: (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
2626: if ($can_toggle_cat) {
1.402 raeburn 2627: push(@Display_Order,'hidefromcat');
2628: }
1.403 raeburn 2629: if ($can_categorize) {
2630: push(@Display_Order,'categories');
2631: }
1.402 raeburn 2632: push (@Display_Order,('grading',
1.278 www 2633: 'externalsyllabus',
1.107 matthew 2634: 'default_xml_style','pageseparators',
1.402 raeburn 2635: 'question.email','question.email.text','comment.email',
2636: 'comment.email.text','policy.email','policy.email.text',
1.169 matthew 2637: 'student_classlist_view',
1.372 raeburn 2638: 'student_classlist_opt_in',
2639: 'student_classlist_portfiles',
1.118 matthew 2640: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2641: 'pch.roles.denied','pch.users.denied',
2642: 'allow_limited_html_in_feedback',
1.170 raeburn 2643: 'allow_discussion_post_editing',
1.108 www 2644: 'languages',
1.397 www 2645: 'timezone',
1.409 raeburn 2646: 'datelocale',
1.436 ! raeburn 2647: 'rolenames',
1.150 www 2648: 'nothideprivileged',
1.107 matthew 2649: 'rndseed',
1.151 albertel 2650: 'receiptalg',
1.107 matthew 2651: 'problem_stream_switch',
1.164 sakharuk 2652: 'suppress_tries',
1.400 raeburn 2653: 'suppress_embed_prompt',
1.161 sakharuk 2654: 'default_paper_size',
1.319 foxr 2655: 'print_header_format',
1.115 www 2656: 'disable_receipt_display',
1.107 matthew 2657: 'spreadsheet_default_classcalc',
2658: 'spreadsheet_default_studentcalc',
2659: 'spreadsheet_default_assesscalc',
2660: 'hideemptyrows',
2661: 'default_enrollment_start_date',
2662: 'default_enrollment_end_date',
1.163 albertel 2663: 'tthoptions',
1.367 albertel 2664: 'texengine',
1.251 albertel 2665: 'disablesigfigs',
1.313 albertel 2666: 'disableexampointprint',
1.402 raeburn 2667: 'task_messages','task_grading'));
1.107 matthew 2668: foreach my $parameter (sort(keys(%values))) {
1.405 raeburn 2669: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2670: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
1.436 ! raeburn 2671: || ($parameter eq 'type') ||
! 2672: ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
1.142 raeburn 2673: if (! $descriptions{$parameter}) {
2674: $descriptions{$parameter}=$parameter;
2675: push(@Display_Order,$parameter);
2676: }
2677: }
1.43 albertel 2678: }
1.315 albertel 2679:
1.107 matthew 2680: foreach my $parameter (@Display_Order) {
2681: my $description = $descriptions{$parameter};
1.51 matthew 2682: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2683: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2684: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2685: '.checked=true;"';
1.315 albertel 2686: $output .= &Apache::loncommon::start_data_table_row().
2687: '<td>'.$description.'</td>';
1.107 matthew 2688: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2689: $output .= '<td>'.
2690: &Apache::lonhtmlcommon::date_setter('envform',
2691: $parameter.'_value',
2692: $values{$parameter},
2693: $onchange).
2694: '</td>';
1.398 www 2695: } elsif ($parameter eq 'timezone') {
1.399 raeburn 2696: my $includeempty = 1;
2697: my $timezone = &Apache::lonlocal::gettimezone();
1.398 www 2698: $output .= '<td>'.
2699: &Apache::loncommon::select_timezone($parameter.'_value',
1.399 raeburn 2700: $timezone,
2701: $onchange,$includeempty).'</td>';
1.409 raeburn 2702: } elsif ($parameter eq 'datelocale') {
2703: my $includeempty = 1;
2704: my $locale_obj = &Apache::lonlocal::getdatelocale();
2705: my $currdatelocale;
2706: if (ref($locale_obj)) {
2707: $currdatelocale = $locale_obj->id();
2708: }
2709: $output .= '<td>'.
2710: &Apache::loncommon::select_datelocale($parameter.'_value',
2711: $currdatelocale,
1.436 ! raeburn 2712: $onchange,$includeempty).'</td>';
! 2713: } elsif ($parameter eq 'rolenames') {
! 2714: $output.= '<td><table>';
! 2715: foreach my $role ('cc','in','ta','ep','ad','st') {
! 2716: my $onchange = 'onFocus="javascript:window.document.forms'.
! 2717: "['envform'].elements['".
! 2718: $parameter.'_'.$role."_setparmval']".
! 2719: '.checked=true;"';
! 2720: $output.= '<tr><td>'.&Apache::lonnet::plaintext($role,$crstype,undef,1).
! 2721: '</td><td>'.
! 2722: &Apache::lonhtmlcommon::textbox($parameter.'_'.$role.'_value',
! 2723: $values{$role.'.plaintext'},
! 2724: 15,$onchange).
! 2725: '</td></tr>';
! 2726: }
! 2727: $output .= '</table></td><td><table>';
! 2728: foreach my $role ('cc','in','ta','ep','ad','st') {
! 2729: $output .= '<tr><td>'.&Apache::lonhtmlcommon::checkbox($parameter.'_'.$role.'_setparmval').
! 2730: '</td></tr>';
! 2731: }
! 2732: $output .= '</table></td>';
1.406 raeburn 2733: } elsif ($parameter eq 'categories') {
2734: my $catdisplay;
2735: if ($values{'categories'} ne '') {
2736: my @curritems = split(/\&/,$values{'categories'});
2737: foreach my $item (@curritems) {
2738: my ($name,$parent,$pos) = split(/:/,$item);
2739: $catdisplay .= &unescape($name).'&';
2740: }
2741: $catdisplay =~ s/\&$//;
2742: }
2743: $output .= '<td>'.
2744: '<input type="hidden" name="categories_value" value="'.
2745: $values{'categories'}.'" />'.
2746: '<input type="textbox" name="categories_display" value="'.
2747: $catdisplay.'" readonly="readonly" size="40" /></td>';
1.107 matthew 2748: } else {
2749: $output .= '<td>'.
2750: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2751: $values{$parameter},
2752: 40,$onchange).'</td>';
2753: }
1.436 ! raeburn 2754: unless ($parameter eq 'rolenames') {
! 2755: $output .= '<td>'.
! 2756: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
! 2757: '</td>';
! 2758: }
1.315 albertel 2759: $output .= &Apache::loncommon::end_data_table_row()."\n";
1.51 matthew 2760: }
1.69 www 2761: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2762: '[\'envform\'].elements[\'newp_setparmval\']'.
2763: '.checked=true;"';
1.315 albertel 2764: $output.=&Apache::loncommon::start_data_table_row().
2765: '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.419 bisitz 2766: '<input type="text" size="40" name="newp_name" '.
1.51 matthew 2767: $onchange.' /></td><td>'.
1.419 bisitz 2768: '<input type="text" size="40" name="newp_value" '.
1.51 matthew 2769: $onchange.' /></td><td>'.
1.315 albertel 2770: '<input type="checkbox" name="newp_setparmval" /></td>'.
2771: &Apache::loncommon::end_data_table_row()."\n";
1.43 albertel 2772: }
1.157 sakharuk 2773: my %lt=&Apache::lonlocal::texthash(
2774: 'par' => 'Parameter',
2775: 'val' => 'Value',
1.395 bisitz 2776: 'set' => 'Set?',
2777: 'sav' => 'Save'
1.157 sakharuk 2778: );
2779:
1.140 sakharuk 2780: my $Parameter=&mt('Parameter');
2781: my $Value=&mt('Value');
1.141 sakharuk 2782: my $Set=&mt('Set');
1.403 raeburn 2783: my ($jscript,$categorize_js);
2784: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
2785: if ($can_categorize) {
2786: $categorize_js = <<ENDSCRIPT;
2787: function catsbrowser() {
2788: var catswin = null;
2789: var url = '/adm/parmset?action=categorizecourse';
2790: if (!catswin || catswin.closed) {
2791: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2792: } else {
2793: catswin.focus();
2794: }
2795: }
2796: ENDSCRIPT
2797: }
2798: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
2799: $browse_js."\n".$categorize_js."\n".'</script>';
1.280 albertel 2800: my $start_page =
1.323 albertel 2801: &Apache::loncommon::start_page('Set Course Environment',
1.403 raeburn 2802: $jscript);
1.280 albertel 2803: my $end_page =
2804: &Apache::loncommon::end_page();
1.315 albertel 2805: my $end_table=&Apache::loncommon::end_data_table();
1.280 albertel 2806: $r->print(<<ENDENV);
2807: $start_page
1.193 albertel 2808: $breadcrumbs
2809: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2810: $setoutput
1.395 bisitz 2811: <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>
1.315 albertel 2812: $start_table
2813: $start_header_row
1.395 bisitz 2814: <th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
1.315 albertel 2815: $end_header_row
1.30 www 2816: $output
1.315 albertel 2817: $end_table
1.395 bisitz 2818: <input type="submit" name="crsenv" value="$lt{'sav'}" />
1.30 www 2819: </form>
1.280 albertel 2820: $end_page
2821: ENDENV
1.30 www 2822: }
1.402 raeburn 2823:
1.403 raeburn 2824: sub can_modify_catsettings {
1.402 raeburn 2825: my ($dom) = @_;
2826: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.403 raeburn 2827: my ($can_toggle_cat,$can_categorize);
1.402 raeburn 2828: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2829: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2830: $can_toggle_cat = 1;
2831: }
1.403 raeburn 2832: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2833: $can_categorize = 1;
2834: }
2835: }
2836: return ($can_toggle_cat,$can_categorize);
2837: }
2838:
2839: sub assign_course_categories {
2840: my ($r) = @_;
2841: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2842: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2843: my $hascats = 0;
2844: my $cathash;
2845: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2846: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2847: $cathash = $domconf{'coursecategories'}{'cats'};
2848: if (ref($cathash) eq 'HASH') {
2849: $hascats = 1;
2850: }
1.402 raeburn 2851: }
1.403 raeburn 2852: my $catwin_js;
2853: if ($hascats) {
2854: my $alert = &mt('Use \"Save\" in the main window to save course categories');
2855: $catwin_js = <<ENDSCRIPT;
2856: <script type="text/javascript">
2857:
2858: function updateCategories() {
2859: var newcategories = '';
1.406 raeburn 2860: var unescapedcats = '';
1.403 raeburn 2861: if (document.chgcats.usecategory.length) {
2862: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2863: if (document.chgcats.usecategory[i].checked == true) {
2864: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1.406 raeburn 2865: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1.403 raeburn 2866: }
2867: }
2868: if (newcategories.length > 0) {
2869: newcategories = newcategories.slice(0,-1);
2870: }
1.406 raeburn 2871: if (unescapedcats.length > 0) {
1.408 raeburn 2872: unescapedcats = unescapedcats.slice(0,-3);
1.406 raeburn 2873: }
1.403 raeburn 2874: } else {
2875: if (document.chgcats.usecategory.checked == true) {
2876: newcategories = document.chgcats.usecategory.value;
1.406 raeburn 2877: unescapedcats = document.chgcats.catname.value;
1.403 raeburn 2878: }
2879: }
2880: opener.document.envform.categories_value.value = newcategories;
1.406 raeburn 2881: opener.document.envform.categories_display.value = unescapedcats;
1.403 raeburn 2882: opener.document.envform.categories_setparmval.checked = true;
2883: alert("$alert");
2884: self.close();
2885: return;
2886: }
2887:
2888: </script>
2889: ENDSCRIPT
2890: } else {
2891: my $onload;
2892: }
2893: my $start_page =
2894: &Apache::loncommon::start_page('Course Categories',$catwin_js,
2895: {'only_body' => 1,});
2896: my $end_page = &Apache::loncommon::end_page();
2897: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
2898: if ($hascats) {
2899: my %currsettings =
2900: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2901: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
2902: '<form name="chgcats" action="/adm/parmset" method="post">'."\n"
2903: .&Apache::loncommon::assign_categories_table($cathash,
2904: $currsettings{'categories'})."\n"
2905: .'<br /><input type="button" name="changes" value="'
2906: .&mt('Copy to main window').'" '
2907: .'onclick="javascript:updateCategories()" /></form><br />';
2908: } else {
2909: $categoriesform .= &mt('No categories defined for this domain');
2910: }
2911: $r->print($start_page.$categoriesform.$end_page);
2912: return;
1.402 raeburn 2913: }
2914:
1.120 www 2915: ##################################################
1.207 www 2916: # Overview mode
2917: ##################################################
1.124 www 2918: my $tableopen;
2919:
2920: sub tablestart {
2921: if ($tableopen) {
2922: return '';
2923: } else {
2924: $tableopen=1;
1.295 albertel 2925: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 2926: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2927: }
2928: }
2929:
2930: sub tableend {
2931: if ($tableopen) {
2932: $tableopen=0;
1.295 albertel 2933: return &Apache::loncommon::end_data_table();
1.124 www 2934: } else {
2935: return'';
2936: }
2937: }
2938:
1.207 www 2939: sub readdata {
2940: my ($crs,$dom)=@_;
2941: # Read coursedata
2942: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2943: # Read userdata
2944:
2945: my $classlist=&Apache::loncoursedata::get_classlist();
2946: foreach (keys %$classlist) {
1.350 albertel 2947: if ($_=~/^($match_username)\:($match_domain)$/) {
1.207 www 2948: my ($tuname,$tudom)=($1,$2);
2949: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2950: foreach my $userkey (keys %{$useropt}) {
2951: if ($userkey=~/^$env{'request.course.id'}/) {
2952: my $newkey=$userkey;
2953: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2954: $$resourcedata{$newkey}=$$useropt{$userkey};
2955: }
2956: }
2957: }
2958: }
2959: return $resourcedata;
2960: }
2961:
2962:
1.124 www 2963: # Setting
1.208 www 2964:
2965: sub storedata {
2966: my ($r,$crs,$dom)=@_;
1.207 www 2967: # Set userlevel immediately
2968: # Do an intermediate store of course level
2969: my $olddata=&readdata($crs,$dom);
1.124 www 2970: my %newdata=();
2971: undef %newdata;
2972: my @deldata=();
2973: undef @deldata;
1.190 albertel 2974: foreach (keys %env) {
1.124 www 2975: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2976: my $cmd=$1;
2977: my $thiskey=$2;
1.207 www 2978: my ($tuname,$tudom)=&extractuser($thiskey);
2979: my $tkey=$thiskey;
2980: if ($tuname) {
2981: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2982: }
1.385 albertel 2983: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.384 albertel 2984: my ($data, $typeof, $text);
2985: if ($cmd eq 'set') {
2986: $data=$env{$_};
2987: $typeof=$env{'form.typeof_'.$thiskey};
2988: $text = &mt('Saved modified parameter for');
2989: } elsif ($cmd eq 'datepointer') {
2990: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
2991: $typeof=$env{'form.typeof_'.$thiskey};
2992: $text = &mt('Saved modified date for');
1.385 albertel 2993: } elsif ($cmd eq 'dateinterval') {
2994: $data=&get_date_interval_from_form($thiskey);
2995: $typeof=$env{'form.typeof_'.$thiskey};
2996: $text = &mt('Saved modified date for');
1.384 albertel 2997: }
2998: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 2999: if ($tuname) {
1.212 www 3000: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
3001: $tkey.'.type' => $typeof},
3002: $tudom,$tuname) eq 'ok') {
1.290 www 3003: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.384 albertel 3004: $r->print('<br />'.$text.' '.
1.207 www 3005: &Apache::loncommon::plainname($tuname,$tudom));
3006: } else {
1.314 albertel 3007: $r->print('<div class="LC_error">'.
1.365 albertel 3008: &mt('Error saving parameters').'</div>');
1.207 www 3009: }
3010: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3011: } else {
3012: $newdata{$thiskey}=$data;
1.212 www 3013: $newdata{$thiskey.'.type'}=$typeof;
3014: }
1.207 www 3015: }
1.124 www 3016: } elsif ($cmd eq 'del') {
1.207 www 3017: if ($tuname) {
3018: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 3019: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 3020: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
3021: } else {
1.314 albertel 3022: $r->print('<div class="LC_error">'.
3023: &mt('Error deleting parameters').'</div>');
1.207 www 3024: }
3025: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3026: } else {
1.333 albertel 3027: push (@deldata,$thiskey,$thiskey.'.type');
1.207 www 3028: }
1.124 www 3029: }
3030: }
3031: }
1.207 www 3032: # Store all course level
1.144 www 3033: my $delentries=$#deldata+1;
3034: my @newdatakeys=keys %newdata;
3035: my $putentries=$#newdatakeys+1;
3036: if ($delentries) {
3037: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 3038: my %loghash=map { $_ => '' } @deldata;
3039: &log_parmset(\%loghash,1);
1.144 www 3040: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
3041: } else {
1.314 albertel 3042: $r->print('<div class="LC_error">'.
3043: &mt('Error deleting parameters').'</div>');
1.144 www 3044: }
1.205 www 3045: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3046: }
3047: if ($putentries) {
3048: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 3049: &log_parmset(\%newdata,0);
1.365 albertel 3050: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 3051: } else {
1.314 albertel 3052: $r->print('<div class="LC_error">'.
1.365 albertel 3053: &mt('Error saving parameters').'</div>');
1.144 www 3054: }
1.205 www 3055: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3056: }
1.208 www 3057: }
1.207 www 3058:
1.208 www 3059: sub extractuser {
3060: my $key=shift;
1.350 albertel 3061: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 3062: }
1.206 www 3063:
1.381 albertel 3064: sub parse_listdata_key {
3065: my ($key,$listdata) = @_;
3066: # split into student/section affected, and
3067: # the realm (folder/resource part and parameter
3068: my ($student,$realm) =
3069: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
3070: # if course wide student would be undefined
3071: if (!defined($student)) {
3072: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
3073: }
3074: # strip off the .type if it's not the Question type parameter
3075: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
3076: $realm=~s/\.type//;
3077: }
3078: # split into resource+part and parameter name
1.388 albertel 3079: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
3080: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 3081: return ($student,$res,$part,$parm);
3082: }
3083:
1.208 www 3084: sub listdata {
1.214 www 3085: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 3086: # Start list output
1.206 www 3087:
1.122 www 3088: my $oldsection='';
3089: my $oldrealm='';
3090: my $oldpart='';
1.123 www 3091: my $pointer=0;
1.124 www 3092: $tableopen=0;
1.145 www 3093: my $foundkeys=0;
1.248 albertel 3094: my %keyorder=&standardkeyorder();
1.381 albertel 3095:
1.214 www 3096: foreach my $thiskey (sort {
1.381 albertel 3097: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
3098: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
3099:
3100: # get the numerical order for the param
3101: $aparm=$keyorder{'parameter_0_'.$aparm};
3102: $bparm=$keyorder{'parameter_0_'.$bparm};
3103:
3104: my $result=0;
3105:
1.214 www 3106: if ($sortorder eq 'realmstudent') {
1.381 albertel 3107: if ($ares ne $bres ) {
3108: $result = ($ares cmp $bres);
3109: } elsif ($astudent ne $bstudent) {
3110: $result = ($astudent cmp $bstudent);
3111: } elsif ($apart ne $bpart ) {
3112: $result = ($apart cmp $bpart);
1.237 albertel 3113: }
1.381 albertel 3114: } else {
3115: if ($astudent ne $bstudent) {
3116: $result = ($astudent cmp $bstudent);
3117: } elsif ($ares ne $bres ) {
3118: $result = ($ares cmp $bres);
3119: } elsif ($apart ne $bpart ) {
3120: $result = ($apart cmp $bpart);
1.247 albertel 3121: }
1.381 albertel 3122: }
3123:
3124: if (!$result) {
3125: if (defined($aparm) && defined($bparm)) {
3126: $result = ($aparm <=> $bparm);
3127: } elsif (defined($aparm)) {
3128: $result = -1;
3129: } elsif (defined($bparm)) {
3130: $result = 1;
1.248 albertel 3131: }
1.214 www 3132: }
1.381 albertel 3133:
3134: $result;
1.214 www 3135: } keys %{$listdata}) {
1.381 albertel 3136:
1.211 www 3137: if ($$listdata{$thiskey.'.type'}) {
3138: my $thistype=$$listdata{$thiskey.'.type'};
3139: if ($$resourcedata{$thiskey.'.type'}) {
3140: $thistype=$$resourcedata{$thiskey.'.type'};
3141: }
1.207 www 3142: my ($middle,$part,$name)=
3143: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 3144: my $section=&mt('All Students');
1.207 www 3145: if ($middle=~/^\[(.*)\]/) {
1.206 www 3146: my $issection=$1;
1.350 albertel 3147: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
1.206 www 3148: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
3149: } else {
3150: $section=&mt('Group/Section').': '.$issection;
3151: }
1.207 www 3152: $middle=~s/^\[(.*)\]//;
1.122 www 3153: }
1.207 www 3154: $middle=~s/\.+$//;
3155: $middle=~s/^\.+//;
1.316 albertel 3156: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.122 www 3157: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 3158: $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 3159: } elsif ($middle) {
1.174 albertel 3160: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 3161: $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 3162: }
1.214 www 3163: if ($sortorder eq 'realmstudent') {
3164: if ($realm ne $oldrealm) {
3165: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3166: $oldrealm=$realm;
3167: $oldsection='';
3168: }
3169: if ($section ne $oldsection) {
3170: $r->print(&tableend()."\n<h2>$section</h2>");
3171: $oldsection=$section;
3172: $oldpart='';
3173: }
3174: } else {
3175: if ($section ne $oldsection) {
3176: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3177: $oldsection=$section;
3178: $oldrealm='';
3179: }
3180: if ($realm ne $oldrealm) {
3181: $r->print(&tableend()."\n<h2>$realm</h2>");
3182: $oldrealm=$realm;
3183: $oldpart='';
3184: }
1.122 www 3185: }
3186: if ($part ne $oldpart) {
1.124 www 3187: $r->print(&tableend().
1.422 bisitz 3188: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
1.122 www 3189: $oldpart=$part;
3190: }
1.123 www 3191: #
3192: # Ready to print
3193: #
1.295 albertel 3194: $r->print(&tablestart().
3195: &Apache::loncommon::start_data_table_row().
3196: '<td><b>'.&standard_parameter_names($name).
1.293 www 3197: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 3198: $thiskey.'" /></td><td>');
1.145 www 3199: $foundkeys++;
1.213 www 3200: if (&isdateparm($thistype)) {
1.123 www 3201: my $jskey='key_'.$pointer;
3202: $pointer++;
3203: $r->print(
1.232 albertel 3204: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 3205: $jskey,
1.219 www 3206: $$resourcedata{$thiskey},
1.325 www 3207: '',1,'','').
1.277 www 3208: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3209: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3210: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3211: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 3212: );
1.385 albertel 3213: } elsif ($thistype eq 'date_interval') {
3214: $r->print(&date_interval_selector($thiskey,
3215: $$resourcedata{$thiskey}));
1.383 albertel 3216: } elsif ($thistype =~ m/^string/) {
3217: $r->print(&string_selector($thistype,$thiskey,
3218: $$resourcedata{$thiskey}));
1.123 www 3219: } else {
1.383 albertel 3220: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 3221: }
1.211 www 3222: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
1.423 bisitz 3223: $thistype.'" />');
1.295 albertel 3224: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 3225: }
1.121 www 3226: }
1.208 www 3227: return $foundkeys;
3228: }
3229:
1.385 albertel 3230:
3231: sub date_interval_selector {
3232: my ($thiskey, $showval) = @_;
3233: my $result;
3234: foreach my $which (['days', 86400, 31],
3235: ['hours', 3600, 23],
3236: ['minutes', 60, 59],
3237: ['seconds', 1, 59]) {
3238: my ($name, $factor, $max) = @{ $which };
3239: my $amount = int($showval/$factor);
3240: $showval %= $factor;
3241: my %select = ((map {$_ => $_} (0..$max)),
3242: 'select_form_order' => [0..$max]);
3243: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
3244: %select);
3245: $result .= ' '.&mt($name);
3246: }
3247: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3248: return $result;
3249:
3250: }
3251:
3252: sub get_date_interval_from_form {
3253: my ($key) = @_;
3254: my $seconds = 0;
3255: foreach my $which (['days', 86400],
3256: ['hours', 3600],
3257: ['minutes', 60],
3258: ['seconds', 1]) {
3259: my ($name, $factor) = @{ $which };
3260: if (defined($env{'form.'.$name.'_'.$key})) {
3261: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3262: }
3263: }
3264: return $seconds;
3265: }
3266:
3267:
1.383 albertel 3268: sub default_selector {
3269: my ($thiskey, $showval) = @_;
1.385 albertel 3270: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3271: }
3272:
3273: my %strings =
3274: (
3275: 'string_yesno'
3276: => [[ 'yes', 'Yes' ],
3277: [ 'no', 'No' ]],
3278: 'string_problemstatus'
3279: => [[ 'yes', 'Yes' ],
1.394 www 3280: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3281: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3282: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3283: );
3284:
3285:
3286: sub string_selector {
3287: my ($thistype, $thiskey, $showval) = @_;
3288:
3289: if (!exists($strings{$thistype})) {
3290: return &default_selector($thiskey,$showval);
3291: }
3292:
3293: my $result;
3294: foreach my $possibilities (@{ $strings{$thistype} }) {
3295: my ($name, $description) = @{ $possibilities };
3296: $result .= '<label><input type="radio" name="set_'.$thiskey.
3297: '" value="'.$name.'"';
3298: if ($showval eq $name) {
3299: $result .= ' checked="checked"';
3300: }
3301: $result .= ' />'.&mt($description).'</label> ';
3302: }
3303: return $result;
3304: }
3305:
1.389 www 3306: #
3307: # Shift all start and end dates by $shift
3308: #
3309:
3310: sub dateshift {
3311: my ($shift)=@_;
3312: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3313: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3314: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3315: # ugly retro fix for broken version of types
3316: foreach my $key (keys %data) {
3317: if ($key=~/\wtype$/) {
3318: my $newkey=$key;
3319: $newkey=~s/type$/\.type/;
3320: $data{$newkey}=$data{$key};
3321: delete $data{$key};
3322: }
3323: }
1.391 www 3324: my %storecontent=();
1.389 www 3325: # go through all parameters and look for dates
3326: foreach my $key (keys %data) {
3327: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3328: my $newdate=$data{$key}+$shift;
1.391 www 3329: $storecontent{$key}=$newdate;
1.389 www 3330: }
3331: }
1.391 www 3332: my $reply=&Apache::lonnet::cput
3333: ('resourcedata',\%storecontent,$dom,$crs);
3334: if ($reply eq 'ok') {
3335: &log_parmset(\%storecontent);
3336: }
3337: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3338: return $reply;
1.389 www 3339: }
3340:
1.208 www 3341: sub newoverview {
1.280 albertel 3342: my ($r) = @_;
3343:
1.208 www 3344: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3345: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3346: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3347: text=>"Overview Mode"});
1.280 albertel 3348: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3349: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3350: $r->print(<<ENDOVER);
1.280 albertel 3351: $start_page
1.208 www 3352: $breadcrumbs
1.232 albertel 3353: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3354: ENDOVER
1.211 www 3355: my @ids=();
3356: my %typep=();
3357: my %keyp=();
3358: my %allparms=();
3359: my %allparts=();
3360: my %allmaps=();
3361: my %mapp=();
3362: my %symbp=();
3363: my %maptitles=();
3364: my %uris=();
3365: my %keyorder=&standardkeyorder();
3366: my %defkeytype=();
3367:
3368: my %alllevs=();
3369: $alllevs{'Resource Level'}='full';
1.215 www 3370: $alllevs{'Map/Folder Level'}='map';
1.211 www 3371: $alllevs{'Course Level'}='general';
3372:
3373: my $csec=$env{'form.csec'};
1.269 raeburn 3374: my $cgroup=$env{'form.cgroup'};
1.211 www 3375:
3376: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3377: my $pschp=$env{'form.pschp'};
3378: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3379: if (!@psprt) { $psprt[0]='0'; }
3380:
3381: my @selected_sections =
3382: &Apache::loncommon::get_env_multiple('form.Section');
3383: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3384: foreach my $sec (@selected_sections) {
3385: if ($sec eq 'all') {
1.211 www 3386: @selected_sections = ('all');
3387: }
3388: }
1.269 raeburn 3389: my @selected_groups =
3390: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3391:
3392: my $pssymb='';
3393: my $parmlev='';
3394:
3395: unless ($env{'form.parmlev'}) {
3396: $parmlev = 'map';
3397: } else {
3398: $parmlev = $env{'form.parmlev'};
3399: }
3400:
3401: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3402: \%mapp, \%symbp,\%maptitles,\%uris,
3403: \%keyorder,\%defkeytype);
3404:
1.374 albertel 3405: if (grep {$_ eq 'all'} (@psprt)) {
3406: @psprt = keys(%allparts);
3407: }
1.211 www 3408: # Menu to select levels, etc
3409:
1.317 albertel 3410: $r->print('<table id="LC_parm_overview_scope">
3411: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3412: &levelmenu($r,\%alllevs,$parmlev);
3413: if ($parmlev ne 'general') {
1.317 albertel 3414: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3415: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3416: $r->print('</td>');
3417: }
3418: $r->print('</td></tr></table>');
3419:
1.317 albertel 3420: $r->print('<table id="LC_parm_overview_controls">
3421: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3422: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3423: $r->print('</td><td class="LC_parm_overview_restrictions">
3424: <table class="LC_parm_overview_restrictions">'.
3425: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3426: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3427: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3428: $r->print('</td><td>');
1.211 www 3429: §ionmenu($r,\@selected_sections);
1.317 albertel 3430: $r->print('</td><td>');
1.269 raeburn 3431: &groupmenu($r,\@selected_groups);
3432: $r->print('</td></tr></table>');
1.214 www 3433: $r->print('</td></tr></table>');
3434:
3435: my $sortorder=$env{'form.sortorder'};
3436: unless ($sortorder) { $sortorder='realmstudent'; }
3437: &sortmenu($r,$sortorder);
3438:
3439: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3440:
3441: # Build the list data hash from the specified parms
3442:
3443: my $listdata;
3444: %{$listdata}=();
3445:
3446: foreach my $cat (@pscat) {
1.269 raeburn 3447: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3448: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3449: }
3450:
1.212 www 3451: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3452:
1.212 www 3453: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3454:
3455: # Read modified data
3456:
3457: my $resourcedata=&readdata($crs,$dom);
3458:
3459: # List data
3460:
1.214 www 3461: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3462: }
3463: $r->print(&tableend().
1.365 albertel 3464: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3465: '</form>'.&Apache::loncommon::end_page());
1.208 www 3466: }
3467:
1.269 raeburn 3468: sub secgroup_lister {
3469: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3470: foreach my $item (@{$selections}) {
3471: foreach my $part (@{$psprt}) {
3472: my $rootparmkey=$env{'request.course.id'};
3473: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3474: $rootparmkey.='.['.$item.']';
3475: }
3476: if ($parmlev eq 'general') {
3477: # course-level parameter
3478: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3479: $$listdata{$newparmkey}=1;
3480: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3481: } elsif ($parmlev eq 'map') {
3482: # map-level parameter
3483: foreach my $mapid (keys %{$allmaps}) {
3484: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3485: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3486: $$listdata{$newparmkey}=1;
3487: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3488: }
3489: } else {
3490: # resource-level parameter
3491: foreach my $rid (@{$ids}) {
3492: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3493: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3494: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3495: $$listdata{$newparmkey}=1;
3496: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3497: }
3498: }
3499: }
3500: }
3501: }
3502:
1.208 www 3503: sub overview {
1.280 albertel 3504: my ($r) = @_;
1.208 www 3505: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3506: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3507:
1.414 droeschl 3508: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3509: text=>"Overview Mode"});
1.280 albertel 3510: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3511: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3512: $r->print(<<ENDOVER);
1.280 albertel 3513: $start_page
1.208 www 3514: $breadcrumbs
1.232 albertel 3515: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3516: ENDOVER
3517: # Store modified
3518:
3519: &storedata($r,$crs,$dom);
3520:
3521: # Read modified data
3522:
3523: my $resourcedata=&readdata($crs,$dom);
3524:
1.214 www 3525:
3526: my $sortorder=$env{'form.sortorder'};
3527: unless ($sortorder) { $sortorder='realmstudent'; }
3528: &sortmenu($r,$sortorder);
3529:
1.208 www 3530: # List data
3531:
1.214 www 3532: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3533:
1.145 www 3534: $r->print(&tableend().'<p>'.
1.430 schafran 3535: ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':&mt('There are no parameters.')).'</p></form>'.
1.280 albertel 3536: &Apache::loncommon::end_page());
1.120 www 3537: }
1.121 www 3538:
1.333 albertel 3539: sub clean_parameters {
3540: my ($r) = @_;
3541: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3542: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3543:
1.414 droeschl 3544: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
3545: text=>"Clean Parameters"});
1.333 albertel 3546: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3547: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3548: $r->print(<<ENDOVER);
3549: $start_page
3550: $breadcrumbs
3551: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3552: ENDOVER
3553: # Store modified
3554:
3555: &storedata($r,$crs,$dom);
3556:
3557: # Read modified data
3558:
3559: my $resourcedata=&readdata($crs,$dom);
3560:
3561: # List data
3562:
3563: $r->print('<h3>'.
3564: &mt('These parameters refer to resources that do not exist.').
3565: '</h3>'.
1.415 schafran 3566: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
1.333 albertel 3567: '<br />');
3568: $r->print(&Apache::loncommon::start_data_table().
3569: '<tr>'.
3570: '<th>'.&mt('Delete').'</th>'.
3571: '<th>'.&mt('Parameter').'</th>'.
3572: '</tr>');
3573: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3574: next if (!exists($resourcedata->{$thiskey.'.type'})
3575: && $thiskey=~/\.type$/);
3576: my %data = &parse_key($thiskey);
1.383 albertel 3577: if (1) { #exists($data{'realm_exists'})
3578: #&& !$data{'realm_exists'}) {
1.333 albertel 3579: $r->print(&Apache::loncommon::start_data_table_row().
3580: '<tr>'.
3581: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3582:
3583: $r->print('<td>');
1.362 albertel 3584: my $display_value = $resourcedata->{$thiskey};
3585: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3586: $display_value =
3587: &Apache::lonlocal::locallocaltime($display_value);
3588: }
1.333 albertel 3589: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3590: &standard_parameter_names($data{'parameter_name'}),
3591: $resourcedata->{$thiskey}));
3592: $r->print('<br />');
3593: if ($data{'scope_type'} eq 'all') {
3594: $r->print(&mt('All users'));
3595: } elsif ($data{'scope_type'} eq 'user') {
3596: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3597: } elsif ($data{'scope_type'} eq 'section') {
3598: $r->print(&mt('Section: [_1]',$data{'scope'}));
3599: } elsif ($data{'scope_type'} eq 'group') {
3600: $r->print(&mt('Group: [_1]',$data{'scope'}));
3601: }
3602: $r->print('<br />');
3603: if ($data{'realm_type'} eq 'all') {
3604: $r->print(&mt('All Resources'));
3605: } elsif ($data{'realm_type'} eq 'folder') {
3606: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3607: } elsif ($data{'realm_type'} eq 'symb') {
3608: my ($map,$resid,$url) =
3609: &Apache::lonnet::decode_symb($data{'realm'});
3610: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3611: $url,$resid,$map));
3612: }
1.362 albertel 3613: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3614: $r->print('</td></tr>');
3615:
3616: }
3617: }
3618: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.415 schafran 3619: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.333 albertel 3620: '</p></form>'.
3621: &Apache::loncommon::end_page());
3622: }
3623:
1.390 www 3624: sub date_shift_one {
3625: my ($r) = @_;
3626: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3627: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3628:
1.414 droeschl 3629: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
3630: text=>"Shifting Dates"});
1.390 www 3631: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3632: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3633: $r->print(<<ENDOVER);
3634: $start_page
3635: $breadcrumbs
3636: ENDOVER
3637: $r->print('<form name="shiftform" method="post">'.
3638: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3639: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3640: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3641: &Apache::lonhtmlcommon::date_setter('shiftform',
3642: 'timeshifted',
3643: $env{'form.timebase'},,
3644: '').
3645: '</td></tr></table>'.
3646: '<input type="hidden" name="action" value="dateshift2" />'.
3647: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3648: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3649: $r->print(&Apache::loncommon::end_page());
3650: }
3651:
3652: sub date_shift_two {
3653: my ($r) = @_;
3654: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3655: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3656: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
3657: text=>"Shifting Dates"});
1.390 www 3658: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3659: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3660: $r->print(<<ENDOVER);
3661: $start_page
3662: $breadcrumbs
3663: ENDOVER
3664: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3665: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3666: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3667: &Apache::lonlocal::locallocaltime($timeshifted)));
3668: my $delta=$timeshifted-$env{'form.timebase'};
3669: &dateshift($delta);
3670: $r->print(&Apache::loncommon::end_page());
3671: }
3672:
1.333 albertel 3673: sub parse_key {
3674: my ($key) = @_;
3675: my %data;
3676: my ($middle,$part,$name)=
3677: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3678: $data{'scope_type'} = 'all';
3679: if ($middle=~/^\[(.*)\]/) {
3680: $data{'scope'} = $1;
1.350 albertel 3681: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3682: $data{'scope_type'} = 'user';
3683: $data{'scope'} = [$1,$2];
3684: } else {
3685: #FIXME check for group scope
3686: $data{'scope_type'} = 'section';
3687: }
3688: $middle=~s/^\[(.*)\]//;
3689: }
3690: $middle=~s/\.+$//;
3691: $middle=~s/^\.+//;
3692: $data{'realm_type'}='all';
3693: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3694: $data{'realm'} = $1;
3695: $data{'realm_type'} = 'folder';
3696: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3697: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3698: } elsif ($middle) {
3699: $data{'realm'} = $middle;
3700: $data{'realm_type'} = 'symb';
3701: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3702: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3703: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3704: }
3705:
3706: $data{'parameter_part'} = $part;
3707: $data{'parameter_name'} = $name;
3708:
3709: return %data;
3710: }
3711:
1.239 raeburn 3712:
1.178 raeburn 3713:
1.239 raeburn 3714: sub extract_cloners {
3715: my ($clonelist,$allowclone) = @_;
3716: if ($clonelist =~ /,/) {
1.380 albertel 3717: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3718: } else {
3719: $$allowclone[0] = $clonelist;
3720: }
3721: }
3722:
3723: sub check_cloners {
3724: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3725: my ($clean_clonelist,%disallowed);
1.239 raeburn 3726: my @allowclone = ();
3727: &extract_cloners($$clonelist,\@allowclone);
3728: foreach my $currclone (@allowclone) {
1.380 albertel 3729: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3730: if ($currclone eq '*') {
3731: $clean_clonelist .= $currclone.',';
3732: } else {
3733: my ($uname,$udom) = split(/:/,$currclone);
3734: if ($uname eq '*') {
3735: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3736: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3737: $disallowed{'domain'} .= $currclone.',';
3738: } else {
3739: $clean_clonelist .= $currclone.',';
3740: }
3741: } else {
3742: $disallowed{'format'} .= $currclone.',';
3743: }
3744: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3745: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3746: } else {
1.379 raeburn 3747: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3748: $disallowed{'newuser'} .= $currclone.',';
3749: } else {
3750: $clean_clonelist .= $currclone.',';
3751: }
1.239 raeburn 3752: }
3753: }
3754: } else {
3755: $clean_clonelist .= $currclone.',';
3756: }
3757: }
1.379 raeburn 3758: foreach my $key (keys(%disallowed)) {
3759: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3760: }
3761: if ($clean_clonelist) {
3762: $clean_clonelist =~ s/,$//;
3763: }
3764: $$clonelist = $clean_clonelist;
1.379 raeburn 3765: return %disallowed;
3766: }
1.178 raeburn 3767:
3768: sub change_clone {
3769: my ($clonelist,$oldcloner) = @_;
3770: my ($uname,$udom);
1.190 albertel 3771: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3772: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3773: my $clone_crs = $cnum.':'.$cdom;
3774:
3775: if ($cnum && $cdom) {
1.239 raeburn 3776: my @allowclone;
3777: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 3778: foreach my $currclone (@allowclone) {
1.380 albertel 3779: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 3780: if ($currclone ne '*') {
1.380 albertel 3781: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 3782: if ($uname && $udom && $uname ne '*') {
3783: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3784: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3785: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3786: if ($currclonecrs{'cloneable'} eq '') {
3787: $currclonecrs{'cloneable'} = $clone_crs;
3788: } else {
3789: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3790: }
3791: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 3792: }
3793: }
3794: }
3795: }
3796: }
3797: }
3798: foreach my $oldclone (@$oldcloner) {
1.380 albertel 3799: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 3800: if ($oldclone ne '*') {
1.380 albertel 3801: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 3802: if ($uname && $udom && $uname ne '*' ) {
3803: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3804: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3805: my %newclonecrs = ();
3806: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3807: if ($currclonecrs{'cloneable'} =~ /,/) {
3808: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3809: foreach my $crs (@currclonecrs) {
3810: if ($crs ne $clone_crs) {
3811: $newclonecrs{'cloneable'} .= $crs.',';
3812: }
1.178 raeburn 3813: }
1.379 raeburn 3814: $newclonecrs{'cloneable'} =~ s/,$//;
3815: } else {
3816: $newclonecrs{'cloneable'} = '';
1.178 raeburn 3817: }
1.379 raeburn 3818: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 3819: }
3820: }
3821: }
3822: }
3823: }
3824: }
3825: }
3826: }
3827:
1.193 albertel 3828:
3829:
1.416 jms 3830: sub header {
3831: return &Apache::loncommon::start_page('Parameter Manager');
3832: }
1.193 albertel 3833:
3834:
3835:
3836: sub print_main_menu {
3837: my ($r,$parm_permission)=@_;
3838: #
1.414 droeschl 3839: $r->print(&header());
3840: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 3841: $r->print(<<ENDMAINFORMHEAD);
3842: <form method="post" enctype="multipart/form-data"
3843: action="/adm/parmset" name="studentform">
3844: ENDMAINFORMHEAD
3845: #
1.195 albertel 3846: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3847: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3848: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3849: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 3850:
1.417 droeschl 3851:
1.193 albertel 3852: my @menu =
1.417 droeschl 3853: ( { categorytitle=>'Settings for this Course',
1.414 droeschl 3854: items => [
1.417 droeschl 3855: { linktext => 'Course Environment',
1.414 droeschl 3856: url => '/adm/parmset?action=crsenv',
3857: permission => $parm_permission,
1.417 droeschl 3858: linktitle =>'Edit environment settings for this course.' ,
3859: icon => 'preferences-desktop-remote-desktop.png' ,
3860: #help => 'Course_Environment',
1.414 droeschl 3861: },
1.417 droeschl 3862: { linktext => 'Portfolio Metadata',
1.414 droeschl 3863: url => '/adm/parmset?action=setrestrictmeta',
3864: permission => $parm_permission,
1.417 droeschl 3865: linktitle => 'Restrict metadata for this course.' ,
3866: icon =>'contact-new.png' ,
1.414 droeschl 3867: },
3868: { linktext => 'Manage Course Slots',
3869: url => '/adm/slotrequest?command=showslots',
3870: permission => $vgr,
1.417 droeschl 3871: linktitle =>'Manage slots for this course.' ,
3872: icon => 'format-justify-fill.png' ,
1.414 droeschl 3873: },
3874: { linktext => 'Reset Student Access Times',
3875: url => '/adm/helper/resettimes.helper',
3876: permission => $mgr,
1.417 droeschl 3877: linktitle =>'Reset access times for folders/maps, resources or the course.' ,
3878: icon => 'start-here.png' ,
1.414 droeschl 3879: },
3880:
3881: { linktext => 'Set Parameter Setting Default Actions',
3882: url => '/adm/parmset?action=setdefaults',
3883: permission => $parm_permission,
1.417 droeschl 3884: linktitle =>'Set default actions for parameters.' ,
3885: icon => 'folder-new.png' ,
1.414 droeschl 3886: }]},
1.417 droeschl 3887: { categorytitle => 'New and Existing Parameter Settings for Resources',
1.414 droeschl 3888: items => [
1.417 droeschl 3889: { linktext => 'Edit Resource Parameters - Helper Mode',
1.414 droeschl 3890: url => '/adm/helper/parameter.helper',
3891: permission => $parm_permission,
1.417 droeschl 3892: linktitle =>'Set/Modify resource parameters in helper mode.' ,
3893: icon => 'dialog-information.png' ,
3894: #help => 'Parameter_Helper',
1.414 droeschl 3895: },
1.417 droeschl 3896: { linktext => 'Edit Resource Parameters - Overview Mode',
1.414 droeschl 3897: url => '/adm/parmset?action=newoverview',
3898: permission => $parm_permission,
1.417 droeschl 3899: linktitle =>'Set/Modify resource parameters in overview mode.' ,
3900: icon => 'edit-find.png' ,
3901: #help => 'Parameter_Overview',
1.414 droeschl 3902: },
1.417 droeschl 3903: { linktext => 'Edit Resource Parameters - Table Mode',
1.414 droeschl 3904: url => '/adm/parmset?action=settable',
3905: permission => $parm_permission,
1.417 droeschl 3906: linktitle =>'Set/Modify resource parameters in table mode.' ,
3907: icon => 'edit-copy.png' ,
3908: #help => 'Table_Mode',
1.414 droeschl 3909: }]},
1.417 droeschl 3910: { categorytitle => 'Existing Parameter Settings for Resources',
1.414 droeschl 3911: items => [
3912: { linktext => 'Modify Resource Parameters - Overview Mode',
3913: url => '/adm/parmset?action=setoverview',
3914: permission => $parm_permission,
1.417 droeschl 3915: linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
3916: icon => 'preferences-desktop-wallpaper.png' ,
3917: #help => 'Parameter_Overview',
1.414 droeschl 3918: },
1.417 droeschl 3919: { linktext => 'Change Log',
1.414 droeschl 3920: url => '/adm/parmset?action=parameterchangelog',
3921: permission => $parm_permission,
1.417 droeschl 3922: linktitle =>'View parameter and course blog posting/user notification change log.' ,
3923: icon => 'emblem-system.png' ,
1.414 droeschl 3924: }]}
1.193 albertel 3925: );
1.414 droeschl 3926: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.193 albertel 3927: return;
3928: }
1.414 droeschl 3929:
1.416 jms 3930:
3931:
1.252 banghart 3932: sub output_row {
1.347 banghart 3933: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3934: my $output;
1.263 banghart 3935: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3936: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3937: if (!defined($options)) {
1.254 banghart 3938: $options = 'active,stuadd';
1.261 banghart 3939: $values = '';
1.252 banghart 3940: }
1.337 banghart 3941: if (!($options =~ /deleted/)) {
3942: my @options= ( ['active', 'Show to student'],
1.418 schafran 3943: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 3944: ['choices','Provide choices for students to select from']);
3945: # ['onlyone','Student may select only one choice']);
1.337 banghart 3946: if ($added_flag) {
3947: push @options,['deleted', 'Delete Metadata Field'];
3948: }
1.351 banghart 3949: $output = &Apache::loncommon::start_data_table_row();
3950: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
3951: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3952: foreach my $opt (@options) {
3953: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 3954: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 3955: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
3956: <input type="checkbox" name="'.
3957: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3958: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 3959: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3960: }
1.351 banghart 3961: $output .= &Apache::loncommon::continue_data_table_row();
3962: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
3963: $output .= &Apache::loncommon::end_data_table_row();
3964: my $multiple_checked;
3965: my $single_checked;
3966: if ($options =~ m/onlyone/) {
1.422 bisitz 3967: $multiple_checked = '';
1.423 bisitz 3968: $single_checked = ' checked="checked"';
1.351 banghart 3969: } else {
1.423 bisitz 3970: $multiple_checked = ' checked="checked"';
1.422 bisitz 3971: $single_checked = '';
1.351 banghart 3972: }
3973: $output .= &Apache::loncommon::continue_data_table_row();
3974: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.423 bisitz 3975: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
1.418 schafran 3976: '.&mt('Student may select multiple choices from list').'</span></td>';
1.351 banghart 3977: $output .= &Apache::loncommon::end_data_table_row();
3978: $output .= &Apache::loncommon::continue_data_table_row();
3979: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.423 bisitz 3980: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
1.418 schafran 3981: '.&mt('Student may select only one choice from list').'</span></td>';
1.351 banghart 3982: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3983: }
3984: return ($output);
3985: }
1.416 jms 3986:
3987:
3988:
1.340 banghart 3989: sub order_meta_fields {
3990: my ($r)=@_;
3991: my $idx = 1;
3992: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3993: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3994: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 3995: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
3996: text=>"Add Metadata Field"});
1.345 banghart 3997: &Apache::lonhtmlcommon::add_breadcrumb
3998: ({href=>"/adm/parmset?action=setrestrictmeta",
3999: text=>"Restrict Metadata"},
4000: {text=>"Order Metadata"});
4001: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 4002: if ($env{'form.storeorder'}) {
4003: my $newpos = $env{'form.newpos'} - 1;
4004: my $currentpos = $env{'form.currentpos'} - 1;
4005: my @neworder = ();
4006: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
4007: my $i;
1.341 banghart 4008: if ($newpos > $currentpos) {
1.340 banghart 4009: # moving stuff up
4010: for ($i=0;$i<$currentpos;$i++) {
4011: $neworder[$i]=$oldorder[$i];
4012: }
4013: for ($i=$currentpos;$i<$newpos;$i++) {
4014: $neworder[$i]=$oldorder[$i+1];
4015: }
4016: $neworder[$newpos]=$oldorder[$currentpos];
4017: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
4018: $neworder[$i]=$oldorder[$i];
4019: }
4020: } else {
4021: # moving stuff down
4022: for ($i=0;$i<$newpos;$i++) {
4023: $neworder[$i]=$oldorder[$i];
4024: }
4025: $neworder[$newpos]=$oldorder[$currentpos];
4026: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
4027: $neworder[$i]=$oldorder[$i-1];
4028: }
4029: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
4030: $neworder[$i]=$oldorder[$i];
4031: }
4032: }
4033: my $ordered_fields = join ",", @neworder;
1.343 banghart 4034: my $put_result = &Apache::lonnet::put('environment',
4035: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 4036: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 4037: }
1.357 raeburn 4038: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 4039: my $ordered_fields;
1.340 banghart 4040: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
4041: if (!@fields_in_order) {
4042: # no order found, pick sorted order then create metadata.addedorder key.
4043: foreach my $key (sort keys %$fields) {
4044: push @fields_in_order, $key;
1.341 banghart 4045: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 4046: }
1.341 banghart 4047: my $put_result = &Apache::lonnet::put('environment',
4048: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
4049: }
1.340 banghart 4050: $r->print('<table>');
4051: my $num_fields = scalar(@fields_in_order);
4052: foreach my $key (@fields_in_order) {
4053: $r->print('<tr><td>');
4054: $r->print('<form method="post" action="">');
4055: $r->print('<select name="newpos" onChange="this.form.submit()">');
4056: for (my $i = 1;$i le $num_fields;$i ++) {
4057: if ($i eq $idx) {
4058: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
4059: } else {
4060: $r->print('<option value="'.$i.'">'.$i.'</option>');
4061: }
4062: }
4063: $r->print('</select></td><td>');
4064: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
4065: $r->print('<input type="hidden" name="storeorder" value="true" />');
4066: $r->print('</form>');
4067: $r->print($$fields{$key}.'</td></tr>');
4068: $idx ++;
4069: }
4070: $r->print('</table>');
4071: return 'ok';
4072: }
1.416 jms 4073:
4074:
1.359 banghart 4075: sub continue {
4076: my $output;
4077: $output .= '<form action="" method="post">';
4078: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
4079: $output .= '<input type="submit" value="Continue" />';
4080: return ($output);
4081: }
1.416 jms 4082:
4083:
1.334 banghart 4084: sub addmetafield {
4085: my ($r)=@_;
1.414 droeschl 4086: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4087: text=>"Add Metadata Field"});
1.334 banghart 4088: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
4089: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 4090: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4091: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 4092: if (exists($env{'form.undelete'})) {
1.358 banghart 4093: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 4094: foreach my $meta_field(@meta_fields) {
4095: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
4096: $options =~ s/deleted//;
4097: $options =~ s/,,/,/;
4098: my $put_result = &Apache::lonnet::put('environment',
4099: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
4100:
4101: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
4102: }
1.359 banghart 4103: $r->print(&continue());
1.339 banghart 4104: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 4105: my $meta_field = $env{'form.fieldname'};
4106: my $display_field = $env{'form.fieldname'};
4107: $meta_field =~ s/\W/_/g;
1.338 banghart 4108: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 4109: my $put_result = &Apache::lonnet::put('environment',
4110: {'metadata.'.$meta_field.'.values'=>"",
4111: 'metadata.'.$meta_field.'.added'=>"$display_field",
4112: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 4113: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
4114: $r->print(&continue());
1.335 banghart 4115: } else {
1.357 raeburn 4116: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 4117: if ($fields) {
4118: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
4119: $r->print('<form method="post" action="">');
4120: foreach my $key(keys(%$fields)) {
1.358 banghart 4121: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 4122: }
4123: $r->print('<input type="submit" name="undelete" value="Undelete" />');
4124: $r->print('</form>');
4125: }
4126: $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 4127: $r->print('<input type="text" name="fieldname" /><br />');
4128: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4129: }
1.361 albertel 4130: $r->print('</form>');
1.334 banghart 4131: }
1.416 jms 4132:
4133:
4134:
1.259 banghart 4135: sub setrestrictmeta {
1.240 banghart 4136: my ($r)=@_;
1.242 banghart 4137: my $next_meta;
1.244 banghart 4138: my $output;
1.245 banghart 4139: my $item_num;
1.246 banghart 4140: my $put_result;
1.414 droeschl 4141: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4142: text=>"Restrict Metadata"});
1.280 albertel 4143: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4144: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4145: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4146: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4147: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4148: my $save_field = '';
1.259 banghart 4149: if ($env{'form.restrictmeta'}) {
1.254 banghart 4150: foreach my $field (sort(keys(%env))) {
1.252 banghart 4151: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4152: my $options;
1.252 banghart 4153: my $meta_field = $1;
4154: my $meta_key = $2;
1.253 banghart 4155: if ($save_field ne $meta_field) {
1.252 banghart 4156: $save_field = $meta_field;
1.253 banghart 4157: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 4158: $options.='stuadd,';
4159: }
1.351 banghart 4160: if ($env{'form.'.$meta_field.'_choices'}) {
4161: $options.='choices,';
4162: }
4163: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 4164: $options.='onlyone,';
4165: }
4166: if ($env{'form.'.$meta_field.'_active'}) {
4167: $options.='active,';
1.253 banghart 4168: }
1.337 banghart 4169: if ($env{'form.'.$meta_field.'_deleted'}) {
4170: $options.='deleted,';
4171: }
1.259 banghart 4172: my $name = $save_field;
1.253 banghart 4173: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4174: {'metadata.'.$meta_field.'.options'=>$options,
4175: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4176: },$dom,$crs);
1.252 banghart 4177: }
4178: }
4179: }
4180: }
1.296 albertel 4181: &Apache::lonnet::coursedescription($env{'request.course.id'},
4182: {'freshen_cache' => 1});
1.335 banghart 4183: # Get the default metadata fields
1.258 albertel 4184: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4185: # Now get possible added metadata fields
1.357 raeburn 4186: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4187: my $row_alt = 1;
1.347 banghart 4188: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4189: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4190: if ($field ne 'courserestricted') {
1.346 banghart 4191: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 4192: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 4193: }
1.255 banghart 4194: }
1.351 banghart 4195: my $buttons = (<<ENDButtons);
4196: <input type="submit" name="restrictmeta" value="Save" />
4197: </form><br />
4198: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4199: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4200: </form>
4201: <br />
4202: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4203: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4204: ENDButtons
1.337 banghart 4205: my $added_flag = 1;
1.335 banghart 4206: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4207: $row_alt = $row_alt ? 0 : 1;
4208: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4209: }
1.347 banghart 4210: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 4211: $r->print(<<ENDenv);
1.259 banghart 4212: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4213: $output
1.351 banghart 4214: $buttons
1.340 banghart 4215: </form>
1.244 banghart 4216: ENDenv
1.280 albertel 4217: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4218: return 'ok';
4219: }
1.416 jms 4220:
4221:
4222:
1.335 banghart 4223: sub get_added_meta_fieldnames {
1.357 raeburn 4224: my ($cid) = @_;
1.335 banghart 4225: my %fields;
4226: foreach my $key(%env) {
1.357 raeburn 4227: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4228: my $field_name = $1;
4229: my ($display_field_name) = $env{$key};
4230: $fields{$field_name} = $display_field_name;
4231: }
4232: }
4233: return \%fields;
4234: }
1.416 jms 4235:
4236:
4237:
1.339 banghart 4238: sub get_deleted_meta_fieldnames {
1.357 raeburn 4239: my ($cid) = @_;
1.339 banghart 4240: my %fields;
4241: foreach my $key(%env) {
1.357 raeburn 4242: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4243: my $field_name = $1;
4244: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4245: my ($display_field_name) = $env{$key};
4246: $fields{$field_name} = $display_field_name;
4247: }
4248: }
4249: }
4250: return \%fields;
4251: }
1.220 www 4252: sub defaultsetter {
1.280 albertel 4253: my ($r) = @_;
4254:
1.414 droeschl 4255: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4256: text=>"Set Defaults"});
1.280 albertel 4257: my $start_page =
4258: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4259: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4260: $r->print(<<ENDDEFHEAD);
1.280 albertel 4261: $start_page
1.220 www 4262: $breadcrumbs
4263: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4264: ENDDEFHEAD
1.280 albertel 4265:
4266: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4267: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4268: my @ids=();
4269: my %typep=();
4270: my %keyp=();
4271: my %allparms=();
4272: my %allparts=();
4273: my %allmaps=();
4274: my %mapp=();
4275: my %symbp=();
4276: my %maptitles=();
4277: my %uris=();
4278: my %keyorder=&standardkeyorder();
4279: my %defkeytype=();
4280:
4281: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4282: \%mapp, \%symbp,\%maptitles,\%uris,
4283: \%keyorder,\%defkeytype);
1.224 www 4284: if ($env{'form.storerules'}) {
4285: my %newrules=();
4286: my @delrules=();
1.226 www 4287: my %triggers=();
1.225 albertel 4288: foreach my $key (keys(%env)) {
4289: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4290: my $tempkey=$1;
1.226 www 4291: my $action=$env{$key};
4292: if ($action) {
4293: $newrules{$tempkey.'_action'}=$action;
4294: if ($action ne 'default') {
4295: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4296: $triggers{$whichparm}.=$tempkey.':';
4297: }
4298: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4299: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4300: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4301: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4302: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4303: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4304: } else {
4305: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4306: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4307: }
4308: } else {
1.225 albertel 4309: push(@delrules,$tempkey.'_action');
1.226 www 4310: push(@delrules,$tempkey.'_type');
1.225 albertel 4311: push(@delrules,$tempkey.'_hours');
4312: push(@delrules,$tempkey.'_min');
4313: push(@delrules,$tempkey.'_sec');
4314: push(@delrules,$tempkey.'_value');
1.224 www 4315: }
4316: }
4317: }
1.226 www 4318: foreach my $key (keys %allparms) {
4319: $newrules{$key.'_triggers'}=$triggers{$key};
4320: }
1.224 www 4321: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4322: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4323: &resetrulescache();
4324: }
1.227 www 4325: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4326: 'hours' => 'Hours',
1.221 www 4327: 'min' => 'Minutes',
4328: 'sec' => 'Seconds',
4329: 'yes' => 'Yes',
4330: 'no' => 'No');
1.222 www 4331: my @standardoptions=('','default');
4332: my @standarddisplay=('',&mt('Default value when manually setting'));
4333: my @dateoptions=('','default');
4334: my @datedisplay=('',&mt('Default value when manually setting'));
4335: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4336: unless ($tempkey) { next; }
4337: push @standardoptions,'when_setting_'.$tempkey;
4338: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4339: if (&isdateparm($defkeytype{$tempkey})) {
4340: push @dateoptions,'later_than_'.$tempkey;
4341: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4342: push @dateoptions,'earlier_than_'.$tempkey;
4343: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4344: }
4345: }
1.231 www 4346: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4347: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4348: $r->print("\n".&Apache::loncommon::start_data_table().
4349: &Apache::loncommon::start_data_table_header_row().
4350: "<th>".&mt('Rule for parameter').'</th><th>'.
4351: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4352: &Apache::loncommon::end_data_table_header_row());
1.221 www 4353: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4354: unless ($tempkey) { next; }
1.318 albertel 4355: $r->print("\n".&Apache::loncommon::start_data_table_row().
4356: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4357: my $action=&rulescache($tempkey.'_action');
4358: $r->print('<select name="'.$tempkey.'_action">');
4359: if (&isdateparm($defkeytype{$tempkey})) {
4360: for (my $i=0;$i<=$#dateoptions;$i++) {
4361: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4362: $r->print("\n<option value='$dateoptions[$i]'".
4363: ($dateoptions[$i] eq $action?' selected="selected"':'').
4364: ">$datedisplay[$i]</option>");
4365: }
4366: } else {
4367: for (my $i=0;$i<=$#standardoptions;$i++) {
4368: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4369: $r->print("\n<option value='$standardoptions[$i]'".
4370: ($standardoptions[$i] eq $action?' selected="selected"':'').
4371: ">$standarddisplay[$i]</option>");
4372: }
4373: }
4374: $r->print('</select>');
1.227 www 4375: unless (&isdateparm($defkeytype{$tempkey})) {
4376: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4377: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4378: }
1.222 www 4379: $r->print("\n</td><td>\n");
4380:
1.221 www 4381: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4382: my $days=&rulescache($tempkey.'_days');
1.222 www 4383: my $hours=&rulescache($tempkey.'_hours');
4384: my $min=&rulescache($tempkey.'_min');
4385: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4386: $r->print(<<ENDINPUTDATE);
1.227 www 4387: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4388: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4389: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4390: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4391: ENDINPUTDATE
4392: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4393: my $yeschecked='';
4394: my $nochecked='';
4395: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4396: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4397:
1.221 www 4398: $r->print(<<ENDYESNO);
1.224 www 4399: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4400: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4401: ENDYESNO
4402: } else {
1.224 www 4403: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4404: }
1.318 albertel 4405: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4406: }
1.318 albertel 4407: $r->print(&Apache::loncommon::end_data_table().
1.419 bisitz 4408: "\n".'<input type="submit" name="storerules" value="'.
1.430 schafran 4409: &mt('Save').'" /></form>'."\n".
1.280 albertel 4410: &Apache::loncommon::end_page());
1.220 www 4411: return;
4412: }
1.193 albertel 4413:
1.290 www 4414: sub components {
1.330 albertel 4415: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4416:
4417: if ($typeflag) {
1.290 www 4418: $key=~s/\.type$//;
4419: }
1.330 albertel 4420:
4421: my ($middle,$part,$name)=
4422: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4423: my $issection;
1.330 albertel 4424:
1.290 www 4425: my $section=&mt('All Students');
4426: if ($middle=~/^\[(.*)\]/) {
1.291 www 4427: $issection=$1;
4428: $section=&mt('Group/Section').': '.$issection;
1.290 www 4429: $middle=~s/^\[(.*)\]//;
4430: }
4431: $middle=~s/\.+$//;
4432: $middle=~s/^\.+//;
1.291 www 4433: if ($uname) {
4434: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4435: $issection='';
4436: }
1.316 albertel 4437: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4438: my $realmdescription=&mt('all resources');
1.290 www 4439: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4440: $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 4441: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4442: } elsif ($middle) {
1.290 www 4443: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4444: $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 4445: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4446: }
1.291 www 4447: my $what=$part.'.'.$name;
1.330 albertel 4448: return ($realm,$section,$name,$part,
1.304 www 4449: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4450: }
1.293 www 4451:
1.328 albertel 4452: my %standard_parms;
1.416 jms 4453:
4454:
1.328 albertel 4455: sub load_parameter_names {
4456: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4457: while (my $configline=<$config>) {
4458: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4459: chomp($configline);
4460: my ($short,$plain)=split(/:/,$configline);
4461: my (undef,$name,$type)=split(/\&/,$short,3);
4462: if ($type eq 'display') {
4463: $standard_parms{$name} = $plain;
4464: }
4465: }
4466: close($config);
4467: $standard_parms{'int_pos'} = 'Positive Integer';
4468: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4469: %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
4470: }
4471:
1.292 www 4472: sub standard_parameter_names {
4473: my ($name)=@_;
1.328 albertel 4474: if (!%standard_parms) {
4475: &load_parameter_names();
4476: }
1.292 www 4477: if ($standard_parms{$name}) {
4478: return $standard_parms{$name};
4479: } else {
4480: return $name;
4481: }
4482: }
1.290 www 4483:
1.309 www 4484:
4485:
1.285 albertel 4486: sub parm_change_log {
1.284 www 4487: my ($r)=@_;
1.414 droeschl 4488: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
4489: text=>"Parameter Change Log"});
1.327 albertel 4490: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4491: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4492:
1.286 www 4493: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4494: $env{'course.'.$env{'request.course.id'}.'.domain'},
4495: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4496:
1.301 www 4497: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4498:
1.327 albertel 4499: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4500: method="post" name="parameterlog">');
1.311 albertel 4501:
4502: my %saveable_parameters = ('show' => 'scalar',);
4503: &Apache::loncommon::store_course_settings('parameter_log',
4504: \%saveable_parameters);
4505: &Apache::loncommon::restore_course_settings('parameter_log',
4506: \%saveable_parameters);
1.348 www 4507: $r->print(&Apache::loncommon::display_filter().
1.326 www 4508: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4509: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4510: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4511:
1.291 www 4512: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4513: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4514: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4515: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4516: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4517: &Apache::loncommon::end_data_table_header_row());
1.309 www 4518: my $shown=0;
1.349 www 4519: my $folder='';
4520: if ($env{'form.displayfilter'} eq 'currentfolder') {
4521: my $last='';
4522: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4523: &GDBM_READER(),0640)) {
4524: $last=$hash{'last_known'};
4525: untie(%hash);
4526: }
4527: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4528: }
1.356 albertel 4529: foreach my $id (sort
4530: {
4531: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4532: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4533: }
4534: my $aid = (split('00000',$a))[-1];
4535: my $bid = (split('00000',$b))[-1];
4536: return $bid<=>$aid;
4537: } (keys(%parmlog))) {
1.294 www 4538: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4539: my $count = 0;
1.288 albertel 4540: my $time =
1.294 www 4541: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4542: my $plainname =
1.294 www 4543: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4544: $parmlog{$id}{'exe_udom'});
1.288 albertel 4545: my $about_me_link =
1.289 www 4546: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4547: $parmlog{$id}{'exe_uname'},
4548: $parmlog{$id}{'exe_udom'});
1.293 www 4549: my $send_msg_link='';
1.294 www 4550: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4551: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4552: $send_msg_link ='<br />'.
1.288 albertel 4553: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4554: $parmlog{$id}{'exe_uname'},
4555: $parmlog{$id}{'exe_udom'});
1.288 albertel 4556: }
1.301 www 4557: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4558: my $makenewrow=0;
4559: my %istype=();
1.332 albertel 4560: my $output;
1.293 www 4561: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4562: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4563: my $typeflag = ($changed =~/\.type$/ &&
4564: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4565: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4566: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4567: if ($env{'form.displayfilter'} eq 'currentfolder') {
4568: if ($folder) {
4569: if ($middle!~/^\Q$folder\E/) { next; }
4570: }
4571: }
1.326 www 4572: if ($typeflag) {
1.329 albertel 4573: $istype{$parmname}=$value;
1.326 www 4574: if (!$env{'form.includetypes'}) { next; }
4575: }
1.332 albertel 4576: $count++;
4577: if ($makenewrow) {
4578: $output .= $row_start;
4579: } else {
4580: $makenewrow=1;
4581: }
4582: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 4583: &standard_parameter_names($parmname).'</td><td>'.
1.332 albertel 4584: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4585: my $stillactive=0;
1.332 albertel 4586: if ($parmlog{$id}{'delflag'}) {
4587: $output .= &mt('Deleted');
1.288 albertel 4588: } else {
1.290 www 4589: if ($typeflag) {
1.332 albertel 4590: $output .= &mt('Type: [_1]',&standard_parameter_names($value));
1.290 www 4591: } else {
1.291 www 4592: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4593: $uname,$udom,$issection,$issection,$courseopt);
4594: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4595: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4596: } else {
1.332 albertel 4597: $output .= $value;
1.291 www 4598: }
4599: if ($value ne $all[$level]) {
1.332 albertel 4600: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4601: } else {
4602: $stillactive=1;
4603: }
1.290 www 4604: }
1.288 albertel 4605: }
1.332 albertel 4606: $output .= '</td><td>';
1.291 www 4607: if ($stillactive) {
1.304 www 4608: my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
4609: my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
4610: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4611: if (($uname) && ($udom)) {
1.332 albertel 4612: $output .=
4613: &Apache::loncommon::messagewrapper('Notify User',
4614: $uname,$udom,$title,
4615: $description);
1.292 www 4616: } else {
1.332 albertel 4617: $output .=
4618: &Apache::lonrss::course_blog_link($id,$title,
4619: $description);
1.292 www 4620: }
1.291 www 4621: }
1.332 albertel 4622: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4623: }
1.349 www 4624: if ($env{'form.displayfilter'} eq 'containing') {
4625: my $wholeentry=$about_me_link.':'.
4626: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4627: $output;
4628: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4629: }
4630: if ($count) {
4631: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4632: <td rowspan="'.$count.'">'.$about_me_link.
4633: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4634: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4635: $send_msg_link.'</td>'.$output);
1.349 www 4636: $shown++;
4637: }
1.311 albertel 4638: if (!($env{'form.show'} eq &mt('all')
4639: || $shown<=$env{'form.show'})) { last; }
1.286 www 4640: }
1.301 www 4641: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4642: $r->print(&Apache::loncommon::end_page());
4643: }
4644:
1.355 albertel 4645: sub check_for_course_info {
4646: my $navmap = Apache::lonnavmaps::navmap->new();
4647: return 1 if ($navmap);
4648: return 0;
4649: }
4650:
1.259 banghart 4651:
1.30 www 4652: sub handler {
1.43 albertel 4653: my $r=shift;
1.30 www 4654:
1.376 albertel 4655: &reset_caches();
4656:
1.414 droeschl 4657: &Apache::loncommon::content_type($r,'text/html');
4658: $r->send_http_header;
4659: return OK if $r->header_only;
4660:
1.193 albertel 4661: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4662: ['action','state',
4663: 'pres_marker',
4664: 'pres_value',
1.206 www 4665: 'pres_type',
1.390 www 4666: 'udom','uname','symb','serial','timebase']);
1.131 www 4667:
1.83 bowersj2 4668:
1.193 albertel 4669: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4670: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4671: text=>"Parameter Manager",
1.204 www 4672: faq=>10,
1.324 www 4673: bug=>'Instructor Interface',
4674: help => 'Parameter_Manager'});
1.203 www 4675:
1.30 www 4676: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4677: my $parm_permission =
4678: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4679: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4680: $env{'request.course.sec'}));
1.355 albertel 4681: my $exists = &check_for_course_info();
4682:
4683: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4684: #
4685: # Main switch on form.action and form.state, as appropriate
4686: #
4687: # Check first if coming from someone else headed directly for
4688: # the table mode
4689: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
4690: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
4691: &assessparms($r);
4692: } elsif (! exists($env{'form.action'})) {
4693: &print_main_menu($r,$parm_permission);
1.414 droeschl 4694: } elsif ($env{'form.action'} eq 'crsenv') {
1.193 albertel 4695: &crsenv($r);
1.414 droeschl 4696: } elsif ($env{'form.action'} eq 'setoverview') {
1.121 www 4697: &overview($r);
1.414 droeschl 4698: } elsif ($env{'form.action'} eq 'addmetadata') {
1.334 banghart 4699: &addmetafield($r);
1.414 droeschl 4700: } elsif ($env{'form.action'} eq 'ordermetadata') {
1.340 banghart 4701: &order_meta_fields($r);
1.414 droeschl 4702: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.259 banghart 4703: &setrestrictmeta($r);
1.414 droeschl 4704: } elsif ($env{'form.action'} eq 'newoverview') {
1.208 www 4705: &newoverview($r);
1.414 droeschl 4706: } elsif ($env{'form.action'} eq 'setdefaults') {
1.220 www 4707: &defaultsetter($r);
1.414 droeschl 4708: } elsif ($env{'form.action'} eq 'settable') {
1.121 www 4709: &assessparms($r);
1.414 droeschl 4710: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.285 albertel 4711: &parm_change_log($r);
1.414 droeschl 4712: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.333 albertel 4713: &clean_parameters($r);
1.414 droeschl 4714: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 4715: &date_shift_one($r);
1.414 droeschl 4716: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 4717: &date_shift_two($r);
1.414 droeschl 4718: } elsif ($env{'form.action'} eq 'categorizecourse') {
1.403 raeburn 4719: &assign_course_categories($r);
4720: }
1.43 albertel 4721: } else {
1.1 www 4722: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 4723: if ($exists) {
4724: $env{'user.error.msg'}=
4725: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4726: } else {
4727: $env{'user.error.msg'}=
4728: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4729: }
1.43 albertel 4730: return HTTP_NOT_ACCEPTABLE;
4731: }
1.376 albertel 4732: &reset_caches();
4733:
1.43 albertel 4734: return OK;
1.1 www 4735: }
4736:
4737: 1;
4738: __END__
4739:
4740:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>