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