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