Annotation of loncom/interface/lonparmset.pm, revision 1.522.2.28.4.6
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.522.2.28.4. (raeburn 4:): # $Id: lonparmset.pm,v 1.522.2.28.4.5 2022/05/27 18:17:11 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:
1.522.2.25 raeburn 39: lonparmset provides an interface to setting content parameters in a
40: course.
1.59 matthew 41:
42: =head1 DESCRIPTION
43:
44: This module sets coursewide and assessment parameters.
45:
46: =head1 INTERNAL SUBROUTINES
47:
1.416 jms 48: =over
1.59 matthew 49:
1.416 jms 50: =item parmval()
1.59 matthew 51:
52: Figure out a cascading parameter.
53:
1.71 albertel 54: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 55: $id - a bighash Id number
1.71 albertel 56: $def - the resource's default value 'stupid emacs
57:
1.269 raeburn 58: 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 59:
1.306 albertel 60: 14- General Course
61: 13- Map or Folder level in course
1.269 raeburn 62: 12- resource default
63: 11- map default
1.306 albertel 64: 10- resource level in course
1.269 raeburn 65: 9 - General for section
66: 8 - Map or Folder level for section
67: 7 - resource level in section
68: 6 - General for group
69: 5 - Map or Folder level for group
70: 4 - resource level in group
1.71 albertel 71: 3 - General for specific student
1.82 www 72: 2 - Map or Folder level for specific student
1.71 albertel 73: 1 - resource level for specific student
1.2 www 74:
1.416 jms 75: =item parmval_by_symb()
76:
77: =item reset_caches()
78:
79: =item cacheparmhash()
80:
81: =item parmhash()
82:
83: =item symbcache()
84:
85: =item preset_defaults()
86:
87: =item date_sanity_info()
88:
89: =item storeparm()
90:
91: Store a parameter by symb
92:
93: Takes
94: - symb
95: - name of parameter
96: - level
97: - new value
98: - new type
99: - username
100: - userdomain
101:
102: =item log_parmset()
103:
104: =item storeparm_by_symb_inner()
105:
106: =item valout()
107:
108: Format a value for output.
109:
110: Inputs: $value, $type, $editable
111:
112: Returns: $value, formatted for output. If $type indicates it is a date,
113: localtime($value) is returned.
114: $editable will return an icon to click on
115:
116: =item plink()
117:
118: Produces a link anchor.
119:
120: Inputs: $type,$dis,$value,$marker,$return,$call
121:
122: Returns: scalar with html code for a link which will envoke the
123: javascript function 'pjump'.
124:
125: =item page_js()
126:
127: =item startpage()
128:
129: =item print_row()
130:
131: =item print_td()
132:
1.522.2.25 raeburn 133: =item check_other_groups()
1.416 jms 134:
135: =item parm_control_group()
136:
137: =item extractResourceInformation() :
138:
1.512 foxr 139: extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes.
1.416 jms 140:
1.522.2.11 raeburn 141: Input: See list below
142:
143: =over 4
1.416 jms 144:
1.512 foxr 145: =item * B<env{'user.name'}> : Current username
1.416 jms 146:
1.512 foxr 147: =item * B<env{'user.domain'}> : Domain of current user.
1.416 jms 148:
1.522.2.12 raeburn 149: =item * B<env{"request.course.fn"}> : Course
1.416 jms 150:
1.522.2.11 raeburn 151: =back
152:
153: Outputs: See list below
154:
155: =over 4
1.416 jms 156:
1.512 foxr 157: =item * B<ids> (out) : An array that will contain all of the ids in the course.
1.416 jms 158:
1.512 foxr 159: =item * B<typep>(out) : hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
1.416 jms 160:
1.512 foxr 161: =item * B<keyp> (out) : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
1.416 jms 162:
1.512 foxr 163: =item * B<allparms> (out) : hash, name of parameter->display value (what is the display value?)
1.416 jms 164:
1.512 foxr 165: =item * B<allparts> (out) : hash, part identification->text representation of part, where the text representation is "[Part $part]"
166:
167: =item * B<allmaps> (out) : hash, ???
1.416 jms 168:
169: =item * B<mapp> : ??
170:
171: =item * B<symbp> : hash, id->full sym?
172:
1.512 foxr 173: =item * B<maptitles>
174:
175: =item * B<uris>
1.416 jms 176:
1.512 foxr 177: =item * B<keyorder>
178:
179: =item * B<defkeytype>
1.416 jms 180:
1.522.2.11 raeburn 181: =back
182:
1.416 jms 183: =item isdateparm()
184:
185: =item parmmenu()
186:
187: =item partmenu()
188:
189: =item usermenu()
190:
191: =item displaymenu()
192:
193: =item mapmenu()
194:
195: =item levelmenu()
196:
197: =item sectionmenu()
198:
199: =item keysplit()
200:
201: =item keysinorder()
202:
203: =item keysinorder_bytype()
204:
205: =item keysindisplayorder()
206:
207: =item standardkeyorder()
208:
209: =item assessparms() :
210:
211: Show assessment data and parameters. This is a large routine that should
212: be simplified and shortened... someday.
213:
1.513 foxr 214: Inputs: $r - the Apache request object.
215:
1.416 jms 216: Returns: nothing
217:
218: Variables used (guessed by Jeremy):
219:
1.522.2.11 raeburn 220: =over
221:
1.416 jms 222: =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.
223:
224: =item * B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
225:
226: =item * B<@catmarker> contains list of all possible parameters including part #s
227:
228: =item * B<$fullkeyp> contains the full part/id # for the extraction of proper parameters
229:
230: =item * B<$tempkeyp> contains part 0 only (no ids - ie, subparts)
231: When storing information, store as part 0
232: When requesting information, request from full part
233:
1.522.2.11 raeburn 234: =back
235:
1.416 jms 236: =item tablestart()
237:
238: =item tableend()
239:
240: =item extractuser()
241:
242: =item parse_listdata_key()
243:
244: =item listdata()
245:
246: =item date_interval_selector()
247:
248: =item get_date_interval_from_form()
249:
250: =item default_selector()
251:
252: =item string_selector()
253:
254: =item dateshift()
255:
256: =item newoverview()
257:
258: =item secgroup_lister()
259:
260: =item overview()
261:
262: =item clean_parameters()
263:
264: =item date_shift_one()
265:
266: =item date_shift_two()
267:
268: =item parse_key()
269:
270: =item header()
271:
272: Output html header for page
273:
274: =item print_main_menu()
275:
276: =item output_row()
277:
278: Set portfolio metadata
279:
280: =item order_meta_fields()
281:
282: =item addmetafield()
283:
284: =item setrestrictmeta()
285:
286: =item get_added_meta_fieldnames()
287:
288: =item get_deleted_meta_fieldnames()
289:
290: =item defaultsetter()
291:
292: =item components()
293:
294: =item load_parameter_names()
295:
296: =item parm_change_log()
297:
298: =item handler() :
299:
1.450 raeburn 300: Main handler. Calls &assessparms subroutine.
1.416 jms 301:
302: =back
303:
1.59 matthew 304: =cut
305:
1.416 jms 306: ###################################################################
307: ###################################################################
308:
309: package Apache::lonparmset;
310:
311: use strict;
312: use Apache::lonnet;
313: use Apache::Constants qw(:common :http REDIRECT);
314: use Apache::lonhtmlcommon();
315: use Apache::loncommon;
316: use GDBM_File;
317: use Apache::lonhomework;
318: use Apache::lonxml;
319: use Apache::lonlocal;
320: use Apache::lonnavmaps;
321: use Apache::longroup;
322: use Apache::lonrss;
1.506 www 323: use HTML::Entities;
1.416 jms 324: use LONCAPA qw(:DEFAULT :match);
325:
326:
1.2 www 327: sub parmval {
1.275 raeburn 328: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
329: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
330: $cgroup,$courseopt);
1.201 www 331: }
332:
333: sub parmval_by_symb {
1.275 raeburn 334: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.200 www 335:
1.352 albertel 336: my $useropt;
337: if ($uname ne '' && $udom ne '') {
1.473 amueller 338: $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
1.352 albertel 339: }
1.200 www 340:
1.8 www 341: my $result='';
1.44 albertel 342: my @outpar=();
1.2 www 343: # ----------------------------------------------------- Cascading lookup scheme
1.446 bisitz 344: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 345: $map = &Apache::lonnet::deversion($map);
1.10 www 346:
1.201 www 347: my $symbparm=$symb.'.'.$what;
348: my $mapparm=$map.'___(all).'.$what;
1.10 www 349:
1.269 raeburn 350: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
351: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
352: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
353:
1.190 albertel 354: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
355: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
356: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
357:
358: my $courselevel=$env{'request.course.id'}.'.'.$what;
359: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
360: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 361:
1.11 www 362:
1.182 albertel 363: # --------------------------------------------------------- first, check course
1.11 www 364:
1.200 www 365: if (defined($$courseopt{$courselevel})) {
1.473 amueller 366: $outpar[14]=$$courseopt{$courselevel};
367: $result=14;
1.43 albertel 368: }
1.11 www 369:
1.200 www 370: if (defined($$courseopt{$courselevelm})) {
1.473 amueller 371: $outpar[13]=$$courseopt{$courselevelm};
372: $result=13;
1.43 albertel 373: }
1.11 www 374:
1.182 albertel 375: # ------------------------------------------------------- second, check default
376:
1.269 raeburn 377: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 378:
379: # ------------------------------------------------------ third, check map parms
380:
1.376 albertel 381: my $thisparm=&parmhash($symbparm);
1.269 raeburn 382: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 383:
1.200 www 384: if (defined($$courseopt{$courselevelr})) {
1.473 amueller 385: $outpar[10]=$$courseopt{$courselevelr};
386: $result=10;
1.43 albertel 387: }
1.11 www 388:
1.182 albertel 389: # ------------------------------------------------------ fourth, back to course
1.352 albertel 390: if ($csec ne '') {
1.200 www 391: if (defined($$courseopt{$seclevel})) {
1.473 amueller 392: $outpar[9]=$$courseopt{$seclevel};
393: $result=9;
394: }
1.200 www 395: if (defined($$courseopt{$seclevelm})) {
1.473 amueller 396: $outpar[8]=$$courseopt{$seclevelm};
397: $result=8;
398: }
1.43 albertel 399:
1.200 www 400: if (defined($$courseopt{$seclevelr})) {
1.473 amueller 401: $outpar[7]=$$courseopt{$seclevelr};
402: $result=7;
403: }
1.43 albertel 404: }
1.275 raeburn 405: # ------------------------------------------------------ fifth, check course group
1.352 albertel 406: if ($cgroup ne '') {
1.269 raeburn 407: if (defined($$courseopt{$grplevel})) {
408: $outpar[6]=$$courseopt{$grplevel};
409: $result=6;
410: }
411: if (defined($$courseopt{$grplevelm})) {
412: $outpar[5]=$$courseopt{$grplevelm};
413: $result=5;
414: }
415: if (defined($$courseopt{$grplevelr})) {
416: $outpar[4]=$$courseopt{$grplevelr};
417: $result=4;
418: }
419: }
1.11 www 420:
1.182 albertel 421: # ---------------------------------------------------------- fifth, check user
1.11 www 422:
1.352 albertel 423: if ($uname ne '') {
1.473 amueller 424: if (defined($$useropt{$courselevel})) {
425: $outpar[3]=$$useropt{$courselevel};
426: $result=3;
427: }
428:
429: if (defined($$useropt{$courselevelm})) {
430: $outpar[2]=$$useropt{$courselevelm};
431: $result=2;
432: }
433:
434: if (defined($$useropt{$courselevelr})) {
435: $outpar[1]=$$useropt{$courselevelr};
436: $result=1;
437: }
1.43 albertel 438: }
1.44 albertel 439: return ($result,@outpar);
1.2 www 440: }
441:
1.198 www 442:
443:
1.376 albertel 444: # --- Caches local to lonparmset
445:
1.446 bisitz 446:
1.376 albertel 447: sub reset_caches {
448: &resetparmhash();
449: &resetsymbcache();
450: &resetrulescache();
1.203 www 451: }
452:
1.376 albertel 453: {
454: my $parmhashid;
455: my %parmhash;
456: sub resetparmhash {
1.473 amueller 457: undef($parmhashid);
458: undef(%parmhash);
1.376 albertel 459: }
1.446 bisitz 460:
1.376 albertel 461: sub cacheparmhash {
1.473 amueller 462: if ($parmhashid eq $env{'request.course.fn'}) { return; }
463: my %parmhashfile;
464: if (tie(%parmhashfile,'GDBM_File',
465: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
466: %parmhash=%parmhashfile;
467: untie(%parmhashfile);
468: $parmhashid=$env{'request.course.fn'};
469: }
1.201 www 470: }
1.446 bisitz 471:
1.376 albertel 472: sub parmhash {
1.473 amueller 473: my ($id) = @_;
474: &cacheparmhash();
475: return $parmhash{$id};
1.376 albertel 476: }
477: }
478:
1.446 bisitz 479: {
1.376 albertel 480: my $symbsid;
481: my %symbs;
482: sub resetsymbcache {
1.473 amueller 483: undef($symbsid);
484: undef(%symbs);
1.376 albertel 485: }
1.446 bisitz 486:
1.376 albertel 487: sub symbcache {
1.473 amueller 488: my $id=shift;
489: if ($symbsid ne $env{'request.course.id'}) {
490: undef(%symbs);
491: }
492: if (!$symbs{$id}) {
493: my $navmap = Apache::lonnavmaps::navmap->new();
494: if ($id=~/\./) {
495: my $resource=$navmap->getById($id);
496: $symbs{$id}=$resource->symb();
497: } else {
498: my $resource=$navmap->getByMapPc($id);
499: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
500: }
501: $symbsid=$env{'request.course.id'};
502: }
503: return $symbs{$id};
1.201 www 504: }
1.376 albertel 505: }
1.201 www 506:
1.446 bisitz 507: {
1.376 albertel 508: my $rulesid;
509: my %rules;
510: sub resetrulescache {
1.473 amueller 511: undef($rulesid);
512: undef(%rules);
1.376 albertel 513: }
1.446 bisitz 514:
1.376 albertel 515: sub rulescache {
1.473 amueller 516: my $id=shift;
517: if ($rulesid ne $env{'request.course.id'}
518: && !defined($rules{$id})) {
519: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
520: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
521: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
522: $rulesid=$env{'request.course.id'};
523: }
524: return $rules{$id};
1.221 www 525: }
526: }
527:
1.416 jms 528:
529:
1.229 www 530: sub preset_defaults {
531: my $type=shift;
532: if (&rulescache($type.'_action') eq 'default') {
533: # yes, there is something
1.473 amueller 534: return (&rulescache($type.'_hours'),
535: &rulescache($type.'_min'),
536: &rulescache($type.'_sec'),
537: &rulescache($type.'_value'));
1.229 www 538: } else {
539: # nothing there or something else
1.473 amueller 540: return ('','','','','');
1.229 www 541: }
542: }
543:
1.416 jms 544:
545:
1.277 www 546:
547: sub date_sanity_info {
548: my $checkdate=shift;
549: unless ($checkdate) { return ''; }
550: my $result='';
551: my $crsprefix='course.'.$env{'request.course.id'}.'.';
552: if ($env{$crsprefix.'default_enrollment_end_date'}) {
553: if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
1.413 bisitz 554: $result.='<div class="LC_warning">'
555: .&mt('After course enrollment end!')
556: .'</div>';
1.277 www 557: }
558: }
559: if ($env{$crsprefix.'default_enrollment_start_date'}) {
560: if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
1.413 bisitz 561: $result.='<div class="LC_warning">'
562: .&mt('Before course enrollment start!')
563: .'</div>';
1.277 www 564: }
565: }
1.413 bisitz 566: # Preparation for additional warnings about dates in the past/future.
567: # An improved, more context sensitive version is recommended,
568: # e.g. warn for due and answer dates which are defined before the corresponding open date, etc.
569: # if ($checkdate<time) {
570: # $result.='<div class="LC_info">'
571: # .'('.&mt('in the past').')'
572: # .'</div>';
573: # }
574: # if ($checkdate>time) {
575: # $result.='<div class="LC_info">'
576: # .'('.&mt('in the future').')'
577: # .'</div>';
578: # }
1.277 www 579: return $result;
580: }
581: ##################################################
1.186 www 582: ##################################################
583: #
1.197 www 584: # Store a parameter by ID
1.186 www 585: #
586: # Takes
587: # - resource id
588: # - name of parameter
589: # - level
590: # - new value
591: # - new type
1.187 www 592: # - username
593: # - userdomain
594:
1.186 www 595: sub storeparm {
1.269 raeburn 596: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 raeburn 597: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 598: }
599:
1.226 www 600: my %recstack;
1.197 www 601: sub storeparm_by_symb {
1.275 raeburn 602: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 603: unless ($recflag) {
604: # first time call
1.473 amueller 605: %recstack=();
606: $recflag=1;
1.226 www 607: }
608: # store parameter
609: &storeparm_by_symb_inner
1.473 amueller 610: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 611: # don't do anything if parameter was reset
612: unless ($nval) { return; }
1.226 www 613: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
614: # remember that this was set
615: $recstack{$parm}=1;
616: # what does this trigger?
617: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
618: # don't backfire
619: unless ((!$triggered) || ($recstack{$triggered})) {
1.473 amueller 620: my $action=&rulescache($triggered.'_action');
621: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
1.226 www 622: # set triggered parameter on same level
1.473 amueller 623: my $newspnam=$prefix.$triggered;
624: my $newvalue='';
625: my $active=1;
626: if ($action=~/^when\_setting/) {
1.228 www 627: # are there restrictions?
1.473 amueller 628: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
629: $active=0;
630: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
631: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
632: }
633: }
634: $newvalue=&rulescache($triggered.'_value');
635: } else {
636: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
637: if ($action=~/^later\_than/) {
638: $newvalue=$nval+$totalsecs;
639: } else {
640: $newvalue=$nval-$totalsecs;
641: }
642: }
643: if ($active) {
644: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
645: $uname,$udom,$csec,$recflag,$cgroup);
646: }
1.226 www 647: }
648: }
649: return '';
650: }
651:
1.293 www 652: sub log_parmset {
1.522.2.3 raeburn 653: return &Apache::lonnet::write_log('course','parameterlog',@_);
1.284 www 654: }
655:
1.226 www 656: sub storeparm_by_symb_inner {
1.197 www 657: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 658: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 659: # ---------------------------------------------------------- Construct prefixes
1.186 www 660: $spnam=~s/\_([^\_]+)$/\.$1/;
1.446 bisitz 661: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 662: $map = &Apache::lonnet::deversion($map);
663:
1.197 www 664: my $symbparm=$symb.'.'.$spnam;
665: my $mapparm=$map.'___(all).'.$spnam;
666:
1.269 raeburn 667: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
668: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
669: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
670:
1.190 albertel 671: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
672: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
673: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.446 bisitz 674:
1.190 albertel 675: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
676: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
677: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.446 bisitz 678:
1.186 www 679: my $storeunder='';
1.269 raeburn 680: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
681: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
682: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
683: if ($snum==9) { $storeunder=$seclevel; }
684: if ($snum==8) { $storeunder=$seclevelm; }
685: if ($snum==7) { $storeunder=$seclevelr; }
686: if ($snum==6) { $storeunder=$grplevel; }
687: if ($snum==5) { $storeunder=$grplevelm; }
688: if ($snum==4) { $storeunder=$grplevelr; }
689:
1.446 bisitz 690:
1.186 www 691: my $delete;
692: if ($nval eq '') { $delete=1;}
693: my %storecontent = ($storeunder => $nval,
1.473 amueller 694: $storeunder.'.type' => $ntype);
1.186 www 695: my $reply='';
696: if ($snum>3) {
697: # ---------------------------------------------------------------- Store Course
698: #
1.473 amueller 699: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
700: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 701: # Expire sheets
1.473 amueller 702: &Apache::lonnet::expirespread('','','studentcalc');
703: if (($snum==10) || ($snum==7) || ($snum==4)) {
704: &Apache::lonnet::expirespread('','','assesscalc',$symb);
705: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
706: &Apache::lonnet::expirespread('','','assesscalc',$map);
707: } else {
708: &Apache::lonnet::expirespread('','','assesscalc');
709: }
1.186 www 710: # Store parameter
1.473 amueller 711: if ($delete) {
712: $reply=&Apache::lonnet::del
713: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.290 www 714: &log_parmset(\%storecontent,1);
1.473 amueller 715: } else {
716: $reply=&Apache::lonnet::cput
717: ('resourcedata',\%storecontent,$cdom,$cnum);
718: &log_parmset(\%storecontent);
719: }
720: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 721: } else {
722: # ------------------------------------------------------------------ Store User
723: #
724: # Expire sheets
1.473 amueller 725: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
726: if ($snum==1) {
727: &Apache::lonnet::expirespread
728: ($uname,$udom,'assesscalc',$symb);
729: } elsif ($snum==2) {
730: &Apache::lonnet::expirespread
731: ($uname,$udom,'assesscalc',$map);
732: } else {
733: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
734: }
1.186 www 735: # Store parameter
1.473 amueller 736: if ($delete) {
737: $reply=&Apache::lonnet::del
738: ('resourcedata',[keys(%storecontent)],$udom,$uname);
739: &log_parmset(\%storecontent,1,$uname,$udom);
740: } else {
741: $reply=&Apache::lonnet::cput
742: ('resourcedata',\%storecontent,$udom,$uname);
743: &log_parmset(\%storecontent,0,$uname,$udom);
744: }
745: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 746: }
1.446 bisitz 747:
1.186 www 748: if ($reply=~/^error\:(.*)/) {
1.473 amueller 749: return "<span class=\"LC_error\">Write Error: $1</span>";
1.186 www 750: }
751: return '';
752: }
753:
1.9 www 754:
755: sub valout {
1.320 www 756: my ($value,$type,$editable)=@_;
1.59 matthew 757: my $result = '';
758: # Values of zero are valid.
759: if (! $value && $value ne '0') {
1.522.2.4 raeburn 760: if ($editable) {
761: $result =
762: '<img src="/res/adm/pages/editmap.png"'
763: .' alt="'.&mt('Change').'"'
1.522.2.8 raeburn 764: .' title="'.&mt('Change').'" style="border:0;" />';
1.522.2.4 raeburn 765: } else {
766: $result=' ';
767: }
1.59 matthew 768: } else {
1.66 www 769: if ($type eq 'date_interval') {
1.522.2.28.4. (raeburn 770:): my ($totalsecs,$donesuffix) = split(/_/,$value,2);
771:): my ($usesdone,$donebuttontext,$proctor,$secretkey);
772:): if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
773:): $donebuttontext = $1;
774:): (undef,$proctor,$secretkey) = split(/_/,$2);
775:): $usesdone = 'done';
776:): } elsif ($donesuffix =~ /^done(|_.+)$/) {
777:): $donebuttontext = &mt('Done');
778:): ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix);
779:): }
780:): my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs);
1.413 bisitz 781: my @timer;
1.66 www 782: $year=$year-70;
783: $mday--;
784: if ($year) {
1.413 bisitz 785: # $result.=&mt('[quant,_1,yr]',$year).' ';
786: push(@timer,&mt('[quant,_1,yr]',$year));
1.66 www 787: }
788: if ($mon) {
1.413 bisitz 789: # $result.=&mt('[quant,_1,mth]',$mon).' ';
790: push(@timer,&mt('[quant,_1,mth]',$mon));
1.66 www 791: }
792: if ($mday) {
1.413 bisitz 793: # $result.=&mt('[quant,_1,day]',$mday).' ';
794: push(@timer,&mt('[quant,_1,day]',$mday));
1.66 www 795: }
796: if ($hour) {
1.413 bisitz 797: # $result.=&mt('[quant,_1,hr]',$hour).' ';
798: push(@timer,&mt('[quant,_1,hr]',$hour));
1.66 www 799: }
800: if ($min) {
1.413 bisitz 801: # $result.=&mt('[quant,_1,min]',$min).' ';
802: push(@timer,&mt('[quant,_1,min]',$min));
1.66 www 803: }
804: if ($sec) {
1.413 bisitz 805: # $result.=&mt('[quant,_1,sec]',$sec).' ';
806: push(@timer,&mt('[quant,_1,sec]',$sec));
1.66 www 807: }
1.413 bisitz 808: # $result=~s/\s+$//;
809: if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable
810: push(@timer,&mt('[quant,_1,sec]',0));
811: }
812: $result.=join(", ",@timer);
1.522.2.28.4. (raeburn 813:): if ($usesdone eq 'done') {
814:): if ($secretkey) {
815:): $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey);
816:): } else {
817:): $result .= ' + "'.$donebuttontext.'"';
818:): }
819:): }
1.213 www 820: } elsif (&isdateparm($type)) {
1.361 albertel 821: $result = &Apache::lonlocal::locallocaltime($value).
1.473 amueller 822: &date_sanity_info($value);
1.59 matthew 823: } else {
824: $result = $value;
1.517 www 825: $result=~s/\,/\, /gs;
1.473 amueller 826: $result = &HTML::Entities::encode($result,'"<>&');
1.59 matthew 827: }
828: }
829: return $result;
1.9 www 830: }
831:
1.59 matthew 832:
1.5 www 833: sub plink {
1.522.2.28.4. (raeburn 834:): my ($type,$dis,$value,$marker,$return,$call,$extra)=@_;
1.23 www 835: my $winvalue=$value;
836: unless ($winvalue) {
1.522.2.28.4. (raeburn 837:): if ((&isdateparm($type)) || (&is_specialstring($type))) {
1.190 albertel 838: $winvalue=$env{'form.recent_'.$type};
1.522.2.28.4. (raeburn 839:): } elsif ($type eq 'string_yesno') {
840:): if ($env{'form.recent_string'} =~ /^(yes|no)$/i) {
841:): $winvalue=$env{'form.recent_string'};
842:): }
1.23 www 843: } else {
1.190 albertel 844: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 845: }
846: }
1.229 www 847: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
848: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
849: unless (defined($winvalue)) { $winvalue=$val; }
1.378 albertel 850: my $valout = &valout($value,$type,1);
1.429 raeburn 851: my $unencmarker = $marker;
1.378 albertel 852: foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
1.522.2.28.4. (raeburn 853:): \$hour, \$min, \$sec, \$extra) {
1.473 amueller 854: $$item = &HTML::Entities::encode($$item,'"<>&');
855: $$item =~ s/\'/\\\'/g;
1.378 albertel 856: }
1.429 raeburn 857: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'.
1.473 amueller 858: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.522.2.28.4. (raeburn 859:): .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."','".$extra."'".');">'.
1.473 amueller 860: $valout.'</a></td></tr></table>';
1.5 www 861: }
862:
1.280 albertel 863: sub page_js {
864:
1.81 www 865: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 866: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.280 albertel 867:
868: return(<<ENDJS);
869: <script type="text/javascript">
1.454 bisitz 870: // <![CDATA[
1.44 albertel 871:
1.88 matthew 872: $pjump_def
1.44 albertel 873:
874: function psub() {
1.522.2.28.4. (raeburn 875:): var specstring = /^string_!(yesno|any)/i;
1.44 albertel 876: if (document.parmform.pres_marker.value!='') {
877: document.parmform.action+='#'+document.parmform.pres_marker.value;
878: var typedef=new Array();
879: typedef=document.parmform.pres_type.value.split('_');
1.522.2.28.4. (raeburn 880:): if (document.parmform.pres_type.value!='') {
881:): if ((typedef[0]=='date') ||
882:): (specstring.test(document.parmform.pres_type.value))) {
883:): eval('document.parmform.recent_'+
884:): document.parmform.pres_type.value+
885:): '.value=document.parmform.pres_value.value;');
886:): } else {
887:): eval('document.parmform.recent_'+typedef[0]+
888:): '.value=document.parmform.pres_value.value;');
889:): }
1.44 albertel 890: }
891: document.parmform.submit();
892: } else {
893: document.parmform.pres_value.value='';
894: document.parmform.pres_marker.value='';
895: }
896: }
897:
1.57 albertel 898: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
899: var options = "width=" + w + ",height=" + h + ",";
900: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
901: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
902: var newWin = window.open(url, wdwName, options);
903: newWin.focus();
904: }
1.454 bisitz 905: // ]]>
1.44 albertel 906: </script>
1.81 www 907: $selscript
1.280 albertel 908: ENDJS
909:
910: }
1.507 www 911:
1.522.2.2 raeburn 912: sub showhide_js {
913: return <<"COURSECONTENTSCRIPT";
914:
915: function showHide_courseContent() {
916: var parmlevValue=document.getElementById("parmlev").value;
917: if (parmlevValue == 'general') {
918: document.getElementById('mapmenu').style.display="none";
919: } else {
920: if ((parmlevValue == "full") || (parmlevValue == "map")) {
921: document.getElementById('mapmenu').style.display ="";
922: } else {
923: document.getElementById('mapmenu').style.display="none";
924: }
925: }
926: return;
927: }
928:
929: COURSECONTENTSCRIPT
930: }
931:
1.522.2.28.4. (raeburn 932:): sub validateparms_js {
933:): return <<'ENDSCRIPT';
934:):
935:): function validateParms() {
936:): var textRegExp = /^settext_/;
937:): var ipRegExp = /^setip/;
938:): var ipallowRegExp = /^setipallow_/;
939:): var ipdenyRegExp = /^setipdeny_/;
940:): var deeplinkRegExp = /^deeplink_/;
941:): var dlListScopeRegExp = /^deeplink_(state|others|listing|scope)_/;
942:): var dlLinkProtectRegExp = /^deeplink_protect_/;
943:): var dlLtidRegExp = /^deeplink_ltid_/;
944:): var dlLticRegExp = /^deeplink_ltic_/;
945:): var dlKeyRegExp = /^deeplink_key_/;
946:): var dlMenusRegExp = /^deeplink_menus_/;
947:): var dlCollsRegExp = /^deeplink_colls_/;
948:): var dlTargetRegExp = /^deeplink_target_/;
949:): var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/;
950:): if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') {
951:): if (document.parmform.elements.length) {
952:): for (i=0; i<document.parmform.elements.length; i++) {
953:): var name=document.parmform.elements[i].name;
954:): if (ipRegExp.test(name)) {
955:): if (ipallowRegExp.test(name)) {
956:): var identifier = name.replace(ipallowRegExp,'');
957:): var possallow = document.parmform.elements[i].value;
958:): possallow = possallow.replace(/^\s+|\s+$/g,'');
959:): if (patternIP.test(possallow)) {
960:): if (document.parmform.elements['set_'+identifier].value) {
961:): possallow = ','+possallow;
962:): }
963:): document.parmform.elements['set_'+identifier].value += possallow;
964:): }
965:): } else if (ipdenyRegExp.test(name)) {
966:): var identifier = name.replace(ipdenyRegExp,'');
967:): var possdeny = document.parmform.elements[i].value;
968:): possdeny = possdeny.replace(/^\s+|\s+$/g,'');
969:): if (patternIP.test(possdeny)) {
970:): possdeny = '!'+possdeny;
971:): if (document.parmform.elements['set_'+identifier].value) {
972:): possdeny = ','+possdeny;
973:): }
974:): document.parmform.elements['set_'+identifier].value += possdeny;
975:): }
976:): }
977:): } else if (deeplinkRegExp.test(name)) {
978:): if (dlListScopeRegExp.test(name)) {
979:): var identifier = name.replace(dlListScopeRegExp,'');
980:): var idx = document.parmform.elements[i].selectedIndex;
981:): if (idx > 0) {
982:): var possdeeplink = document.parmform.elements[i].options[idx].value
983:): possdeeplink = possdeeplink.replace(/^\s+|\s+$/g,'');
984:): if (document.parmform.elements['set_'+identifier].value) {
985:): possdeeplink = ','+possdeeplink;
986:): }
987:): document.parmform.elements['set_'+identifier].value += possdeeplink;
988:): }
989:): } else if (dlLinkProtectRegExp.test(name)) {
990:): if (document.parmform.elements[i].checked) {
991:): var identifier = name.replace(dlLinkProtectRegExp,'');
992:): var posslinkurl = document.parmform.elements[i].value;
993:): posslinkurl = posslinkurl.replace(/^\s+|\s+$/g,'');
994:): if (document.parmform.elements['set_'+identifier].value) {
995:): posslinkurl = ','+posslinkurl;
996:): }
997:): document.parmform.elements['set_'+identifier].value += posslinkurl;
998:): }
999:): } else if (dlLtidRegExp.test(name)) {
1000:): var identifier = name.replace(dlLtidRegExp,'');
1001:): if (isRadioSet('deeplink_protect_'+identifier,'ltid')) {
1002:): var possltid = document.parmform.elements[i].value;
1003:): possltid = possltid.replace(/\D+/g,'');
1004:): if (possltid.length) {
1005:): if (document.parmform.elements['set_'+identifier].value) {
1006:): possltid = ':'+possltid;
1007:): }
1008:): document.parmform.elements['set_'+identifier].value += possltid;
1009:): } else {
1010:): document.parmform.elements['set_'+identifier].value = '';
1011:): alert("A link type of 'domain LTI launch' was selected but no domain LTI launcher was selected.\nPlease select one, or choose a different supported link type.");
1012:): return false;
1013:): }
1014:): }
1015:): } else if (dlLticRegExp.test(name)) {
1016:): var identifier = name.replace(dlLticRegExp,'');
1017:): if (isRadioSet('deeplink_protect_'+identifier,'ltic')) {
1018:): var possltic = document.parmform.elements[i].value;
1019:): possltic = possltic.replace(/\D+/g,'');
1020:): if (possltic.length) {
1021:): if (document.parmform.elements['set_'+identifier].value) {
1022:): possltic = ':'+possltic;
1023:): }
1024:): document.parmform.elements['set_'+identifier].value += possltic;
1025:): } else {
1026:): document.parmform.elements['set_'+identifier].value = '';
1027:): alert("A link type of 'course LTI launch' was selected but no course LTI launcher was selected.\nPlease select one, or choose a different supported link type.");
1028:): return false;
1029:): }
1030:): }
1031:): } else if (dlKeyRegExp.test(name)) {
1032:): var identifier = name.replace(dlKeyRegExp,'');
1033:): if (isRadioSet('deeplink_protect_'+identifier,'key')) {
1034:): var posskey = document.parmform.elements[i].value;
1035:): posskey = posskey.replace(/^\s+|\s+$/g,'');
1036:): var origlength = posskey.length;
1037:): posskey = posskey.replace(/[^a-zA-Z\d_.!@#$%^&*()+=-]/g,'');
1038:): var newlength = posskey.length;
1039:): if (newlength > 0) {
1040:): var change = origlength - newlength;
1041:): if (change) {
1042:): alert(change+' disallowed character(s) removed from deeplink key');
1043:): }
1044:): if (document.parmform.elements['set_'+identifier].value) {
1045:): posskey = ':'+posskey;
1046:): }
1047:): document.parmform.elements['set_'+identifier].value += posskey;
1048:): } else {
1049:): document.parmform.elements['set_'+identifier].value = '';
1050:): if (newlength < origlength) {
1051:): alert("A link type of 'deep with key' was selected but the key value was blank, after removing disallowed characters.\nPlease enter a key using one or more of: a-zA-Z0-9_.!@#$%^&*()+=-");
1052:): } else {
1053:): alert("A link type of 'deep with key' was selected but the key value was blank.\nPlease enter a key.");
1054:): }
1055:): return false;
1056:): }
1057:): }
1058:): } else if (dlMenusRegExp.test(name)) {
1059:): if (document.parmform.elements[i].checked) {
1060:): var identifier = name.replace(dlMenusRegExp,'');
1061:): var posslinkmenu = document.parmform.elements[i].value;
1062:): posslinkmenu = posslinkmenu.replace(/^\s+|\s+$/g,'');
1063:): if (posslinkmenu == 'std') {
1064:): posslinkmenu = '0';
1065:): if (document.parmform.elements['set_'+identifier].value) {
1066:): posslinkmenu = ','+posslinkmenu;
1067:): }
1068:): document.parmform.elements['set_'+identifier].value += posslinkmenu;
1069:): }
1070:): }
1071:): } else if (dlCollsRegExp.test(name)) {
1072:): var identifier = name.replace(dlCollsRegExp,'');
1073:): if (isRadioSet('deeplink_menus_'+identifier,'colls')) {
1074:): var posslinkmenu = document.parmform.elements[i].value;
1075:): if (document.parmform.elements['set_'+identifier].value) {
1076:): posslinkmenu = ','+posslinkmenu;
1077:): }
1078:): document.parmform.elements['set_'+identifier].value += posslinkmenu;
1079:): }
1080:): } else if (dlTargetRegExp.test(name)) {
1081:): var identifier = name.replace(dlTargetRegExp,'');
1082:): var idx = document.parmform.elements[i].selectedIndex;
1083:): if (idx > 0) {
1084:): var possdeeplink = document.parmform.elements[i].options[idx].value
1085:): possdeeplink = possdeeplink.replace(/^\s+|\s+$/g,'');
1086:): if (document.parmform.elements['set_'+identifier].value) {
1087:): possdeeplink = ','+possdeeplink;
1088:): }
1089:): document.parmform.elements['set_'+identifier].value += possdeeplink;
1090:): }
1091:): }
1092:): }
1093:): }
1094:): }
1095:): }
1096:): return true;
1097:): }
1098:):
1099:): function isRadioSet(name,expected) {
1100:): var menuitems = document.getElementsByName(name);
1101:): var radioLength = menuitems.length;
1102:): result = false;
1103:): if (radioLength > 1) {
1104:): for (var j=0; j<radioLength; j++) {
1105:): if (menuitems[j].checked) {
1106:): if (menuitems[j].value == expected) {
1107:): result = true;
1108:): break;
1109:): }
1110:): }
1111:): }
1112:): }
1113:): return result;
1114:): }
1115:):
1116:): ENDSCRIPT
1117:): }
1118:):
1119:): # Javascript initialization, for overview mode
1120:): sub ipacc_boxes_js {
1121:): my $remove = &mt('Remove');
1122:): return <<"END";
1123:): \$(document).ready(function() {
1124:): var wrapper = \$(".LC_string_ipacc_wrap");
1125:): var add_button = \$(".LC_add_ipacc_button");
1126:): var ipaccRegExp = /^LC_string_ipacc_/;
1127:):
1128:): \$(add_button).click(function(e){
1129:): e.preventDefault();
1130:): var identifier = \$(this).closest("div").attr("id");
1131:): identifier = identifier.replace(ipaccRegExp,'');
1132:): \$(this).closest('div').find('.LC_string_ipacc_inner').append('<div><input type="text" name="setip'+identifier+'" /><a href="#" class="LC_remove_ipacc">$remove</a></div>');
1133:): });
1134:):
1135:): \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){
1136:): e.preventDefault(); \$(this).closest("div").remove();
1137:): })
1138:): });
1139:):
1140:):
1141:): END
1142:): }
1143:):
1144:): sub done_proctor_js {
1145:): return <<"END";
1146:): function toggleSecret(form,radio,key) {
1147:): var radios = form[radio+key];
1148:): if (radios.length) {
1149:): for (var i=0; i<radios.length; i++) {
1150:): if (radios[i].checked) {
1151:): if (radios[i].value == '_done_proctor') {
1152:): if (document.getElementById('done_'+key+'_proctorkey')) {
1153:): document.getElementById('done_'+key+'_proctorkey').type='text';
1154:): }
1155:): } else {
1156:): if (document.getElementById('done_'+key+'_proctorkey')) {
1157:): document.getElementById('done_'+key+'_proctorkey').type='hidden';
1158:): document.getElementById('done_'+key+'_proctorkey').value='';
1159:): }
1160:): }
1161:): }
1162:): }
1163:): }
1164:): }
1165:): END
1166:):
1167:): }
1168:):
1169:): # Javascript function toggle
1170:): sub deeplink_js {
1171:): return <<"END";
1172:): function toggleDeepLink(form,item,key) {
1173:): var radios = form['deeplink_'+item+'_'+key];
1174:): if (radios.length) {
1175:): var keybox;
1176:): if (document.getElementById('deeplink_key_'+item+'_'+key)) {
1177:): keybox = document.getElementById('deeplink_key_'+item+'_'+key);
1178:): }
1179:): var divoptions = new Array();
1180:): if (item == 'protect') {
1181:): divoptions = ['ltic','ltid'];
1182:): } else {
1183:): if (item == 'menus') {
1184:): divoptions = ['colls'];
1185:): }
1186:): }
1187:): var seldivs = new Array();
1188:): if ((item == 'protect') || (item == 'menus')) {
1189:): for (var i=0; i<divoptions.length; i++) {
1190:): if (document.getElementById('deeplinkdiv_'+divoptions[i]+'_'+item+'_'+key)) {
1191:): seldivs[i] = document.getElementById('deeplinkdiv_'+divoptions[i]+'_'+item+'_'+key);
1192:): } else {
1193:): seldivs[i] = '';
1194:): }
1195:): }
1196:): }
1197:): for (var i=0; i<radios.length; i++) {
1198:): if (radios[i].checked) {
1199:): if ((item == 'protect') || (item == 'menus')) {
1200:): for (var j=0; j<seldivs.length; j++) {
1201:): if (radios[i].value == divoptions[j]) {
1202:): if (seldivs[j] != '') {
1203:): seldivs[j].style.display = 'inline-block';
1204:): }
1205:): if (item == 'protect') {
1206:): keybox.type = 'hidden';
1207:): keybox.value = '';
1208:): }
1209:): } else {
1210:): if (seldivs[j] != '') {
1211:): seldivs[j].style.display = 'none';
1212:): form['deeplink_'+divoptions[j]+'_'+key].selectedIndex = 0;
1213:): }
1214:): }
1215:): }
1216:): if (item == 'protect') {
1217:): if (radios[i].value == 'key') {
1218:): keybox.type = 'text';
1219:): } else {
1220:): keybox.type = 'hidden';
1221:): }
1222:): }
1223:): }
1224:): }
1225:): }
1226:): }
1227:): }
1228:): END
1229:):
1230:): }
1231:):
1.280 albertel 1232: sub startpage {
1.515 raeburn 1233: my ($r,$psymb) = @_;
1.281 albertel 1234:
1.515 raeburn 1235: my %loaditems = (
1236: 'onload' => "group_or_section('cgroup')",
1237: );
1238: if (!$psymb) {
1.522.2.2 raeburn 1239: $loaditems{'onload'} = "showHide_courseContent(); group_or_section('cgroup'); resize_scrollbox('mapmenuscroll','1','1');";
1.515 raeburn 1240: }
1.280 albertel 1241:
1.414 droeschl 1242: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
1.473 amueller 1243: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
1244: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
1245: text=>"Problem Parameters"});
1.414 droeschl 1246: } else {
1.473 amueller 1247: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1248: text=>"Table Mode",
1249: help => 'Course_Setting_Parameters'});
1.414 droeschl 1250: }
1.522.2.2 raeburn 1251: my $js = &page_js().'
1252: <script type="text/javascript">
1253: // <![CDATA[
1254: '.
1255: &Apache::lonhtmlcommon::resize_scrollbox_js('params').'
1256: // ]]>
1257: </script>
1258: ';
1.446 bisitz 1259: my $start_page =
1.522.2.2 raeburn 1260: &Apache::loncommon::start_page('Set/Modify Course Parameters',$js,
1.473 amueller 1261: {'add_entries' => \%loaditems,});
1.446 bisitz 1262: my $breadcrumbs =
1.473 amueller 1263: &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode');
1.506 www 1264: my $escfilter=&Apache::lonhtmlcommon::entity_encode($env{'form.filter'});
1265: my $escpart=&Apache::lonhtmlcommon::entity_encode($env{'form.part'});
1.507 www 1266: $r->print($start_page.$breadcrumbs);
1.280 albertel 1267: $r->print(<<ENDHEAD);
1.193 albertel 1268: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.419 bisitz 1269: <input type="hidden" value="" name="pres_value" />
1270: <input type="hidden" value="" name="pres_type" />
1271: <input type="hidden" value="" name="pres_marker" />
1272: <input type="hidden" value="1" name="prevvisit" />
1.506 www 1273: <input type="hidden" value="$escfilter" name="filter" />
1274: <input type="hidden" value="$escpart" name="part" />
1.44 albertel 1275: ENDHEAD
1276: }
1277:
1.209 www 1278:
1.44 albertel 1279: sub print_row {
1.201 www 1280: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.522.2.19 raeburn 1281: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp,
1282: $readonly)=@_;
1.275 raeburn 1283: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1284: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1285: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 1286: # get the values for the parameter in cascading order
1287: # empty levels will remain empty
1.44 albertel 1288: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.473 amueller 1289: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 1290: # get the type for the parameters
1291: # problem: these may not be set for all levels
1292: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 raeburn 1293: $$name{$which}.'.type',$rid,
1.473 amueller 1294: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 1295: # cascade down manually
1.182 albertel 1296: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 1297: for (my $i=14;$i>0;$i--) {
1.473 amueller 1298: if ($typeoutpar[$i]) {
1.66 www 1299: $cascadetype=$typeoutpar[$i];
1.473 amueller 1300: } else {
1.66 www 1301: $typeoutpar[$i]=$cascadetype;
1302: }
1303: }
1.57 albertel 1304: my $parm=$$display{$which};
1305:
1.203 www 1306: if ($parmlev eq 'full') {
1.419 bisitz 1307: $r->print('<td style="background-color:'.$defbgtwo.';" align="center">'
1.506 www 1308: .($$part{$which} eq '0'?'0 ('.&mt('default').')':$$part{$which}).'</td>');
1.433 raeburn 1309: } else {
1.57 albertel 1310: $parm=~s|\[.*\]\s||g;
1311: }
1.231 www 1312: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
1313: if ($automatic) {
1.473 amueller 1314: $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
1.231 www 1315: }
1.427 bisitz 1316: $r->print('<td>'.$parm.'</td>');
1.446 bisitz 1317:
1.44 albertel 1318: my $thismarker=$which;
1319: $thismarker=~s/^parameter\_//;
1320: my $mprefix=$rid.'&'.$thismarker.'&';
1.522.2.28.4. (raeburn 1321:): my ($parmname)=($thismarker=~/\_([^\_]+)$/);
1.275 raeburn 1322: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
1.522.2.28.4. (raeburn 1323:): my ($othergrp,$grp_parm,$controlgrp,$extra);
1.44 albertel 1324:
1.522.2.28.4. (raeburn 1325:): if ($parmname eq 'deeplink') {
1326:): my ($domltistr,$crsltistr);
1327:): my %lti =
1328:): &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'},
1329:): 'linkprot');
1330:): if (keys(%lti)) {
1331:): foreach my $item (sort { $a <=> $b } (keys(%lti))) {
1332:): if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
1333:): $domltistr .= $item.':'.&escape(&escape($lti{$item}{'name'})).',';
1334:): }
1335:): }
1336:): $domltistr =~ s/,$//;
1337:): if ($domltistr) {
1338:): $extra = 'ltid_'.$domltistr;
1339:): }
1340:): }
1341:): my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom);
1342:): if (keys(%courselti)) {
1343:): foreach my $item (sort { $a <=> $b } keys(%courselti)) {
1344:): if (($item =~ /^\d+$/) && (ref($courselti{$item}) eq 'HASH')) {
1345:): $crsltistr .= $item.':'.&escape(&escape($courselti{$item}{'name'})).',';
1346:): }
1347:): }
1348:): $crsltistr =~ s/,$//;
1349:): if ($crsltistr) {
1350:): if ($extra) {
1351:): $extra .= '&';
1352:): }
1353:): $extra .= 'ltic_'.$crsltistr;
1354:): }
1355:): }
1356:): if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
1357:): my @colls;
1358:): foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
1359:): my ($num,$value) = split(/\%/,$item);
1360:): if ($num =~ /^\d+$/) {
1361:): push(@colls,$num);
1362:): }
1363:): }
1364:): if (@colls) {
1365:): if ($extra) {
1366:): $extra .= '&';
1367:): }
1368:): $extra .= 'menus_'.join(',',@colls);
1369:): }
1370:): }
1371:): }
1.57 albertel 1372: if ($parmlev eq 'general') {
1373:
1374: if ($uname) {
1.522.2.28.4. (raeburn 1375:): &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.269 raeburn 1376: } elsif ($cgroup) {
1.522.2.28.4. (raeburn 1377:): &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
1.57 albertel 1378: } elsif ($csec) {
1.522.2.28.4. (raeburn 1379:): &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.57 albertel 1380: } else {
1.522.2.28.4. (raeburn 1381:): &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.57 albertel 1382: }
1383: } elsif ($parmlev eq 'map') {
1384:
1385: if ($uname) {
1.522.2.28.4. (raeburn 1386:): &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.269 raeburn 1387: } elsif ($cgroup) {
1.522.2.28.4. (raeburn 1388:): &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
1.57 albertel 1389: } elsif ($csec) {
1.522.2.28.4. (raeburn 1390:): &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.57 albertel 1391: } else {
1.522.2.28.4. (raeburn 1392:): &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.57 albertel 1393: }
1394: } else {
1.275 raeburn 1395: if ($uname) {
1396: if (@{$usersgroups} > 1) {
1397: my ($coursereply,$grp_parm,$controlgrp);
1398: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
1.522.2.26 raeburn 1399: &check_other_groups($$part{$which}.'.'.$$name{$which},
1.275 raeburn 1400: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
1401: if ($coursereply && $result > 3) {
1402: if (defined($controlgrp)) {
1403: if ($cgroup ne $controlgrp) {
1404: $effective_parm = $grp_parm;
1405: $result = 0;
1406: }
1407: }
1408: }
1409: }
1410: }
1.57 albertel 1411:
1.522.2.28.4. (raeburn 1412:): &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.57 albertel 1413:
1.522.2.28.4. (raeburn 1414:): &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1415:): &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1416:): &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1417:): &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.473 amueller 1418:
1419: if ($csec) {
1.522.2.28.4. (raeburn 1420:): &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1421:): &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1422:): &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.473 amueller 1423: }
1.269 raeburn 1424:
1425: if ($cgroup) {
1.522.2.28.4. (raeburn 1426:): &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
1427:): &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
1428:): &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
1.269 raeburn 1429: }
1.446 bisitz 1430:
1.473 amueller 1431: if ($uname) {
1.275 raeburn 1432: if ($othergrp) {
1433: $r->print($othergrp);
1434: }
1.522.2.28.4. (raeburn 1435:): &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1436:): &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1437:): &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
1.473 amueller 1438: }
1.57 albertel 1439:
1440: } # end of $parmlev if/else
1.419 bisitz 1441: $r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.'</td>');
1.136 albertel 1442:
1.203 www 1443: if ($parmlev eq 'full') {
1.136 albertel 1444: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 1445: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 1446: my $sessionvaltype=$typeoutpar[$result];
1447: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.419 bisitz 1448: $r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'.
1.66 www 1449: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 1450: '</font></td>');
1.136 albertel 1451: }
1.44 albertel 1452: $r->print('</tr>');
1.57 albertel 1453: $r->print("\n");
1.44 albertel 1454: }
1.59 matthew 1455:
1.44 albertel 1456: sub print_td {
1.522.2.28.4. (raeburn 1457:): my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly,$extra)=@_;
1.419 bisitz 1458: $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).
1459: ';" align="center">');
1.437 raeburn 1460: my $nolink = 0;
1.522.2.19 raeburn 1461: if ($readonly) {
1.437 raeburn 1462: $nolink = 1;
1.522.2.19 raeburn 1463: } else {
1464: if ($which == 11 || $which == 12) {
1.522.2.7 raeburn 1465: $nolink = 1;
1.522.2.24 raeburn 1466: } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) {
1467: $nolink = 1;
1468: } elsif ($which == 4 || $which == 5 || $which == 6) {
1469: if ($noeditgrp) {
1470: $nolink = 1;
1471: }
1.522.2.19 raeburn 1472: } elsif ($mprefix =~ /availablestudent\&$/) {
1.522.2.28 raeburn 1473: $nolink = 1;
1.522.2.19 raeburn 1474: } elsif ($mprefix =~ /examcode\&$/) {
1475: unless ($which == 2) {
1476: $nolink = 1;
1477: }
1.522.2.7 raeburn 1478: }
1.437 raeburn 1479: }
1480: if ($nolink) {
1481: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
1.114 www 1482: } else {
1.437 raeburn 1483: $r->print(&plink($$typeoutpar[$which],
1484: $$display{$value},$$outpar[$which],
1.522.2.28.4. (raeburn 1485:): $mprefix."$which",'parmform.pres','psub',$extra));
1.114 www 1486: }
1487: $r->print('</td>'."\n");
1.57 albertel 1488: }
1489:
1.522.2.25 raeburn 1490: sub check_other_groups {
1491: my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
1.275 raeburn 1492: my $courseid = $env{'request.course.id'};
1493: my $output;
1494: my $symb = &symbcache($rid);
1495: my $symbparm=$symb.'.'.$what;
1496: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1497: my $mapparm=$map.'___(all).'.$what;
1498: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
1499: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
1500: $courseopt);
1501: my $bgcolor = $defbg;
1502: my $grp_parm;
1.446 bisitz 1503: if (($coursereply) && ($cgroup ne $resultgroup)) {
1.275 raeburn 1504: if ($result > 3) {
1.419 bisitz 1505: $bgcolor = '#AAFFAA';
1.275 raeburn 1506: }
1507: $grp_parm = &valout($coursereply,$resulttype);
1.419 bisitz 1508: $output = '<td style="background-color:'.$bgcolor.';" align="center">';
1.275 raeburn 1509: if ($resultgroup && $resultlevel) {
1510: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
1511: } else {
1512: $output .= ' ';
1513: }
1514: $output .= '</td>';
1515: } else {
1.419 bisitz 1516: $output .= '<td style="background-color:'.$bgcolor.';"> </td>';
1.275 raeburn 1517: }
1518: return ($coursereply,$output,$grp_parm,$resultgroup);
1519: }
1520:
1521: sub parm_control_group {
1522: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
1523: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
1524: my $grpfound = 0;
1525: my @levels = ($symbparm,$mapparm,$what);
1526: my @levelnames = ('resource','map/folder','general');
1527: foreach my $group (@{$usersgroups}) {
1528: if ($grpfound) { last; }
1529: for (my $i=0; $i<@levels; $i++) {
1530: my $item = $courseid.'.['.$group.'].'.$levels[$i];
1531: if (defined($$courseopt{$item})) {
1532: $coursereply = $$courseopt{$item};
1533: $resultitem = $item;
1534: $resultgroup = $group;
1535: $resultlevel = $levelnames[$i];
1536: $resulttype = $$courseopt{$item.'.type'};
1537: $grpfound = 1;
1538: last;
1539: }
1540: }
1541: }
1542: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
1543: }
1.201 www 1544:
1.63 bowersj2 1545:
1546:
1547: sub extractResourceInformation {
1548: my $ids = shift;
1549: my $typep = shift;
1550: my $keyp = shift;
1551: my $allparms = shift;
1552: my $allparts = shift;
1553: my $allmaps = shift;
1554: my $mapp = shift;
1555: my $symbp = shift;
1.82 www 1556: my $maptitles=shift;
1.196 www 1557: my $uris=shift;
1.210 www 1558: my $keyorder=shift;
1.211 www 1559: my $defkeytype=shift;
1.196 www 1560:
1.210 www 1561: my $keyordercnt=100;
1.63 bowersj2 1562:
1.196 www 1563: my $navmap = Apache::lonnavmaps::navmap->new();
1564: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
1565: foreach my $resource (@allres) {
1.480 amueller 1566: my $id=$resource->id();
1.196 www 1567: my ($mapid,$resid)=split(/\./,$id);
1.480 amueller 1568: if ($mapid eq '0') { next; }
1569: $$ids[$#$ids+1]=$id;
1570: my $srcf=$resource->src();
1571: $srcf=~/\.(\w+)$/;
1572: $$typep{$id}=$1;
1573: $$keyp{$id}='';
1.196 www 1574: $$uris{$id}=$srcf;
1.512 foxr 1575:
1.480 amueller 1576: foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
1577: next if ($key!~/^parameter_/);
1.363 albertel 1578:
1.209 www 1579: # Hidden parameters
1.480 amueller 1580: next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
1.209 www 1581: #
1582: # allparms is a hash of parameter names
1583: #
1.480 amueller 1584: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
1585: if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
1586: my ($display,$parmdis);
1587: $display = &standard_parameter_names($name);
1588: if ($display eq '') {
1589: $display= &Apache::lonnet::metadata($srcf,$key.'.display');
1590: $parmdis = $display;
1591: $parmdis =~ s/\s*\[Part.*$//g;
1592: } else {
1593: $parmdis = &mt($display);
1594: }
1595: $$allparms{$name}=$parmdis;
1596: if (ref($defkeytype)) {
1597: $$defkeytype{$name}=
1598: &Apache::lonnet::metadata($srcf,$key.'.type');
1599: }
1600: }
1.363 albertel 1601:
1.209 www 1602: #
1603: # allparts is a hash of all parts
1604: #
1.480 amueller 1605: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1606: $$allparts{$part} = &mt('Part: [_1]',$part);
1.209 www 1607: #
1608: # Remember all keys going with this resource
1609: #
1.480 amueller 1610: if ($$keyp{$id}) {
1611: $$keyp{$id}.=','.$key;
1612: } else {
1613: $$keyp{$id}=$key;
1614: }
1.210 www 1615: #
1616: # Put in order
1.446 bisitz 1617: #
1.480 amueller 1618: unless ($$keyorder{$key}) {
1619: $$keyorder{$key}=$keyordercnt;
1620: $keyordercnt++;
1621: }
1.473 amueller 1622: }
1623:
1624:
1.480 amueller 1625: if (!exists($$mapp{$mapid})) {
1626: $$mapp{$id}=
1627: &Apache::lonnet::declutter($resource->enclosing_map_src());
1628: $$mapp{$mapid}=$$mapp{$id};
1629: $$allmaps{$mapid}=$$mapp{$id};
1630: if ($mapid eq '1') {
1.522.2.6 raeburn 1631: $$maptitles{$mapid}=&mt('Main Content');
1.480 amueller 1632: } else {
1633: $$maptitles{$mapid}=&Apache::lonnet::gettitle($$mapp{$id});
1634: }
1635: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1636: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.473 amueller 1637: } else {
1.480 amueller 1638: $$mapp{$id} = $$mapp{$mapid};
1.473 amueller 1639: }
1.480 amueller 1640: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
1.63 bowersj2 1641: }
1642: }
1643:
1.208 www 1644:
1645:
1.213 www 1646: sub isdateparm {
1647: my $type=shift;
1648: return (($type=~/^date/) && (!($type eq 'date_interval')));
1649: }
1650:
1.522.2.28.4. (raeburn 1651:): # Determine if parameter type is specialized string type (i.e.,
1652:): # not just string or string_yesno.
1653:):
1654:): sub is_specialstring {
1655:): my $type=shift;
1656:): return (($type=~/^string_/) && ($type ne 'string_yesno'));
1657:): }
1658:):
1.468 amueller 1659: #
1.501 bisitz 1660: # parmmenu displays a list of the selected parameters.
1661: # It also offers a link to show/hide the complete parameter list
1662: # from which you can select all desired parameters.
1.468 amueller 1663: #
1.208 www 1664: sub parmmenu {
1.522.2.25 raeburn 1665: my ($r)=@_;
1.208 www 1666: $r->print(<<ENDSCRIPT);
1667: <script type="text/javascript">
1.454 bisitz 1668: // <![CDATA[
1.208 www 1669: function checkall(value, checkName) {
1.453 schualex 1670:
1671: var li = "_li";
1672: var displayOverview = "";
1673:
1674: if (value == false) {
1675: displayOverview = "none"
1676: }
1677:
1.473 amueller 1678: for (i=0; i<document.forms.parmform.elements.length; i++) {
1.208 www 1679: ele = document.forms.parmform.elements[i];
1680: if (ele.name == checkName) {
1681: document.forms.parmform.elements[i].checked=value;
1682: }
1683: }
1684: }
1.210 www 1685:
1686: function checkthis(thisvalue, checkName) {
1.458 schualex 1687:
1688:
1.473 amueller 1689: for (i=0; i<document.forms.parmform.elements.length; i++) {
1.210 www 1690: ele = document.forms.parmform.elements[i];
1691: if (ele.name == checkName) {
1.473 amueller 1692: if (ele.value == thisvalue) {
1693: document.forms.parmform.elements[i].checked=true;
1694: }
1.210 www 1695: }
1696: }
1697: }
1698:
1699: function checkdates() {
1.473 amueller 1700: checkthis('duedate','pscat');
1701: checkthis('opendate','pscat');
1702: checkthis('answerdate','pscat');
1.218 www 1703: }
1704:
1705: function checkdisset() {
1.521 raeburn 1706: checkthis('discussend','pscat');
1.473 amueller 1707: checkthis('discusshide','pscat');
1.521 raeburn 1708: checkthis('discussvote','pscat');
1.218 www 1709: }
1710:
1711: function checkcontdates() {
1.473 amueller 1712: checkthis('contentopen','pscat');
1713: checkthis('contentclose','pscat');
1.218 www 1714: }
1.446 bisitz 1715:
1.210 www 1716: function checkvisi() {
1.473 amueller 1717: checkthis('hiddenresource','pscat');
1718: checkthis('encrypturl','pscat');
1719: checkthis('problemstatus','pscat');
1720: checkthis('contentopen','pscat');
1721: checkthis('opendate','pscat');
1.210 www 1722: }
1723:
1724: function checkparts() {
1.473 amueller 1725: checkthis('hiddenparts','pscat');
1726: checkthis('display','pscat');
1727: checkthis('ordered','pscat');
1.210 www 1728: }
1729:
1730: function checkstandard() {
1731: checkall(false,'pscat');
1.473 amueller 1732: checkdates();
1733: checkthis('weight','pscat');
1734: checkthis('maxtries','pscat');
1.501 bisitz 1735: checkthis('type','pscat');
1736: checkthis('problemstatus','pscat');
1.210 www 1737: }
1738:
1.454 bisitz 1739: // ]]>
1.208 www 1740: </script>
1741: ENDSCRIPT
1.453 schualex 1742:
1.491 bisitz 1743: $r->print('<hr />');
1.522.2.25 raeburn 1744: &shortCuts($r);
1.491 bisitz 1745: $r->print('<hr />');
1.453 schualex 1746: }
1.465 amueller 1747: # return a hash
1748: sub categories {
1749: return ('time_settings' => 'Time Settings',
1750: 'grading' => 'Grading',
1751: 'tries' => 'Tries',
1752: 'problem_appearance' => 'Problem Appearance',
1753: 'behaviour_of_input_fields' => 'Behaviour of Input Fields',
1754: 'hiding' => 'Hiding',
1755: 'high_level_randomization' => 'High Level Randomization',
1756: 'slots' => 'Slots',
1757: 'file_submission' => 'File Submission',
1758: 'misc' => 'Miscellaneous' );
1759: }
1760:
1761: # return a hash. Like a look-up table
1762: sub lookUpTableParameter {
1763:
1764: return (
1765: 'opendate' => 'time_settings',
1766: 'duedate' => 'time_settings',
1767: 'answerdate' => 'time_settings',
1768: 'interval' => 'time_settings',
1769: 'contentopen' => 'time_settings',
1770: 'contentclose' => 'time_settings',
1771: 'discussend' => 'time_settings',
1.522.2.15 raeburn 1772: 'printstartdate' => 'time_settings',
1773: 'printenddate' => 'time_settings',
1.465 amueller 1774: 'weight' => 'grading',
1775: 'handgrade' => 'grading',
1776: 'maxtries' => 'tries',
1777: 'hinttries' => 'tries',
1.503 raeburn 1778: 'randomizeontries' => 'tries',
1.465 amueller 1779: 'type' => 'problem_appearance',
1780: 'problemstatus' => 'problem_appearance',
1781: 'display' => 'problem_appearance',
1782: 'ordered' => 'problem_appearance',
1783: 'numbubbles' => 'problem_appearance',
1784: 'tol' => 'behaviour_of_input_fields',
1785: 'sig' => 'behaviour_of_input_fields',
1786: 'turnoffunit' => 'behaviour_of_input_fields',
1787: 'hiddenresource' => 'hiding',
1788: 'hiddenparts' => 'hiding',
1789: 'discusshide' => 'hiding',
1790: 'buttonshide' => 'hiding',
1791: 'turnoffeditor' => 'hiding',
1792: 'encrypturl' => 'hiding',
1.522.2.28.4. (raeburn 1793:): 'deeplink' => 'hiding',
1.465 amueller 1794: 'randomorder' => 'high_level_randomization',
1795: 'randompick' => 'high_level_randomization',
1796: 'available' => 'slots',
1797: 'useslots' => 'slots',
1798: 'availablestudent' => 'slots',
1799: 'uploadedfiletypes' => 'file_submission',
1800: 'maxfilesize' => 'file_submission',
1801: 'cssfile' => 'misc',
1802: 'mapalias' => 'misc',
1803: 'acc' => 'misc',
1804: 'maxcollaborators' => 'misc',
1805: 'scoreformat' => 'misc',
1.514 raeburn 1806: 'lenient' => 'grading',
1.519 raeburn 1807: 'retrypartial' => 'tries',
1.521 raeburn 1808: 'discussvote' => 'misc',
1.522.2.7 raeburn 1809: 'examcode' => 'high_level_randomization',
1.522.2.25 raeburn 1810: );
1.465 amueller 1811: }
1812:
1813: sub whatIsMyCategory {
1814: my $name = shift;
1815: my $catList = shift;
1816: my @list;
1817: my %lookUpList = &lookUpTableParameter; #Initilize the lookupList
1818: my $cat = $lookUpList{$name};
1819: if (defined($cat)) {
1820: if (!defined($$catList{$cat})){
1821: push @list, ($name);
1822: $$catList{$cat} = \@list;
1823: } else {
1824: push @{${$catList}{$cat}}, ($name);
1825: }
1826: } else {
1827: if (!defined($$catList{'misc'})){
1828: push @list, ($name);
1829: $$catList{'misc'} = \@list;
1830: } else {
1831: push @{${$catList}{'misc'}}, ($name);
1832: }
1833: }
1834: }
1835:
1836: sub keysindisplayorderCategory {
1837: my ($name,$keyorder)=@_;
1838: return sort {
1.473 amueller 1839: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1.465 amueller 1840: } ( @{$name});
1841: }
1842:
1.467 amueller 1843: sub category_order {
1844: return (
1845: 'time_settings' => 1,
1846: 'grading' => 2,
1847: 'tries' => 3,
1848: 'problem_appearance' => 4,
1849: 'hiding' => 5,
1850: 'behaviour_of_input_fields' => 6,
1851: 'high_level_randomization' => 7,
1852: 'slots' => 8,
1853: 'file_submission' => 9,
1854: 'misc' => 10
1855: );
1856:
1857: }
1.453 schualex 1858:
1859: sub parmboxes {
1860: my ($r,$allparms,$pscat,$keyorder)=@_;
1861: my $tempkey;
1.465 amueller 1862: my $tempparameter;
1863: my %categories = &categories;
1.467 amueller 1864: my %category_order = &category_order();
1.465 amueller 1865: my %categoryList = (
1866: 'time_settings' => [],
1867: 'grading' => [],
1868: 'tries' => [],
1869: 'problem_appearance' => [],
1870: 'behaviour_of_input_fields' => [],
1871: 'hiding' => [],
1872: 'high_level_randomization' => [],
1873: 'slots' => [],
1874: 'file_submission' => [],
1875: 'misc' => [],
1.489 bisitz 1876: );
1.510 www 1877:
1.465 amueller 1878: foreach $tempparameter (keys %$allparms) {
1879: &whatIsMyCategory($tempparameter, \%categoryList);
1880: }
1.453 schualex 1881: #part to print the parm-list
1.510 www 1882: $r->print('<div class="LC_columnSection">'."\n");
1.453 schualex 1883:
1.465 amueller 1884: #Print parameters
1.467 amueller 1885: for my $key (sort { $category_order{$a} <=> $category_order{$b} } keys %categoryList) {
1.522.2.8 raeburn 1886: next if(@{$categoryList{$key}} == 0);
1887: $r->print('<div class="LC_Box LC_400Box">'
1888: .'<h4 class="LC_hcell">'
1889: .&mt($categories{$key})
1890: .'</h4>'."\n");
1891: foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
1.522.2.25 raeburn 1892: next if ($tempkey eq '');
1.522.2.8 raeburn 1893: $r->print('<span class="LC_nobreak">'
1894: .'<label><input type="checkbox" name="pscat" '
1895: .'value="'.$tempkey.'" ');
1896: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1897: $r->print(' checked="checked"');
1898: }
1899: $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
1.465 amueller 1900: : $tempkey)
1.522.2.8 raeburn 1901: .'</label></span><br />'."\n");
1.465 amueller 1902: }
1.522.2.9 raeburn 1903: $r->print("</div>\n");
1.465 amueller 1904: }
1.453 schualex 1905:
1.510 www 1906: $r->print("</div>\n");
1.453 schualex 1907: }
1.468 amueller 1908: #
1909: # This function offers some links on the parameter section to get with one click a group a parameters
1910: #
1.453 schualex 1911: sub shortCuts {
1.522.2.25 raeburn 1912: my ($r)=@_;
1.453 schualex 1913:
1.491 bisitz 1914: # Parameter Selection
1915: $r->print(
1916: &Apache::lonhtmlcommon::start_funclist(&mt('Parameter Selection'))
1917: .&Apache::lonhtmlcommon::add_item_funclist(
1918: '<a href="javascript:checkall(true, \'pscat\')">'.&mt('Select All').'</a>')
1919: .&Apache::lonhtmlcommon::add_item_funclist(
1920: '<a href="javascript:checkstandard()">'.&mt('Select Common Only').'</a>')
1921: .&Apache::lonhtmlcommon::add_item_funclist(
1922: '<a href="javascript:checkall(false, \'pscat\')">'.&mt('Unselect All').'</a>')
1923: .&Apache::lonhtmlcommon::end_funclist()
1924: );
1925:
1926: # Add Selection for...
1927: $r->print(
1928: &Apache::lonhtmlcommon::start_funclist(&mt('Add Selection for...'))
1929: .&Apache::lonhtmlcommon::add_item_funclist(
1930: '<a href="javascript:checkdates()">'.&mt('Problem Dates').'</a>')
1931: .&Apache::lonhtmlcommon::add_item_funclist(
1932: '<a href="javascript:checkcontdates()">'.&mt('Content Dates').'</a>')
1933: .&Apache::lonhtmlcommon::add_item_funclist(
1934: '<a href="javascript:checkdisset()">'.&mt('Discussion Settings').'</a>')
1935: .&Apache::lonhtmlcommon::add_item_funclist(
1936: '<a href="javascript:checkvisi()">'.&mt('Visibilities').'</a>')
1937: .&Apache::lonhtmlcommon::add_item_funclist(
1938: '<a href="javascript:checkparts()">'.&mt('Part Parameters').'</a>')
1939: .&Apache::lonhtmlcommon::end_funclist()
1940: );
1.208 www 1941: }
1942:
1.209 www 1943: sub partmenu {
1.446 bisitz 1944: my ($r,$allparts,$psprt)=@_;
1.522.2.2 raeburn 1945: my $selsize = 1+scalar(keys(%{$allparts}));
1946: if ($selsize > 8) {
1947: $selsize = 8;
1948: }
1.446 bisitz 1949:
1.522.2.2 raeburn 1950: $r->print('<select multiple="multiple" name="psprt" size="'.$selsize.'">');
1.208 www 1951: $r->print('<option value="all"');
1.401 bisitz 1952: $r->print(' selected="selected"') unless (@{$psprt});
1.208 www 1953: $r->print('>'.&mt('All Parts').'</option>');
1954: my %temphash=();
1955: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1956: foreach my $tempkey (sort {
1.473 amueller 1957: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1.234 albertel 1958: } keys(%{$allparts})) {
1.473 amueller 1959: unless ($tempkey =~ /\./) {
1960: $r->print('<option value="'.$tempkey.'"');
1961: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1962: $r->print(' selected="selected"');
1963: }
1964: $r->print('>'.$$allparts{$tempkey}.'</option>');
1965: }
1.208 www 1966: }
1.446 bisitz 1967: $r->print('</select>');
1.209 www 1968: }
1969:
1970: sub usermenu {
1.522.2.24 raeburn 1971: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_;
1.209 www 1972: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1.522.2.27 raeburn 1973: &Apache::loncommon::selectstudent_link('parmform','uname','udom','condition').
1974: &Apache::lonhtmlcommon::scripttag(<<ENDJS);
1975: function setCourseadv(form,caller) {
1976: if (caller.value == 'st') {
1977: form.courseadv.value = 'none';
1978: } else {
1979: form.courseadv.value = '';
1980: }
1981: return;
1982: }
1983: ENDJS
1.412 bisitz 1984:
1.522.2.27 raeburn 1985: my (%chkroles,$stuonly,$courseadv);
1986: if ($env{'form.userroles'} eq 'any') {
1987: $chkroles{'any'} = ' checked="checked"';
1988: } else {
1989: $chkroles{'st'} = ' checked="checked"';
1990: $courseadv = 'none';
1991: }
1992: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1993: if ($crstype eq 'Community') {
1994: $stuonly = &mt('member only');
1995: } else {
1996: $stuonly = &mt('student only');
1997: }
1998: $chooseopt .= '<br /><span class="LC_cusr_subheading">'.
1999: &mt("User's role").': '.
2000: '<label><input type="radio" name="userroles" value="st"'.$chkroles{'st'}.' onclick="setCourseadv(this.form,this);" />'.
2001: $stuonly.'</label> '.
2002: '<label><input type="radio" name="userroles" value="any"'.$chkroles{'any'}.' onclick="setCourseadv(this.form,this);" />'.
2003: &mt('any role').'</label><input type="hidden" id="courseadv" name="courseadv" value="'.$courseadv.'" /></span>';
1.209 www 2004: my $sections='';
1.300 albertel 2005: my %sectionhash = &Apache::loncommon::get_sections();
2006:
1.269 raeburn 2007: my $groups;
1.522.2.24 raeburn 2008: my %grouphash;
2009: if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
2010: %grouphash = &Apache::longroup::coursegroups();
2011: } elsif ($env{'request.course.groups'} ne '') {
2012: map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
2013: }
1.299 albertel 2014:
1.412 bisitz 2015: my $g_s_header='';
2016: my $g_s_footer='';
1.446 bisitz 2017:
1.522.2.24 raeburn 2018: my $currsec = $env{'request.course.sec'};
2019: if ($currsec) {
2020: $sections=&mt('Section:').' '.$currsec;
2021: if (%grouphash) {
2022: $sections .= ';'.(' ' x2);
2023: }
2024: } elsif (%sectionhash && $currsec eq '') {
1.412 bisitz 2025: $sections=&mt('Section:').' <select name="csec"';
1.299 albertel 2026: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 2027: $sections .= qq| onchange="group_or_section('csec')" |;
2028: }
2029: $sections .= '>';
1.473 amueller 2030: foreach my $section ('',sort keys %sectionhash) {
2031: $sections.='<option value="'.$section.'" '.
2032: ($section eq $csec?'selected="selected"':'').'>'.$section.
1.275 raeburn 2033: '</option>';
1.209 www 2034: }
2035: $sections.='</select>';
1.269 raeburn 2036: }
1.412 bisitz 2037:
1.522.2.24 raeburn 2038: if (%sectionhash && %grouphash && $parmlev ne 'full' && $currsec eq '') {
1.412 bisitz 2039: $sections .= ' '.&mt('or').' ';
1.269 raeburn 2040: $sections .= qq|
2041: <script type="text/javascript">
1.454 bisitz 2042: // <![CDATA[
1.269 raeburn 2043: function group_or_section(caller) {
2044: if (caller == "cgroup") {
2045: if (document.parmform.cgroup.selectedIndex != 0) {
2046: document.parmform.csec.selectedIndex = 0;
2047: }
2048: } else {
2049: if (document.parmform.csec.selectedIndex != 0) {
2050: document.parmform.cgroup.selectedIndex = 0;
2051: }
2052: }
2053: }
1.454 bisitz 2054: // ]]>
1.269 raeburn 2055: </script>
2056: |;
1.522.2.24 raeburn 2057: } elsif ($currsec eq '') {
1.269 raeburn 2058: $sections .= qq|
2059: <script type="text/javascript">
1.454 bisitz 2060: // <![CDATA[
1.269 raeburn 2061: function group_or_section(caller) {
2062: return;
2063: }
1.454 bisitz 2064: // ]]>
1.269 raeburn 2065: </script>
2066: |;
1.446 bisitz 2067: }
1.299 albertel 2068:
2069: if (%grouphash) {
1.522.2.28.4. (raeburn 2070:): $groups=&mt('Group').': <select name="cgroup"';
1.522.2.24 raeburn 2071: if (%sectionhash && $env{'form.action'} eq 'settable' && $currsec eq '') {
1.269 raeburn 2072: $groups .= qq| onchange="group_or_section('cgroup')" |;
2073: }
2074: $groups .= '>';
1.275 raeburn 2075: foreach my $grp ('',sort keys %grouphash) {
2076: $groups.='<option value="'.$grp.'" ';
2077: if ($grp eq $cgroup) {
2078: unless ((defined($uname)) && ($grp eq '')) {
2079: $groups .= 'selected="selected" ';
2080: }
2081: } elsif (!defined($cgroup)) {
2082: if (@{$usersgroups} == 1) {
2083: if ($grp eq $$usersgroups[0]) {
2084: $groups .= 'selected="selected" ';
2085: }
2086: }
2087: }
2088: $groups .= '>'.$grp.'</option>';
1.269 raeburn 2089: }
2090: $groups.='</select>';
2091: }
1.412 bisitz 2092:
1.445 neumanie 2093: if (%sectionhash || %grouphash) {
1.446 bisitz 2094: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Group/Section')));
2095: $r->print($sections.$groups);
1.448 bisitz 2096: $r->print(&Apache::lonhtmlcommon::row_closure());
1.445 neumanie 2097: }
1.446 bisitz 2098:
2099: $r->print(&Apache::lonhtmlcommon::row_title(&mt('User')));
1.443 neumanie 2100: $r->print(&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]'
1.412 bisitz 2101: ,'<input type="text" value="'.$uname.'" size="12" name="uname" />'
2102: ,'<input type="text" value="'.$id.'" size="12" name="id" /> '
1.446 bisitz 2103: ,$chooseopt));
1.209 www 2104: }
2105:
1.468 amueller 2106: #
2107: # This function shows on table Mode the available Parameters for the selected Resources
2108: #
1.209 www 2109: sub displaymenu {
1.522.2.25 raeburn 2110: my ($r,$allparms,$pscat,$keyorder,$divid)=@_;
1.510 www 2111:
1.445 neumanie 2112: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.510 www 2113: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));
2114:
1.522.2.25 raeburn 2115: &parmmenu($r);
1.522.2.8 raeburn 2116: $r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid));
1.510 www 2117: &parmboxes($r,$allparms,$pscat,$keyorder);
2118: $r->print(&Apache::loncommon::end_scrollbox());
2119:
2120: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.453 schualex 2121: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.510 www 2122:
1.209 www 2123: }
2124:
1.445 neumanie 2125: sub mapmenu {
1.499 raeburn 2126: my ($r,$allmaps,$pschp,$maptitles,$symbp)=@_;
1.468 amueller 2127: my %allmaps_inverted = reverse %$allmaps;
1.461 neumanie 2128: my $navmap = Apache::lonnavmaps::navmap->new();
2129: my $tree=[];
2130: my $treeinfo={};
2131: if (defined($navmap)) {
1.499 raeburn 2132: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
1.461 neumanie 2133: my $curRes;
2134: my $depth = 0;
1.468 amueller 2135: my %parent = ();
2136: my $startcount = 5;
2137: my $lastcontainer = $startcount;
2138: # preparing what is to show ...
1.461 neumanie 2139: while ($curRes = $it->next()) {
2140: if ($curRes == $it->BEGIN_MAP()) {
2141: $depth++;
1.468 amueller 2142: $parent{$depth}= $lastcontainer;
1.461 neumanie 2143: }
2144: if ($curRes == $it->END_MAP()) {
2145: $depth--;
1.468 amueller 2146: $lastcontainer = $parent{$depth};
1.461 neumanie 2147: }
2148: if (ref($curRes)) {
1.468 amueller 2149: my $symb = $curRes->symb();
2150: my $ressymb = $symb;
1.461 neumanie 2151: if (($curRes->is_sequence()) || ($curRes->is_page())) {
2152: my $type = 'sequence';
2153: if ($curRes->is_page()) {
2154: $type = 'page';
2155: }
2156: my $id= $curRes->id();
1.468 amueller 2157: my $srcf = $curRes->src();
2158: my $resource_name = &Apache::lonnet::gettitle($srcf);
2159: if(!exists($treeinfo->{$id})) {
2160: push(@$tree,$id);
1.473 amueller 2161: my $enclosing_map_folder = &Apache::lonnet::declutter($curRes->enclosing_map_src());
1.468 amueller 2162: $treeinfo->{$id} = {
1.461 neumanie 2163: depth => $depth,
2164: type => $type,
1.468 amueller 2165: name => $resource_name,
2166: enclosing_map_folder => $enclosing_map_folder,
1.461 neumanie 2167: };
1.462 neumanie 2168: }
1.461 neumanie 2169: }
2170: }
2171: }
1.462 neumanie 2172: }
1.473 amueller 2173: # Show it ...
1.484 amueller 2174: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"'));
1.461 neumanie 2175: if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) {
2176: my $icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />';
1.497 bisitz 2177: my $whitespace =
2178: '<img src="'
2179: .&Apache::loncommon::lonhttpdurl('/adm/lonIcons/whitespace_21.gif')
2180: .'" alt="" />';
2181:
1.498 bisitz 2182: # Info about selectable folders/maps
2183: $r->print(
2184: '<div class="LC_info">'
1.508 www 2185: .&mt('You can only select maps and folders which have modifiable settings.')
2186: .' '.&Apache::loncommon::help_open_topic('Parameter_Set_Folder')
1.498 bisitz 2187: .'</div>'
2188: );
2189:
1.522.2.8 raeburn 2190: $r->print(&Apache::loncommon::start_scrollbox('700px','680px','400px','mapmenuscroll'));
1.522.2.2 raeburn 2191: $r->print(&Apache::loncommon::start_data_table(undef,'mapmenuinner'));
1.497 bisitz 2192:
1.498 bisitz 2193: # Display row: "All Maps or Folders"
2194: $r->print(
1.522.2.2 raeburn 2195: &Apache::loncommon::start_data_table_row(undef,'picklevel')
1.498 bisitz 2196: .'<td>'
2197: .'<label>'
2198: .'<input type="radio" name="pschp"'
1.497 bisitz 2199: );
2200: $r->print(' checked="checked"') if ($pschp eq 'all' || !$pschp);
1.498 bisitz 2201: $r->print(
2202: ' value="all" /> '.$icon.' '
2203: .&mt('All Maps or Folders')
2204: .'</label>'
2205: .'<hr /></td>'
2206: .&Apache::loncommon::end_data_table_row()
1.463 bisitz 2207: );
1.497 bisitz 2208:
1.522.2.6 raeburn 2209: # Display row: "Main Content"
1.468 amueller 2210: if (exists($$allmaps{1})) {
1.498 bisitz 2211: $r->print(
2212: &Apache::loncommon::start_data_table_row()
2213: .'<td>'
2214: .'<label>'
2215: .'<input type="radio" name="pschp" value="1"'
1.468 amueller 2216: );
1.497 bisitz 2217: $r->print(' checked="checked"') if ($pschp eq '1');
1.498 bisitz 2218: $r->print(
2219: '/> '.$icon.' '
2220: .$$maptitles{1}
2221: .($$allmaps{1} !~/^uploaded/?' ['.$$allmaps{1}.']':'')
2222: .'</label>'
2223: .'</td>'
2224: .&Apache::loncommon::end_data_table_row()
1.468 amueller 2225: );
2226: }
1.497 bisitz 2227:
2228: # Display rows for all course maps and folders
1.468 amueller 2229: foreach my $id (@{$tree}) {
2230: my ($mapid,$resid)=split(/\./,$id);
1.464 bisitz 2231: # Indentation
1.468 amueller 2232: my $depth = $treeinfo->{$id}->{'depth'};
1.464 bisitz 2233: my $indent;
2234: for (my $i = 0; $i < $depth; $i++) {
2235: $indent.= $whitespace;
2236: }
1.461 neumanie 2237: $icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />';
1.468 amueller 2238: if ($treeinfo->{$id}->{'type'} eq 'page') {
1.461 neumanie 2239: $icon = '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" />';
2240: }
1.468 amueller 2241: my $symb_name = $$symbp{$id};
2242: my ($front, $tail) = split (/___${resid}___/, $symb_name);
2243: $symb_name = $tail;
1.498 bisitz 2244: $r->print(
2245: &Apache::loncommon::start_data_table_row()
2246: .'<td>'
2247: .'<label>'
1.463 bisitz 2248: );
1.498 bisitz 2249: # Only offer radio button for folders/maps which can be parameterized
2250: if ($allmaps_inverted{$symb_name}) {
2251: $r->print(
2252: '<input type ="radio" name="pschp"'
2253: .' value="'.$allmaps_inverted{$symb_name}.'"'
2254: );
2255: $r->print(' checked="checked"') if ($allmaps_inverted{$symb_name} eq $pschp);
2256: $r->print('/>');
2257: } else {
2258: $r->print($whitespace);
1.461 neumanie 2259: }
1.498 bisitz 2260: $r->print(
2261: $indent.$icon.' '
2262: .$treeinfo->{$id}->{name}
2263: .($$allmaps{$mapid}!~/^uploaded/?' ['.$$allmaps{$mapid}.']':'')
2264: .'</label>'
2265: .'</td>'
2266: .&Apache::loncommon::end_data_table_row()
1.463 bisitz 2267: );
1.461 neumanie 2268: }
1.497 bisitz 2269:
1.522.2.2 raeburn 2270: $r->print(&Apache::loncommon::end_data_table().
2271: '<br style="line-height:2px;" />'.
2272: &Apache::loncommon::end_scrollbox());
1.209 www 2273: }
2274: }
2275:
1.482 amueller 2276: # Build up the select Box to choose if your parameter specification should work for the resource, map/folder or the course level
2277: # 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 2278: sub levelmenu {
1.446 bisitz 2279: my ($r,$alllevs,$parmlev)=@_;
2280:
1.445 neumanie 2281: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameter Level').&Apache::loncommon::help_open_topic('Course_Parameter_Levels')));
1.474 amueller 2282: $r->print('<select id="parmlev" name="parmlev" onchange="showHide_courseContent()">');
1.209 www 2283: foreach (reverse sort keys %{$alllevs}) {
1.473 amueller 2284: $r->print('<option value="'.$$alllevs{$_}.'"');
2285: if ($parmlev eq $$alllevs{$_}) {
2286: $r->print(' selected="selected"');
2287: }
2288: $r->print('>'.&mt($_).'</option>');
1.208 www 2289: }
1.446 bisitz 2290: $r->print("</select>");
1.208 www 2291: }
2292:
1.211 www 2293:
2294: sub sectionmenu {
1.522.2.24 raeburn 2295: my ($selectedsections)=@_;
1.300 albertel 2296: my %sectionhash = &Apache::loncommon::get_sections();
1.522.2.24 raeburn 2297: return '' if (!%sectionhash);
1.300 albertel 2298:
1.522.2.24 raeburn 2299: my (@possibles,$disabled);
2300: if ($env{'request.course.sec'} ne '') {
2301: @possibles = ($env{'request.course.sec'});
2302: $selectedsections = [$env{'request.course.sec'}];
2303: $disabled = ' disabled="disabled"';
2304: } else {
2305: @possibles = ('all',sort(keys(%sectionhash)));
1.473 amueller 2306: }
1.522.2.24 raeburn 2307: my $output = '<select name="Section" multiple="multiple" size="8"'.$disabled.'>';
2308: foreach my $s (@possibles) {
2309: $output .= ' <option value="'.$s.'"';
2310: if ((@{$selectedsections}) && (grep(/^\Q$s\E$/,@{$selectedsections}))) {
2311: $output .= ' selected="selected"';
2312: }
2313: $output .= '>'."$s</option>\n";
1.300 albertel 2314: }
1.522.2.26 raeburn 2315: $output .= "</select>\n";
1.522.2.24 raeburn 2316: return $output;
1.269 raeburn 2317: }
2318:
2319: sub groupmenu {
1.522.2.24 raeburn 2320: my ($selectedgroups)=@_;
2321: my %grouphash;
2322: if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
2323: %grouphash = &Apache::longroup::coursegroups();
2324: } elsif ($env{'request.course.groups'} ne '') {
2325: map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
2326: }
2327: return '' if (!%grouphash);
1.299 albertel 2328:
1.522.2.24 raeburn 2329: my $output = '<select name="Group" multiple="multiple" size="8">';
1.299 albertel 2330: foreach my $group (sort(keys(%grouphash))) {
1.522.2.24 raeburn 2331: $output .= ' <option value="'.$group.'"';
2332: if ((@{$selectedgroups}) && (grep(/^\Q$group\E$/,\@{$selectedgroups}))) {
2333: $output .= ' selected="selected"';
1.473 amueller 2334: }
1.522.2.24 raeburn 2335: $output .= '>'.$group."</option>\n";
1.473 amueller 2336: }
1.522.2.24 raeburn 2337: $output .= "</select>\n";
2338: return $output;
1.211 www 2339: }
2340:
1.210 www 2341: sub keysplit {
2342: my $keyp=shift;
2343: return (split(/\,/,$keyp));
2344: }
2345:
2346: sub keysinorder {
2347: my ($name,$keyorder)=@_;
2348: return sort {
1.473 amueller 2349: $$keyorder{$a} <=> $$keyorder{$b};
1.210 www 2350: } (keys %{$name});
2351: }
2352:
1.236 albertel 2353: sub keysinorder_bytype {
2354: my ($name,$keyorder)=@_;
2355: return sort {
1.473 amueller 2356: my $ta=(split('_',$a))[-1];
2357: my $tb=(split('_',$b))[-1];
2358: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
2359: return ($a cmp $b);
2360: }
2361: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1.236 albertel 2362: } (keys %{$name});
2363: }
2364:
1.211 www 2365: sub keysindisplayorder {
2366: my ($name,$keyorder)=@_;
2367: return sort {
1.473 amueller 2368: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1.211 www 2369: } (keys %{$name});
2370: }
2371:
1.214 www 2372: sub sortmenu {
2373: my ($r,$sortorder)=@_;
1.236 albertel 2374: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 2375: if ($sortorder eq 'realmstudent') {
1.422 bisitz 2376: $r->print(' checked="checked"');
1.214 www 2377: }
2378: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 2379: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 2380: if ($sortorder eq 'studentrealm') {
1.422 bisitz 2381: $r->print(' checked="checked"');
1.214 www 2382: }
1.236 albertel 2383: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1.473 amueller 2384: '</label>');
1.214 www 2385: }
2386:
1.211 www 2387: sub standardkeyorder {
2388: return ('parameter_0_opendate' => 1,
1.473 amueller 2389: 'parameter_0_duedate' => 2,
2390: 'parameter_0_answerdate' => 3,
2391: 'parameter_0_interval' => 4,
2392: 'parameter_0_weight' => 5,
2393: 'parameter_0_maxtries' => 6,
2394: 'parameter_0_hinttries' => 7,
2395: 'parameter_0_contentopen' => 8,
2396: 'parameter_0_contentclose' => 9,
2397: 'parameter_0_type' => 10,
2398: 'parameter_0_problemstatus' => 11,
2399: 'parameter_0_hiddenresource' => 12,
2400: 'parameter_0_hiddenparts' => 13,
2401: 'parameter_0_display' => 14,
2402: 'parameter_0_ordered' => 15,
2403: 'parameter_0_tol' => 16,
2404: 'parameter_0_sig' => 17,
2405: 'parameter_0_turnoffunit' => 18,
1.521 raeburn 2406: 'parameter_0_discussend' => 19,
2407: 'parameter_0_discusshide' => 20,
2408: 'parameter_0_discussvote' => 21,
1.522.2.15 raeburn 2409: 'parameter_0_printstartdate' => 22,
2410: 'parameter_0_printenddate' => 23);
1.211 www 2411: }
2412:
1.59 matthew 2413:
1.30 www 2414: sub assessparms {
1.1 www 2415:
1.522.2.19 raeburn 2416: my ($r,$parm_permission) = @_;
1.512 foxr 2417:
2418:
2419: # -------------------------------------------------------- Variable declaration
1.201 www 2420: my @ids=();
2421: my %symbp=();
2422: my %mapp=();
2423: my %typep=();
2424: my %keyp=();
2425: my %uris=();
2426: my %maptitles=();
1.129 www 2427: my %allmaps=();
2428: my %alllevs=();
1.57 albertel 2429:
1.187 www 2430: my $uname;
2431: my $udom;
2432: my $uhome;
2433: my $csec;
1.269 raeburn 2434: my $cgroup;
1.275 raeburn 2435: my @usersgroups = ();
1.446 bisitz 2436:
1.190 albertel 2437: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 2438:
1.57 albertel 2439: $alllevs{'Resource Level'}='full';
1.215 www 2440: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 2441: $alllevs{'Course Level'}='general';
2442:
2443: my %allparms;
2444: my %allparts;
1.512 foxr 2445: # ------------------------------------------------------------------------------
2446:
1.210 www 2447: #
2448: # Order in which these parameters will be displayed
2449: #
1.211 www 2450: my %keyorder=&standardkeyorder();
2451:
1.512 foxr 2452: # @ids=();
2453: # %symbp=(); # These seem defined above already.
2454: # %typep=();
1.43 albertel 2455:
2456: my $message='';
2457:
1.190 albertel 2458: $csec=$env{'form.csec'};
1.522.2.24 raeburn 2459: if ($env{'request.course.sec'} ne '') {
2460: $csec = $env{'request.course.sec'};
2461: }
2462:
2463: # Check group privs.
1.269 raeburn 2464: $cgroup=$env{'form.cgroup'};
1.522.2.20 raeburn 2465: my $noeditgrp;
2466: if ($cgroup ne '') {
2467: unless (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
2468: if (($env{'request.course.groups'} eq '') ||
1.522.2.24 raeburn 2469: (!grep(/^\Q$cgroup\E$/,split(/:/,$env{'request.course.groups'})))) {
1.522.2.20 raeburn 2470: $noeditgrp = 1;
2471: }
2472: }
2473: }
1.188 www 2474:
1.190 albertel 2475: if ($udom=$env{'form.udom'}) {
2476: } elsif ($udom=$env{'request.role.domain'}) {
2477: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 2478: } else {
1.473 amueller 2479: $udom=$r->dir_config('lonDefDomain');
1.172 albertel 2480: }
1.468 amueller 2481:
1.43 albertel 2482:
1.134 albertel 2483: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 2484: my $pschp=$env{'form.pschp'};
1.506 www 2485:
2486:
1.134 albertel 2487: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.522.2.1 raeburn 2488: if (!@psprt) { $psprt[0]='0'; }
1.506 www 2489: if (($env{'form.part'}) && ($psprt[0] ne 'all')) { $psprt[0]=$env{'form.part'}; }
1.57 albertel 2490:
1.43 albertel 2491: my $pssymb='';
1.57 albertel 2492: my $parmlev='';
1.446 bisitz 2493:
1.190 albertel 2494: unless ($env{'form.parmlev'}) {
1.57 albertel 2495: $parmlev = 'map';
2496: } else {
1.190 albertel 2497: $parmlev = $env{'form.parmlev'};
1.57 albertel 2498: }
1.26 www 2499:
1.29 www 2500: # ----------------------------------------------- Was this started from grades?
2501:
1.190 albertel 2502: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1.473 amueller 2503: && (!$env{'form.dis'})) {
2504: my $url=$env{'form.url'};
2505: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
2506: $pssymb=&Apache::lonnet::symbread($url);
2507: if (!@pscat) { @pscat=('all'); }
2508: $pschp='';
1.57 albertel 2509: $parmlev = 'full';
1.190 albertel 2510: } elsif ($env{'form.symb'}) {
1.473 amueller 2511: $pssymb=$env{'form.symb'};
2512: if (!@pscat) { @pscat=('all'); }
2513: $pschp='';
1.57 albertel 2514: $parmlev = 'full';
1.43 albertel 2515: } else {
1.473 amueller 2516: $env{'form.url'}='';
1.43 albertel 2517: }
2518:
1.190 albertel 2519: my $id=$env{'form.id'};
1.43 albertel 2520: if (($id) && ($udom)) {
1.473 amueller 2521: $uname=(&Apache::lonnet::idget($udom,$id))[1];
2522: if ($uname) {
2523: $id='';
2524: } else {
2525: $message=
2526: '<span class="LC_error">'.&mt("Unknown ID")." '$id' ".
2527: &mt('at domain')." '$udom'</span>";
2528: }
1.43 albertel 2529: } else {
1.473 amueller 2530: $uname=$env{'form.uname'};
1.43 albertel 2531: }
2532: unless ($udom) { $uname=''; }
2533: $uhome='';
2534: if ($uname) {
1.473 amueller 2535: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1.43 albertel 2536: if ($uhome eq 'no_host') {
1.473 amueller 2537: $message=
2538: '<span class="LC_error">'.&mt("Unknown user")." '$uname' ".
2539: &mt("at domain")." '$udom'</span>";
2540: $uname='';
1.12 www 2541: } else {
1.473 amueller 2542: $csec=&Apache::lonnet::getsection($udom,$uname,
2543: $env{'request.course.id'});
2544: if ($csec eq '-1') {
1.522.2.27 raeburn 2545: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
2546: if ($env{'form.userroles'} eq 'any') {
2547: if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
2548: $csec = $env{'request.course.sec'};
2549: $message = '<span class="LC_info">';
2550: if ($crstype eq 'Community') {
2551: $message .= &mt('User [_1] at domain [_2] has a non-member role in this community',
2552: $uname,$udom);
2553: } else {
2554: $message .= &mt('User [_1] at domain [_2] has a non-student role in this course',
2555: $uname,$udom);
2556: }
2557: $message .= '</span>';
2558: } else {
2559: my @possroles = ('in','ep','ta','cr');
2560: if ($crstype eq 'Community') {
2561: unshift(@possroles,'co');
2562: } else {
2563: unshift(@possroles,'cc');
2564: }
2565: my %not_student_roles =
2566: &Apache::lonnet::get_my_roles($uname,$udom,'userroles',['active'],
2567: \@possroles,[$udom],1,1);
2568: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2569: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2570: my %sections_by_role;
2571: foreach my $role (keys(%not_student_roles)) {
2572: if ($role =~ /^\Q$cnum:$cdom:\E([^:]+):(|[^:]+)$/) {
2573: my ($rolename,$sec) = ($1,$2);
2574: if ($rolename =~ m{^cr/}) {
2575: $rolename = 'cr';
2576: }
2577: push(@{$sections_by_role{$rolename}},$sec);
2578: }
2579: }
2580: my $numroles = scalar(keys(%sections_by_role));
2581: if ($numroles) {
2582: foreach my $role (@possroles) {
2583: if (ref($sections_by_role{$role}) eq 'ARRAY') {
2584: my @secs = sort { $a <=> $b } @{$sections_by_role{$role}};
1.522.2.28.4. (raeburn 2585:): $csec = $secs[0];
1.522.2.27 raeburn 2586: last;
2587: }
2588: }
2589: }
2590: if ($csec eq '-1') {
2591: $message = '<span class="LC_warning">';
2592: if ($crstype eq 'Community') {
2593: $message .= &mt('User [_1] at domain [_2] does not have a role in this community',
2594: $uname,$udom);
2595: } else {
2596: $message .= &mt('User [_1] at domain [_2] does not have a role in this course',
2597: $uname,$udom);
2598: }
2599: $message .= '</span>';
2600: $uname='';
2601: if ($env{'request.course.sec'} ne '') {
2602: $csec=$env{'request.course.sec'};
2603: } else {
2604: $csec=$env{'form.csec'};
2605: }
2606: $cgroup=$env{'form.cgroup'};
2607: } else {
2608: $message = '<span class="LC_info">';
2609: if ($crstype eq 'Community') {
2610: $message .= &mt('User [_1] at domain [_2] has a non-member role in this community',
2611: $uname,$udom);
2612: } else {
2613: $message .= &mt('User [_1] at domain [_2] has a non-student role in this course',
2614: $uname,$udom);
2615: }
2616: $message .= '</span>';
2617: }
2618: }
2619: } else {
2620: $message = '<span class="LC_warning">';
2621: if ($crstype eq 'Community') {
2622: $message .= &mt('User [_1] at domain [_2] does not have a member role in this community',
2623: $uname,$udom);
2624: } else {
2625: $message .= &mt('User [_1] at domain [_2] does not have a student role in this course',
2626: $uname,$udom);
2627: }
2628: $message .= '</span>';
1.522.2.28.4. (raeburn 2629:): $uname='';
1.522.2.27 raeburn 2630: if ($env{'request.course.sec'} ne '') {
2631: $csec=$env{'request.course.sec'};
2632: } else {
2633: $csec=$env{'form.csec'};
2634: }
2635: $cgroup=$env{'form.cgroup'};
2636: }
2637: } elsif ($env{'request.course.sec'} ne '') {
2638: if ($csec ne $env{'request.course.sec'}) {
2639: $message='<span class="LC_warning">'.
2640: &mt("User '[_1]' at domain '[_2]' not in section '[_3]'",
2641: $uname,$udom,$env{'request.course.sec'}).
2642: '</span>';
2643: $uname='';
2644: $csec=$env{'request.course.sec'};
2645: }
1.269 raeburn 2646: $cgroup=$env{'form.cgroup'};
1.522.2.27 raeburn 2647: }
2648: if ($uname ne '') {
1.473 amueller 2649: my %name=&Apache::lonnet::userenvironment($udom,$uname,
2650: ('firstname','middlename','lastname','generation','id'));
1.522.2.27 raeburn 2651: $message .= "\n<p>\n".&mt('Full Name').': '
2652: .$name{'firstname'}.' '.$name{'middlename'}.' '
2653: .$name{'lastname'}.' '.$name{'generation'}
2654: ."<br />\n".&mt('Student/Employee ID').': '.$name{'id'}.'</p>';
2655: @usersgroups = &Apache::lonnet::get_users_groups(
2656: $udom,$uname,$env{'request.course.id'});
2657: if (@usersgroups > 0) {
2658: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
2659: $cgroup = $usersgroups[0];
2660: }
2661: } else {
2662: $cgroup = '';
1.297 raeburn 2663: }
1.269 raeburn 2664: }
1.12 www 2665: }
1.43 albertel 2666: }
1.2 www 2667:
1.43 albertel 2668: unless ($csec) { $csec=''; }
1.269 raeburn 2669: unless ($cgroup) { $cgroup=''; }
1.12 www 2670:
1.14 www 2671: # --------------------------------------------------------- Get all assessments
1.446 bisitz 2672: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 2673: \%mapp, \%symbp,\%maptitles,\%uris,
2674: \%keyorder);
1.63 bowersj2 2675:
1.57 albertel 2676: $mapp{'0.0'} = '';
2677: $symbp{'0.0'} = '';
1.99 albertel 2678:
1.14 www 2679: # ---------------------------------------------------------- Anything to store?
1.522.2.19 raeburn 2680: if ($env{'form.pres_marker'} && $parm_permission->{'edit'}) {
1.205 www 2681: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
2682: my @values=split(/\&\&\&/,$env{'form.pres_value'});
2683: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1.500 raeburn 2684: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2685: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.504 raeburn 2686: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
2687: my ($got_chostname,$chostname,$cmajor,$cminor);
2688: my $totalstored = 0;
1.522.2.28.4. (raeburn 2689:): my $totalskippeduser = 0;
1.522.2.16 raeburn 2690: my $now = time;
1.473 amueller 2691: for (my $i=0;$i<=$#markers;$i++) {
1.514 raeburn 2692: my ($needsrelease,$needsnewer,$name);
1.522.2.24 raeburn 2693: if (($env{'request.course.sec'} ne '') && ($markers[$i] =~ /\&(7|8|9)$/)) {
2694: next if ($csec ne $env{'request.course.sec'});
2695: }
2696: if ($markers[$i] =~ /\&(6|5|4)$/) {
2697: next if ($noeditgrp);
1.522.2.28.4. (raeburn 2698:): } elsif ($markers[$i] =~ /\&(3|2|1)$/) {
2699:): if ($uname eq '') {
2700:): $totalskippeduser ++;
2701:): next;
2702:): }
1.522.2.24 raeburn 2703: }
1.437 raeburn 2704: if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
2705: my (@ok_slots,@fail_slots,@del_slots);
2706: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
2707: my ($level,@all) =
2708: &parmval_by_symb('0.availablestudent',$pssymb,'',$uname,$udom,
2709: $csec,$cgroup,$courseopt);
2710: foreach my $slot_name (split(/:/,$values[$i])) {
2711: next if ($slot_name eq '');
2712: if (&update_slots($slot_name,$cdom,$cnum,$pssymb,$uname,$udom) eq 'ok') {
2713: push(@ok_slots,$slot_name);
2714:
2715: } else {
2716: push(@fail_slots,$slot_name);
2717: }
2718: }
2719: if (@ok_slots) {
2720: $values[$i] = join(':',@ok_slots);
2721: } else {
2722: $values[$i] = '';
2723: }
2724: if ($all[$level] ne '') {
2725: my @existing = split(/:/,$all[$level]);
2726: foreach my $slot_name (@existing) {
2727: if (!grep(/^\Q$slot_name\E$/,split(/:/,$values[$i]))) {
2728: if (&delete_slots($slot_name,$cdom,$cnum,$uname,$udom,$pssymb) eq 'ok') {
2729: push(@del_slots,$slot_name);
2730: }
2731: }
2732: }
2733: }
1.522.2.16 raeburn 2734: } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode|printstartdate|printenddate)\&\d+$/) {
1.514 raeburn 2735: $name = $1;
1.522.2.7 raeburn 2736: my $val = $values[$i];
2737: if ($name eq 'examcode') {
1.522.2.14 raeburn 2738: if (&Apache::lonnet::validCODE($values[$i])) {
2739: $val = 'valid';
2740: }
1.522.2.16 raeburn 2741: } elsif ($name eq 'printstartdate') {
2742: if ($val =~ /^\d+$/) {
2743: if ($val > $now) {
2744: $val = 'future';
2745: }
2746: }
2747: } elsif ($name eq 'printenddate') {
2748: if ($val =~ /^\d+$/) {
2749: if ($val < $now) {
2750: $val = 'past';
2751: }
2752: }
1.522.2.7 raeburn 2753: }
1.504 raeburn 2754: $needsrelease =
1.522.2.7 raeburn 2755: $Apache::lonnet::needsrelease{"parameter:$name:$val"};
1.504 raeburn 2756: if ($needsrelease) {
1.505 raeburn 2757: unless ($got_chostname) {
1.514 raeburn 2758: ($chostname,$cmajor,$cminor) = ¶meter_release_vars();
1.504 raeburn 2759: $got_chostname = 1;
2760: }
1.522.2.7 raeburn 2761: $needsnewer = ¶meter_releasecheck($name,$val,
1.514 raeburn 2762: $needsrelease,
2763: $cmajor,$cminor);
1.500 raeburn 2764: }
1.437 raeburn 2765: }
1.504 raeburn 2766: if ($needsnewer) {
1.514 raeburn 2767: $message .= &oldversion_warning($name,$values[$i],$chostname,$cmajor,
1.504 raeburn 2768: $cminor,$needsrelease);
2769: } else {
2770: $message.=&storeparm(split(/\&/,$markers[$i]),
2771: $values[$i],
2772: $types[$i],
2773: $uname,$udom,$csec,$cgroup);
2774: $totalstored ++;
2775: }
1.473 amueller 2776: }
1.68 www 2777: # ---------------------------------------------------------------- Done storing
1.504 raeburn 2778: if ($totalstored) {
2779: $message.='<p class="LC_warning">'
1.522.2.28.4. (raeburn 2780:): .&mt('Changes for [quant,_1,parameter] saved.',$totalstored)
2781:): .'<br />'
1.504 raeburn 2782: .&mt('Changes can take up to 10 minutes before being active for all students.')
2783: .&Apache::loncommon::help_open_topic('Caching')
2784: .'</p>';
1.522.2.28.4. (raeburn 2785:): } else {
2786:): $message.='<p class="LC_info">'.&mt('No parameter changes saved.').'</p>';
2787:): }
2788:): if ($totalskippeduser) {
2789:): $message .= '<p class="LC_warning">';
2790:): if ($uhome eq 'no_host') {
2791:): $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the username or ID was invalid.',
2792:): $totalskippeduser);
2793:): } elsif ($env{'form.userroles'} eq 'any') {
2794:): $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user does not have a course role.',
2795:): $totalskippeduser);
2796:): } else {
2797:): $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user is not a student.',
2798:): $totalskippeduser);
2799:): }
2800:): $message .= '</p>';
1.504 raeburn 2801: }
1.68 www 2802: }
1.57 albertel 2803: #----------------------------------------------- if all selected, fill in array
1.209 www 2804: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1.501 bisitz 2805: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries','type','problemstatus') };
1.57 albertel 2806: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 2807: # ------------------------------------------------------------------ Start page
1.63 bowersj2 2808:
1.515 raeburn 2809: &startpage($r,$pssymb);
1.57 albertel 2810:
1.522.2.28.4. (raeburn 2811:): foreach my $item ('tolerance','date_default','date_start','date_end',
2812:): 'date_interval','int','float','string','string_lenient',
2813:): 'string_examcode','string_deeplink','string_discussvote',
2814:): 'string_useslots','string_problemstatus','string_ip',
2815:): 'string_questiontype') {
1.473 amueller 2816: $r->print('<input type="hidden" value="'.
1.522.2.28.4. (raeburn 2817:): &HTML::Entities::encode($env{'form.recent_'.$item},'"&<>').
2818:): '" name="recent_'.$item.'" />');
1.44 albertel 2819: }
1.446 bisitz 2820:
1.459 bisitz 2821: # ----- Start Parameter Selection
2822:
1.522.2.28.4. (raeburn 2823:): # Hide parm selection and possibly table?
2824:): my ($tablejs,$tabledivsty);
2825:): if (((($env{'form.uname'} ne '') || ($env{'form.id'} ne '')) && ($uname eq '')) &&
2826:): ($env{'form.dis'}) && ($pssymb eq '')) {
2827:): $tablejs = 'document.getElementById('."'parmtable'".').style.display = "";';
2828:): $tabledivsty = ' style="display:none"';
2829:): }
1.459 bisitz 2830: $r->print(<<ENDPARMSELSCRIPT);
2831: <script type="text/javascript">
2832: // <![CDATA[
2833: function parmsel_show() {
2834: document.getElementById('parmsel').style.display = "";
2835: document.getElementById('parmsellink').style.display = "none";
1.522.2.28.4. (raeburn 2836:): $tablejs
1.459 bisitz 2837: }
2838: // ]]>
2839: </script>
2840: ENDPARMSELSCRIPT
1.474 amueller 2841:
1.445 neumanie 2842: if (!$pssymb) {
1.486 www 2843: my $parmselhiddenstyle=' style="display:none"';
2844: if($env{'form.hideparmsel'} eq 'hidden') {
2845: $r->print('<div id="parmsel"'.$parmselhiddenstyle.'>');
2846: } else {
2847: $r->print('<div id="parmsel">');
2848: }
2849:
1.491 bisitz 2850: # Step 1
1.522.2.2 raeburn 2851: $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'),'parmstep1'));
2852: $r->print('
1.474 amueller 2853: <script type="text/javascript">
1.522.2.2 raeburn 2854: // <![CDATA['.
2855: &showhide_js().'
1.474 amueller 2856: // ]]>
2857: </script>
1.522.2.2 raeburn 2858: ');
2859: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.209 www 2860: &levelmenu($r,\%alllevs,$parmlev);
1.491 bisitz 2861: $r->print(&Apache::lonhtmlcommon::row_closure());
1.474 amueller 2862: &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp);
1.491 bisitz 2863: $r->print(&Apache::lonhtmlcommon::row_closure());
2864: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
2865: &partmenu($r,\%allparts,\@psprt);
1.474 amueller 2866: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2867: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2868:
2869: # Step 2
1.522.2.2 raeburn 2870: $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
1.522.2.25 raeburn 2871: &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
1.491 bisitz 2872:
2873: # Step 3
1.522.2.2 raeburn 2874: $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
1.486 www 2875: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.522.2.24 raeburn 2876: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
1.486 www 2877: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2878: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2879:
2880: # Update Display Button
1.486 www 2881: $r->print('<p>'
2882: .'<input type="submit" name="dis"'
1.511 www 2883: .' value="'.&mt('Update Display').'" />'
1.486 www 2884: .'<input type="hidden" name="hideparmsel" value="hidden" />'
2885: .'</p>');
2886: $r->print('</div>');
1.491 bisitz 2887:
1.486 www 2888: # Offer link to display parameter selection again
2889: $r->print('<p id="parmsellink"');
2890: if ($env{'form.hideparmsel'} ne 'hidden') {
2891: $r->print($parmselhiddenstyle);
2892: }
2893: $r->print('>'
2894: .'<a href="javascript:parmsel_show()">'
2895: .&mt('Change Parameter Selection')
2896: .'</a>'
2897: .'</p>');
1.44 albertel 2898: } else {
1.515 raeburn 2899: $r->print();
1.478 amueller 2900: # parameter screen for a single resource.
1.486 www 2901: my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.473 amueller 2902: my $title = &Apache::lonnet::gettitle($pssymb);
1.501 bisitz 2903: $r->print(&mt('Specific Resource: [_1] ([_2])',
2904: $title,'<span class="LC_filename">'.$resource.'</span>').
1.472 amueller 2905: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.486 www 2906: '<br />');
2907: $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));
2908: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.522.2.1 raeburn 2909: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')).
2910: '<label>'.
2911: '<input type="checkbox" name="psprt" value="all"'.
2912: ($env{'form.psprt'}?' checked="checked"':'').' />'.
2913: &mt('Show all parts').
2914: '</label></td></tr>');
1.522.2.24 raeburn 2915: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
1.486 www 2916: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2917: $r->print(&Apache::lonhtmlcommon::end_pick_box());
2918: $r->print('<p>'
1.459 bisitz 2919: .'<input type="submit" name="dis"'
1.511 www 2920: .' value="'.&mt('Update Display').'" />'
1.459 bisitz 2921: .'<input type="hidden" name="hideparmsel" value="hidden" />'
1.486 www 2922: .'</p>');
1.459 bisitz 2923: }
1.478 amueller 2924:
1.486 www 2925: # ----- End Parameter Selection
1.57 albertel 2926:
1.459 bisitz 2927: # Display Messages
2928: $r->print('<div>'.$message.'</div>');
1.210 www 2929:
1.57 albertel 2930:
2931: my @temp_pscat;
2932: map {
2933: my $cat = $_;
2934: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
2935: } @pscat;
2936:
2937: @pscat = @temp_pscat;
2938:
1.209 www 2939: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 2940: # ----------------------------------------------------------------- Start Table
1.57 albertel 2941: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 2942: my $csuname=$env{'user.name'};
2943: my $csudom=$env{'user.domain'};
1.522.2.19 raeburn 2944: my $readonly = 1;
2945: if ($parm_permission->{'edit'}) {
2946: undef($readonly);
2947: }
1.522.2.28.4. (raeburn 2948:): $r->print('<div id="parmtable"'.$tabledivsty.'>');
1.57 albertel 2949:
1.203 www 2950: if ($parmlev eq 'full') {
1.506 www 2951: #
2952: # This produces the cascading table output of parameters
2953: #
1.473 amueller 2954: my $coursespan=$csec?8:5;
2955: my $userspan=3;
2956: if ($cgroup ne '') {
2957: $coursespan += 3;
2958: }
2959:
1.517 www 2960: $r->print(&Apache::loncommon::start_data_table());
1.506 www 2961: #
2962: # This produces the headers
2963: #
1.473 amueller 2964: $r->print('<tr><td colspan="5"></td>');
2965: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
2966: if ($uname) {
2967: if (@usersgroups > 1) {
2968: $userspan ++;
2969: }
2970: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
2971: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
2972: }
2973: my %lt=&Apache::lonlocal::texthash(
2974: 'pie' => "Parameter in Effect",
2975: 'csv' => "Current Session Value",
1.472 amueller 2976: 'rl' => "Resource Level",
1.473 amueller 2977: 'ic' => 'in Course',
2978: 'aut' => "Assessment URL and Title",
2979: 'type' => 'Type',
2980: 'emof' => "Enclosing Map or Folder",
2981: 'part' => 'Part',
1.472 amueller 2982: 'pn' => 'Parameter Name',
1.473 amueller 2983: 'def' => 'default',
2984: 'femof' => 'from Enclosing Map or Folder',
2985: 'gen' => 'general',
2986: 'foremf' => 'for Enclosing Map or Folder',
2987: 'fr' => 'for Resource'
2988: );
2989: $r->print(<<ENDTABLETWO);
1.419 bisitz 2990: <th rowspan="3">$lt{'pie'}</th>
1.501 bisitz 2991: <th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>
1.419 bisitz 2992: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
2993: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 2994:
1.10 www 2995: ENDTABLETWO
1.473 amueller 2996: if ($csec) {
2997: $r->print('<th colspan="3">'.
2998: &mt("in Section")." $csec</th>");
2999: }
3000: if ($cgroup) {
1.419 bisitz 3001: $r->print('<th colspan="3">'.
1.472 amueller 3002: &mt("in Group")." $cgroup</th>");
1.473 amueller 3003: }
3004: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 3005: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
3006: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 3007: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
3008: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 3009: ENDTABLEHEADFOUR
1.57 albertel 3010:
1.473 amueller 3011: if ($csec) {
3012: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
3013: }
3014:
3015: if ($cgroup) {
3016: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
3017: }
3018:
3019: if ($uname) {
3020: if (@usersgroups > 1) {
3021: $r->print('<th>'.&mt('Control by other group?').'</th>');
3022: }
3023: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
3024: }
3025:
3026: $r->print('</tr>');
1.506 www 3027: #
3028: # Done with the headers
3029: #
1.473 amueller 3030: my $defbgone='';
3031: my $defbgtwo='';
3032: my $defbgthree = '';
1.57 albertel 3033:
1.473 amueller 3034: foreach (@ids) {
1.57 albertel 3035:
1.473 amueller 3036: my $rid=$_;
1.57 albertel 3037: my ($inmapid)=($rid=~/\.(\d+)$/);
3038:
1.446 bisitz 3039: if ((!$pssymb &&
1.473 amueller 3040: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
3041: ||
3042: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 3043: # ------------------------------------------------------ Entry for one resource
1.473 amueller 3044: if ($defbgone eq '#E0E099') {
3045: $defbgone='#E0E0DD';
1.57 albertel 3046: } else {
1.419 bisitz 3047: $defbgone='#E0E099';
1.57 albertel 3048: }
1.419 bisitz 3049: if ($defbgtwo eq '#FFFF99') {
1.473 amueller 3050: $defbgtwo='#FFFFDD';
1.57 albertel 3051: } else {
1.473 amueller 3052: $defbgtwo='#FFFF99';
1.57 albertel 3053: }
1.419 bisitz 3054: if ($defbgthree eq '#FFBB99') {
3055: $defbgthree='#FFBBDD';
1.269 raeburn 3056: } else {
1.419 bisitz 3057: $defbgthree='#FFBB99';
1.269 raeburn 3058: }
3059:
1.57 albertel 3060: my $thistitle='';
3061: my %name= ();
3062: undef %name;
3063: my %part= ();
3064: my %display=();
3065: my %type= ();
3066: my %default=();
1.196 www 3067: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 3068:
1.506 www 3069: my $filter=$env{'form.filter'};
1.210 www 3070: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 3071: my $tempkeyp = $_;
3072: if (grep $_ eq $tempkeyp, @catmarker) {
1.506 www 3073: my $parmname=&Apache::lonnet::metadata($uri,$_.'.name');
3074: # We may only want certain parameters listed
3075: if ($filter) {
3076: unless ($filter=~/\Q$parmname\E/) { next; }
3077: }
3078: $name{$_}=$parmname;
1.57 albertel 3079: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1.506 www 3080:
1.433 raeburn 3081: my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
3082: if ($allparms{$name{$_}} ne '') {
3083: my $identifier;
3084: if ($parmdis =~ /(\s*\[Part.*)$/) {
3085: $identifier = $1;
3086: }
3087: $display{$_} = $allparms{$name{$_}}.$identifier;
3088: } else {
3089: $display{$_} = $parmdis;
3090: }
1.57 albertel 3091: unless ($display{$_}) { $display{$_}=''; }
3092: $display{$_}.=' ('.$name{$_}.')';
3093: $default{$_}=&Apache::lonnet::metadata($uri,$_);
3094: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
3095: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
3096: }
3097: }
3098: my $totalparms=scalar keys %name;
3099: if ($totalparms>0) {
1.473 amueller 3100: my $firstrow=1;
3101: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 3102: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 3103: ' rowspan='.$totalparms.
1.419 bisitz 3104: '><tt><font size="-1">'.
1.57 albertel 3105: join(' / ',split(/\//,$uri)).
3106: '</font></tt><p><b>'.
1.154 albertel 3107: "<a href=\"javascript:openWindow('".
1.473 amueller 3108: &Apache::lonnet::clutter($uri).'?symb='.
3109: &escape($symbp{$rid}).
1.336 albertel 3110: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
3111: " target=\"_self\">$title");
1.57 albertel 3112:
3113: if ($thistitle) {
1.473 amueller 3114: $r->print(' ('.$thistitle.')');
1.57 albertel 3115: }
3116: $r->print('</a></b></td>');
1.419 bisitz 3117: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 3118: ' rowspan='.$totalparms.'>'.$typep{$rid}.
3119: '</td>');
3120:
1.419 bisitz 3121: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 3122: ' rowspan='.$totalparms.
1.238 www 3123: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.512 foxr 3124: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 3125:
3126: unless ($firstrow) {
3127: $r->print('<tr>');
3128: } else {
3129: undef $firstrow;
3130: }
1.201 www 3131: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 3132: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 3133: $defbgthree,$parmlev,$uname,$udom,$csec,
1.522.2.19 raeburn 3134: $cgroup,\@usersgroups,$noeditgrp,$readonly);
1.57 albertel 3135: }
3136: }
3137: }
3138: } # end foreach ids
1.43 albertel 3139: # -------------------------------------------------- End entry for one resource
1.517 www 3140: $r->print(&Apache::loncommon::end_data_table);
1.203 www 3141: } # end of full
1.57 albertel 3142: #--------------------------------------------------- Entry for parm level map
3143: if ($parmlev eq 'map') {
1.419 bisitz 3144: my $defbgone = '#E0E099';
3145: my $defbgtwo = '#FFFF99';
3146: my $defbgthree = '#FFBB99';
1.57 albertel 3147:
3148: my %maplist;
3149:
3150: if ($pschp eq 'all') {
1.446 bisitz 3151: %maplist = %allmaps;
1.57 albertel 3152: } else {
3153: %maplist = ($pschp => $mapp{$pschp});
3154: }
3155:
3156: #-------------------------------------------- for each map, gather information
3157: my $mapid;
1.473 amueller 3158: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1.60 albertel 3159: my $maptitle = $maplist{$mapid};
1.57 albertel 3160:
3161: #----------------------- loop through ids and get all parameter types for map
3162: #----------------------------------------- and associated information
3163: my %name = ();
3164: my %part = ();
3165: my %display = ();
3166: my %type = ();
3167: my %default = ();
3168: my $map = 0;
3169:
1.473 amueller 3170: # $r->print("Catmarker: @catmarker<br />\n");
1.446 bisitz 3171:
1.57 albertel 3172: foreach (@ids) {
1.473 amueller 3173: ($map)=(/([\d]*?)\./);
3174: my $rid = $_;
1.446 bisitz 3175:
1.57 albertel 3176: # $r->print("$mapid:$map: $rid <br /> \n");
3177:
1.473 amueller 3178: if ($map eq $mapid) {
3179: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 3180: # $r->print("Keys: $keyp{$rid} <br />\n");
3181:
3182: #--------------------------------------------------------------------
3183: # @catmarker contains list of all possible parameters including part #s
3184: # $fullkeyp contains the full part/id # for the extraction of proper parameters
3185: # $tempkeyp contains part 0 only (no ids - ie, subparts)
3186: # When storing information, store as part 0
3187: # When requesting information, request from full part
3188: #-------------------------------------------------------------------
1.473 amueller 3189: foreach (&keysplit($keyp{$rid})) {
3190: my $tempkeyp = $_;
3191: my $fullkeyp = $tempkeyp;
3192: $tempkeyp =~ s/_\w+_/_0_/;
3193:
3194: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
3195: $part{$tempkeyp}="0";
3196: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
3197: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
3198: if ($allparms{$name{$tempkeyp}} ne '') {
3199: my $identifier;
3200: if ($parmdis =~ /(\s*\[Part.*)$/) {
3201: $identifier = $1;
3202: }
3203: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
3204: } else {
3205: $display{$tempkeyp} = $parmdis;
3206: }
3207: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
3208: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
3209: $display{$tempkeyp} =~ s/_\w+_/_0_/;
3210: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
3211: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
3212: }
3213: } # end loop through keys
3214: }
1.57 albertel 3215: } # end loop through ids
1.446 bisitz 3216:
1.57 albertel 3217: #---------------------------------------------------- print header information
1.133 www 3218: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 3219: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 3220: my $tmp="";
1.57 albertel 3221: if ($uname) {
1.473 amueller 3222: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 3223: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
3224: &mt('in')." \n";
1.57 albertel 3225: } else {
1.401 bisitz 3226: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 3227: }
1.269 raeburn 3228: if ($cgroup) {
1.401 bisitz 3229: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
3230: "</i></font> ".&mt('of')." \n";
1.269 raeburn 3231: $csec = '';
3232: } elsif ($csec) {
1.401 bisitz 3233: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
3234: "</i></font> ".&mt('of')." \n";
1.269 raeburn 3235: }
1.401 bisitz 3236: $r->print('<div align="center"><h4>'
3237: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 3238: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 3239: ,$tmp
3240: ,'<font color="red"><i>'.$coursename.'</i></font>'
3241: )
3242: ."<br /></h4>\n"
1.422 bisitz 3243: );
1.57 albertel 3244: #---------------------------------------------------------------- print table
1.419 bisitz 3245: $r->print('<p>'.&Apache::loncommon::start_data_table()
3246: .&Apache::loncommon::start_data_table_header_row()
3247: .'<th>'.&mt('Parameter Name').'</th>'
3248: .'<th>'.&mt('Default Value').'</th>'
3249: .'<th>'.&mt('Parameter in Effect').'</th>'
3250: .&Apache::loncommon::end_data_table_header_row()
3251: );
1.57 albertel 3252:
1.473 amueller 3253: foreach (&keysinorder(\%name,\%keyorder)) {
3254: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 3255: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 3256: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1.522.2.19 raeburn 3257: $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
3258: $readonly);
1.57 albertel 3259: }
1.422 bisitz 3260: $r->print(&Apache::loncommon::end_data_table().'</p>'
3261: .'</div>'
3262: );
1.57 albertel 3263: } # end each map
3264: } # end of $parmlev eq map
3265: #--------------------------------- Entry for parm level general (Course level)
3266: if ($parmlev eq 'general') {
1.473 amueller 3267: my $defbgone = '#E0E099';
1.419 bisitz 3268: my $defbgtwo = '#FFFF99';
3269: my $defbgthree = '#FFBB99';
1.57 albertel 3270:
3271: #-------------------------------------------- for each map, gather information
3272: my $mapid="0.0";
3273: #----------------------- loop through ids and get all parameter types for map
3274: #----------------------------------------- and associated information
3275: my %name = ();
3276: my %part = ();
3277: my %display = ();
3278: my %type = ();
3279: my %default = ();
1.446 bisitz 3280:
1.57 albertel 3281: foreach (@ids) {
3282: my $rid = $_;
1.446 bisitz 3283:
1.196 www 3284: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 3285:
3286: #--------------------------------------------------------------------
3287: # @catmarker contains list of all possible parameters including part #s
3288: # $fullkeyp contains the full part/id # for the extraction of proper parameters
3289: # $tempkeyp contains part 0 only (no ids - ie, subparts)
3290: # When storing information, store as part 0
3291: # When requesting information, request from full part
3292: #-------------------------------------------------------------------
1.473 amueller 3293: foreach (&keysplit($keyp{$rid})) {
3294: my $tempkeyp = $_;
3295: my $fullkeyp = $tempkeyp;
3296: $tempkeyp =~ s/_\w+_/_0_/;
3297: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
3298: $part{$tempkeyp}="0";
3299: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
3300: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
3301: if ($allparms{$name{$tempkeyp}} ne '') {
3302: my $identifier;
3303: if ($parmdis =~ /(\s*\[Part.*)$/) {
3304: $identifier = $1;
3305: }
3306: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
3307: } else {
3308: $display{$tempkeyp} = $parmdis;
3309: }
3310: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
3311: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
3312: $display{$tempkeyp} =~ s/_\w+_/_0_/;
3313: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
3314: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
3315: }
1.57 albertel 3316: } # end loop through keys
3317: } # end loop through ids
1.446 bisitz 3318:
1.57 albertel 3319: #---------------------------------------------------- print header information
1.473 amueller 3320: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 3321: $r->print(<<ENDMAPONE);
1.419 bisitz 3322: <center>
3323: <h4>$setdef
1.135 albertel 3324: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 3325: ENDMAPONE
3326: if ($uname) {
1.473 amueller 3327: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 3328: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 3329: } else {
1.135 albertel 3330: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 3331: }
1.446 bisitz 3332:
1.135 albertel 3333: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 3334: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 3335: $r->print("</h4>\n");
1.57 albertel 3336: #---------------------------------------------------------------- print table
1.419 bisitz 3337: $r->print('<p>'.&Apache::loncommon::start_data_table()
3338: .&Apache::loncommon::start_data_table_header_row()
3339: .'<th>'.&mt('Parameter Name').'</th>'
3340: .'<th>'.&mt('Default Value').'</th>'
3341: .'<th>'.&mt('Parameter in Effect').'</th>'
3342: .&Apache::loncommon::end_data_table_header_row()
3343: );
1.57 albertel 3344:
1.473 amueller 3345: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 3346: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 3347: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.522.2.19 raeburn 3348: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
3349: $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
3350: $readonly);
1.57 albertel 3351: }
1.419 bisitz 3352: $r->print(&Apache::loncommon::end_data_table()
3353: .'</p>'
3354: .'</center>'
3355: );
1.57 albertel 3356: } # end of $parmlev eq general
1.522.2.28.4. (raeburn 3357:): $r->print('</div>');
1.43 albertel 3358: }
1.507 www 3359: $r->print('</form>');
3360: $r->print(&Apache::loncommon::end_page());
1.57 albertel 3361: } # end sub assessparms
1.30 www 3362:
1.120 www 3363: ##################################################
1.207 www 3364: # Overview mode
3365: ##################################################
1.124 www 3366: my $tableopen;
3367:
3368: sub tablestart {
1.522.2.19 raeburn 3369: my ($readonly) = @_;
1.124 www 3370: if ($tableopen) {
1.522.2.19 raeburn 3371: return '';
1.124 www 3372: } else {
1.522.2.19 raeburn 3373: $tableopen=1;
3374: my $output = &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th>';
3375: if ($readonly) {
3376: $output .= '<th>'.&mt('Current value').'</th>';
3377: } else {
3378: $output .= '<th>'.&mt('Delete').'</th><th>'.&mt('Set to ...').'</th>';
3379: }
3380: $output .= '</tr>';
3381: return $output;
1.124 www 3382: }
3383: }
3384:
3385: sub tableend {
3386: if ($tableopen) {
1.473 amueller 3387: $tableopen=0;
3388: return &Apache::loncommon::end_data_table();
1.124 www 3389: } else {
1.473 amueller 3390: return'';
1.124 www 3391: }
3392: }
3393:
1.207 www 3394: sub readdata {
3395: my ($crs,$dom)=@_;
3396: # Read coursedata
3397: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
3398: # Read userdata
3399:
3400: my $classlist=&Apache::loncoursedata::get_classlist();
3401: foreach (keys %$classlist) {
1.350 albertel 3402: if ($_=~/^($match_username)\:($match_domain)$/) {
1.473 amueller 3403: my ($tuname,$tudom)=($1,$2);
3404: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
1.207 www 3405: foreach my $userkey (keys %{$useropt}) {
1.473 amueller 3406: if ($userkey=~/^$env{'request.course.id'}/) {
1.207 www 3407: my $newkey=$userkey;
1.473 amueller 3408: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
3409: $$resourcedata{$newkey}=$$useropt{$userkey};
3410: }
3411: }
3412: }
1.207 www 3413: }
1.522.2.19 raeburn 3414: if (wantarray) {
3415: return ($resourcedata,$classlist);
3416: } else {
3417: return $resourcedata;
3418: }
1.207 www 3419: }
3420:
3421:
1.124 www 3422: # Setting
1.208 www 3423:
3424: sub storedata {
3425: my ($r,$crs,$dom)=@_;
1.207 www 3426: # Set userlevel immediately
3427: # Do an intermediate store of course level
3428: my $olddata=&readdata($crs,$dom);
1.124 www 3429: my %newdata=();
3430: undef %newdata;
3431: my @deldata=();
3432: undef @deldata;
1.504 raeburn 3433: my ($got_chostname,$chostname,$cmajor,$cminor);
1.522.2.16 raeburn 3434: my $now = time;
1.504 raeburn 3435: foreach my $key (keys(%env)) {
3436: if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
1.473 amueller 3437: my $cmd=$1;
3438: my $thiskey=$2;
1.522.2.28.4. (raeburn 3439:): next if ($cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink');
1.473 amueller 3440: my ($tuname,$tudom)=&extractuser($thiskey);
3441: my $tkey=$thiskey;
3442: if ($tuname) {
3443: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
3444: }
3445: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.522.2.28.4. (raeburn 3446:): my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch);
1.473 amueller 3447: if ($cmd eq 'set') {
1.504 raeburn 3448: $data=$env{$key};
1.522.2.28.4. (raeburn 3449:): $valmatch = '';
1.522.2.16 raeburn 3450: $valchk = $data;
1.473 amueller 3451: $typeof=$env{'form.typeof_'.$thiskey};
3452: $text = &mt('Saved modified parameter for');
1.504 raeburn 3453: if ($typeof eq 'string_questiontype') {
1.514 raeburn 3454: $name = 'type';
1.522.2.28.4. (raeburn 3455:): } elsif ($typeof eq 'string_deeplink') {
3456:): ($name) = ($typeof =~ /^string_(deeplink)$/);
3457:): my $stringmatch = &standard_string_matches($typeof);
3458:): if (ref($stringmatch) eq 'ARRAY') {
3459:): foreach my $item (@{$stringmatch}) {
3460:): if (ref($item) eq 'ARRAY') {
3461:): my ($regexpname,$pattern) = @{$item};
3462:): if ($pattern ne '') {
3463:): if ($data =~ /$pattern/) {
3464:): $valmatch = $regexpname;
3465:): $valchk = '';
3466:): last;
3467:): }
3468:): }
3469:): }
3470:): }
3471:): }
1.514 raeburn 3472: } elsif ($typeof eq 'string_lenient') {
3473: $name = 'lenient';
1.521 raeburn 3474: } elsif ($typeof eq 'string_discussvote') {
3475: $name = 'discussvote';
1.522.2.7 raeburn 3476: } elsif ($typeof eq 'string_examcode') {
3477: $name = 'examcode';
1.522.2.16 raeburn 3478: if (&Apache::lonnet::validCODE($data)) {
3479: $valchk = 'valid';
3480: }
1.519 raeburn 3481: } elsif ($typeof eq 'string_yesno') {
3482: if ($thiskey =~ /\.retrypartial$/) {
3483: $name = 'retrypartial';
3484: }
1.514 raeburn 3485: }
1.522.2.16 raeburn 3486: } elsif ($cmd eq 'datepointer') {
3487: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
3488: $typeof=$env{'form.typeof_'.$thiskey};
3489: $text = &mt('Saved modified date for');
3490: if ($typeof eq 'date_start') {
3491: if ($thiskey =~ /\.printstartdate$/) {
3492: $name = 'printstartdate';
3493: if (($data) && ($data > $now)) {
3494: $valchk = 'future';
1.504 raeburn 3495: }
3496: }
1.522.2.16 raeburn 3497: } elsif ($typeof eq 'date_end') {
3498: if ($thiskey =~ /\.printenddate$/) {
3499: $name = 'printenddate';
3500: if (($data) && ($data < $now)) {
3501: $valchk = 'past';
3502: }
3503: }
3504: }
3505: } elsif ($cmd eq 'dateinterval') {
3506: $data=&get_date_interval_from_form($thiskey);
3507: $typeof=$env{'form.typeof_'.$thiskey};
3508: $text = &mt('Saved modified date for');
3509: }
3510: if ($name ne '') {
3511: my ($needsrelease,$needsnewer);
3512: $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"};
3513: if ($needsrelease) {
3514: unless ($got_chostname) {
3515: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
3516: $got_chostname = 1;
3517: }
3518: $needsnewer = ¶meter_releasecheck($name,$valchk,
3519: $needsrelease,
3520: $cmajor,$cminor);
1.504 raeburn 3521: if ($needsnewer) {
1.514 raeburn 3522: $r->print('<br />'.&oldversion_warning($name,$data,
3523: $chostname,$cmajor,
1.504 raeburn 3524: $cminor,$needsrelease));
3525: next;
3526: }
3527: }
1.473 amueller 3528: }
3529: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 3530: if ($tuname) {
1.473 amueller 3531: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
3532: $tkey.'.type' => $typeof},
3533: $tudom,$tuname) eq 'ok') {
3534: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
3535: $r->print('<br />'.$text.' '.
3536: &Apache::loncommon::plainname($tuname,$tudom));
3537: } else {
3538: $r->print('<div class="LC_error">'.
3539: &mt('Error saving parameters').'</div>');
3540: }
3541: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3542: } else {
3543: $newdata{$thiskey}=$data;
3544: $newdata{$thiskey.'.type'}=$typeof;
1.446 bisitz 3545: }
1.473 amueller 3546: }
3547: } elsif ($cmd eq 'del') {
3548: if ($tuname) {
3549: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
3550: &log_parmset({$tkey=>''},1,$tuname,$tudom);
3551: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
3552: } else {
3553: $r->print('<div class="LC_error">'.
3554: &mt('Error deleting parameters').'</div>');
3555: }
3556: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3557: } else {
3558: push (@deldata,$thiskey,$thiskey.'.type');
3559: }
3560: }
3561: }
1.124 www 3562: }
1.207 www 3563: # Store all course level
1.144 www 3564: my $delentries=$#deldata+1;
3565: my @newdatakeys=keys %newdata;
3566: my $putentries=$#newdatakeys+1;
3567: if ($delentries) {
1.473 amueller 3568: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
3569: my %loghash=map { $_ => '' } @deldata;
3570: &log_parmset(\%loghash,1);
1.522.2.18 raeburn 3571: $r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>');
1.473 amueller 3572: } else {
3573: $r->print('<div class="LC_error">'.
3574: &mt('Error deleting parameters').'</div>');
3575: }
3576: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3577: }
3578: if ($putentries) {
1.473 amueller 3579: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
3580: &log_parmset(\%newdata,0);
1.522.2.17 raeburn 3581: $r->print('<h3>'.&mt('Saved [quant,_1,parameter]',$putentries/2).'</h3>');
1.473 amueller 3582: } else {
3583: $r->print('<div class="LC_error">'.
3584: &mt('Error saving parameters').'</div>');
3585: }
3586: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3587: }
1.208 www 3588: }
1.207 www 3589:
1.208 www 3590: sub extractuser {
3591: my $key=shift;
1.350 albertel 3592: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 3593: }
1.206 www 3594:
1.381 albertel 3595: sub parse_listdata_key {
3596: my ($key,$listdata) = @_;
3597: # split into student/section affected, and
3598: # the realm (folder/resource part and parameter
1.446 bisitz 3599: my ($student,$realm) =
1.473 amueller 3600: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
1.381 albertel 3601: # if course wide student would be undefined
3602: if (!defined($student)) {
1.473 amueller 3603: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.381 albertel 3604: }
3605: # strip off the .type if it's not the Question type parameter
3606: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
1.473 amueller 3607: $realm=~s/\.type//;
1.381 albertel 3608: }
3609: # split into resource+part and parameter name
1.388 albertel 3610: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
3611: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 3612: return ($student,$res,$part,$parm);
3613: }
3614:
1.208 www 3615: sub listdata {
1.522.2.19 raeburn 3616: my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly)=@_;
1.207 www 3617: # Start list output
1.206 www 3618:
1.122 www 3619: my $oldsection='';
3620: my $oldrealm='';
3621: my $oldpart='';
1.123 www 3622: my $pointer=0;
1.124 www 3623: $tableopen=0;
1.145 www 3624: my $foundkeys=0;
1.248 albertel 3625: my %keyorder=&standardkeyorder();
1.522.2.27 raeburn 3626: my $readonlyall = $readonly;
1.381 albertel 3627:
1.522.2.24 raeburn 3628: my ($secidx,%grouphash);
3629: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3630: $secidx = &Apache::loncoursedata::CL_SECTION();
3631: if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
3632: %grouphash = &Apache::longroup::coursegroups();
3633: } elsif ($env{'request.course.groups'} ne '') {
3634: map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
3635: }
3636: }
3637:
1.214 www 3638: foreach my $thiskey (sort {
1.473 amueller 3639: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
3640: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
1.381 albertel 3641:
1.473 amueller 3642: # get the numerical order for the param
3643: $aparm=$keyorder{'parameter_0_'.$aparm};
3644: $bparm=$keyorder{'parameter_0_'.$bparm};
1.381 albertel 3645:
1.473 amueller 3646: my $result=0;
1.381 albertel 3647:
1.473 amueller 3648: if ($sortorder eq 'realmstudent') {
1.381 albertel 3649: if ($ares ne $bres ) {
1.473 amueller 3650: $result = ($ares cmp $bres);
1.446 bisitz 3651: } elsif ($astudent ne $bstudent) {
1.473 amueller 3652: $result = ($astudent cmp $bstudent);
3653: } elsif ($apart ne $bpart ) {
3654: $result = ($apart cmp $bpart);
3655: }
3656: } else {
3657: if ($astudent ne $bstudent) {
3658: $result = ($astudent cmp $bstudent);
3659: } elsif ($ares ne $bres ) {
3660: $result = ($ares cmp $bres);
3661: } elsif ($apart ne $bpart ) {
3662: $result = ($apart cmp $bpart);
3663: }
3664: }
1.446 bisitz 3665:
1.473 amueller 3666: if (!$result) {
1.381 albertel 3667: if (defined($aparm) && defined($bparm)) {
1.473 amueller 3668: $result = ($aparm <=> $bparm);
1.381 albertel 3669: } elsif (defined($aparm)) {
1.473 amueller 3670: $result = -1;
1.381 albertel 3671: } elsif (defined($bparm)) {
1.473 amueller 3672: $result = 1;
3673: }
3674: }
1.381 albertel 3675:
1.473 amueller 3676: $result;
1.214 www 3677: } keys %{$listdata}) {
1.381 albertel 3678:
1.473 amueller 3679: if ($$listdata{$thiskey.'.type'}) {
1.522.2.24 raeburn 3680: my $thistype=$$listdata{$thiskey.'.type'};
3681: if ($$resourcedata{$thiskey.'.type'}) {
3682: $thistype=$$resourcedata{$thiskey.'.type'};
1.473 amueller 3683: }
3684: my ($middle,$part,$name)=
3685: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3686: my $section=&mt('All Students');
1.522.2.27 raeburn 3687: $readonly = $readonlyall;
1.522.2.28 raeburn 3688: my $userscope;
3689: my $showval = $$resourcedata{$thiskey};
1.473 amueller 3690: if ($middle=~/^\[(.*)\]/) {
1.522.2.24 raeburn 3691: my $issection=$1;
3692: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
3693: my ($stuname,$studom) = ($1,$2);
3694: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3695: if (ref($classlist) eq 'HASH') {
3696: if (ref($classlist->{$stuname.':'.$studom}) eq 'ARRAY') {
3697: next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'});
3698: }
3699: }
3700: }
3701: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
1.522.2.28 raeburn 3702: $userscope = 1;
1.522.2.24 raeburn 3703: } else {
3704: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3705: if (exists($grouphash{$issection})) {
3706: $section=&mt('Group').': '.$issection;
3707: } elsif ($issection eq $env{'request.course.sec'}) {
3708: $section = &mt('Section').': '.$issection;
3709: } else {
3710: next;
3711: }
3712: } else {
3713: $section=&mt('Group/Section').': '.$issection;
3714: }
3715: }
3716: $middle=~s/^\[(.*)\]//;
3717: } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3718: $readonly = 1;
1.473 amueller 3719: }
3720: $middle=~s/\.+$//;
3721: $middle=~s/^\.+//;
3722: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.522.2.24 raeburn 3723:
1.473 amueller 3724: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3725: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
3726: } elsif ($middle) {
3727: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
3728: $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>';
3729: }
3730: if ($sortorder eq 'realmstudent') {
3731: if ($realm ne $oldrealm) {
3732: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3733: $oldrealm=$realm;
3734: $oldsection='';
3735: }
3736: if ($section ne $oldsection) {
3737: $r->print(&tableend()."\n<h2>$section</h2>");
3738: $oldsection=$section;
3739: $oldpart='';
3740: }
3741: } else {
3742: if ($section ne $oldsection) {
3743: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3744: $oldsection=$section;
3745: $oldrealm='';
3746: }
3747: if ($realm ne $oldrealm) {
3748: $r->print(&tableend()."\n<h2>$realm</h2>");
3749: $oldrealm=$realm;
3750: $oldpart='';
3751: }
3752: }
3753: if ($part ne $oldpart) {
3754: $r->print(&tableend().
3755: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
3756: $oldpart=$part;
3757: }
1.123 www 3758: #
3759: # Ready to print
3760: #
1.470 raeburn 3761: my $parmitem = &standard_parameter_names($name);
1.522.2.19 raeburn 3762: $r->print(&tablestart($readonly).
1.473 amueller 3763: &Apache::loncommon::start_data_table_row().
3764: '<td><b>'.&mt($parmitem).
1.522.2.19 raeburn 3765: '</b></td>');
3766: unless ($readonly) {
1.522.2.28 raeburn 3767: my $disabled;
3768: if (($name eq 'availablestudent') &&
3769: (($showval eq '') || ($userscope))) {
3770: $disabled = ' disabled="disabled"';
3771: }
1.522.2.19 raeburn 3772: $r->print('<td><input type="checkbox" name="del_'.
1.522.2.28 raeburn 3773: $thiskey.'"'.$disabled.' /></td>');
1.522.2.19 raeburn 3774: }
3775: $r->print('<td>');
1.473 amueller 3776: $foundkeys++;
3777: if (&isdateparm($thistype)) {
1.522.2.19 raeburn 3778: my $jskey='key_'.$pointer;
3779: my $state;
3780: $pointer++;
3781: if ($readonly) {
3782: $state = 'disabled';
3783: }
3784: $r->print(
3785: &Apache::lonhtmlcommon::date_setter('parmform',
3786: $jskey,
3787: $$resourcedata{$thiskey},
3788: '',1,$state));
3789: unless ($readonly) {
3790: $r->print(
1.277 www 3791: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3792: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3793: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3794: &date_sanity_info($$resourcedata{$thiskey})
1.473 amueller 3795: );
1.522.2.19 raeburn 3796: }
1.473 amueller 3797: } elsif ($thistype eq 'date_interval') {
1.522.2.28.4. (raeburn 3798:): $r->print(&date_interval_selector($thiskey,$name,
1.522.2.19 raeburn 3799: $$resourcedata{$thiskey},$readonly));
1.473 amueller 3800: } elsif ($thistype =~ m/^string/) {
1.522.2.28 raeburn 3801: if ($name eq 'availablestudent') {
3802: $readonly = 1;
3803: }
1.522.2.19 raeburn 3804: $r->print(&string_selector($thistype,$thiskey,
3805: $$resourcedata{$thiskey},$name,$readonly));
1.473 amueller 3806: } else {
1.522.2.19 raeburn 3807: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
1.473 amueller 3808: }
1.522.2.19 raeburn 3809: unless ($readonly) {
3810: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
3811: $thistype.'" />');
1.522.2.20 raeburn 3812: }
1.473 amueller 3813: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
3814: }
1.121 www 3815: }
1.208 www 3816: return $foundkeys;
3817: }
3818:
1.385 albertel 3819:
3820: sub date_interval_selector {
1.522.2.28.4. (raeburn 3821:): my ($thiskey, $pname, $showval, $readonly) = @_;
3822:): my ($result,%skipval);
3823:): my $currval = $showval;
1.385 albertel 3824: foreach my $which (['days', 86400, 31],
1.473 amueller 3825: ['hours', 3600, 23],
3826: ['minutes', 60, 59],
3827: ['seconds', 1, 59]) {
3828: my ($name, $factor, $max) = @{ $which };
3829: my $amount = int($showval/$factor);
3830: $showval %= $factor;
3831: my %select = ((map {$_ => $_} (0..$max)),
3832: 'select_form_order' => [0..$max]);
3833: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
1.522.2.19 raeburn 3834: \%select,'',$readonly);
1.473 amueller 3835: $result .= ' '.&mt($name);
1.385 albertel 3836: }
1.522.2.28.4. (raeburn 3837:): if ($pname eq 'interval') {
3838:): unless ($skipval{'done'}) {
3839:): my $checkedon = '';
3840:): my $checkedproc = '';
3841:): my $currproctorkey = '';
3842:): my $currprocdisplay = 'hidden';
3843:): my $currdonetext = &mt('Done');
3844:): my $checkedoff = ' checked="checked"';
3845:): if ($currval =~ /^(?:\d+)_done$/) {
3846:): $checkedon = ' checked="checked"';
3847:): $checkedoff = '';
3848:): } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
3849:): $currdonetext = $1;
3850:): $checkedon = ' checked="checked"';
3851:): $checkedoff = '';
3852:): } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
3853:): $currproctorkey = $1;
3854:): $checkedproc = ' checked="checked"';
3855:): $checkedoff = '';
3856:): $currprocdisplay = 'text';
3857:): } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
3858:): $currdonetext = $1;
3859:): $currproctorkey = $2;
3860:): $checkedproc = ' checked="checked"';
3861:): $checkedoff = '';
3862:): $currprocdisplay = 'text';
3863:): }
3864:): my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
3865:): my $disabled;
3866:): if ($readonly) {
3867:): $disabled = ' disabled="disabled"';
3868:): }
3869:): $result .= '<br /><span class="LC_nobreak">'.&mt('Include "done" button').
3870:): '<label><input type="radio" value="" name="done_'.$thiskey.'"'.$checkedoff.$onclick.$disabled.' />'.
3871:): &mt('No').'</label>'.(' 'x2).
3872:): '<label><input type="radio" value="_done" name="done_'.$thiskey.'"'.$checkedon.$onclick.$disabled.' />'.
3873:): &mt('Yes').'</label>'.(' 'x2).
3874:): '<label><input type="radio" value="_done_proctor" name="done_'.$thiskey.'"'.$checkedproc.$onclick.$disabled.' />'.
3875:): &mt('Yes, with proctor key').'</label>'.
3876:): '<input type="'.$currprocdisplay.'" id="done_'.$thiskey.'_proctorkey" '.
3877:): 'name="done_'.$thiskey.'_proctorkey" value="'.&HTML::Entities::encode($currproctorkey,'"<>&').'"'.$disabled.' /></span><br />'.
3878:): '<span class="LC_nobreak">'.&mt('Button text').': '.
3879:): '<input type="text" name="done_'.$thiskey.'_buttontext" value="'.&HTML::Entities::encode($currdonetext,'"<>&').'"'.$disabled.' /></span>';
3880:): }
3881:): }
1.522.2.19 raeburn 3882: unless ($readonly) {
3883: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3884: }
1.385 albertel 3885: return $result;
3886:
3887: }
3888:
3889: sub get_date_interval_from_form {
3890: my ($key) = @_;
3891: my $seconds = 0;
3892: foreach my $which (['days', 86400],
1.473 amueller 3893: ['hours', 3600],
3894: ['minutes', 60],
3895: ['seconds', 1]) {
3896: my ($name, $factor) = @{ $which };
3897: if (defined($env{'form.'.$name.'_'.$key})) {
3898: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3899: }
1.385 albertel 3900: }
3901: return $seconds;
3902: }
3903:
3904:
1.383 albertel 3905: sub default_selector {
1.522.2.19 raeburn 3906: my ($thiskey, $showval, $readonly) = @_;
3907: my $disabled;
3908: if ($readonly) {
3909: $disabled = ' disabled="disabled"';
3910: }
3911: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'"'.$disabled.' />';
1.383 albertel 3912: }
3913:
1.522.2.28.4. (raeburn 3914:): sub string_ip_selector {
3915:): my ($thiskey, $showval, $readonly) = @_;
3916:): my %access = (
3917:): allow => [],
3918:): deny => [],
3919:): );
3920:): if ($showval ne '') {
3921:): my @current;
3922:): if ($showval =~ /,/) {
3923:): @current = split(/,/,$showval);
3924:): } else {
3925:): @current = ($showval);
3926:): }
3927:): foreach my $item (@current) {
3928:): if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) {
3929:): push(@{$access{'deny'}},$1);
3930:): } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) {
3931:): push(@{$access{'allow'}},$item);
3932:): }
3933:): }
3934:): }
3935:): if (!@{$access{'allow'}}) {
3936:): @{$access{'allow'}} = ('');
3937:): }
3938:): if (!@{$access{'deny'}}) {
3939:): @{$access{'deny'}} = ('');
3940:): }
3941:): my ($disabled,$addmore);
3942:): if ($readonly) {
3943:): $disabled=' disabled="disabled"';
3944:): } else {
3945:): $addmore = "\n".'<button class="LC_add_ipacc_button">'.&mt('Add more').'</button>';
3946:): }
3947:): my $output = '<input type="hidden" name="set_'.$thiskey.'" />
3948:): <table><tr><th>'.&mt('Allow from').'</th><th>'.&mt('Deny from').'</th></tr><tr>';
3949:): foreach my $acctype ('allow','deny') {
3950:): $output .= '
3951:): <td valign="top">
3952:): <div class="LC_string_ipacc_wrap" id="LC_string_ipacc_'.$acctype.'_'.$thiskey.'">
3953:): <div class="LC_string_ipacc_inner">'."\n";
3954:): my $num = 0;
3955:): foreach my $curr (@{$access{$acctype}}) {
3956:): $output .= '<div><input type="text" name="setip'.$acctype.'_'.$thiskey.'" value="'.$curr.'"'.$disabled.' />';
3957:): if ($num > 0) {
3958:): $output .= '<a href="#" class="LC_remove_ipacc">'.&mt('Remove').'</a>';
3959:): }
3960:): $output .= '</div>'."\n";
3961:): $num ++;
3962:): }
3963:): $output .= '
3964:): </div>'.$addmore.'
3965:): </div>
3966:): </td>';
3967:): }
3968:): $output .= '
3969:): </tr>
3970:): </table>'."\n";
3971:): return $output;
3972:): }
3973:):
3974:): sub string_deeplink_selector {
3975:): my ($thiskey, $showval, $readonly) = @_;
3976:): my (@components,%values,@current,%titles,%options,%optiontext,%defaults,
3977:): %selectnull,%domlti,%crslti,@possmenus);
3978:): @components = ('state','others','listing','scope','protect','menus','target');
3979:): %titles = &Apache::lonlocal::texthash (
3980:): state => 'Access status',
3981:): others => 'Hide other resources',
3982:): listing => 'In Contents and/or Gradebook',
3983:): scope => 'Access scope for link',
3984:): protect => 'Link protection',
3985:): menus => 'Menu Items Displayed',
3986:): target => 'Embedded?',
3987:): );
3988:): %options = (
3989:): state => ['only','off','both'],
3990:): others => ['hide','unhide'],
3991:): listing => ['full','absent','grades','details','datestatus'],
3992:): scope => ['res','map','rec'],
3993:): protect => ['none','key','ltid','ltic'],
3994:): menus => ['std','colls'],
3995:): target => ['_self','_top'],
3996:): );
3997:): %optiontext = &Apache::lonlocal::texthash (
3998:): only => 'deep only',
3999:): off => 'deeplink off',
4000:): both => 'regular + deep',
4001:): hide => 'Hidden',
4002:): unhide => 'Unhidden',
4003:): full => 'Listed (linked) in both',
4004:): absent => 'Not listed',
4005:): grades => 'Listed in grades only',
4006:): details => 'Listed (unlinked) in both',
4007:): datestatus => 'Listed (unlinked) inc. status in both',
4008:): res => 'resource only',
4009:): map => 'enclosing map/folder',
4010:): rec => 'recursive map/folder',
4011:): none => 'not in use',
4012:): key => 'key access',
4013:): ltic => 'LTI access (course)',
4014:): ltid => 'LTI access (domain)' ,
4015:): std => 'Standard (all menus)',
4016:): colls => 'Numbered collection',
4017:): _self => 'Embedded',
4018:): _top => 'Not embedded',
4019:): );
4020:): %selectnull = &Apache::lonlocal::texthash (
4021:): ltic => 'Select Launcher',
4022:): ltid => 'Select Launcher',
4023:): colls => 'Select',
4024:): );
4025:): if ($showval =~ /,/) {
4026:): %values=();
4027:): @current = split(/,/,$showval);
4028:): ($values{'state'}) = ($current[0] =~ /^(only|off|both)$/);
4029:): ($values{'others'}) = ($current[1] =~ /^(hide|unhide)$/);
4030:): ($values{'listing'}) = ($current[2] =~ /^(full|absent|grades|details|datestatus)$/);
4031:): ($values{'scope'}) = ($current[3] =~ /^(res|map|rec)$/);
4032:): ($values{'protect'}) = ($current[4] =~ /^(key:[a-zA-Z\d_.!\@#\$%^&*()+=-]+|ltic:\d+|ltid:\d+)$/);
4033:): ($values{'menus'}) = ($current[5] =~ /^(\d+)$/);
4034:): ($values{'target'}) = ($current[6] =~ /^(_self|_top)$/);
4035:): } else {
4036:): $defaults{'state'} = 'off',
4037:): $defaults{'others'} = 'unhide',
4038:): $defaults{'listing'} = 'full';
4039:): $defaults{'scope'} = 'res';
4040:): $defaults{'protect'} = 'none';
4041:): $defaults{'menus'} = '0';
4042:): $defaults{'target'} = '_top';
4043:): }
4044:): my $disabled;
4045:): if ($readonly) {
4046:): $disabled=' disabled="disabled"';
4047:): }
4048:): my %courselti =
4049:): &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'},
4050:): $env{'course.'.$env{'request.course.id'}.'.domain'});
4051:): foreach my $item (keys(%courselti)) {
4052:): if (ref($courselti{$item}) eq 'HASH') {
4053:): $crslti{$item} = $courselti{$item}{'name'};
4054:): }
4055:): }
4056:): my %lti =
4057:): &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'},
4058:): 'linkprot');
4059:): foreach my $item (keys(%lti)) {
4060:): if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
4061:): $domlti{$item} = $lti{$item}{'name'};
4062:): }
4063:): }
4064:): if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
4065:): foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
4066:): my ($num,$value) = split(/\%/,$item);
4067:): if ($num =~ /^\d+$/) {
4068:): push(@possmenus,$num);
4069:): }
4070:): }
4071:): }
4072:):
4073:): my $output = '<input type="hidden" name="set_'.$thiskey.'" /><table><tr>';
4074:): foreach my $item (@components) {
4075:): $output .= '<th>'.$titles{$item}.'</th>';
4076:): }
4077:): $output .= '</tr><tr>';
4078:): foreach my $item (@components) {
4079:): $output .= '<td>';
4080:): if (($item eq 'protect') || ($item eq 'menus')) {
4081:): my $selected = $values{$item};
4082:): foreach my $option (@{$options{$item}}) {
4083:): if ($item eq 'protect') {
4084:): if ($option eq 'ltid') {
4085:): next unless (keys(%domlti));
4086:): } elsif ($option eq 'ltic') {
4087:): next unless (keys(%crslti));
4088:): }
4089:): } elsif (($item eq 'menus') && ($option eq 'colls')) {
4090:): next unless (@possmenus);
4091:): }
4092:): my $checked;
4093:): if ($item eq 'menus') {
4094:): if (($selected =~ /^\d+$/) && (@possmenus) &&
4095:): (grep(/^\Q$selected\E$/,@possmenus))) {
4096:): if ($option eq 'colls') {
4097:): $checked = ' checked="checked"';
4098:): }
4099:): } elsif (($option eq 'std') && ($selected == 0) && ($selected ne '')) {
4100:): $checked = ' checked="checked"';
4101:): }
4102:): } elsif ($selected =~ /^\Q$option\E/) {
4103:): $checked = ' checked="checked"';
4104:): }
4105:): my $onclick;
4106:): unless ($readonly) {
4107:): my $esc_key = &js_escape($thiskey);
4108:): $onclick = ' onclick="toggleDeepLink(this.form,'."'$item','$esc_key'".');"';
4109:): }
4110:): $output .= '<span class="LC_nobreak"><label>'.
4111:): '<input type="radio" name="deeplink_'.$item.'_'.$thiskey.'" value="'.$option.'"'.$onclick.$disabled.$checked.' />'."\n".
4112:): $optiontext{$option}.'</label>';
4113:): if (($item eq 'protect') && ($option eq 'key')) {
4114:): my $visibility="hidden";
4115:): my $currkey;
4116:): if ($checked) {
4117:): $visibility = "text";
4118:): $currkey = (split(/\:/,$values{$item}))[1];
4119:): }
4120:): $output .= ' '.
4121:): '<input type="'.$visibility.'" name="deeplink_'.$option.'_'.$thiskey.'" id="deeplink_'.$option.'_'.$item.'_'.$thiskey.'" value="'.$currkey.'" size="10"'.$disabled.' />';
4122:): } elsif (($option eq 'ltic') || ($option eq 'ltid') || ($option eq 'colls')) {
4123:): my $display="none";
4124:): my ($current,$blankcheck,@possibles);
4125:): if ($checked) {
4126:): $display = 'inline-block';
4127:): if (($option eq 'ltic') || ($option eq 'ltid')) {
4128:): $current = (split(/\:/,$selected))[1];
4129:): } else {
4130:): $current = $selected;
4131:): }
4132:): } else {
4133:): $blankcheck = ' selected="selected"';
4134:): }
4135:): if ($option eq 'ltid') {
4136:): @possibles = keys(%domlti);
4137:): } elsif ($option eq 'ltic') {
4138:): @possibles = keys(%crslti);
4139:): } else {
4140:): @possibles = @possmenus;
4141:): }
4142:): $output .= '<div id="deeplinkdiv_'.$option.'_'.$item.'_'.$thiskey.'"'.
4143:): ' style="display: '.$display.'"> <select name="'.
4144:): 'deeplink_'.$option.'_'.$thiskey.'"'.$disabled.'>';
4145:): if (@possibles > 1) {
4146:): $output .= '<option value=""'.$blankcheck.'>'.$selectnull{$option}.
4147:): '</option>'."\n";
4148:): }
4149:): foreach my $poss (sort { $a <=> $b } @possibles) {
4150:): my $selected;
4151:): if (($poss == $current) || (scalar(@possibles) ==1)) {
4152:): $selected = ' selected="selected"';
4153:): }
4154:): my $shown = $poss;
4155:): if ($option eq 'ltid') {
4156:): $shown = $domlti{$poss};
4157:): } elsif ($option eq 'ltic') {
4158:): $shown = $crslti{$poss};
4159:): }
4160:): $output .= '<option value="'.$poss.'"'.$selected.'>'.$shown.'</option>';
4161:): }
4162:): $output .= '</select></div>';
4163:): }
4164:): $output .= '</span> ';
4165:): }
4166:): } else {
4167:): my $selected = $values{$item};
4168:): my $defsel;
4169:): if ($selected eq '') {
4170:): $defsel = ' selected="selected"';
4171:): }
4172:): $output .= '<select name="deeplink_'.$item.'_'.$thiskey.'"'.$disabled.'>'."\n".
4173:): '<option value=""'.$defsel.'>'.&mt('Please select').'</option>'."\n";
4174:): foreach my $option (@{$options{$item}}) {
4175:): $output .= '<option value="'.$option.'"';
4176:): if ($option eq $selected) {
4177:): $output .= ' selected="selected"';
4178:): }
4179:): $output .= '>'.$optiontext{$option}.'</option>';
4180:): }
4181:): $output .= '</select>';
4182:): }
4183:): $output .= '</td>';
4184:): }
4185:): $output .= '</tr></table>'."\n";
4186:): return $output;
4187:): }
4188:):
4189:): {
4190:):
1.446 bisitz 4191: my %strings =
1.383 albertel 4192: (
4193: 'string_yesno'
4194: => [[ 'yes', 'Yes' ],
1.473 amueller 4195: [ 'no', 'No' ]],
1.383 albertel 4196: 'string_problemstatus'
4197: => [[ 'yes', 'Yes' ],
1.473 amueller 4198: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
4199: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
4200: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
1.504 raeburn 4201: 'string_questiontype'
4202: => [[ 'problem', 'Standard Problem'],
4203: [ 'survey', 'Survey'],
4204: [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'],
4205: [ 'exam', 'Exam'],
4206: [ 'anonsurvey', 'Anonymous Survey'],
4207: [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'],
4208: [ 'practice', 'Practice'],
4209: [ 'surveycred', 'Survey (credit for submission)']],
1.514 raeburn 4210: 'string_lenient'
4211: => [['yes', 'Yes' ],
4212: [ 'no', 'No' ],
1.521 raeburn 4213: [ 'default', 'Default - only bubblesheet grading is lenient' ]],
4214: 'string_discussvote'
4215: => [['yes','Yes'],
4216: ['notended','Yes, unless discussion ended'],
4217: ['no','No']],
1.522.2.28.4. (raeburn 4218:): 'string_ip'
4219:): => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'],
4220:): ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']],
4221:): 'string_deeplink'
4222:): => [['on','Set choices for link protection, resource listing, access scope, shown menu items, and embedding']],
1.383 albertel 4223: );
4224:
1.522.2.28.4. (raeburn 4225:): my %stringmatches = (
4226:): 'string_ip'
4227:): => [['_allowfrom_','[^\!]+'],
4228:): ['_denyfrom_','\!']],
4229:): 'string_deeplink'
4230:): => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)\,_(self|top)$']],
4231:): );
4232:):
4233:): my %stringtypes = (
4234:): type => 'string_questiontype',
4235:): lenient => 'string_lenient',
4236:): retrypartial => 'string_yesno',
4237:): discussvote => 'string_discussvote',
4238:): examcode => 'string_examcode',
4239:): acc => 'string_ip',
4240:): deeplink => 'string_deeplink',
4241:): );
4242:):
1.505 raeburn 4243: sub standard_string_options {
4244: my ($string_type) = @_;
4245: if (ref($strings{$string_type}) eq 'ARRAY') {
4246: return $strings{$string_type};
4247: }
4248: return;
4249: }
1.383 albertel 4250:
1.522.2.28.4. (raeburn 4251:): sub standard_string_matches {
4252:): my ($string_type) = @_;
4253:): if (ref($stringmatches{$string_type}) eq 'ARRAY') {
4254:): return $stringmatches{$string_type};
4255:): }
4256:): return;
4257:): }
4258:):
1.383 albertel 4259: sub string_selector {
1.522.2.19 raeburn 4260: my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
1.446 bisitz 4261:
1.383 albertel 4262: if (!exists($strings{$thistype})) {
1.522.2.19 raeburn 4263: return &default_selector($thiskey,$showval,$readonly);
1.383 albertel 4264: }
4265:
1.504 raeburn 4266: my %skiptype;
1.514 raeburn 4267: if (($thistype eq 'string_questiontype') ||
1.519 raeburn 4268: ($thistype eq 'string_lenient') ||
1.521 raeburn 4269: ($thistype eq 'string_discussvote') ||
1.519 raeburn 4270: ($name eq 'retrypartial')) {
1.504 raeburn 4271: my ($got_chostname,$chostname,$cmajor,$cminor);
4272: foreach my $possibilities (@{ $strings{$thistype} }) {
4273: next unless (ref($possibilities) eq 'ARRAY');
1.514 raeburn 4274: my ($parmval, $description) = @{ $possibilities };
4275: my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"};
1.504 raeburn 4276: if ($needsrelease) {
4277: unless ($got_chostname) {
1.514 raeburn 4278: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
1.504 raeburn 4279: $got_chostname = 1;
4280: }
1.514 raeburn 4281: my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease,
1.522.2.14 raeburn 4282: $cmajor,$cminor);
1.504 raeburn 4283: if ($needsnewer) {
1.514 raeburn 4284: $skiptype{$parmval} = 1;
1.504 raeburn 4285: }
4286: }
4287: }
4288: }
1.522.2.28.4. (raeburn 4289:):
4290:): if ($thistype eq 'string_ip') {
4291:): return &string_ip_selector($thiskey,$showval,$readonly);
4292:): } elsif ($thistype eq 'string_deeplink') {
4293:): return &string_deeplink_selector($thiskey,$showval,$readonly);
4294:): }
1.522.2.19 raeburn 4295:
4296: my ($result,$disabled);
1.504 raeburn 4297:
1.522.2.19 raeburn 4298: if ($readonly) {
4299: $disabled = ' disabled="disabled"';
4300: }
1.504 raeburn 4301: my $numinrow = 3;
4302: if ($thistype eq 'string_problemstatus') {
4303: $numinrow = 2;
4304: } elsif ($thistype eq 'string_questiontype') {
4305: if (keys(%skiptype) > 0) {
4306: $numinrow = 4;
4307: }
4308: }
4309: my $rem;
4310: if (ref($strings{$thistype}) eq 'ARRAY') {
4311: my $i=0;
4312: foreach my $possibilities (@{ $strings{$thistype} }) {
4313: next unless (ref($possibilities) eq 'ARRAY');
4314: my ($name, $description) = @{ $possibilities };
4315: next if ($skiptype{$name});
4316: $rem = $i%($numinrow);
4317: if ($rem == 0) {
4318: if ($i > 0) {
4319: $result .= '</tr>';
4320: }
4321: $result .= '<tr>';
4322: }
4323: $result .= '<td class="LC_left_item">'.
4324: '<span class="LC_nobreak"><label>'.
4325: '<input type="radio" name="set_'.$thiskey.
1.522.2.19 raeburn 4326: '" value="'.$name.'"'.$disabled;
1.504 raeburn 4327: if ($showval eq $name) {
4328: $result .= ' checked="checked"';
4329: }
4330: $result .= ' />'.&mt($description).'</label></span></td>';
4331: $i++;
4332: }
4333: $rem = @{ $strings{$thistype} }%($numinrow);
4334: my $colsleft = $numinrow - $rem;
4335: if ($colsleft > 1 ) {
4336: $result .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
4337: ' </td>';
4338: } elsif ($colsleft == 1) {
4339: $result .= '<td class="LC_left_item"> </td>';
4340: }
4341: $result .= '</tr>';
1.473 amueller 4342: }
1.504 raeburn 4343: if ($result) {
4344: $result = '<table border="0">'.$result.'</table>';
1.383 albertel 4345: }
4346: return $result;
4347: }
4348:
1.522.2.28.4. (raeburn 4349:): sub oldversion_warning {
4350:): my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
4351:): my $desc;
4352:): my %stringtypes = (
4353:): type => 'string_questiontype',
4354:): lenient => 'string_lenient',
4355:): retrypartial => 'string_yesno',
4356:): discussvote => 'string_discussvote',
4357:): examcode => 'string_examcode',
4358:): );
4359:): if (exists($stringtypes{$name})) {
4360:): if ($name eq 'examcode') {
4361:): $desc = $value;
4362:): } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
4363:): foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
4364:): next unless (ref($possibilities) eq 'ARRAY');
4365:): my ($parmval, $description) = @{ $possibilities };
4366:): if ($parmval eq $value) {
4367:): $desc = $description;
4368:): last;
4369:): }
4370:): }
4371:): }
4372:): } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
4373:): my $now = time;
4374:): if ($value =~ /^\d+$/) {
4375:): if ($name eq 'printstartdate') {
4376:): if ($value > $now) {
4377:): $desc = &Apache::lonlocal::locallocaltime($value);
4378:): }
4379:): } elsif ($name eq 'printenddate') {
4380:): if ($value < $now) {
4381:): $desc = &Apache::lonlocal::locallocaltime($value);
4382:): }
4383:): }
4384:): }
4385:): }
4386:): my $standard_name = &standard_parameter_names($name);
4387:): return '<p class="LC_warning">'.
4388:): &mt('[_1] was [_2]not[_3] set to [_4].',
4389:): $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
4390:): &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
4391:): $cmajor.'.'.$cminor,$chostname,
4392:): $needsrelease).
4393:): '</p>';
4394:): }
4395:):
4396:): }
4397:):
1.389 www 4398: #
4399: # Shift all start and end dates by $shift
4400: #
4401:
4402: sub dateshift {
1.522.2.27 raeburn 4403: my ($shift,$numchanges)=@_;
1.389 www 4404: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4405: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4406: my $sec = $env{'request.course.sec'};
4407: my $secgrpregex;
4408: if ($sec ne '') {
4409: my @groups;
4410: if ($env{'request.course.groups'} ne '') {
4411: @groups = split(/:/,$env{'request.course.groups'});
4412: }
4413: if (@groups) {
4414: $secgrpregex = '(?:'.join('|',($sec,@groups)).')';
4415: } else {
4416: $secgrpregex = $sec;
4417: }
4418: }
1.389 www 4419: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
4420: # ugly retro fix for broken version of types
4421: foreach my $key (keys %data) {
4422: if ($key=~/\wtype$/) {
4423: my $newkey=$key;
4424: $newkey=~s/type$/\.type/;
4425: $data{$newkey}=$data{$key};
4426: delete $data{$key};
4427: }
4428: }
1.391 www 4429: my %storecontent=();
1.389 www 4430: # go through all parameters and look for dates
4431: foreach my $key (keys %data) {
4432: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
1.522.2.27 raeburn 4433: if ($sec ne '') {
4434: next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./);
4435: }
1.389 www 4436: my $newdate=$data{$key}+$shift;
1.522.2.27 raeburn 4437: $$numchanges ++;
1.391 www 4438: $storecontent{$key}=$newdate;
1.389 www 4439: }
4440: }
1.391 www 4441: my $reply=&Apache::lonnet::cput
4442: ('resourcedata',\%storecontent,$dom,$crs);
4443: if ($reply eq 'ok') {
4444: &log_parmset(\%storecontent);
4445: }
4446: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
4447: return $reply;
1.389 www 4448: }
4449:
1.208 www 4450: sub newoverview {
1.522.2.19 raeburn 4451: my ($r,$parm_permission) = @_;
1.280 albertel 4452:
1.208 www 4453: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4454: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.19 raeburn 4455: my $readonly = 1;
4456: if ($parm_permission->{'edit'}) {
4457: undef($readonly);
4458: }
1.414 droeschl 4459: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 4460: text=>"Overview Mode"});
1.522.2.2 raeburn 4461:
4462: my %loaditems = (
4463: 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1');",
4464: );
4465: my $js = '
4466: <script type="text/javascript">
4467: // <![CDATA[
4468: '.
4469: &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n".
4470: &showhide_js()."\n".
1.522.2.28.4. (raeburn 4471:): &validateparms_js()."\n".
4472:): &ipacc_boxes_js()."\n".
4473:): &done_proctor_js()."\n".
4474:): &deeplink_js()."\n".
1.522.2.2 raeburn 4475: '// ]]>
4476: </script>
4477: ';
4478: my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
4479: {'add_entries' => \%loaditems,});
1.298 albertel 4480: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 4481: $r->print($start_page.$breadcrumbs);
1.208 www 4482: $r->print(<<ENDOVER);
1.522.2.28.4. (raeburn 4483:): <form method="post" action="/adm/parmset?action=newoverview" name="parmform" onsubmit="return validateParms();">
1.208 www 4484: ENDOVER
1.211 www 4485: my @ids=();
4486: my %typep=();
4487: my %keyp=();
4488: my %allparms=();
4489: my %allparts=();
4490: my %allmaps=();
4491: my %mapp=();
4492: my %symbp=();
4493: my %maptitles=();
4494: my %uris=();
4495: my %keyorder=&standardkeyorder();
4496: my %defkeytype=();
4497:
4498: my %alllevs=();
4499: $alllevs{'Resource Level'}='full';
1.215 www 4500: $alllevs{'Map/Folder Level'}='map';
1.211 www 4501: $alllevs{'Course Level'}='general';
4502:
4503: my $csec=$env{'form.csec'};
1.269 raeburn 4504: my $cgroup=$env{'form.cgroup'};
1.211 www 4505:
4506: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
4507: my $pschp=$env{'form.pschp'};
1.506 www 4508:
1.211 www 4509: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.522.2.1 raeburn 4510: if (!@psprt) { $psprt[0]='0'; }
1.211 www 4511:
1.446 bisitz 4512: my @selected_sections =
1.473 amueller 4513: &Apache::loncommon::get_env_multiple('form.Section');
1.211 www 4514: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 4515: foreach my $sec (@selected_sections) {
4516: if ($sec eq 'all') {
1.211 www 4517: @selected_sections = ('all');
4518: }
4519: }
1.522.2.24 raeburn 4520: if ($env{'request.course.sec'} ne '') {
4521: @selected_sections = ($env{'request.course.sec'});
4522: }
1.269 raeburn 4523: my @selected_groups =
4524: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 4525:
4526: my $pssymb='';
4527: my $parmlev='';
1.446 bisitz 4528:
1.211 www 4529: unless ($env{'form.parmlev'}) {
4530: $parmlev = 'map';
4531: } else {
4532: $parmlev = $env{'form.parmlev'};
4533: }
4534:
1.446 bisitz 4535: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 4536: \%mapp, \%symbp,\%maptitles,\%uris,
4537: \%keyorder,\%defkeytype);
1.211 www 4538:
1.374 albertel 4539: if (grep {$_ eq 'all'} (@psprt)) {
1.481 amueller 4540: @psprt = keys(%allparts);
1.374 albertel 4541: }
1.211 www 4542: # Menu to select levels, etc
4543:
1.456 bisitz 4544: $r->print('<div class="LC_Box">');
1.445 neumanie 4545: #$r->print('<h2 class="LC_hcell">Step 1</h2>');
1.452 bisitz 4546: $r->print('<div>');
1.522.2.2 raeburn 4547: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.211 www 4548: &levelmenu($r,\%alllevs,$parmlev);
4549: if ($parmlev ne 'general') {
1.447 bisitz 4550: $r->print(&Apache::lonhtmlcommon::row_closure());
1.483 amueller 4551: &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp);
1.211 www 4552: }
1.447 bisitz 4553: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 4554: $r->print(&Apache::lonhtmlcommon::end_pick_box());
4555: $r->print('</div></div>');
1.446 bisitz 4556:
1.456 bisitz 4557: $r->print('<div class="LC_Box">');
1.452 bisitz 4558: $r->print('<div>');
1.510 www 4559: &displaymenu($r,\%allparms,\@pscat,\%keyorder);
1.453 schualex 4560: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.446 bisitz 4561: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
1.522.2.24 raeburn 4562: my $sectionselector = §ionmenu(\@selected_sections);
4563: my $groupselector = &groupmenu(\@selected_groups);
1.481 amueller 4564: $r->print('<table>'.
1.522.2.24 raeburn 4565: '<tr><th>'.&mt('Parts').'</th>');
4566: if ($sectionselector) {
4567: $r->print('<th>'.&mt('Section(s)').'</th>');
4568: }
4569: if ($groupselector) {
4570: $r->print('<th>'.&mt('Group(s)').'</th>');
4571: }
4572: $r->print('</tr><tr><td>');
1.211 www 4573: &partmenu($r,\%allparts,\@psprt);
1.522.2.24 raeburn 4574: $r->print('</td>');
4575: if ($sectionselector) {
4576: $r->print('<td>'.$sectionselector.'</td>');
4577: }
4578: if ($groupselector) {
4579: $r->print('<td>'.$groupselector.'</td>');
4580: }
4581: $r->print('</tr></table>');
1.447 bisitz 4582: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 4583: $r->print(&Apache::lonhtmlcommon::end_pick_box());
4584: $r->print('</div></div>');
4585:
1.456 bisitz 4586: $r->print('<div class="LC_Box">');
1.452 bisitz 4587: $r->print('<div>');
1.214 www 4588: my $sortorder=$env{'form.sortorder'};
4589: unless ($sortorder) { $sortorder='realmstudent'; }
4590: &sortmenu($r,$sortorder);
1.445 neumanie 4591: $r->print('</div></div>');
1.446 bisitz 4592:
1.214 www 4593: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.446 bisitz 4594:
1.211 www 4595: # Build the list data hash from the specified parms
4596:
4597: my $listdata;
4598: %{$listdata}=();
4599:
4600: foreach my $cat (@pscat) {
1.269 raeburn 4601: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
4602: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 4603: }
4604:
1.212 www 4605: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 4606:
1.481 amueller 4607: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 4608:
4609: # Read modified data
4610:
1.481 amueller 4611: my $resourcedata=&readdata($crs,$dom);
1.211 www 4612:
4613: # List data
4614:
1.522.2.19 raeburn 4615: &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly);
4616: }
4617: $r->print(&tableend());
4618: unless ($readonly) {
4619: $r->print(((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':''));
1.211 www 4620: }
1.522.2.19 raeburn 4621: $r->print('</form>');
1.507 www 4622: $r->print(&Apache::loncommon::end_page());
1.208 www 4623: }
4624:
1.269 raeburn 4625: sub secgroup_lister {
4626: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
4627: foreach my $item (@{$selections}) {
4628: foreach my $part (@{$psprt}) {
4629: my $rootparmkey=$env{'request.course.id'};
4630: if (($item ne 'all') && ($item ne 'none') && ($item)) {
4631: $rootparmkey.='.['.$item.']';
4632: }
4633: if ($parmlev eq 'general') {
4634: # course-level parameter
4635: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
4636: $$listdata{$newparmkey}=1;
4637: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
4638: } elsif ($parmlev eq 'map') {
4639: # map-level parameter
4640: foreach my $mapid (keys %{$allmaps}) {
4641: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
4642: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
4643: $$listdata{$newparmkey}=1;
4644: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
4645: }
4646: } else {
4647: # resource-level parameter
4648: foreach my $rid (@{$ids}) {
4649: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
4650: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
4651: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
4652: $$listdata{$newparmkey}=1;
4653: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
4654: }
4655: }
4656: }
4657: }
4658: }
4659:
1.208 www 4660: sub overview {
1.522.2.19 raeburn 4661: my ($r,$parm_permission) = @_;
1.208 www 4662: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4663: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.28.4. (raeburn 4664:): my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
4665:): my $js = '<script type="text/javascript">'."\n".
4666:): '// <![CDATA['."\n".
4667:): &done_proctor_js()."\n".
4668:): &validateparms_js()."\n".
4669:): &ipacc_boxes_js()."\n".
4670:): &deeplink_js()."\n".
4671:): '// ]]>'."\n".
4672:): '</script>'."\n";
1.522.2.19 raeburn 4673: my $readonly = 1;
4674: if ($parm_permission->{'edit'}) {
4675: undef($readonly);
4676: }
1.414 droeschl 4677: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 4678: text=>"Overview Mode"});
1.522.2.28.4. (raeburn 4679:): my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js);
1.298 albertel 4680: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 4681: $r->print($start_page.$breadcrumbs);
1.522.2.28.4. (raeburn 4682:): $r->print('<form method="post" action="/adm/parmset?action=setoverview" name="parmform" onsubmit="return validateParms();">');
1.507 www 4683:
1.208 www 4684: # Store modified
1.522.2.19 raeburn 4685: unless ($readonly) {
4686: &storedata($r,$crs,$dom);
4687: }
1.208 www 4688:
4689: # Read modified data
4690:
1.522.2.19 raeburn 4691: my ($resourcedata,$classlist)=&readdata($crs,$dom);
1.208 www 4692:
1.214 www 4693:
4694: my $sortorder=$env{'form.sortorder'};
4695: unless ($sortorder) { $sortorder='realmstudent'; }
4696: &sortmenu($r,$sortorder);
4697:
1.522.2.19 raeburn 4698: my $submitbutton = '<input type="submit" value="'.&mt('Save').'" />';
4699:
4700: if ($readonly) {
4701: $r->print('<p>'.$submitbutton.'</p>');
4702: }
4703:
4704:
1.208 www 4705: # List data
4706:
1.522.2.19 raeburn 4707: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist,$readonly);
1.208 www 4708:
1.522.2.19 raeburn 4709: $r->print(&tableend().'<p>');
4710: if ($foundkeys) {
4711: unless ($readonly) {
4712: $r->print('<p>'.$submitbutton.'</p>');
4713: }
4714: } else {
4715: $r->print('<p class="LC_info">'.&mt('There are no parameters.').'</p>');
4716: }
4717: $r->print('</form>'.&Apache::loncommon::end_page());
1.120 www 4718: }
1.121 www 4719:
1.333 albertel 4720: sub clean_parameters {
4721: my ($r) = @_;
4722: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4723: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
4724:
1.414 droeschl 4725: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
1.473 amueller 4726: text=>"Clean Parameters"});
1.333 albertel 4727: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
4728: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
4729: $r->print(<<ENDOVER);
4730: $start_page
4731: $breadcrumbs
4732: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
4733: ENDOVER
4734: # Store modified
4735:
4736: &storedata($r,$crs,$dom);
4737:
4738: # Read modified data
4739:
4740: my $resourcedata=&readdata($crs,$dom);
4741:
4742: # List data
4743:
4744: $r->print('<h3>'.
1.473 amueller 4745: &mt('These parameters refer to resources that do not exist.').
4746: '</h3>'.
4747: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
4748: '<br />');
1.333 albertel 4749: $r->print(&Apache::loncommon::start_data_table().
1.473 amueller 4750: '<tr>'.
4751: '<th>'.&mt('Delete').'</th>'.
4752: '<th>'.&mt('Parameter').'</th>'.
4753: '</tr>');
1.333 albertel 4754: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
1.473 amueller 4755: next if (!exists($resourcedata->{$thiskey.'.type'})
4756: && $thiskey=~/\.type$/);
4757: my %data = &parse_key($thiskey);
4758: if (1) { #exists($data{'realm_exists'})
4759: #&& !$data{'realm_exists'}) {
4760: $r->print(&Apache::loncommon::start_data_table_row().
4761: '<tr>'.
4762: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
4763:
4764: $r->print('<td>');
4765: my $display_value = $resourcedata->{$thiskey};
4766: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
4767: $display_value =
4768: &Apache::lonlocal::locallocaltime($display_value);
4769: }
1.470 raeburn 4770: my $parmitem = &standard_parameter_names($data{'parameter_name'});
4771: $parmitem = &mt($parmitem);
1.473 amueller 4772: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
4773: $parmitem,$resourcedata->{$thiskey}));
4774: $r->print('<br />');
4775: if ($data{'scope_type'} eq 'all') {
4776: $r->print(&mt('All users'));
4777: } elsif ($data{'scope_type'} eq 'user') {
4778: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
1.522.2.25 raeburn 4779: } elsif ($data{'scope_type'} eq 'secgroup') {
4780: $r->print(&mt('Group/Section: [_1]',$data{'scope'}));
1.473 amueller 4781: }
4782: $r->print('<br />');
4783: if ($data{'realm_type'} eq 'all') {
4784: $r->print(&mt('All Resources'));
4785: } elsif ($data{'realm_type'} eq 'folder') {
4786: $r->print(&mt('Folder: [_1]'),$data{'realm'});
4787: } elsif ($data{'realm_type'} eq 'symb') {
4788: my ($map,$resid,$url) =
4789: &Apache::lonnet::decode_symb($data{'realm'});
1.522.2.5 raeburn 4790: $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
4791: $url.' <br /> ',
4792: $resid.' <br /> ',$map));
1.473 amueller 4793: }
4794: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
4795: $r->print('</td></tr>');
1.446 bisitz 4796:
1.473 amueller 4797: }
1.333 albertel 4798: }
4799: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.473 amueller 4800: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.507 www 4801: '</p></form>');
4802: $r->print(&Apache::loncommon::end_page());
1.333 albertel 4803: }
4804:
1.390 www 4805: sub date_shift_one {
4806: my ($r) = @_;
4807: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4808: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4809: my $sec = $env{'request.course.sec'};
1.414 droeschl 4810: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 4811: text=>"Shifting Dates"});
1.522.2.27 raeburn 4812: my $submit_text = &mt('Shift all dates accordingly');
4813: if ($sec ne '') {
4814: my @groups;
4815: if ($env{'request.course.groups'} ne '') {
4816: @groups = split(/:/,$env{'request.course.groups'});
4817: }
4818: if (@groups) {
4819: $submit_text = &mt("Shift dates set just for your section/group(s), accordingly");
4820: } else {
4821: $submit_text = &mt("Shift dates set just for your section, accordingly");
4822: }
4823: }
1.390 www 4824: my $start_page=&Apache::loncommon::start_page('Shift Dates');
4825: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 4826: $r->print($start_page.$breadcrumbs);
1.522.2.8 raeburn 4827: $r->print('<form name="shiftform" method="post" action="">'.
1.390 www 4828: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
4829: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
4830: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
1.522.2.10 raeburn 4831: &Apache::lonhtmlcommon::date_setter('shiftform',
1.390 www 4832: 'timeshifted',
4833: $env{'form.timebase'},,
4834: '').
4835: '</td></tr></table>'.
4836: '<input type="hidden" name="action" value="dateshift2" />'.
4837: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
1.522.2.27 raeburn 4838: '<input type="submit" value="'.$submit_text.'" /></form>');
1.390 www 4839: $r->print(&Apache::loncommon::end_page());
4840: }
4841:
4842: sub date_shift_two {
4843: my ($r) = @_;
4844: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4845: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4846: my $sec = $env{'request.course.sec'};
1.414 droeschl 4847: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 4848: text=>"Shifting Dates"});
1.390 www 4849: my $start_page=&Apache::loncommon::start_page('Shift Dates');
4850: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 4851: $r->print($start_page.$breadcrumbs);
1.390 www 4852: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
1.522.2.27 raeburn 4853: $r->print('<h2>'.&mt('Shift Dates').'</h2>');
4854: if ($sec ne '') {
4855: my @groups;
4856: if ($env{'request.course.groups'} ne '') {
4857: @groups = split(/:/,$env{'request.course.groups'});
4858: }
4859: if (@groups) {
4860: $r->print('<p>'.
4861: &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]",
4862: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4863: &Apache::lonlocal::locallocaltime($timeshifted)).
4864: '</p>');
4865: } else {
4866: $r->print('<p>'.
4867: &mt("Shift dates set just for your section, such that [_1] becomes [_2]",
4868: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4869: &Apache::lonlocal::locallocaltime($timeshifted)).
4870: '</p>');
4871: }
4872: } else {
4873: $r->print('<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
4874: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4875: &Apache::lonlocal::locallocaltime($timeshifted)).
4876: '</p>');
4877: }
1.390 www 4878: my $delta=$timeshifted-$env{'form.timebase'};
1.522.2.27 raeburn 4879: my $numchanges = 0;
4880: my $result = &dateshift($delta,\$numchanges);
4881: if ($result eq 'ok') {
4882: $r->print(
4883: &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]',
4884: $numchanges)));
4885: } elsif ($result eq 'con_delayed') {
4886: $r->print(
4887: &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]',
4888: $numchanges)));
4889: } else {
4890: $r->print(
4891: &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1));
4892: }
1.522.2.13 raeburn 4893: $r->print(
4894: '<br /><br />'.
4895: &Apache::lonhtmlcommon::actionbox(
4896: ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));
1.390 www 4897: $r->print(&Apache::loncommon::end_page());
4898: }
4899:
1.333 albertel 4900: sub parse_key {
4901: my ($key) = @_;
4902: my %data;
4903: my ($middle,$part,$name)=
1.473 amueller 4904: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.333 albertel 4905: $data{'scope_type'} = 'all';
4906: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4907: $data{'scope'} = $1;
4908: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
4909: $data{'scope_type'} = 'user';
4910: $data{'scope'} = [$1,$2];
4911: } else {
1.522.2.25 raeburn 4912: $data{'scope_type'} = 'secgroup';
1.473 amueller 4913: }
4914: $middle=~s/^\[(.*)\]//;
1.333 albertel 4915: }
4916: $middle=~s/\.+$//;
4917: $middle=~s/^\.+//;
4918: $data{'realm_type'}='all';
4919: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4920: $data{'realm'} = $1;
4921: $data{'realm_type'} = 'folder';
4922: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
4923: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
1.333 albertel 4924: } elsif ($middle) {
1.473 amueller 4925: $data{'realm'} = $middle;
4926: $data{'realm_type'} = 'symb';
4927: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
4928: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
4929: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
1.333 albertel 4930: }
1.446 bisitz 4931:
1.333 albertel 4932: $data{'parameter_part'} = $part;
4933: $data{'parameter_name'} = $name;
4934:
4935: return %data;
4936: }
4937:
1.239 raeburn 4938:
1.416 jms 4939: sub header {
1.522.2.3 raeburn 4940: return &Apache::loncommon::start_page('Content and Problem Settings');
1.416 jms 4941: }
1.193 albertel 4942:
4943:
4944:
4945: sub print_main_menu {
4946: my ($r,$parm_permission)=@_;
4947: #
1.414 droeschl 4948: $r->print(&header());
1.522.2.3 raeburn 4949: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
1.522.2.19 raeburn 4950: my $crstype = &Apache::loncommon::course_type();
4951: my $lc_crstype = lc($crstype);
4952:
1.193 albertel 4953: $r->print(<<ENDMAINFORMHEAD);
4954: <form method="post" enctype="multipart/form-data"
4955: action="/adm/parmset" name="studentform">
4956: ENDMAINFORMHEAD
4957: #
1.195 albertel 4958: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4959: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 4960: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 4961: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.520 raeburn 4962: my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
1.522.2.19 raeburn 4963: my $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'});
4964: my $vpa = &Apache::lonnet::allowed('vpa',$env{'request.course.id'});
1.520 raeburn 4965: if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
4966: $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
4967: '/'.$env{'request.course.sec'});
4968: }
1.522.2.19 raeburn 4969: if ((!$vcb) && ($env{'request.course.sec'} ne '')) {
4970: $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'}.
4971: '/'.$env{'request.course.sec'});
4972: }
4973: my (%linktext,%linktitle,%url);
4974: if ($parm_permission->{'edit'}) {
4975: %linktext = (
4976: newoverview => 'Edit Resource Parameters - Overview Mode',
4977: settable => 'Edit Resource Parameters - Table Mode',
4978: setoverview => 'Modify Resource Parameters - Overview Mode',
4979: );
4980: %linktitle = (
4981: newoverview => 'Set/Modify resource parameters in overview mode.',
4982: settable => 'Set/Modify resource parameters in table mode.',
4983: setoverview => 'Set/Modify existing resource parameters in overview mode.',
4984: );
4985: } else {
4986: %linktext = (
4987: newoverview => 'View Resource Parameters - Overview Mode',
4988: settable => 'View Resource Parameters - Table Mode',
4989: setoverview => 'View Resource Parameters - Overview Mode',
4990: );
4991: %linktitle = (
4992: newoverview => 'Display resource parameters in overview mode.',
4993: settable => 'Display resource parameters in table mode.',
4994: setoverview => 'Display existing resource parameters in overview mode.',
4995: );
4996: }
4997: if ($mgr) {
4998: $linktext{'resettimes'} = 'Reset Student Access Times';
4999: $linktitle{'resettimes'} = "Reset access times for folders/maps, resources or the $lc_crstype.";
5000: $url{'resettimes'} = '/adm/helper/resettimes.helper';
5001: } elsif ($vgr) {
5002: $linktext{'resettimes'} = 'Display Student Access Times',
5003: $linktitle{'resettimes'} = "Display access times for folders/maps, resources or the $lc_crstype.",
5004: $url{'resettimes'} = '/adm/accesstimes';
5005: }
1.193 albertel 5006: my @menu =
1.507 www 5007: ( { categorytitle=>"Content Settings for this $crstype",
1.473 amueller 5008: items => [
5009: { linktext => 'Portfolio Metadata',
5010: url => '/adm/parmset?action=setrestrictmeta',
1.522.2.19 raeburn 5011: permission => $parm_permission->{'setrestrictmeta'},
1.477 raeburn 5012: linktitle => "Restrict metadata for this $lc_crstype." ,
1.473 amueller 5013: icon =>'contact-new.png' ,
5014: },
1.522.2.19 raeburn 5015: { linktext => $linktext{'resettimes'},
5016: url => $url{'resettimes'},
1.522.2.20 raeburn 5017: permission => ($vgr || $mgr),
1.522.2.19 raeburn 5018: linktitle => $linktitle{'resettimes'},
5019: icon => 'start-here.png',
1.473 amueller 5020: },
1.520 raeburn 5021: { linktext => 'Blocking Communication/Resource Access',
5022: url => '/adm/setblock',
1.522.2.19 raeburn 5023: permission => ($vcb || $dcm),
1.520 raeburn 5024: linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
5025: icon => 'comblock.png',
5026: },
1.473 amueller 5027: { linktext => 'Set Parameter Setting Default Actions',
5028: url => '/adm/parmset?action=setdefaults',
1.522.2.19 raeburn 5029: permission => $parm_permission->{'setdefaults'},
1.473 amueller 5030: linktitle =>'Set default actions for parameters.' ,
5031: icon => 'folder-new.png' ,
5032: }]},
5033: { categorytitle => 'New and Existing Parameter Settings for Resources',
5034: items => [
5035: { linktext => 'Edit Resource Parameters - Helper Mode',
5036: url => '/adm/helper/parameter.helper',
1.522.2.19 raeburn 5037: permission => $parm_permission->{'helper'},
1.473 amueller 5038: linktitle =>'Set/Modify resource parameters in helper mode.' ,
5039: icon => 'dialog-information.png' ,
5040: #help => 'Parameter_Helper',
5041: },
1.522.2.19 raeburn 5042: { linktext => $linktext{'newoverview'},
1.473 amueller 5043: url => '/adm/parmset?action=newoverview',
1.522.2.19 raeburn 5044: permission => $parm_permission->{'newoverview'},
5045: linktitle => $linktitle{'newoverview'},
5046: icon => 'edit-find.png',
1.473 amueller 5047: #help => 'Parameter_Overview',
5048: },
1.522.2.19 raeburn 5049: { linktext => $linktext{'settable'},
1.473 amueller 5050: url => '/adm/parmset?action=settable',
1.522.2.19 raeburn 5051: permission => $parm_permission->{'settable'},
5052: linktitle => $linktitle{'settable'},
5053: icon => 'edit-copy.png',
1.473 amueller 5054: #help => 'Table_Mode',
5055: }]},
1.417 droeschl 5056: { categorytitle => 'Existing Parameter Settings for Resources',
1.473 amueller 5057: items => [
1.522.2.19 raeburn 5058: { linktext => $linktext{'setoverview'},
1.473 amueller 5059: url => '/adm/parmset?action=setoverview',
1.522.2.19 raeburn 5060: permission => $parm_permission->{'setoverview'},
5061: linktitle => $linktitle{'setoverview'},
5062: icon => 'preferences-desktop-wallpaper.png',
1.473 amueller 5063: #help => 'Parameter_Overview',
5064: },
5065: { linktext => 'Change Log',
5066: url => '/adm/parmset?action=parameterchangelog',
1.522.2.19 raeburn 5067: permission => $parm_permission->{'parameterchangelog'},
1.477 raeburn 5068: linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
1.487 wenzelju 5069: icon => 'document-properties.png',
1.473 amueller 5070: }]}
1.193 albertel 5071: );
1.414 droeschl 5072: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.522.2.8 raeburn 5073: $r->print('</form>'.&Apache::loncommon::end_page());
1.193 albertel 5074: return;
5075: }
1.414 droeschl 5076:
1.416 jms 5077:
5078:
1.252 banghart 5079: sub output_row {
1.347 banghart 5080: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 5081: my $output;
1.263 banghart 5082: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
5083: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 5084: if (!defined($options)) {
1.254 banghart 5085: $options = 'active,stuadd';
1.261 banghart 5086: $values = '';
1.252 banghart 5087: }
1.337 banghart 5088: if (!($options =~ /deleted/)) {
5089: my @options= ( ['active', 'Show to student'],
1.418 schafran 5090: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 5091: ['choices','Provide choices for students to select from']);
1.473 amueller 5092: # ['onlyone','Student may select only one choice']);
1.337 banghart 5093: if ($added_flag) {
5094: push @options,['deleted', 'Delete Metadata Field'];
5095: }
1.351 banghart 5096: $output = &Apache::loncommon::start_data_table_row();
1.451 bisitz 5097: $output .= '<td><strong>'.$field_text.':</strong></td>';
1.351 banghart 5098: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 5099: foreach my $opt (@options) {
1.473 amueller 5100: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
5101: $output .= &Apache::loncommon::continue_data_table_row();
5102: $output .= '<td>'.(' ' x 5).'<label>
5103: <input type="checkbox" name="'.
5104: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
5105: &mt($opt->[1]).'</label></td>';
5106: $output .= &Apache::loncommon::end_data_table_row();
5107: }
1.351 banghart 5108: $output .= &Apache::loncommon::continue_data_table_row();
1.451 bisitz 5109: $output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
1.351 banghart 5110: $output .= &Apache::loncommon::end_data_table_row();
5111: my $multiple_checked;
5112: my $single_checked;
5113: if ($options =~ m/onlyone/) {
1.422 bisitz 5114: $multiple_checked = '';
1.423 bisitz 5115: $single_checked = ' checked="checked"';
1.351 banghart 5116: } else {
1.423 bisitz 5117: $multiple_checked = ' checked="checked"';
1.422 bisitz 5118: $single_checked = '';
1.351 banghart 5119: }
1.473 amueller 5120: $output .= &Apache::loncommon::continue_data_table_row();
5121: $output .= '<td>'.(' ' x 10).'
5122: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
5123: '.&mt('Student may select multiple choices from list').'</td>';
5124: $output .= &Apache::loncommon::end_data_table_row();
5125: $output .= &Apache::loncommon::continue_data_table_row();
5126: $output .= '<td>'.(' ' x 10).'
5127: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
5128: '.&mt('Student may select only one choice from list').'</td>';
5129: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 5130: }
5131: return ($output);
5132: }
1.416 jms 5133:
5134:
5135:
1.340 banghart 5136: sub order_meta_fields {
5137: my ($r)=@_;
5138: my $idx = 1;
5139: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5140: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 5141: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 5142: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 5143: text=>"Add Metadata Field"});
1.345 banghart 5144: &Apache::lonhtmlcommon::add_breadcrumb
5145: ({href=>"/adm/parmset?action=setrestrictmeta",
5146: text=>"Restrict Metadata"},
5147: {text=>"Order Metadata"});
5148: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 5149: if ($env{'form.storeorder'}) {
5150: my $newpos = $env{'form.newpos'} - 1;
5151: my $currentpos = $env{'form.currentpos'} - 1;
5152: my @neworder = ();
5153: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
5154: my $i;
1.341 banghart 5155: if ($newpos > $currentpos) {
1.340 banghart 5156: # moving stuff up
5157: for ($i=0;$i<$currentpos;$i++) {
1.473 amueller 5158: $neworder[$i]=$oldorder[$i];
1.340 banghart 5159: }
5160: for ($i=$currentpos;$i<$newpos;$i++) {
1.473 amueller 5161: $neworder[$i]=$oldorder[$i+1];
1.340 banghart 5162: }
5163: $neworder[$newpos]=$oldorder[$currentpos];
5164: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
1.473 amueller 5165: $neworder[$i]=$oldorder[$i];
1.340 banghart 5166: }
5167: } else {
5168: # moving stuff down
1.473 amueller 5169: for ($i=0;$i<$newpos;$i++) {
5170: $neworder[$i]=$oldorder[$i];
5171: }
5172: $neworder[$newpos]=$oldorder[$currentpos];
5173: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
5174: $neworder[$i]=$oldorder[$i-1];
5175: }
5176: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
5177: $neworder[$i]=$oldorder[$i];
5178: }
1.340 banghart 5179: }
1.473 amueller 5180: my $ordered_fields = join ",", @neworder;
1.343 banghart 5181: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 5182: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.473 amueller 5183: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 5184: }
1.357 raeburn 5185: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 5186: my $ordered_fields;
1.340 banghart 5187: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
5188: if (!@fields_in_order) {
5189: # no order found, pick sorted order then create metadata.addedorder key.
5190: foreach my $key (sort keys %$fields) {
5191: push @fields_in_order, $key;
1.341 banghart 5192: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 5193: }
1.341 banghart 5194: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 5195: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
5196: }
1.340 banghart 5197: $r->print('<table>');
5198: my $num_fields = scalar(@fields_in_order);
5199: foreach my $key (@fields_in_order) {
5200: $r->print('<tr><td>');
5201: $r->print('<form method="post" action="">');
1.522.2.8 raeburn 5202: $r->print('<select name="newpos" onchange="this.form.submit()">');
1.340 banghart 5203: for (my $i = 1;$i le $num_fields;$i ++) {
5204: if ($i eq $idx) {
5205: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
5206: } else {
5207: $r->print('<option value="'.$i.'">'.$i.'</option>');
5208: }
5209: }
5210: $r->print('</select></td><td>');
5211: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
5212: $r->print('<input type="hidden" name="storeorder" value="true" />');
5213: $r->print('</form>');
5214: $r->print($$fields{$key}.'</td></tr>');
5215: $idx ++;
5216: }
5217: $r->print('</table>');
5218: return 'ok';
5219: }
1.416 jms 5220:
5221:
1.359 banghart 5222: sub continue {
5223: my $output;
5224: $output .= '<form action="" method="post">';
5225: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
1.522.2.25 raeburn 5226: $output .= '<input type="submit" value="'.&mt('Continue').'" />';
1.359 banghart 5227: return ($output);
5228: }
1.416 jms 5229:
5230:
1.334 banghart 5231: sub addmetafield {
5232: my ($r)=@_;
1.414 droeschl 5233: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 5234: text=>"Add Metadata Field"});
1.334 banghart 5235: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
5236: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 5237: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5238: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 5239: if (exists($env{'form.undelete'})) {
1.358 banghart 5240: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 5241: foreach my $meta_field(@meta_fields) {
5242: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
5243: $options =~ s/deleted//;
5244: $options =~ s/,,/,/;
5245: my $put_result = &Apache::lonnet::put('environment',
5246: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
1.446 bisitz 5247:
1.522.2.25 raeburn 5248: $r->print(&mt('Undeleted Metadata Field [_1] with result [_2]',
5249: '<strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}.
5250: '</strong>',$put_result).
5251: '<br />');
1.339 banghart 5252: }
1.359 banghart 5253: $r->print(&continue());
1.339 banghart 5254: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 5255: my $meta_field = $env{'form.fieldname'};
5256: my $display_field = $env{'form.fieldname'};
5257: $meta_field =~ s/\W/_/g;
1.338 banghart 5258: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 5259: my $put_result = &Apache::lonnet::put('environment',
5260: {'metadata.'.$meta_field.'.values'=>"",
5261: 'metadata.'.$meta_field.'.added'=>"$display_field",
5262: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.522.2.25 raeburn 5263: $r->print(&mt('Added new Metadata Field [_1] with result [_2]',
5264: '<strong>'.$env{'form.fieldname'}.'</strong>',$put_result).
5265: '<br />');
1.359 banghart 5266: $r->print(&continue());
1.335 banghart 5267: } else {
1.357 raeburn 5268: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 5269: if ($fields) {
1.522.2.25 raeburn 5270: $r->print(&mt('You may undelete previously deleted fields.').
5271: '<br />'.
5272: &mt('Check those you wish to undelete and click Undelete.').
5273: '<br />');
1.339 banghart 5274: $r->print('<form method="post" action="">');
5275: foreach my $key(keys(%$fields)) {
1.358 banghart 5276: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 5277: }
5278: $r->print('<input type="submit" name="undelete" value="Undelete" />');
5279: $r->print('</form>');
5280: }
1.522.2.25 raeburn 5281: $r->print('<hr />'.
5282: &mt('[_1]Or[_2] you may enter a new metadata field name.',
5283: '<strong>','</strong>').
5284: '<form method="post" action="/adm/parmset?action=addmetadata">');
1.335 banghart 5285: $r->print('<input type="text" name="fieldname" /><br />');
1.522.2.25 raeburn 5286: $r->print('<input type="submit" value="'.&mt('Add Metadata Field').'" />');
1.334 banghart 5287: }
1.361 albertel 5288: $r->print('</form>');
1.334 banghart 5289: }
1.416 jms 5290:
5291:
5292:
1.259 banghart 5293: sub setrestrictmeta {
1.240 banghart 5294: my ($r)=@_;
1.242 banghart 5295: my $next_meta;
1.244 banghart 5296: my $output;
1.245 banghart 5297: my $item_num;
1.246 banghart 5298: my $put_result;
1.414 droeschl 5299: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
1.473 amueller 5300: text=>"Restrict Metadata"});
1.280 albertel 5301: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 5302: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 5303: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5304: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 5305: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 5306: my $save_field = '';
1.522.2.25 raeburn 5307: my %lt = &Apache::lonlocal::texthash(
5308: addm => 'Add Metadata Field',
5309: ordm => 'Order Metadata Fields',
5310: save => 'Save',
5311: );
1.259 banghart 5312: if ($env{'form.restrictmeta'}) {
1.254 banghart 5313: foreach my $field (sort(keys(%env))) {
1.252 banghart 5314: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 5315: my $options;
1.252 banghart 5316: my $meta_field = $1;
5317: my $meta_key = $2;
1.253 banghart 5318: if ($save_field ne $meta_field) {
1.252 banghart 5319: $save_field = $meta_field;
1.473 amueller 5320: if ($env{'form.'.$meta_field.'_stuadd'}) {
5321: $options.='stuadd,';
5322: }
5323: if ($env{'form.'.$meta_field.'_choices'}) {
5324: $options.='choices,';
5325: }
5326: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
5327: $options.='onlyone,';
5328: }
5329: if ($env{'form.'.$meta_field.'_active'}) {
5330: $options.='active,';
5331: }
5332: if ($env{'form.'.$meta_field.'_deleted'}) {
5333: $options.='deleted,';
5334: }
1.259 banghart 5335: my $name = $save_field;
1.253 banghart 5336: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 5337: {'metadata.'.$meta_field.'.options'=>$options,
5338: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 5339: },$dom,$crs);
1.252 banghart 5340: }
5341: }
5342: }
5343: }
1.296 albertel 5344: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.473 amueller 5345: {'freshen_cache' => 1});
1.335 banghart 5346: # Get the default metadata fields
1.258 albertel 5347: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 5348: # Now get possible added metadata fields
1.357 raeburn 5349: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.347 banghart 5350: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 5351: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 5352: if ($field ne 'courserestricted') {
1.473 amueller 5353: $output.= &output_row($r, $field, $metadata_fields{$field});
5354: }
1.255 banghart 5355: }
1.351 banghart 5356: my $buttons = (<<ENDButtons);
1.522.2.25 raeburn 5357: <input type="submit" name="restrictmeta" value="$lt{'save'}" />
1.351 banghart 5358: </form><br />
5359: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
1.522.2.25 raeburn 5360: <input type="submit" name="restrictmeta" value="$lt{'addm'}" />
1.351 banghart 5361: </form>
5362: <br />
5363: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
1.522.2.25 raeburn 5364: <input type="submit" name="restrictmeta" value="$lt{'ordm'}" />
1.351 banghart 5365: ENDButtons
1.337 banghart 5366: my $added_flag = 1;
1.335 banghart 5367: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.522.2.25 raeburn 5368: $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag);
1.335 banghart 5369: }
1.347 banghart 5370: $output .= &Apache::loncommon::end_data_table();
1.446 bisitz 5371: $r->print(<<ENDenv);
1.259 banghart 5372: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 5373: $output
1.351 banghart 5374: $buttons
1.340 banghart 5375: </form>
1.244 banghart 5376: ENDenv
1.280 albertel 5377: $r->print(&Apache::loncommon::end_page());
1.240 banghart 5378: return 'ok';
5379: }
1.416 jms 5380:
5381:
5382:
1.335 banghart 5383: sub get_added_meta_fieldnames {
1.357 raeburn 5384: my ($cid) = @_;
1.335 banghart 5385: my %fields;
5386: foreach my $key(%env) {
1.357 raeburn 5387: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 5388: my $field_name = $1;
5389: my ($display_field_name) = $env{$key};
5390: $fields{$field_name} = $display_field_name;
5391: }
5392: }
5393: return \%fields;
5394: }
1.416 jms 5395:
5396:
5397:
1.339 banghart 5398: sub get_deleted_meta_fieldnames {
1.357 raeburn 5399: my ($cid) = @_;
1.339 banghart 5400: my %fields;
5401: foreach my $key(%env) {
1.357 raeburn 5402: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 5403: my $field_name = $1;
5404: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
5405: my ($display_field_name) = $env{$key};
5406: $fields{$field_name} = $display_field_name;
5407: }
5408: }
5409: }
5410: return \%fields;
5411: }
1.220 www 5412: sub defaultsetter {
1.280 albertel 5413: my ($r) = @_;
5414:
1.414 droeschl 5415: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
1.473 amueller 5416: text=>"Set Defaults"});
1.446 bisitz 5417: my $start_page =
1.473 amueller 5418: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 5419: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.507 www 5420: $r->print($start_page.$breadcrumbs);
5421: $r->print('<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">');
1.280 albertel 5422:
5423: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5424: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 5425: my @ids=();
5426: my %typep=();
5427: my %keyp=();
5428: my %allparms=();
5429: my %allparts=();
5430: my %allmaps=();
5431: my %mapp=();
5432: my %symbp=();
5433: my %maptitles=();
5434: my %uris=();
5435: my %keyorder=&standardkeyorder();
5436: my %defkeytype=();
5437:
1.446 bisitz 5438: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 5439: \%mapp, \%symbp,\%maptitles,\%uris,
5440: \%keyorder,\%defkeytype);
1.224 www 5441: if ($env{'form.storerules'}) {
1.473 amueller 5442: my %newrules=();
5443: my @delrules=();
5444: my %triggers=();
5445: foreach my $key (keys(%env)) {
1.225 albertel 5446: if ($key=~/^form\.(\w+)\_action$/) {
1.473 amueller 5447: my $tempkey=$1;
5448: my $action=$env{$key};
1.226 www 5449: if ($action) {
1.473 amueller 5450: $newrules{$tempkey.'_action'}=$action;
5451: if ($action ne 'default') {
5452: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
5453: $triggers{$whichparm}.=$tempkey.':';
5454: }
5455: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
5456: if (&isdateparm($defkeytype{$tempkey})) {
5457: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
5458: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
5459: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
5460: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
5461: } else {
5462: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
5463: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
5464: }
5465: } else {
5466: push(@delrules,$tempkey.'_action');
5467: push(@delrules,$tempkey.'_type');
5468: push(@delrules,$tempkey.'_hours');
5469: push(@delrules,$tempkey.'_min');
5470: push(@delrules,$tempkey.'_sec');
5471: push(@delrules,$tempkey.'_value');
5472: }
5473: }
5474: }
5475: foreach my $key (keys %allparms) {
5476: $newrules{$key.'_triggers'}=$triggers{$key};
5477: }
5478: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
5479: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
5480: &resetrulescache();
1.224 www 5481: }
1.227 www 5482: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
1.473 amueller 5483: 'hours' => 'Hours',
5484: 'min' => 'Minutes',
5485: 'sec' => 'Seconds',
5486: 'yes' => 'Yes',
5487: 'no' => 'No');
1.222 www 5488: my @standardoptions=('','default');
5489: my @standarddisplay=('',&mt('Default value when manually setting'));
5490: my @dateoptions=('','default');
5491: my @datedisplay=('',&mt('Default value when manually setting'));
5492: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 5493: unless ($tempkey) { next; }
5494: push @standardoptions,'when_setting_'.$tempkey;
5495: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
5496: if (&isdateparm($defkeytype{$tempkey})) {
5497: push @dateoptions,'later_than_'.$tempkey;
5498: push @datedisplay,&mt('Automatically set later than ').$tempkey;
5499: push @dateoptions,'earlier_than_'.$tempkey;
5500: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
5501: }
1.222 www 5502: }
1.231 www 5503: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
1.473 amueller 5504: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 5505: $r->print("\n".&Apache::loncommon::start_data_table().
1.473 amueller 5506: &Apache::loncommon::start_data_table_header_row().
5507: "<th>".&mt('Rule for parameter').'</th><th>'.
5508: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
5509: &Apache::loncommon::end_data_table_header_row());
1.221 www 5510: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 5511: unless ($tempkey) { next; }
5512: $r->print("\n".&Apache::loncommon::start_data_table_row().
5513: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
5514: my $action=&rulescache($tempkey.'_action');
5515: $r->print('<select name="'.$tempkey.'_action">');
5516: if (&isdateparm($defkeytype{$tempkey})) {
5517: for (my $i=0;$i<=$#dateoptions;$i++) {
5518: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
5519: $r->print("\n<option value='$dateoptions[$i]'".
5520: ($dateoptions[$i] eq $action?' selected="selected"':'').
5521: ">$datedisplay[$i]</option>");
5522: }
5523: } else {
5524: for (my $i=0;$i<=$#standardoptions;$i++) {
5525: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
5526: $r->print("\n<option value='$standardoptions[$i]'".
5527: ($standardoptions[$i] eq $action?' selected="selected"':'').
5528: ">$standarddisplay[$i]</option>");
5529: }
5530: }
5531: $r->print('</select>');
5532: unless (&isdateparm($defkeytype{$tempkey})) {
5533: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
5534: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
5535: }
5536: $r->print("\n</td><td>\n");
1.222 www 5537:
1.221 www 5538: if (&isdateparm($defkeytype{$tempkey})) {
1.473 amueller 5539: my $days=&rulescache($tempkey.'_days');
5540: my $hours=&rulescache($tempkey.'_hours');
5541: my $min=&rulescache($tempkey.'_min');
5542: my $sec=&rulescache($tempkey.'_sec');
5543: $r->print(<<ENDINPUTDATE);
1.227 www 5544: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 5545: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
5546: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
5547: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 5548: ENDINPUTDATE
1.473 amueller 5549: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 5550: my $yeschecked='';
5551: my $nochecked='';
1.444 bisitz 5552: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
5553: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
1.222 www 5554:
1.473 amueller 5555: $r->print(<<ENDYESNO);
1.444 bisitz 5556: <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
5557: <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
1.221 www 5558: ENDYESNO
5559: } else {
1.473 amueller 5560: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
5561: }
1.318 albertel 5562: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 5563: }
1.318 albertel 5564: $r->print(&Apache::loncommon::end_data_table().
1.473 amueller 5565: "\n".'<input type="submit" name="storerules" value="'.
1.507 www 5566: &mt('Save').'" /></form>'."\n");
5567: $r->print(&Apache::loncommon::end_page());
1.220 www 5568: return;
5569: }
1.193 albertel 5570:
1.290 www 5571: sub components {
1.330 albertel 5572: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
5573:
5574: if ($typeflag) {
1.473 amueller 5575: $key=~s/\.type$//;
1.290 www 5576: }
1.330 albertel 5577:
5578: my ($middle,$part,$name)=
1.473 amueller 5579: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 5580: my $issection;
1.330 albertel 5581:
1.290 www 5582: my $section=&mt('All Students');
5583: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 5584: $issection=$1;
5585: $section=&mt('Group/Section').': '.$issection;
5586: $middle=~s/^\[(.*)\]//;
1.290 www 5587: }
5588: $middle=~s/\.+$//;
5589: $middle=~s/^\.+//;
1.291 www 5590: if ($uname) {
1.473 amueller 5591: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
5592: $issection='';
1.291 www 5593: }
1.316 albertel 5594: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.446 bisitz 5595: my $realmdescription=&mt('all resources');
1.290 www 5596: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 5597: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
5598: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
1.304 www 5599: } elsif ($middle) {
1.473 amueller 5600: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
5601: $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>';
5602: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 5603: }
1.291 www 5604: my $what=$part.'.'.$name;
1.330 albertel 5605: return ($realm,$section,$name,$part,
1.473 amueller 5606: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 5607: }
1.293 www 5608:
1.328 albertel 5609: my %standard_parms;
1.469 raeburn 5610: my %standard_parms_types;
1.416 jms 5611:
1.328 albertel 5612: sub load_parameter_names {
1.522.2.25 raeburn 5613: open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
1.328 albertel 5614: while (my $configline=<$config>) {
1.473 amueller 5615: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
5616: chomp($configline);
5617: my ($short,$plain)=split(/:/,$configline);
5618: my (undef,$name,$type)=split(/\&/,$short,3);
5619: if ($type eq 'display') {
5620: $standard_parms{$name} = $plain;
1.469 raeburn 5621: } elsif ($type eq 'type') {
5622: $standard_parms_types{$name} = $plain;
5623: }
1.328 albertel 5624: }
5625: close($config);
5626: $standard_parms{'int_pos'} = 'Positive Integer';
5627: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
1.522.2.25 raeburn 5628: $standard_parms{'scoreformat'} = 'Format for display of score';
1.328 albertel 5629: }
5630:
1.292 www 5631: sub standard_parameter_names {
5632: my ($name)=@_;
1.328 albertel 5633: if (!%standard_parms) {
1.473 amueller 5634: &load_parameter_names();
1.328 albertel 5635: }
1.292 www 5636: if ($standard_parms{$name}) {
1.473 amueller 5637: return $standard_parms{$name};
1.446 bisitz 5638: } else {
1.473 amueller 5639: return $name;
1.292 www 5640: }
5641: }
1.290 www 5642:
1.469 raeburn 5643: sub standard_parameter_types {
5644: my ($name)=@_;
5645: if (!%standard_parms_types) {
5646: &load_parameter_names();
5647: }
5648: if ($standard_parms_types{$name}) {
5649: return $standard_parms_types{$name};
5650: }
5651: return;
5652: }
1.309 www 5653:
1.285 albertel 5654: sub parm_change_log {
1.522.2.19 raeburn 5655: my ($r,$parm_permission)=@_;
1.414 droeschl 5656: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.473 amueller 5657: text=>"Parameter Change Log"});
1.522 raeburn 5658: my $js = '<script type="text/javascript">'."\n".
5659: '// <![CDATA['."\n".
5660: &Apache::loncommon::display_filter_js('parmslog')."\n".
5661: '// ]]>'."\n".
5662: '</script>'."\n";
5663: $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
1.327 albertel 5664: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
1.286 www 5665: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
1.473 amueller 5666: $env{'course.'.$env{'request.course.id'}.'.domain'},
5667: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 5668:
1.301 www 5669: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 5670:
1.522 raeburn 5671: $r->print('<div class="LC_left_float">'.
5672: '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
5673: '<form action="/adm/parmset?action=parameterchangelog"
1.327 albertel 5674: method="post" name="parameterlog">');
1.446 bisitz 5675:
1.311 albertel 5676: my %saveable_parameters = ('show' => 'scalar',);
5677: &Apache::loncommon::store_course_settings('parameter_log',
5678: \%saveable_parameters);
5679: &Apache::loncommon::restore_course_settings('parameter_log',
5680: \%saveable_parameters);
1.522 raeburn 5681: $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
5682: '<input type="submit" value="'.&mt('Display').'" />'.
5683: '</form></fieldset></div><br clear="all" />');
1.522.2.19 raeburn 5684: my $readonly = 1;
5685: if ($parm_permission->{'edit'}) {
5686: undef($readonly);
5687: }
1.291 www 5688: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
1.473 amueller 5689: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 5690: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1.473 amueller 5691: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
1.522.2.19 raeburn 5692: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th>');
5693: unless ($readonly) {
5694: $r->print('<th>'.&mt('Announce').'</th>');
5695: }
5696: $r->print(&Apache::loncommon::end_data_table_header_row());
1.309 www 5697: my $shown=0;
1.349 www 5698: my $folder='';
5699: if ($env{'form.displayfilter'} eq 'currentfolder') {
1.473 amueller 5700: my $last='';
5701: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
5702: &GDBM_READER(),0640)) {
5703: $last=$hash{'last_known'};
5704: untie(%hash);
5705: }
5706: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
1.349 www 5707: }
1.522.2.27 raeburn 5708: my $numgroups = 0;
5709: my @groups;
5710: if ($env{'request.course.groups'} ne '') {
5711: @groups = split(/:/,$env{'request.course.groups'});
5712: $numgroups = scalar(@groups);
5713: }
1.446 bisitz 5714: foreach my $id (sort
1.473 amueller 5715: {
5716: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
5717: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
5718: }
5719: my $aid = (split('00000',$a))[-1];
5720: my $bid = (split('00000',$b))[-1];
5721: return $bid<=>$aid;
5722: } (keys(%parmlog))) {
1.294 www 5723: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.473 amueller 5724: my $count = 0;
5725: my $time =
5726: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
5727: my $plainname =
5728: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
5729: $parmlog{$id}{'exe_udom'});
5730: my $about_me_link =
5731: &Apache::loncommon::aboutmewrapper($plainname,
5732: $parmlog{$id}{'exe_uname'},
5733: $parmlog{$id}{'exe_udom'});
5734: my $send_msg_link='';
1.522.2.19 raeburn 5735: if ((!$readonly) &&
5736: (($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
1.473 amueller 5737: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
5738: $send_msg_link ='<br />'.
5739: &Apache::loncommon::messagewrapper(&mt('Send message'),
5740: $parmlog{$id}{'exe_uname'},
5741: $parmlog{$id}{'exe_udom'});
5742: }
5743: my $row_start=&Apache::loncommon::start_data_table_row();
5744: my $makenewrow=0;
5745: my %istype=();
5746: my $output;
5747: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 5748: my $value=$parmlog{$id}{'logentry'}{$changed};
1.473 amueller 5749: my $typeflag = ($changed =~/\.type$/ &&
5750: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 5751: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.473 amueller 5752: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.522.2.24 raeburn 5753: if ($env{'request.course.sec'} ne '') {
1.522.2.27 raeburn 5754: next if (($issection ne '') && (!(($issection eq $env{'request.course.sec'}) ||
5755: ($numgroups && (grep(/^\Q$issection\E$/,@groups))))));
1.522.2.24 raeburn 5756: if ($uname ne '') {
5757: my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'});
5758: next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'}));
5759: }
5760: }
1.473 amueller 5761: if ($env{'form.displayfilter'} eq 'currentfolder') {
5762: if ($folder) {
5763: if ($middle!~/^\Q$folder\E/) { next; }
5764: }
5765: }
5766: if ($typeflag) {
5767: $istype{$parmname}=$value;
5768: if (!$env{'form.includetypes'}) { next; }
5769: }
5770: $count++;
5771: if ($makenewrow) {
5772: $output .= $row_start;
5773: } else {
5774: $makenewrow=1;
5775: }
1.470 raeburn 5776: my $parmitem = &standard_parameter_names($parmname);
1.473 amueller 5777: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
5778: &mt($parmitem).'</td><td>'.
5779: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
5780: my $stillactive=0;
5781: if ($parmlog{$id}{'delflag'}) {
5782: $output .= &mt('Deleted');
5783: } else {
5784: if ($typeflag) {
1.470 raeburn 5785: my $parmitem = &standard_parameter_names($value);
5786: $parmitem = &mt($parmitem);
1.473 amueller 5787: $output .= &mt('Type: [_1]',$parmitem);
5788: } else {
5789: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
5790: $uname,$udom,$issection,$issection,$courseopt);
1.469 raeburn 5791: my $showvalue = $value;
5792: if ($istype{$parmname} eq '') {
5793: my $type = &standard_parameter_types($parmname);
5794: if ($type ne '') {
5795: if (&isdateparm($type)) {
5796: $showvalue =
5797: &Apache::lonlocal::locallocaltime($value);
5798: }
5799: }
5800: } else {
1.473 amueller 5801: if (&isdateparm($istype{$parmname})) {
5802: $showvalue =
1.469 raeburn 5803: &Apache::lonlocal::locallocaltime($value);
1.473 amueller 5804: }
1.469 raeburn 5805: }
5806: $output .= $showvalue;
1.473 amueller 5807: if ($value ne $all[$level]) {
5808: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
5809: } else {
5810: $stillactive=1;
5811: }
5812: }
5813: }
1.522.2.19 raeburn 5814: $output .= '</td>';
5815:
5816: unless ($readonly) {
5817: $output .= '<td>';
5818: if ($stillactive) {
5819: my $parmitem = &standard_parameter_names($parmname);
5820: $parmitem = &mt($parmitem);
5821: my $title=&mt('Changed [_1]',$parmitem);
5822: my $description=&mt('Changed [_1] for [_2] to [_3]',
5823: $parmitem,$realmdescription,
5824: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
5825: if (($uname) && ($udom)) {
5826: $output .=
5827: &Apache::loncommon::messagewrapper('Notify User',
5828: $uname,$udom,$title,
5829: $description);
5830: } else {
5831: $output .=
5832: &Apache::lonrss::course_blog_link($id,$title,
5833: $description);
5834: }
5835: }
5836: $output .= '</td>';
5837: }
5838: $output .= &Apache::loncommon::end_data_table_row();
1.473 amueller 5839: }
1.349 www 5840: if ($env{'form.displayfilter'} eq 'containing') {
1.473 amueller 5841: my $wholeentry=$about_me_link.':'.
5842: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
5843: $output;
5844: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
5845: }
1.349 www 5846: if ($count) {
1.473 amueller 5847: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 5848: <td rowspan="'.$count.'">'.$about_me_link.
1.473 amueller 5849: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
5850: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
5851: $send_msg_link.'</td>'.$output);
5852: $shown++;
5853: }
5854: if (!($env{'form.show'} eq &mt('all')
5855: || $shown<=$env{'form.show'})) { last; }
1.286 www 5856: }
1.301 www 5857: $r->print(&Apache::loncommon::end_data_table());
1.284 www 5858: $r->print(&Apache::loncommon::end_page());
5859: }
5860:
1.437 raeburn 5861: sub update_slots {
5862: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
5863: my %slot=&Apache::lonnet::get_slot($slot_name);
5864: if (!keys(%slot)) {
5865: return 'error: slot does not exist';
5866: }
5867: my $max=$slot{'maxspace'};
5868: if (!defined($max)) { $max=99999; }
5869:
5870: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
5871: "^$slot_name\0");
5872: my ($tmp)=%consumed;
5873: if ($tmp=~/^error: 2 / ) {
5874: return 'error: unable to determine current slot status';
5875: }
5876: my $last=0;
5877: foreach my $key (keys(%consumed)) {
5878: my $num=(split('\0',$key))[1];
5879: if ($num > $last) { $last=$num; }
5880: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
5881: return 'ok';
5882: }
5883: }
5884:
5885: if (scalar(keys(%consumed)) >= $max) {
5886: return 'error: no space left in slot';
5887: }
5888: my $wanted=$last+1;
5889:
5890: my %reservation=('name' => $uname.':'.$udom,
5891: 'timestamp' => time,
5892: 'symb' => $symb);
5893:
5894: my $success=&Apache::lonnet::newput('slot_reservations',
5895: {"$slot_name\0$wanted" =>
5896: \%reservation},
5897: $cdom, $cnum);
1.438 raeburn 5898: if ($success eq 'ok') {
5899: my %storehash = (
5900: symb => $symb,
5901: slot => $slot_name,
5902: action => 'reserve',
5903: context => 'parameter',
5904: );
1.522.2.3 raeburn 5905: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.438 raeburn 5906: '',$uname,$udom,$cnum,$cdom);
5907:
1.522.2.3 raeburn 5908: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 5909: '',$uname,$udom,$uname,$udom);
5910: }
1.437 raeburn 5911: return $success;
5912: }
5913:
5914: sub delete_slots {
5915: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
5916: my $delresult;
5917: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
5918: $cnum, "^$slot_name\0");
5919: if (&Apache::lonnet::error(%consumed)) {
5920: return 'error: unable to determine current slot status';
5921: }
5922: my ($tmp)=%consumed;
5923: if ($tmp=~/^error: 2 /) {
5924: return 'error: unable to determine current slot status';
5925: }
5926: foreach my $key (keys(%consumed)) {
5927: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
5928: my $num=(split('\0',$key))[1];
5929: my $entry = $slot_name.'\0'.$num;
5930: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
5931: $cdom,$cnum);
5932: if ($delresult eq 'ok') {
5933: my %storehash = (
5934: symb => $symb,
5935: slot => $slot_name,
5936: action => 'release',
5937: context => 'parameter',
5938: );
1.522.2.3 raeburn 5939: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.437 raeburn 5940: 1,$uname,$udom,$cnum,$cdom);
1.522.2.3 raeburn 5941: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 5942: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 5943: }
5944: }
5945: }
5946: return $delresult;
5947: }
5948:
1.355 albertel 5949: sub check_for_course_info {
5950: my $navmap = Apache::lonnavmaps::navmap->new();
5951: return 1 if ($navmap);
5952: return 0;
5953: }
5954:
1.514 raeburn 5955: sub parameter_release_vars {
1.504 raeburn 5956: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5957: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
5958: my $chostname = &Apache::lonnet::hostname($chome);
5959: my ($cmajor,$cminor) =
5960: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
5961: return ($chostname,$cmajor,$cminor);
5962: }
5963:
1.514 raeburn 5964: sub parameter_releasecheck {
1.522.2.14 raeburn 5965: my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
1.504 raeburn 5966: my $needsnewer;
5967: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
5968: if (($cmajor < $needsmajor) ||
5969: ($cmajor == $needsmajor && $cminor < $needsminor)) {
5970: $needsnewer = 1;
5971: } else {
1.514 raeburn 5972: &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
1.504 raeburn 5973: }
5974: return $needsnewer;
5975: }
5976:
1.522.2.19 raeburn 5977: sub get_permission {
5978: my %permission;
5979: my $allowed = 0;
5980: return (\%permission,$allowed) unless ($env{'request.course.id'});
5981: if ((&Apache::lonnet::allowed('opa',$env{'request.course.id'})) ||
5982: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
5983: $env{'request.course.sec'}))) {
5984: %permission= (
5985: 'edit' => 1,
5986: 'set' => 1,
5987: 'setoverview' => 1,
5988: 'addmetadata' => 1,
5989: 'ordermetadata' => 1,
5990: 'setrestrictmeta' => 1,
5991: 'newoverview' => 1,
5992: 'setdefaults' => 1,
5993: 'settable' => 1,
5994: 'parameterchangelog' => 1,
5995: 'cleanparameters' => 1,
5996: 'dateshift1' => 1,
5997: 'dateshift2' => 1,
5998: 'helper' => 1,
5999: );
6000: } elsif ((&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) ||
6001: (&Apache::lonnet::allowed('vpa',$env{'request.course.id'}.'/'.
6002: $env{'request.course.sec'}))) {
6003: %permission = (
6004: 'set' => 1,
6005: 'settable' => 1,
6006: 'newoverview' => 1,
6007: 'setoverview' => 1,
6008: 'parameterchangelog' => 1,
6009: );
6010: }
6011: foreach my $perm (values(%permission)) {
6012: if ($perm) { $allowed=1; last; }
6013: }
6014: return (\%permission,$allowed);
6015: }
6016:
1.30 www 6017: sub handler {
1.43 albertel 6018: my $r=shift;
1.30 www 6019:
1.376 albertel 6020: &reset_caches();
6021:
1.414 droeschl 6022: &Apache::loncommon::content_type($r,'text/html');
6023: $r->send_http_header;
6024: return OK if $r->header_only;
6025:
1.193 albertel 6026: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.473 amueller 6027: ['action','state',
1.205 www 6028: 'pres_marker',
6029: 'pres_value',
1.206 www 6030: 'pres_type',
1.506 www 6031: 'filter','part',
1.390 www 6032: 'udom','uname','symb','serial','timebase']);
1.131 www 6033:
1.83 bowersj2 6034:
1.193 albertel 6035: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 6036: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
1.522.2.3 raeburn 6037: text=>"Content and Problem Settings",
1.473 amueller 6038: faq=>10,
6039: bug=>'Instructor Interface',
1.442 droeschl 6040: help =>
6041: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 6042:
1.30 www 6043: # ----------------------------------------------------- Needs to be in a course
1.522.2.19 raeburn 6044: my ($parm_permission,$allowed) = &get_permission();
1.355 albertel 6045: my $exists = &check_for_course_info();
6046:
1.522.2.19 raeburn 6047: if ($env{'request.course.id'} && $allowed && $exists) {
1.193 albertel 6048: #
6049: # Main switch on form.action and form.state, as appropriate
6050: #
6051: # Check first if coming from someone else headed directly for
6052: # the table mode
1.522.2.19 raeburn 6053: if (($parm_permission->{'set'}) &&
6054: ((($env{'form.command'} eq 'set') && ($env{'form.url'})
6055: && (!$env{'form.dis'})) || ($env{'form.symb'}))) {
6056: &assessparms($r,$parm_permission);
1.193 albertel 6057: } elsif (! exists($env{'form.action'})) {
6058: &print_main_menu($r,$parm_permission);
1.522.2.19 raeburn 6059: } elsif (!$parm_permission->{$env{'form.action'}}) {
6060: &print_main_menu($r,$parm_permission);
1.414 droeschl 6061: } elsif ($env{'form.action'} eq 'setoverview') {
1.522.2.19 raeburn 6062: &overview($r,$parm_permission);
6063: } elsif ($env{'form.action'} eq 'addmetadata') {
6064: &addmetafield($r);
6065: } elsif ($env{'form.action'} eq 'ordermetadata') {
6066: &order_meta_fields($r);
1.414 droeschl 6067: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.522.2.19 raeburn 6068: &setrestrictmeta($r);
1.414 droeschl 6069: } elsif ($env{'form.action'} eq 'newoverview') {
1.522.2.19 raeburn 6070: &newoverview($r,$parm_permission);
1.414 droeschl 6071: } elsif ($env{'form.action'} eq 'setdefaults') {
1.522.2.19 raeburn 6072: &defaultsetter($r);
6073: } elsif ($env{'form.action'} eq 'settable') {
6074: &assessparms($r,$parm_permission);
1.414 droeschl 6075: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.522.2.19 raeburn 6076: &parm_change_log($r,$parm_permission);
1.414 droeschl 6077: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.522.2.19 raeburn 6078: &clean_parameters($r);
1.414 droeschl 6079: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 6080: &date_shift_one($r);
1.414 droeschl 6081: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 6082: &date_shift_two($r);
1.446 bisitz 6083: }
1.43 albertel 6084: } else {
1.1 www 6085: # ----------------------------- Not in a course, or not allowed to modify parms
1.473 amueller 6086: if ($exists) {
6087: $env{'user.error.msg'}=
6088: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
6089: } else {
6090: $env{'user.error.msg'}=
6091: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
6092: }
6093: return HTTP_NOT_ACCEPTABLE;
1.43 albertel 6094: }
1.376 albertel 6095: &reset_caches();
6096:
1.43 albertel 6097: return OK;
1.1 www 6098: }
6099:
6100: 1;
6101: __END__
6102:
6103:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>