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