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