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