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