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