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