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