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