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