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