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