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