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