Annotation of loncom/interface/lonparmset.pm, revision 1.522.2.28.4.4
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.3 2022/03/23 17:29:29 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:
1.522.2.28.4. (raeburn 2810:): # Hide parm selection and possibly table?
2811:): my ($tablejs,$tabledivsty);
2812:): if (((($env{'form.uname'} ne '') || ($env{'form.id'} ne '')) && ($uname eq '')) &&
2813:): ($env{'form.dis'}) && ($pssymb eq '')) {
2814:): $tablejs = 'document.getElementById('."'parmtable'".').style.display = "";';
2815:): $tabledivsty = ' style="display:none"';
2816:): }
1.459 bisitz 2817: $r->print(<<ENDPARMSELSCRIPT);
2818: <script type="text/javascript">
2819: // <![CDATA[
2820: function parmsel_show() {
2821: document.getElementById('parmsel').style.display = "";
2822: document.getElementById('parmsellink').style.display = "none";
1.522.2.28.4. (raeburn 2823:): $tablejs
1.459 bisitz 2824: }
2825: // ]]>
2826: </script>
2827: ENDPARMSELSCRIPT
1.474 amueller 2828:
1.445 neumanie 2829: if (!$pssymb) {
1.486 www 2830: my $parmselhiddenstyle=' style="display:none"';
2831: if($env{'form.hideparmsel'} eq 'hidden') {
2832: $r->print('<div id="parmsel"'.$parmselhiddenstyle.'>');
2833: } else {
2834: $r->print('<div id="parmsel">');
2835: }
2836:
1.491 bisitz 2837: # Step 1
1.522.2.2 raeburn 2838: $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'),'parmstep1'));
2839: $r->print('
1.474 amueller 2840: <script type="text/javascript">
1.522.2.2 raeburn 2841: // <![CDATA['.
2842: &showhide_js().'
1.474 amueller 2843: // ]]>
2844: </script>
1.522.2.2 raeburn 2845: ');
2846: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.209 www 2847: &levelmenu($r,\%alllevs,$parmlev);
1.491 bisitz 2848: $r->print(&Apache::lonhtmlcommon::row_closure());
1.474 amueller 2849: &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp);
1.491 bisitz 2850: $r->print(&Apache::lonhtmlcommon::row_closure());
2851: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
2852: &partmenu($r,\%allparts,\@psprt);
1.474 amueller 2853: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2854: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2855:
2856: # Step 2
1.522.2.2 raeburn 2857: $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
1.522.2.25 raeburn 2858: &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
1.491 bisitz 2859:
2860: # Step 3
1.522.2.2 raeburn 2861: $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
1.486 www 2862: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.522.2.24 raeburn 2863: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
1.486 www 2864: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2865: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2866:
2867: # Update Display Button
1.486 www 2868: $r->print('<p>'
2869: .'<input type="submit" name="dis"'
1.511 www 2870: .' value="'.&mt('Update Display').'" />'
1.486 www 2871: .'<input type="hidden" name="hideparmsel" value="hidden" />'
2872: .'</p>');
2873: $r->print('</div>');
1.491 bisitz 2874:
1.486 www 2875: # Offer link to display parameter selection again
2876: $r->print('<p id="parmsellink"');
2877: if ($env{'form.hideparmsel'} ne 'hidden') {
2878: $r->print($parmselhiddenstyle);
2879: }
2880: $r->print('>'
2881: .'<a href="javascript:parmsel_show()">'
2882: .&mt('Change Parameter Selection')
2883: .'</a>'
2884: .'</p>');
1.44 albertel 2885: } else {
1.515 raeburn 2886: $r->print();
1.478 amueller 2887: # parameter screen for a single resource.
1.486 www 2888: my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.473 amueller 2889: my $title = &Apache::lonnet::gettitle($pssymb);
1.501 bisitz 2890: $r->print(&mt('Specific Resource: [_1] ([_2])',
2891: $title,'<span class="LC_filename">'.$resource.'</span>').
1.472 amueller 2892: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.486 www 2893: '<br />');
2894: $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));
2895: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.522.2.1 raeburn 2896: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')).
2897: '<label>'.
2898: '<input type="checkbox" name="psprt" value="all"'.
2899: ($env{'form.psprt'}?' checked="checked"':'').' />'.
2900: &mt('Show all parts').
2901: '</label></td></tr>');
1.522.2.24 raeburn 2902: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
1.486 www 2903: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2904: $r->print(&Apache::lonhtmlcommon::end_pick_box());
2905: $r->print('<p>'
1.459 bisitz 2906: .'<input type="submit" name="dis"'
1.511 www 2907: .' value="'.&mt('Update Display').'" />'
1.459 bisitz 2908: .'<input type="hidden" name="hideparmsel" value="hidden" />'
1.486 www 2909: .'</p>');
1.459 bisitz 2910: }
1.478 amueller 2911:
1.486 www 2912: # ----- End Parameter Selection
1.57 albertel 2913:
1.459 bisitz 2914: # Display Messages
2915: $r->print('<div>'.$message.'</div>');
1.210 www 2916:
1.57 albertel 2917:
2918: my @temp_pscat;
2919: map {
2920: my $cat = $_;
2921: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
2922: } @pscat;
2923:
2924: @pscat = @temp_pscat;
2925:
1.209 www 2926: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 2927: # ----------------------------------------------------------------- Start Table
1.57 albertel 2928: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 2929: my $csuname=$env{'user.name'};
2930: my $csudom=$env{'user.domain'};
1.522.2.19 raeburn 2931: my $readonly = 1;
2932: if ($parm_permission->{'edit'}) {
2933: undef($readonly);
2934: }
1.522.2.28.4. (raeburn 2935:): $r->print('<div id="parmtable"'.$tabledivsty.'>');
1.57 albertel 2936:
1.203 www 2937: if ($parmlev eq 'full') {
1.506 www 2938: #
2939: # This produces the cascading table output of parameters
2940: #
1.473 amueller 2941: my $coursespan=$csec?8:5;
2942: my $userspan=3;
2943: if ($cgroup ne '') {
2944: $coursespan += 3;
2945: }
2946:
1.517 www 2947: $r->print(&Apache::loncommon::start_data_table());
1.506 www 2948: #
2949: # This produces the headers
2950: #
1.473 amueller 2951: $r->print('<tr><td colspan="5"></td>');
2952: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
2953: if ($uname) {
2954: if (@usersgroups > 1) {
2955: $userspan ++;
2956: }
2957: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
2958: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
2959: }
2960: my %lt=&Apache::lonlocal::texthash(
2961: 'pie' => "Parameter in Effect",
2962: 'csv' => "Current Session Value",
1.472 amueller 2963: 'rl' => "Resource Level",
1.473 amueller 2964: 'ic' => 'in Course',
2965: 'aut' => "Assessment URL and Title",
2966: 'type' => 'Type',
2967: 'emof' => "Enclosing Map or Folder",
2968: 'part' => 'Part',
1.472 amueller 2969: 'pn' => 'Parameter Name',
1.473 amueller 2970: 'def' => 'default',
2971: 'femof' => 'from Enclosing Map or Folder',
2972: 'gen' => 'general',
2973: 'foremf' => 'for Enclosing Map or Folder',
2974: 'fr' => 'for Resource'
2975: );
2976: $r->print(<<ENDTABLETWO);
1.419 bisitz 2977: <th rowspan="3">$lt{'pie'}</th>
1.501 bisitz 2978: <th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>
1.419 bisitz 2979: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
2980: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 2981:
1.10 www 2982: ENDTABLETWO
1.473 amueller 2983: if ($csec) {
2984: $r->print('<th colspan="3">'.
2985: &mt("in Section")." $csec</th>");
2986: }
2987: if ($cgroup) {
1.419 bisitz 2988: $r->print('<th colspan="3">'.
1.472 amueller 2989: &mt("in Group")." $cgroup</th>");
1.473 amueller 2990: }
2991: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 2992: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
2993: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 2994: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
2995: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 2996: ENDTABLEHEADFOUR
1.57 albertel 2997:
1.473 amueller 2998: if ($csec) {
2999: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
3000: }
3001:
3002: if ($cgroup) {
3003: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
3004: }
3005:
3006: if ($uname) {
3007: if (@usersgroups > 1) {
3008: $r->print('<th>'.&mt('Control by other group?').'</th>');
3009: }
3010: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
3011: }
3012:
3013: $r->print('</tr>');
1.506 www 3014: #
3015: # Done with the headers
3016: #
1.473 amueller 3017: my $defbgone='';
3018: my $defbgtwo='';
3019: my $defbgthree = '';
1.57 albertel 3020:
1.473 amueller 3021: foreach (@ids) {
1.57 albertel 3022:
1.473 amueller 3023: my $rid=$_;
1.57 albertel 3024: my ($inmapid)=($rid=~/\.(\d+)$/);
3025:
1.446 bisitz 3026: if ((!$pssymb &&
1.473 amueller 3027: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
3028: ||
3029: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 3030: # ------------------------------------------------------ Entry for one resource
1.473 amueller 3031: if ($defbgone eq '#E0E099') {
3032: $defbgone='#E0E0DD';
1.57 albertel 3033: } else {
1.419 bisitz 3034: $defbgone='#E0E099';
1.57 albertel 3035: }
1.419 bisitz 3036: if ($defbgtwo eq '#FFFF99') {
1.473 amueller 3037: $defbgtwo='#FFFFDD';
1.57 albertel 3038: } else {
1.473 amueller 3039: $defbgtwo='#FFFF99';
1.57 albertel 3040: }
1.419 bisitz 3041: if ($defbgthree eq '#FFBB99') {
3042: $defbgthree='#FFBBDD';
1.269 raeburn 3043: } else {
1.419 bisitz 3044: $defbgthree='#FFBB99';
1.269 raeburn 3045: }
3046:
1.57 albertel 3047: my $thistitle='';
3048: my %name= ();
3049: undef %name;
3050: my %part= ();
3051: my %display=();
3052: my %type= ();
3053: my %default=();
1.196 www 3054: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 3055:
1.506 www 3056: my $filter=$env{'form.filter'};
1.210 www 3057: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 3058: my $tempkeyp = $_;
3059: if (grep $_ eq $tempkeyp, @catmarker) {
1.506 www 3060: my $parmname=&Apache::lonnet::metadata($uri,$_.'.name');
3061: # We may only want certain parameters listed
3062: if ($filter) {
3063: unless ($filter=~/\Q$parmname\E/) { next; }
3064: }
3065: $name{$_}=$parmname;
1.57 albertel 3066: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1.506 www 3067:
1.433 raeburn 3068: my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
3069: if ($allparms{$name{$_}} ne '') {
3070: my $identifier;
3071: if ($parmdis =~ /(\s*\[Part.*)$/) {
3072: $identifier = $1;
3073: }
3074: $display{$_} = $allparms{$name{$_}}.$identifier;
3075: } else {
3076: $display{$_} = $parmdis;
3077: }
1.57 albertel 3078: unless ($display{$_}) { $display{$_}=''; }
3079: $display{$_}.=' ('.$name{$_}.')';
3080: $default{$_}=&Apache::lonnet::metadata($uri,$_);
3081: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
3082: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
3083: }
3084: }
3085: my $totalparms=scalar keys %name;
3086: if ($totalparms>0) {
1.473 amueller 3087: my $firstrow=1;
3088: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 3089: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 3090: ' rowspan='.$totalparms.
1.419 bisitz 3091: '><tt><font size="-1">'.
1.57 albertel 3092: join(' / ',split(/\//,$uri)).
3093: '</font></tt><p><b>'.
1.154 albertel 3094: "<a href=\"javascript:openWindow('".
1.473 amueller 3095: &Apache::lonnet::clutter($uri).'?symb='.
3096: &escape($symbp{$rid}).
1.336 albertel 3097: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
3098: " target=\"_self\">$title");
1.57 albertel 3099:
3100: if ($thistitle) {
1.473 amueller 3101: $r->print(' ('.$thistitle.')');
1.57 albertel 3102: }
3103: $r->print('</a></b></td>');
1.419 bisitz 3104: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 3105: ' rowspan='.$totalparms.'>'.$typep{$rid}.
3106: '</td>');
3107:
1.419 bisitz 3108: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 3109: ' rowspan='.$totalparms.
1.238 www 3110: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.512 foxr 3111: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 3112:
3113: unless ($firstrow) {
3114: $r->print('<tr>');
3115: } else {
3116: undef $firstrow;
3117: }
1.201 www 3118: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 3119: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 3120: $defbgthree,$parmlev,$uname,$udom,$csec,
1.522.2.19 raeburn 3121: $cgroup,\@usersgroups,$noeditgrp,$readonly);
1.57 albertel 3122: }
3123: }
3124: }
3125: } # end foreach ids
1.43 albertel 3126: # -------------------------------------------------- End entry for one resource
1.517 www 3127: $r->print(&Apache::loncommon::end_data_table);
1.203 www 3128: } # end of full
1.57 albertel 3129: #--------------------------------------------------- Entry for parm level map
3130: if ($parmlev eq 'map') {
1.419 bisitz 3131: my $defbgone = '#E0E099';
3132: my $defbgtwo = '#FFFF99';
3133: my $defbgthree = '#FFBB99';
1.57 albertel 3134:
3135: my %maplist;
3136:
3137: if ($pschp eq 'all') {
1.446 bisitz 3138: %maplist = %allmaps;
1.57 albertel 3139: } else {
3140: %maplist = ($pschp => $mapp{$pschp});
3141: }
3142:
3143: #-------------------------------------------- for each map, gather information
3144: my $mapid;
1.473 amueller 3145: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1.60 albertel 3146: my $maptitle = $maplist{$mapid};
1.57 albertel 3147:
3148: #----------------------- loop through ids and get all parameter types for map
3149: #----------------------------------------- and associated information
3150: my %name = ();
3151: my %part = ();
3152: my %display = ();
3153: my %type = ();
3154: my %default = ();
3155: my $map = 0;
3156:
1.473 amueller 3157: # $r->print("Catmarker: @catmarker<br />\n");
1.446 bisitz 3158:
1.57 albertel 3159: foreach (@ids) {
1.473 amueller 3160: ($map)=(/([\d]*?)\./);
3161: my $rid = $_;
1.446 bisitz 3162:
1.57 albertel 3163: # $r->print("$mapid:$map: $rid <br /> \n");
3164:
1.473 amueller 3165: if ($map eq $mapid) {
3166: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 3167: # $r->print("Keys: $keyp{$rid} <br />\n");
3168:
3169: #--------------------------------------------------------------------
3170: # @catmarker contains list of all possible parameters including part #s
3171: # $fullkeyp contains the full part/id # for the extraction of proper parameters
3172: # $tempkeyp contains part 0 only (no ids - ie, subparts)
3173: # When storing information, store as part 0
3174: # When requesting information, request from full part
3175: #-------------------------------------------------------------------
1.473 amueller 3176: foreach (&keysplit($keyp{$rid})) {
3177: my $tempkeyp = $_;
3178: my $fullkeyp = $tempkeyp;
3179: $tempkeyp =~ s/_\w+_/_0_/;
3180:
3181: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
3182: $part{$tempkeyp}="0";
3183: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
3184: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
3185: if ($allparms{$name{$tempkeyp}} ne '') {
3186: my $identifier;
3187: if ($parmdis =~ /(\s*\[Part.*)$/) {
3188: $identifier = $1;
3189: }
3190: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
3191: } else {
3192: $display{$tempkeyp} = $parmdis;
3193: }
3194: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
3195: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
3196: $display{$tempkeyp} =~ s/_\w+_/_0_/;
3197: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
3198: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
3199: }
3200: } # end loop through keys
3201: }
1.57 albertel 3202: } # end loop through ids
1.446 bisitz 3203:
1.57 albertel 3204: #---------------------------------------------------- print header information
1.133 www 3205: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 3206: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 3207: my $tmp="";
1.57 albertel 3208: if ($uname) {
1.473 amueller 3209: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 3210: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
3211: &mt('in')." \n";
1.57 albertel 3212: } else {
1.401 bisitz 3213: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 3214: }
1.269 raeburn 3215: if ($cgroup) {
1.401 bisitz 3216: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
3217: "</i></font> ".&mt('of')." \n";
1.269 raeburn 3218: $csec = '';
3219: } elsif ($csec) {
1.401 bisitz 3220: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
3221: "</i></font> ".&mt('of')." \n";
1.269 raeburn 3222: }
1.401 bisitz 3223: $r->print('<div align="center"><h4>'
3224: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 3225: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 3226: ,$tmp
3227: ,'<font color="red"><i>'.$coursename.'</i></font>'
3228: )
3229: ."<br /></h4>\n"
1.422 bisitz 3230: );
1.57 albertel 3231: #---------------------------------------------------------------- print table
1.419 bisitz 3232: $r->print('<p>'.&Apache::loncommon::start_data_table()
3233: .&Apache::loncommon::start_data_table_header_row()
3234: .'<th>'.&mt('Parameter Name').'</th>'
3235: .'<th>'.&mt('Default Value').'</th>'
3236: .'<th>'.&mt('Parameter in Effect').'</th>'
3237: .&Apache::loncommon::end_data_table_header_row()
3238: );
1.57 albertel 3239:
1.473 amueller 3240: foreach (&keysinorder(\%name,\%keyorder)) {
3241: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 3242: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 3243: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1.522.2.19 raeburn 3244: $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
3245: $readonly);
1.57 albertel 3246: }
1.422 bisitz 3247: $r->print(&Apache::loncommon::end_data_table().'</p>'
3248: .'</div>'
3249: );
1.57 albertel 3250: } # end each map
3251: } # end of $parmlev eq map
3252: #--------------------------------- Entry for parm level general (Course level)
3253: if ($parmlev eq 'general') {
1.473 amueller 3254: my $defbgone = '#E0E099';
1.419 bisitz 3255: my $defbgtwo = '#FFFF99';
3256: my $defbgthree = '#FFBB99';
1.57 albertel 3257:
3258: #-------------------------------------------- for each map, gather information
3259: my $mapid="0.0";
3260: #----------------------- loop through ids and get all parameter types for map
3261: #----------------------------------------- and associated information
3262: my %name = ();
3263: my %part = ();
3264: my %display = ();
3265: my %type = ();
3266: my %default = ();
1.446 bisitz 3267:
1.57 albertel 3268: foreach (@ids) {
3269: my $rid = $_;
1.446 bisitz 3270:
1.196 www 3271: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 3272:
3273: #--------------------------------------------------------------------
3274: # @catmarker contains list of all possible parameters including part #s
3275: # $fullkeyp contains the full part/id # for the extraction of proper parameters
3276: # $tempkeyp contains part 0 only (no ids - ie, subparts)
3277: # When storing information, store as part 0
3278: # When requesting information, request from full part
3279: #-------------------------------------------------------------------
1.473 amueller 3280: foreach (&keysplit($keyp{$rid})) {
3281: my $tempkeyp = $_;
3282: my $fullkeyp = $tempkeyp;
3283: $tempkeyp =~ s/_\w+_/_0_/;
3284: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
3285: $part{$tempkeyp}="0";
3286: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
3287: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
3288: if ($allparms{$name{$tempkeyp}} ne '') {
3289: my $identifier;
3290: if ($parmdis =~ /(\s*\[Part.*)$/) {
3291: $identifier = $1;
3292: }
3293: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
3294: } else {
3295: $display{$tempkeyp} = $parmdis;
3296: }
3297: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
3298: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
3299: $display{$tempkeyp} =~ s/_\w+_/_0_/;
3300: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
3301: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
3302: }
1.57 albertel 3303: } # end loop through keys
3304: } # end loop through ids
1.446 bisitz 3305:
1.57 albertel 3306: #---------------------------------------------------- print header information
1.473 amueller 3307: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 3308: $r->print(<<ENDMAPONE);
1.419 bisitz 3309: <center>
3310: <h4>$setdef
1.135 albertel 3311: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 3312: ENDMAPONE
3313: if ($uname) {
1.473 amueller 3314: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 3315: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 3316: } else {
1.135 albertel 3317: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 3318: }
1.446 bisitz 3319:
1.135 albertel 3320: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 3321: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 3322: $r->print("</h4>\n");
1.57 albertel 3323: #---------------------------------------------------------------- print table
1.419 bisitz 3324: $r->print('<p>'.&Apache::loncommon::start_data_table()
3325: .&Apache::loncommon::start_data_table_header_row()
3326: .'<th>'.&mt('Parameter Name').'</th>'
3327: .'<th>'.&mt('Default Value').'</th>'
3328: .'<th>'.&mt('Parameter in Effect').'</th>'
3329: .&Apache::loncommon::end_data_table_header_row()
3330: );
1.57 albertel 3331:
1.473 amueller 3332: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 3333: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 3334: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.522.2.19 raeburn 3335: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
3336: $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
3337: $readonly);
1.57 albertel 3338: }
1.419 bisitz 3339: $r->print(&Apache::loncommon::end_data_table()
3340: .'</p>'
3341: .'</center>'
3342: );
1.57 albertel 3343: } # end of $parmlev eq general
1.522.2.28.4. (raeburn 3344:): $r->print('</div>');
1.43 albertel 3345: }
1.507 www 3346: $r->print('</form>');
3347: $r->print(&Apache::loncommon::end_page());
1.57 albertel 3348: } # end sub assessparms
1.30 www 3349:
1.120 www 3350: ##################################################
1.207 www 3351: # Overview mode
3352: ##################################################
1.124 www 3353: my $tableopen;
3354:
3355: sub tablestart {
1.522.2.19 raeburn 3356: my ($readonly) = @_;
1.124 www 3357: if ($tableopen) {
1.522.2.19 raeburn 3358: return '';
1.124 www 3359: } else {
1.522.2.19 raeburn 3360: $tableopen=1;
3361: my $output = &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th>';
3362: if ($readonly) {
3363: $output .= '<th>'.&mt('Current value').'</th>';
3364: } else {
3365: $output .= '<th>'.&mt('Delete').'</th><th>'.&mt('Set to ...').'</th>';
3366: }
3367: $output .= '</tr>';
3368: return $output;
1.124 www 3369: }
3370: }
3371:
3372: sub tableend {
3373: if ($tableopen) {
1.473 amueller 3374: $tableopen=0;
3375: return &Apache::loncommon::end_data_table();
1.124 www 3376: } else {
1.473 amueller 3377: return'';
1.124 www 3378: }
3379: }
3380:
1.207 www 3381: sub readdata {
3382: my ($crs,$dom)=@_;
3383: # Read coursedata
3384: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
3385: # Read userdata
3386:
3387: my $classlist=&Apache::loncoursedata::get_classlist();
3388: foreach (keys %$classlist) {
1.350 albertel 3389: if ($_=~/^($match_username)\:($match_domain)$/) {
1.473 amueller 3390: my ($tuname,$tudom)=($1,$2);
3391: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
1.207 www 3392: foreach my $userkey (keys %{$useropt}) {
1.473 amueller 3393: if ($userkey=~/^$env{'request.course.id'}/) {
1.207 www 3394: my $newkey=$userkey;
1.473 amueller 3395: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
3396: $$resourcedata{$newkey}=$$useropt{$userkey};
3397: }
3398: }
3399: }
1.207 www 3400: }
1.522.2.19 raeburn 3401: if (wantarray) {
3402: return ($resourcedata,$classlist);
3403: } else {
3404: return $resourcedata;
3405: }
1.207 www 3406: }
3407:
3408:
1.124 www 3409: # Setting
1.208 www 3410:
3411: sub storedata {
3412: my ($r,$crs,$dom)=@_;
1.207 www 3413: # Set userlevel immediately
3414: # Do an intermediate store of course level
3415: my $olddata=&readdata($crs,$dom);
1.124 www 3416: my %newdata=();
3417: undef %newdata;
3418: my @deldata=();
3419: undef @deldata;
1.504 raeburn 3420: my ($got_chostname,$chostname,$cmajor,$cminor);
1.522.2.16 raeburn 3421: my $now = time;
1.504 raeburn 3422: foreach my $key (keys(%env)) {
3423: if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
1.473 amueller 3424: my $cmd=$1;
3425: my $thiskey=$2;
1.522.2.28.4. (raeburn 3426:): next if ($cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink');
1.473 amueller 3427: my ($tuname,$tudom)=&extractuser($thiskey);
3428: my $tkey=$thiskey;
3429: if ($tuname) {
3430: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
3431: }
3432: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.522.2.28.4. (raeburn 3433:): my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch);
1.473 amueller 3434: if ($cmd eq 'set') {
1.504 raeburn 3435: $data=$env{$key};
1.522.2.28.4. (raeburn 3436:): $valmatch = '';
1.522.2.16 raeburn 3437: $valchk = $data;
1.473 amueller 3438: $typeof=$env{'form.typeof_'.$thiskey};
3439: $text = &mt('Saved modified parameter for');
1.504 raeburn 3440: if ($typeof eq 'string_questiontype') {
1.514 raeburn 3441: $name = 'type';
1.522.2.28.4. (raeburn 3442:): } elsif ($typeof eq 'string_deeplink') {
3443:): ($name) = ($typeof =~ /^string_(deeplink)$/);
3444:): my $stringmatch = &standard_string_matches($typeof);
3445:): if (ref($stringmatch) eq 'ARRAY') {
3446:): foreach my $item (@{$stringmatch}) {
3447:): if (ref($item) eq 'ARRAY') {
3448:): my ($regexpname,$pattern) = @{$item};
3449:): if ($pattern ne '') {
3450:): if ($data =~ /$pattern/) {
3451:): $valmatch = $regexpname;
3452:): $valchk = '';
3453:): last;
3454:): }
3455:): }
3456:): }
3457:): }
3458:): }
1.514 raeburn 3459: } elsif ($typeof eq 'string_lenient') {
3460: $name = 'lenient';
1.521 raeburn 3461: } elsif ($typeof eq 'string_discussvote') {
3462: $name = 'discussvote';
1.522.2.7 raeburn 3463: } elsif ($typeof eq 'string_examcode') {
3464: $name = 'examcode';
1.522.2.16 raeburn 3465: if (&Apache::lonnet::validCODE($data)) {
3466: $valchk = 'valid';
3467: }
1.519 raeburn 3468: } elsif ($typeof eq 'string_yesno') {
3469: if ($thiskey =~ /\.retrypartial$/) {
3470: $name = 'retrypartial';
3471: }
1.514 raeburn 3472: }
1.522.2.16 raeburn 3473: } elsif ($cmd eq 'datepointer') {
3474: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
3475: $typeof=$env{'form.typeof_'.$thiskey};
3476: $text = &mt('Saved modified date for');
3477: if ($typeof eq 'date_start') {
3478: if ($thiskey =~ /\.printstartdate$/) {
3479: $name = 'printstartdate';
3480: if (($data) && ($data > $now)) {
3481: $valchk = 'future';
1.504 raeburn 3482: }
3483: }
1.522.2.16 raeburn 3484: } elsif ($typeof eq 'date_end') {
3485: if ($thiskey =~ /\.printenddate$/) {
3486: $name = 'printenddate';
3487: if (($data) && ($data < $now)) {
3488: $valchk = 'past';
3489: }
3490: }
3491: }
3492: } elsif ($cmd eq 'dateinterval') {
3493: $data=&get_date_interval_from_form($thiskey);
3494: $typeof=$env{'form.typeof_'.$thiskey};
3495: $text = &mt('Saved modified date for');
3496: }
3497: if ($name ne '') {
3498: my ($needsrelease,$needsnewer);
3499: $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"};
3500: if ($needsrelease) {
3501: unless ($got_chostname) {
3502: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
3503: $got_chostname = 1;
3504: }
3505: $needsnewer = ¶meter_releasecheck($name,$valchk,
3506: $needsrelease,
3507: $cmajor,$cminor);
1.504 raeburn 3508: if ($needsnewer) {
1.514 raeburn 3509: $r->print('<br />'.&oldversion_warning($name,$data,
3510: $chostname,$cmajor,
1.504 raeburn 3511: $cminor,$needsrelease));
3512: next;
3513: }
3514: }
1.473 amueller 3515: }
3516: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 3517: if ($tuname) {
1.473 amueller 3518: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
3519: $tkey.'.type' => $typeof},
3520: $tudom,$tuname) eq 'ok') {
3521: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
3522: $r->print('<br />'.$text.' '.
3523: &Apache::loncommon::plainname($tuname,$tudom));
3524: } else {
3525: $r->print('<div class="LC_error">'.
3526: &mt('Error saving parameters').'</div>');
3527: }
3528: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3529: } else {
3530: $newdata{$thiskey}=$data;
3531: $newdata{$thiskey.'.type'}=$typeof;
1.446 bisitz 3532: }
1.473 amueller 3533: }
3534: } elsif ($cmd eq 'del') {
3535: if ($tuname) {
3536: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
3537: &log_parmset({$tkey=>''},1,$tuname,$tudom);
3538: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
3539: } else {
3540: $r->print('<div class="LC_error">'.
3541: &mt('Error deleting parameters').'</div>');
3542: }
3543: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3544: } else {
3545: push (@deldata,$thiskey,$thiskey.'.type');
3546: }
3547: }
3548: }
1.124 www 3549: }
1.207 www 3550: # Store all course level
1.144 www 3551: my $delentries=$#deldata+1;
3552: my @newdatakeys=keys %newdata;
3553: my $putentries=$#newdatakeys+1;
3554: if ($delentries) {
1.473 amueller 3555: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
3556: my %loghash=map { $_ => '' } @deldata;
3557: &log_parmset(\%loghash,1);
1.522.2.18 raeburn 3558: $r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>');
1.473 amueller 3559: } else {
3560: $r->print('<div class="LC_error">'.
3561: &mt('Error deleting parameters').'</div>');
3562: }
3563: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3564: }
3565: if ($putentries) {
1.473 amueller 3566: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
3567: &log_parmset(\%newdata,0);
1.522.2.17 raeburn 3568: $r->print('<h3>'.&mt('Saved [quant,_1,parameter]',$putentries/2).'</h3>');
1.473 amueller 3569: } else {
3570: $r->print('<div class="LC_error">'.
3571: &mt('Error saving parameters').'</div>');
3572: }
3573: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3574: }
1.208 www 3575: }
1.207 www 3576:
1.208 www 3577: sub extractuser {
3578: my $key=shift;
1.350 albertel 3579: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 3580: }
1.206 www 3581:
1.381 albertel 3582: sub parse_listdata_key {
3583: my ($key,$listdata) = @_;
3584: # split into student/section affected, and
3585: # the realm (folder/resource part and parameter
1.446 bisitz 3586: my ($student,$realm) =
1.473 amueller 3587: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
1.381 albertel 3588: # if course wide student would be undefined
3589: if (!defined($student)) {
1.473 amueller 3590: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.381 albertel 3591: }
3592: # strip off the .type if it's not the Question type parameter
3593: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
1.473 amueller 3594: $realm=~s/\.type//;
1.381 albertel 3595: }
3596: # split into resource+part and parameter name
1.388 albertel 3597: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
3598: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 3599: return ($student,$res,$part,$parm);
3600: }
3601:
1.208 www 3602: sub listdata {
1.522.2.19 raeburn 3603: my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly)=@_;
1.207 www 3604: # Start list output
1.206 www 3605:
1.122 www 3606: my $oldsection='';
3607: my $oldrealm='';
3608: my $oldpart='';
1.123 www 3609: my $pointer=0;
1.124 www 3610: $tableopen=0;
1.145 www 3611: my $foundkeys=0;
1.248 albertel 3612: my %keyorder=&standardkeyorder();
1.522.2.27 raeburn 3613: my $readonlyall = $readonly;
1.381 albertel 3614:
1.522.2.24 raeburn 3615: my ($secidx,%grouphash);
3616: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3617: $secidx = &Apache::loncoursedata::CL_SECTION();
3618: if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
3619: %grouphash = &Apache::longroup::coursegroups();
3620: } elsif ($env{'request.course.groups'} ne '') {
3621: map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
3622: }
3623: }
3624:
1.214 www 3625: foreach my $thiskey (sort {
1.473 amueller 3626: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
3627: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
1.381 albertel 3628:
1.473 amueller 3629: # get the numerical order for the param
3630: $aparm=$keyorder{'parameter_0_'.$aparm};
3631: $bparm=$keyorder{'parameter_0_'.$bparm};
1.381 albertel 3632:
1.473 amueller 3633: my $result=0;
1.381 albertel 3634:
1.473 amueller 3635: if ($sortorder eq 'realmstudent') {
1.381 albertel 3636: if ($ares ne $bres ) {
1.473 amueller 3637: $result = ($ares cmp $bres);
1.446 bisitz 3638: } elsif ($astudent ne $bstudent) {
1.473 amueller 3639: $result = ($astudent cmp $bstudent);
3640: } elsif ($apart ne $bpart ) {
3641: $result = ($apart cmp $bpart);
3642: }
3643: } else {
3644: if ($astudent ne $bstudent) {
3645: $result = ($astudent cmp $bstudent);
3646: } elsif ($ares ne $bres ) {
3647: $result = ($ares cmp $bres);
3648: } elsif ($apart ne $bpart ) {
3649: $result = ($apart cmp $bpart);
3650: }
3651: }
1.446 bisitz 3652:
1.473 amueller 3653: if (!$result) {
1.381 albertel 3654: if (defined($aparm) && defined($bparm)) {
1.473 amueller 3655: $result = ($aparm <=> $bparm);
1.381 albertel 3656: } elsif (defined($aparm)) {
1.473 amueller 3657: $result = -1;
1.381 albertel 3658: } elsif (defined($bparm)) {
1.473 amueller 3659: $result = 1;
3660: }
3661: }
1.381 albertel 3662:
1.473 amueller 3663: $result;
1.214 www 3664: } keys %{$listdata}) {
1.381 albertel 3665:
1.473 amueller 3666: if ($$listdata{$thiskey.'.type'}) {
1.522.2.24 raeburn 3667: my $thistype=$$listdata{$thiskey.'.type'};
3668: if ($$resourcedata{$thiskey.'.type'}) {
3669: $thistype=$$resourcedata{$thiskey.'.type'};
1.473 amueller 3670: }
3671: my ($middle,$part,$name)=
3672: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3673: my $section=&mt('All Students');
1.522.2.27 raeburn 3674: $readonly = $readonlyall;
1.522.2.28 raeburn 3675: my $userscope;
3676: my $showval = $$resourcedata{$thiskey};
1.473 amueller 3677: if ($middle=~/^\[(.*)\]/) {
1.522.2.24 raeburn 3678: my $issection=$1;
3679: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
3680: my ($stuname,$studom) = ($1,$2);
3681: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3682: if (ref($classlist) eq 'HASH') {
3683: if (ref($classlist->{$stuname.':'.$studom}) eq 'ARRAY') {
3684: next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'});
3685: }
3686: }
3687: }
3688: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
1.522.2.28 raeburn 3689: $userscope = 1;
1.522.2.24 raeburn 3690: } else {
3691: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3692: if (exists($grouphash{$issection})) {
3693: $section=&mt('Group').': '.$issection;
3694: } elsif ($issection eq $env{'request.course.sec'}) {
3695: $section = &mt('Section').': '.$issection;
3696: } else {
3697: next;
3698: }
3699: } else {
3700: $section=&mt('Group/Section').': '.$issection;
3701: }
3702: }
3703: $middle=~s/^\[(.*)\]//;
3704: } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3705: $readonly = 1;
1.473 amueller 3706: }
3707: $middle=~s/\.+$//;
3708: $middle=~s/^\.+//;
3709: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.522.2.24 raeburn 3710:
1.473 amueller 3711: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3712: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
3713: } elsif ($middle) {
3714: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
3715: $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>';
3716: }
3717: if ($sortorder eq 'realmstudent') {
3718: if ($realm ne $oldrealm) {
3719: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3720: $oldrealm=$realm;
3721: $oldsection='';
3722: }
3723: if ($section ne $oldsection) {
3724: $r->print(&tableend()."\n<h2>$section</h2>");
3725: $oldsection=$section;
3726: $oldpart='';
3727: }
3728: } else {
3729: if ($section ne $oldsection) {
3730: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3731: $oldsection=$section;
3732: $oldrealm='';
3733: }
3734: if ($realm ne $oldrealm) {
3735: $r->print(&tableend()."\n<h2>$realm</h2>");
3736: $oldrealm=$realm;
3737: $oldpart='';
3738: }
3739: }
3740: if ($part ne $oldpart) {
3741: $r->print(&tableend().
3742: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
3743: $oldpart=$part;
3744: }
1.123 www 3745: #
3746: # Ready to print
3747: #
1.470 raeburn 3748: my $parmitem = &standard_parameter_names($name);
1.522.2.19 raeburn 3749: $r->print(&tablestart($readonly).
1.473 amueller 3750: &Apache::loncommon::start_data_table_row().
3751: '<td><b>'.&mt($parmitem).
1.522.2.19 raeburn 3752: '</b></td>');
3753: unless ($readonly) {
1.522.2.28 raeburn 3754: my $disabled;
3755: if (($name eq 'availablestudent') &&
3756: (($showval eq '') || ($userscope))) {
3757: $disabled = ' disabled="disabled"';
3758: }
1.522.2.19 raeburn 3759: $r->print('<td><input type="checkbox" name="del_'.
1.522.2.28 raeburn 3760: $thiskey.'"'.$disabled.' /></td>');
1.522.2.19 raeburn 3761: }
3762: $r->print('<td>');
1.473 amueller 3763: $foundkeys++;
3764: if (&isdateparm($thistype)) {
1.522.2.19 raeburn 3765: my $jskey='key_'.$pointer;
3766: my $state;
3767: $pointer++;
3768: if ($readonly) {
3769: $state = 'disabled';
3770: }
3771: $r->print(
3772: &Apache::lonhtmlcommon::date_setter('parmform',
3773: $jskey,
3774: $$resourcedata{$thiskey},
3775: '',1,$state));
3776: unless ($readonly) {
3777: $r->print(
1.277 www 3778: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3779: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3780: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3781: &date_sanity_info($$resourcedata{$thiskey})
1.473 amueller 3782: );
1.522.2.19 raeburn 3783: }
1.473 amueller 3784: } elsif ($thistype eq 'date_interval') {
1.522.2.28.4. (raeburn 3785:): $r->print(&date_interval_selector($thiskey,$name,
1.522.2.19 raeburn 3786: $$resourcedata{$thiskey},$readonly));
1.473 amueller 3787: } elsif ($thistype =~ m/^string/) {
1.522.2.28 raeburn 3788: if ($name eq 'availablestudent') {
3789: $readonly = 1;
3790: }
1.522.2.19 raeburn 3791: $r->print(&string_selector($thistype,$thiskey,
3792: $$resourcedata{$thiskey},$name,$readonly));
1.473 amueller 3793: } else {
1.522.2.19 raeburn 3794: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
1.473 amueller 3795: }
1.522.2.19 raeburn 3796: unless ($readonly) {
3797: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
3798: $thistype.'" />');
1.522.2.20 raeburn 3799: }
1.473 amueller 3800: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
3801: }
1.121 www 3802: }
1.208 www 3803: return $foundkeys;
3804: }
3805:
1.385 albertel 3806:
3807: sub date_interval_selector {
1.522.2.28.4. (raeburn 3808:): my ($thiskey, $pname, $showval, $readonly) = @_;
3809:): my ($result,%skipval);
3810:): my $currval = $showval;
1.385 albertel 3811: foreach my $which (['days', 86400, 31],
1.473 amueller 3812: ['hours', 3600, 23],
3813: ['minutes', 60, 59],
3814: ['seconds', 1, 59]) {
3815: my ($name, $factor, $max) = @{ $which };
3816: my $amount = int($showval/$factor);
3817: $showval %= $factor;
3818: my %select = ((map {$_ => $_} (0..$max)),
3819: 'select_form_order' => [0..$max]);
3820: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
1.522.2.19 raeburn 3821: \%select,'',$readonly);
1.473 amueller 3822: $result .= ' '.&mt($name);
1.385 albertel 3823: }
1.522.2.28.4. (raeburn 3824:): if ($pname eq 'interval') {
3825:): unless ($skipval{'done'}) {
3826:): my $checkedon = '';
3827:): my $checkedproc = '';
3828:): my $currproctorkey = '';
3829:): my $currprocdisplay = 'hidden';
3830:): my $currdonetext = &mt('Done');
3831:): my $checkedoff = ' checked="checked"';
3832:): if ($currval =~ /^(?:\d+)_done$/) {
3833:): $checkedon = ' checked="checked"';
3834:): $checkedoff = '';
3835:): } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
3836:): $currdonetext = $1;
3837:): $checkedon = ' checked="checked"';
3838:): $checkedoff = '';
3839:): } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
3840:): $currproctorkey = $1;
3841:): $checkedproc = ' checked="checked"';
3842:): $checkedoff = '';
3843:): $currprocdisplay = 'text';
3844:): } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
3845:): $currdonetext = $1;
3846:): $currproctorkey = $2;
3847:): $checkedproc = ' checked="checked"';
3848:): $checkedoff = '';
3849:): $currprocdisplay = 'text';
3850:): }
3851:): my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
3852:): my $disabled;
3853:): if ($readonly) {
3854:): $disabled = ' disabled="disabled"';
3855:): }
3856:): $result .= '<br /><span class="LC_nobreak">'.&mt('Include "done" button').
3857:): '<label><input type="radio" value="" name="done_'.$thiskey.'"'.$checkedoff.$onclick.$disabled.' />'.
3858:): &mt('No').'</label>'.(' 'x2).
3859:): '<label><input type="radio" value="_done" name="done_'.$thiskey.'"'.$checkedon.$onclick.$disabled.' />'.
3860:): &mt('Yes').'</label>'.(' 'x2).
3861:): '<label><input type="radio" value="_done_proctor" name="done_'.$thiskey.'"'.$checkedproc.$onclick.$disabled.' />'.
3862:): &mt('Yes, with proctor key').'</label>'.
3863:): '<input type="'.$currprocdisplay.'" id="done_'.$thiskey.'_proctorkey" '.
3864:): 'name="done_'.$thiskey.'_proctorkey" value="'.&HTML::Entities::encode($currproctorkey,'"<>&').'"'.$disabled.' /></span><br />'.
3865:): '<span class="LC_nobreak">'.&mt('Button text').': '.
3866:): '<input type="text" name="done_'.$thiskey.'_buttontext" value="'.&HTML::Entities::encode($currdonetext,'"<>&').'"'.$disabled.' /></span>';
3867:): }
3868:): }
1.522.2.19 raeburn 3869: unless ($readonly) {
3870: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3871: }
1.385 albertel 3872: return $result;
3873:
3874: }
3875:
3876: sub get_date_interval_from_form {
3877: my ($key) = @_;
3878: my $seconds = 0;
3879: foreach my $which (['days', 86400],
1.473 amueller 3880: ['hours', 3600],
3881: ['minutes', 60],
3882: ['seconds', 1]) {
3883: my ($name, $factor) = @{ $which };
3884: if (defined($env{'form.'.$name.'_'.$key})) {
3885: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3886: }
1.385 albertel 3887: }
3888: return $seconds;
3889: }
3890:
3891:
1.383 albertel 3892: sub default_selector {
1.522.2.19 raeburn 3893: my ($thiskey, $showval, $readonly) = @_;
3894: my $disabled;
3895: if ($readonly) {
3896: $disabled = ' disabled="disabled"';
3897: }
3898: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'"'.$disabled.' />';
1.383 albertel 3899: }
3900:
1.522.2.28.4. (raeburn 3901:): sub string_ip_selector {
3902:): my ($thiskey, $showval, $readonly) = @_;
3903:): my %access = (
3904:): allow => [],
3905:): deny => [],
3906:): );
3907:): if ($showval ne '') {
3908:): my @current;
3909:): if ($showval =~ /,/) {
3910:): @current = split(/,/,$showval);
3911:): } else {
3912:): @current = ($showval);
3913:): }
3914:): foreach my $item (@current) {
3915:): if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) {
3916:): push(@{$access{'deny'}},$1);
3917:): } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) {
3918:): push(@{$access{'allow'}},$item);
3919:): }
3920:): }
3921:): }
3922:): if (!@{$access{'allow'}}) {
3923:): @{$access{'allow'}} = ('');
3924:): }
3925:): if (!@{$access{'deny'}}) {
3926:): @{$access{'deny'}} = ('');
3927:): }
3928:): my ($disabled,$addmore);
3929:): if ($readonly) {
3930:): $disabled=' disabled="disabled"';
3931:): } else {
3932:): $addmore = "\n".'<button class="LC_add_ipacc_button">'.&mt('Add more').'</button>';
3933:): }
3934:): my $output = '<input type="hidden" name="set_'.$thiskey.'" />
3935:): <table><tr><th>'.&mt('Allow from').'</th><th>'.&mt('Deny from').'</th></tr><tr>';
3936:): foreach my $acctype ('allow','deny') {
3937:): $output .= '
3938:): <td valign="top">
3939:): <div class="LC_string_ipacc_wrap" id="LC_string_ipacc_'.$acctype.'_'.$thiskey.'">
3940:): <div class="LC_string_ipacc_inner">'."\n";
3941:): my $num = 0;
3942:): foreach my $curr (@{$access{$acctype}}) {
3943:): $output .= '<div><input type="text" name="setip'.$acctype.'_'.$thiskey.'" value="'.$curr.'"'.$disabled.' />';
3944:): if ($num > 0) {
3945:): $output .= '<a href="#" class="LC_remove_ipacc">'.&mt('Remove').'</a>';
3946:): }
3947:): $output .= '</div>'."\n";
3948:): $num ++;
3949:): }
3950:): $output .= '
3951:): </div>'.$addmore.'
3952:): </div>
3953:): </td>';
3954:): }
3955:): $output .= '
3956:): </tr>
3957:): </table>'."\n";
3958:): return $output;
3959:): }
3960:):
3961:): sub string_deeplink_selector {
3962:): my ($thiskey, $showval, $readonly) = @_;
3963:): my (@components,%values,@current,%titles,%options,%optiontext,%defaults,
3964:): %selectnull,%domlti,%crslti,@possmenus);
3965:): @components = ('state','others','listing','scope','protect','menus');
3966:): %titles = &Apache::lonlocal::texthash (
3967:): state => 'Access status',
3968:): others => 'Hide other resources',
3969:): listing => 'In Contents and/or Gradebook',
3970:): scope => 'Access scope for link',
3971:): protect => 'Link protection',
3972:): menus => 'Menu Items Displayed',
3973:): );
3974:): %options = (
3975:): state => ['only','off','both'],
3976:): others => ['hide','unhide'],
3977:): listing => ['full','absent','grades','details','datestatus'],
3978:): scope => ['res','map','rec'],
3979:): protect => ['none','key','ltid','ltic'],
3980:): menus => ['std','colls'],
3981:): );
3982:): %optiontext = &Apache::lonlocal::texthash (
3983:): only => 'deep only',
3984:): off => 'deeplink off',
3985:): both => 'regular + deep',
3986:): hide => 'Hidden',
3987:): unhide => 'Unhidden',
3988:): full => 'Listed (linked) in both',
3989:): absent => 'Not listed',
3990:): grades => 'Listed in grades only',
3991:): details => 'Listed (unlinked) in both',
3992:): datestatus => 'Listed (unlinked) inc. status in both',
3993:): res => 'resource only',
3994:): map => 'enclosing map/folder',
3995:): rec => 'recursive map/folder',
3996:): none => 'not in use',
3997:): key => 'key access',
3998:): ltic => 'LTI access (course)',
3999:): ltid => 'LTI access (domain)' ,
4000:): std => 'Standard (all menus)',
4001:): colls => 'Numbered collection',
4002:): );
4003:): %selectnull = &Apache::lonlocal::texthash (
4004:): ltic => 'Select Launcher',
4005:): ltid => 'Select Launcher',
4006:): colls => 'Select',
4007:): );
4008:): if ($showval =~ /,/) {
4009:): %values=();
4010:): @current = split(/,/,$showval);
4011:): ($values{'state'}) = ($current[0] =~ /^(only|off|both)$/);
4012:): ($values{'others'}) = ($current[1] =~ /^(hide|unhide)$/);
4013:): ($values{'listing'}) = ($current[2] =~ /^(full|absent|grades|details|datestatus)$/);
4014:): ($values{'scope'}) = ($current[3] =~ /^(res|map|rec)$/);
4015:): ($values{'protect'}) = ($current[4] =~ /^(key:[a-zA-Z\d_.!\@#\$%^&*()+=-]+|ltic:\d+|ltid:\d+)$/);
4016:): ($values{'menus'}) = ($current[5] =~ /^(\d+)$/);
4017:): } else {
4018:): $defaults{'state'} = 'off',
4019:): $defaults{'others'} = 'unhide',
4020:): $defaults{'listing'} = 'full';
4021:): $defaults{'scope'} = 'res';
4022:): $defaults{'protect'} = 'none';
4023:): $defaults{'menus'} = '0';
4024:): }
4025:): my $disabled;
4026:): if ($readonly) {
4027:): $disabled=' disabled="disabled"';
4028:): }
4029:): my %courselti =
4030:): &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'},
4031:): $env{'course.'.$env{'request.course.id'}.'.domain'});
4032:): foreach my $item (keys(%courselti)) {
4033:): if (ref($courselti{$item}) eq 'HASH') {
4034:): $crslti{$item} = $courselti{$item}{'name'};
4035:): }
4036:): }
4037:): my %lti =
4038:): &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'},
4039:): 'linkprot');
4040:): foreach my $item (keys(%lti)) {
4041:): if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
4042:): $domlti{$item} = $lti{$item}{'name'};
4043:): }
4044:): }
4045:): if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
4046:): foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
4047:): my ($num,$value) = split(/\%/,$item);
4048:): if ($num =~ /^\d+$/) {
4049:): push(@possmenus,$num);
4050:): }
4051:): }
4052:): }
4053:):
4054:): my $output = '<input type="hidden" name="set_'.$thiskey.'" /><table><tr>';
4055:): foreach my $item (@components) {
4056:): $output .= '<th>'.$titles{$item}.'</th>';
4057:): }
4058:): $output .= '</tr><tr>';
4059:): foreach my $item (@components) {
4060:): $output .= '<td>';
4061:): if (($item eq 'protect') || ($item eq 'menus')) {
4062:): my $selected = $values{$item};
4063:): foreach my $option (@{$options{$item}}) {
4064:): if ($item eq 'protect') {
4065:): if ($option eq 'ltid') {
4066:): next unless (keys(%domlti));
4067:): } elsif ($option eq 'ltic') {
4068:): next unless (keys(%crslti));
4069:): }
4070:): } elsif (($item eq 'menus') && ($option eq 'colls')) {
4071:): next unless (@possmenus);
4072:): }
4073:): my $checked;
4074:): if ($item eq 'menus') {
4075:): if (($selected =~ /^\d+$/) && (@possmenus) &&
4076:): (grep(/^\Q$selected\E$/,@possmenus))) {
4077:): if ($option eq 'colls') {
4078:): $checked = ' checked="checked"';
4079:): }
4080:): } elsif (($option eq 'std') && ($selected == 0) && ($selected ne '')) {
4081:): $checked = ' checked="checked"';
4082:): }
4083:): } elsif ($selected =~ /^\Q$option\E/) {
4084:): $checked = ' checked="checked"';
4085:): }
4086:): my $onclick;
4087:): unless ($readonly) {
4088:): my $esc_key = &js_escape($thiskey);
4089:): $onclick = ' onclick="toggleDeepLink(this.form,'."'$item','$esc_key'".');"';
4090:): }
4091:): $output .= '<span class="LC_nobreak"><label>'.
4092:): '<input type="radio" name="deeplink_'.$item.'_'.$thiskey.'" value="'.$option.'"'.$onclick.$disabled.$checked.' />'."\n".
4093:): $optiontext{$option}.'</label>';
4094:): if (($item eq 'protect') && ($option eq 'key')) {
4095:): my $visibility="hidden";
4096:): my $currkey;
4097:): if ($checked) {
4098:): $visibility = "text";
4099:): $currkey = (split(/\:/,$values{$item}))[1];
4100:): }
4101:): $output .= ' '.
4102:): '<input type="'.$visibility.'" name="deeplink_'.$option.'_'.$thiskey.'" id="deeplink_'.$option.'_'.$item.'_'.$thiskey.'" value="'.$currkey.'" size="10"'.$disabled.' />';
4103:): } elsif (($option eq 'ltic') || ($option eq 'ltid') || ($option eq 'colls')) {
4104:): my $display="none";
4105:): my ($current,$blankcheck,@possibles);
4106:): if ($checked) {
4107:): $display = 'inline-block';
4108:): if (($option eq 'ltic') || ($option eq 'ltid')) {
4109:): $current = (split(/\:/,$selected))[1];
4110:): } else {
4111:): $current = $selected;
4112:): }
4113:): } else {
4114:): $blankcheck = ' selected="selected"';
4115:): }
4116:): if ($option eq 'ltid') {
4117:): @possibles = keys(%domlti);
4118:): } elsif ($option eq 'ltic') {
4119:): @possibles = keys(%crslti);
4120:): } else {
4121:): @possibles = @possmenus;
4122:): }
4123:): $output .= '<div id="deeplinkdiv_'.$option.'_'.$item.'_'.$thiskey.'"'.
4124:): ' style="display: '.$display.'"> <select name="'.
4125:): 'deeplink_'.$option.'_'.$thiskey.'"'.$disabled.'>';
4126:): if (@possibles > 1) {
4127:): $output .= '<option value=""'.$blankcheck.'>'.$selectnull{$option}.
4128:): '</option>'."\n";
4129:): }
4130:): foreach my $poss (sort { $a <=> $b } @possibles) {
4131:): my $selected;
4132:): if (($poss == $current) || (scalar(@possibles) ==1)) {
4133:): $selected = ' selected="selected"';
4134:): }
4135:): my $shown = $poss;
4136:): if ($option eq 'ltid') {
4137:): $shown = $domlti{$poss};
4138:): } elsif ($option eq 'ltic') {
4139:): $shown = $crslti{$poss};
4140:): }
4141:): $output .= '<option value="'.$poss.'"'.$selected.'>'.$shown.'</option>';
4142:): }
4143:): $output .= '</select></div>';
4144:): }
4145:): $output .= '</span> ';
4146:): }
4147:): } else {
4148:): my $selected = $values{$item};
4149:): my $defsel;
4150:): if ($selected eq '') {
4151:): $defsel = ' selected="selected"';
4152:): }
4153:): $output .= '<select name="deeplink_'.$item.'_'.$thiskey.'"'.$disabled.'>'."\n".
4154:): '<option value=""'.$defsel.'>'.&mt('Please select').'</option>'."\n";
4155:): foreach my $option (@{$options{$item}}) {
4156:): $output .= '<option value="'.$option.'"';
4157:): if ($option eq $selected) {
4158:): $output .= ' selected="selected"';
4159:): }
4160:): $output .= '>'.$optiontext{$option}.'</option>';
4161:): }
4162:): $output .= '</select>';
4163:): }
4164:): $output .= '</td>';
4165:): }
4166:): $output .= '</tr></table>'."\n";
4167:): return $output;
4168:): }
4169:):
4170:): {
4171:):
1.446 bisitz 4172: my %strings =
1.383 albertel 4173: (
4174: 'string_yesno'
4175: => [[ 'yes', 'Yes' ],
1.473 amueller 4176: [ 'no', 'No' ]],
1.383 albertel 4177: 'string_problemstatus'
4178: => [[ 'yes', 'Yes' ],
1.473 amueller 4179: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
4180: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
4181: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
1.504 raeburn 4182: 'string_questiontype'
4183: => [[ 'problem', 'Standard Problem'],
4184: [ 'survey', 'Survey'],
4185: [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'],
4186: [ 'exam', 'Exam'],
4187: [ 'anonsurvey', 'Anonymous Survey'],
4188: [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'],
4189: [ 'practice', 'Practice'],
4190: [ 'surveycred', 'Survey (credit for submission)']],
1.514 raeburn 4191: 'string_lenient'
4192: => [['yes', 'Yes' ],
4193: [ 'no', 'No' ],
1.521 raeburn 4194: [ 'default', 'Default - only bubblesheet grading is lenient' ]],
4195: 'string_discussvote'
4196: => [['yes','Yes'],
4197: ['notended','Yes, unless discussion ended'],
4198: ['no','No']],
1.522.2.28.4. (raeburn 4199:): 'string_ip'
4200:): => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'],
4201:): ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']],
4202:): 'string_deeplink'
4203:): => [['on','Set choices for link protection, resource listing, access scope, and shown menu items']],
1.383 albertel 4204: );
4205:
1.522.2.28.4. (raeburn 4206:): my %stringmatches = (
4207:): 'string_ip'
4208:): => [['_allowfrom_','[^\!]+'],
4209:): ['_denyfrom_','\!']],
4210:): 'string_deeplink'
4211:): => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)$']],
4212:): );
4213:):
4214:): my %stringtypes = (
4215:): type => 'string_questiontype',
4216:): lenient => 'string_lenient',
4217:): retrypartial => 'string_yesno',
4218:): discussvote => 'string_discussvote',
4219:): examcode => 'string_examcode',
4220:): acc => 'string_ip',
4221:): deeplink => 'string_deeplink',
4222:): );
4223:):
1.505 raeburn 4224: sub standard_string_options {
4225: my ($string_type) = @_;
4226: if (ref($strings{$string_type}) eq 'ARRAY') {
4227: return $strings{$string_type};
4228: }
4229: return;
4230: }
1.383 albertel 4231:
1.522.2.28.4. (raeburn 4232:): sub standard_string_matches {
4233:): my ($string_type) = @_;
4234:): if (ref($stringmatches{$string_type}) eq 'ARRAY') {
4235:): return $stringmatches{$string_type};
4236:): }
4237:): return;
4238:): }
4239:):
1.383 albertel 4240: sub string_selector {
1.522.2.19 raeburn 4241: my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
1.446 bisitz 4242:
1.383 albertel 4243: if (!exists($strings{$thistype})) {
1.522.2.19 raeburn 4244: return &default_selector($thiskey,$showval,$readonly);
1.383 albertel 4245: }
4246:
1.504 raeburn 4247: my %skiptype;
1.514 raeburn 4248: if (($thistype eq 'string_questiontype') ||
1.519 raeburn 4249: ($thistype eq 'string_lenient') ||
1.521 raeburn 4250: ($thistype eq 'string_discussvote') ||
1.519 raeburn 4251: ($name eq 'retrypartial')) {
1.504 raeburn 4252: my ($got_chostname,$chostname,$cmajor,$cminor);
4253: foreach my $possibilities (@{ $strings{$thistype} }) {
4254: next unless (ref($possibilities) eq 'ARRAY');
1.514 raeburn 4255: my ($parmval, $description) = @{ $possibilities };
4256: my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"};
1.504 raeburn 4257: if ($needsrelease) {
4258: unless ($got_chostname) {
1.514 raeburn 4259: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
1.504 raeburn 4260: $got_chostname = 1;
4261: }
1.514 raeburn 4262: my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease,
1.522.2.14 raeburn 4263: $cmajor,$cminor);
1.504 raeburn 4264: if ($needsnewer) {
1.514 raeburn 4265: $skiptype{$parmval} = 1;
1.504 raeburn 4266: }
4267: }
4268: }
4269: }
1.522.2.28.4. (raeburn 4270:):
4271:): if ($thistype eq 'string_ip') {
4272:): return &string_ip_selector($thiskey,$showval,$readonly);
4273:): } elsif ($thistype eq 'string_deeplink') {
4274:): return &string_deeplink_selector($thiskey,$showval,$readonly);
4275:): }
1.522.2.19 raeburn 4276:
4277: my ($result,$disabled);
1.504 raeburn 4278:
1.522.2.19 raeburn 4279: if ($readonly) {
4280: $disabled = ' disabled="disabled"';
4281: }
1.504 raeburn 4282: my $numinrow = 3;
4283: if ($thistype eq 'string_problemstatus') {
4284: $numinrow = 2;
4285: } elsif ($thistype eq 'string_questiontype') {
4286: if (keys(%skiptype) > 0) {
4287: $numinrow = 4;
4288: }
4289: }
4290: my $rem;
4291: if (ref($strings{$thistype}) eq 'ARRAY') {
4292: my $i=0;
4293: foreach my $possibilities (@{ $strings{$thistype} }) {
4294: next unless (ref($possibilities) eq 'ARRAY');
4295: my ($name, $description) = @{ $possibilities };
4296: next if ($skiptype{$name});
4297: $rem = $i%($numinrow);
4298: if ($rem == 0) {
4299: if ($i > 0) {
4300: $result .= '</tr>';
4301: }
4302: $result .= '<tr>';
4303: }
4304: $result .= '<td class="LC_left_item">'.
4305: '<span class="LC_nobreak"><label>'.
4306: '<input type="radio" name="set_'.$thiskey.
1.522.2.19 raeburn 4307: '" value="'.$name.'"'.$disabled;
1.504 raeburn 4308: if ($showval eq $name) {
4309: $result .= ' checked="checked"';
4310: }
4311: $result .= ' />'.&mt($description).'</label></span></td>';
4312: $i++;
4313: }
4314: $rem = @{ $strings{$thistype} }%($numinrow);
4315: my $colsleft = $numinrow - $rem;
4316: if ($colsleft > 1 ) {
4317: $result .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
4318: ' </td>';
4319: } elsif ($colsleft == 1) {
4320: $result .= '<td class="LC_left_item"> </td>';
4321: }
4322: $result .= '</tr>';
1.473 amueller 4323: }
1.504 raeburn 4324: if ($result) {
4325: $result = '<table border="0">'.$result.'</table>';
1.383 albertel 4326: }
4327: return $result;
4328: }
4329:
1.522.2.28.4. (raeburn 4330:): sub oldversion_warning {
4331:): my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
4332:): my $desc;
4333:): my %stringtypes = (
4334:): type => 'string_questiontype',
4335:): lenient => 'string_lenient',
4336:): retrypartial => 'string_yesno',
4337:): discussvote => 'string_discussvote',
4338:): examcode => 'string_examcode',
4339:): );
4340:): if (exists($stringtypes{$name})) {
4341:): if ($name eq 'examcode') {
4342:): $desc = $value;
4343:): } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
4344:): foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
4345:): next unless (ref($possibilities) eq 'ARRAY');
4346:): my ($parmval, $description) = @{ $possibilities };
4347:): if ($parmval eq $value) {
4348:): $desc = $description;
4349:): last;
4350:): }
4351:): }
4352:): }
4353:): } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
4354:): my $now = time;
4355:): if ($value =~ /^\d+$/) {
4356:): if ($name eq 'printstartdate') {
4357:): if ($value > $now) {
4358:): $desc = &Apache::lonlocal::locallocaltime($value);
4359:): }
4360:): } elsif ($name eq 'printenddate') {
4361:): if ($value < $now) {
4362:): $desc = &Apache::lonlocal::locallocaltime($value);
4363:): }
4364:): }
4365:): }
4366:): }
4367:): my $standard_name = &standard_parameter_names($name);
4368:): return '<p class="LC_warning">'.
4369:): &mt('[_1] was [_2]not[_3] set to [_4].',
4370:): $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
4371:): &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
4372:): $cmajor.'.'.$cminor,$chostname,
4373:): $needsrelease).
4374:): '</p>';
4375:): }
4376:):
4377:): }
4378:):
1.389 www 4379: #
4380: # Shift all start and end dates by $shift
4381: #
4382:
4383: sub dateshift {
1.522.2.27 raeburn 4384: my ($shift,$numchanges)=@_;
1.389 www 4385: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4386: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4387: my $sec = $env{'request.course.sec'};
4388: my $secgrpregex;
4389: if ($sec ne '') {
4390: my @groups;
4391: if ($env{'request.course.groups'} ne '') {
4392: @groups = split(/:/,$env{'request.course.groups'});
4393: }
4394: if (@groups) {
4395: $secgrpregex = '(?:'.join('|',($sec,@groups)).')';
4396: } else {
4397: $secgrpregex = $sec;
4398: }
4399: }
1.389 www 4400: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
4401: # ugly retro fix for broken version of types
4402: foreach my $key (keys %data) {
4403: if ($key=~/\wtype$/) {
4404: my $newkey=$key;
4405: $newkey=~s/type$/\.type/;
4406: $data{$newkey}=$data{$key};
4407: delete $data{$key};
4408: }
4409: }
1.391 www 4410: my %storecontent=();
1.389 www 4411: # go through all parameters and look for dates
4412: foreach my $key (keys %data) {
4413: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
1.522.2.27 raeburn 4414: if ($sec ne '') {
4415: next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./);
4416: }
1.389 www 4417: my $newdate=$data{$key}+$shift;
1.522.2.27 raeburn 4418: $$numchanges ++;
1.391 www 4419: $storecontent{$key}=$newdate;
1.389 www 4420: }
4421: }
1.391 www 4422: my $reply=&Apache::lonnet::cput
4423: ('resourcedata',\%storecontent,$dom,$crs);
4424: if ($reply eq 'ok') {
4425: &log_parmset(\%storecontent);
4426: }
4427: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
4428: return $reply;
1.389 www 4429: }
4430:
1.208 www 4431: sub newoverview {
1.522.2.19 raeburn 4432: my ($r,$parm_permission) = @_;
1.280 albertel 4433:
1.208 www 4434: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4435: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.19 raeburn 4436: my $readonly = 1;
4437: if ($parm_permission->{'edit'}) {
4438: undef($readonly);
4439: }
1.414 droeschl 4440: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 4441: text=>"Overview Mode"});
1.522.2.2 raeburn 4442:
4443: my %loaditems = (
4444: 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1');",
4445: );
4446: my $js = '
4447: <script type="text/javascript">
4448: // <![CDATA[
4449: '.
4450: &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n".
4451: &showhide_js()."\n".
1.522.2.28.4. (raeburn 4452:): &done_proctor_js()."\n".
4453:): &deeplink_js()."\n".
1.522.2.2 raeburn 4454: '// ]]>
4455: </script>
4456: ';
4457: my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
4458: {'add_entries' => \%loaditems,});
1.298 albertel 4459: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 4460: $r->print($start_page.$breadcrumbs);
1.208 www 4461: $r->print(<<ENDOVER);
1.232 albertel 4462: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 4463: ENDOVER
1.211 www 4464: my @ids=();
4465: my %typep=();
4466: my %keyp=();
4467: my %allparms=();
4468: my %allparts=();
4469: my %allmaps=();
4470: my %mapp=();
4471: my %symbp=();
4472: my %maptitles=();
4473: my %uris=();
4474: my %keyorder=&standardkeyorder();
4475: my %defkeytype=();
4476:
4477: my %alllevs=();
4478: $alllevs{'Resource Level'}='full';
1.215 www 4479: $alllevs{'Map/Folder Level'}='map';
1.211 www 4480: $alllevs{'Course Level'}='general';
4481:
4482: my $csec=$env{'form.csec'};
1.269 raeburn 4483: my $cgroup=$env{'form.cgroup'};
1.211 www 4484:
4485: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
4486: my $pschp=$env{'form.pschp'};
1.506 www 4487:
1.211 www 4488: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.522.2.1 raeburn 4489: if (!@psprt) { $psprt[0]='0'; }
1.211 www 4490:
1.446 bisitz 4491: my @selected_sections =
1.473 amueller 4492: &Apache::loncommon::get_env_multiple('form.Section');
1.211 www 4493: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 4494: foreach my $sec (@selected_sections) {
4495: if ($sec eq 'all') {
1.211 www 4496: @selected_sections = ('all');
4497: }
4498: }
1.522.2.24 raeburn 4499: if ($env{'request.course.sec'} ne '') {
4500: @selected_sections = ($env{'request.course.sec'});
4501: }
1.269 raeburn 4502: my @selected_groups =
4503: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 4504:
4505: my $pssymb='';
4506: my $parmlev='';
1.446 bisitz 4507:
1.211 www 4508: unless ($env{'form.parmlev'}) {
4509: $parmlev = 'map';
4510: } else {
4511: $parmlev = $env{'form.parmlev'};
4512: }
4513:
1.446 bisitz 4514: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 4515: \%mapp, \%symbp,\%maptitles,\%uris,
4516: \%keyorder,\%defkeytype);
1.211 www 4517:
1.374 albertel 4518: if (grep {$_ eq 'all'} (@psprt)) {
1.481 amueller 4519: @psprt = keys(%allparts);
1.374 albertel 4520: }
1.211 www 4521: # Menu to select levels, etc
4522:
1.456 bisitz 4523: $r->print('<div class="LC_Box">');
1.445 neumanie 4524: #$r->print('<h2 class="LC_hcell">Step 1</h2>');
1.452 bisitz 4525: $r->print('<div>');
1.522.2.2 raeburn 4526: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.211 www 4527: &levelmenu($r,\%alllevs,$parmlev);
4528: if ($parmlev ne 'general') {
1.447 bisitz 4529: $r->print(&Apache::lonhtmlcommon::row_closure());
1.483 amueller 4530: &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp);
1.211 www 4531: }
1.447 bisitz 4532: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 4533: $r->print(&Apache::lonhtmlcommon::end_pick_box());
4534: $r->print('</div></div>');
1.446 bisitz 4535:
1.456 bisitz 4536: $r->print('<div class="LC_Box">');
1.452 bisitz 4537: $r->print('<div>');
1.510 www 4538: &displaymenu($r,\%allparms,\@pscat,\%keyorder);
1.453 schualex 4539: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.446 bisitz 4540: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
1.522.2.24 raeburn 4541: my $sectionselector = §ionmenu(\@selected_sections);
4542: my $groupselector = &groupmenu(\@selected_groups);
1.481 amueller 4543: $r->print('<table>'.
1.522.2.24 raeburn 4544: '<tr><th>'.&mt('Parts').'</th>');
4545: if ($sectionselector) {
4546: $r->print('<th>'.&mt('Section(s)').'</th>');
4547: }
4548: if ($groupselector) {
4549: $r->print('<th>'.&mt('Group(s)').'</th>');
4550: }
4551: $r->print('</tr><tr><td>');
1.211 www 4552: &partmenu($r,\%allparts,\@psprt);
1.522.2.24 raeburn 4553: $r->print('</td>');
4554: if ($sectionselector) {
4555: $r->print('<td>'.$sectionselector.'</td>');
4556: }
4557: if ($groupselector) {
4558: $r->print('<td>'.$groupselector.'</td>');
4559: }
4560: $r->print('</tr></table>');
1.447 bisitz 4561: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 4562: $r->print(&Apache::lonhtmlcommon::end_pick_box());
4563: $r->print('</div></div>');
4564:
1.456 bisitz 4565: $r->print('<div class="LC_Box">');
1.452 bisitz 4566: $r->print('<div>');
1.214 www 4567: my $sortorder=$env{'form.sortorder'};
4568: unless ($sortorder) { $sortorder='realmstudent'; }
4569: &sortmenu($r,$sortorder);
1.445 neumanie 4570: $r->print('</div></div>');
1.446 bisitz 4571:
1.214 www 4572: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.446 bisitz 4573:
1.211 www 4574: # Build the list data hash from the specified parms
4575:
4576: my $listdata;
4577: %{$listdata}=();
4578:
4579: foreach my $cat (@pscat) {
1.269 raeburn 4580: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
4581: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 4582: }
4583:
1.212 www 4584: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 4585:
1.481 amueller 4586: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 4587:
4588: # Read modified data
4589:
1.481 amueller 4590: my $resourcedata=&readdata($crs,$dom);
1.211 www 4591:
4592: # List data
4593:
1.522.2.19 raeburn 4594: &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly);
4595: }
4596: $r->print(&tableend());
4597: unless ($readonly) {
4598: $r->print(((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':''));
1.211 www 4599: }
1.522.2.19 raeburn 4600: $r->print('</form>');
1.507 www 4601: $r->print(&Apache::loncommon::end_page());
1.208 www 4602: }
4603:
1.269 raeburn 4604: sub secgroup_lister {
4605: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
4606: foreach my $item (@{$selections}) {
4607: foreach my $part (@{$psprt}) {
4608: my $rootparmkey=$env{'request.course.id'};
4609: if (($item ne 'all') && ($item ne 'none') && ($item)) {
4610: $rootparmkey.='.['.$item.']';
4611: }
4612: if ($parmlev eq 'general') {
4613: # course-level parameter
4614: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
4615: $$listdata{$newparmkey}=1;
4616: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
4617: } elsif ($parmlev eq 'map') {
4618: # map-level parameter
4619: foreach my $mapid (keys %{$allmaps}) {
4620: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
4621: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
4622: $$listdata{$newparmkey}=1;
4623: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
4624: }
4625: } else {
4626: # resource-level parameter
4627: foreach my $rid (@{$ids}) {
4628: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
4629: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
4630: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
4631: $$listdata{$newparmkey}=1;
4632: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
4633: }
4634: }
4635: }
4636: }
4637: }
4638:
1.208 www 4639: sub overview {
1.522.2.19 raeburn 4640: my ($r,$parm_permission) = @_;
1.208 www 4641: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4642: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.28.4. (raeburn 4643:): my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
4644:): my $js = '<script type="text/javascript">'."\n".
4645:): '// <![CDATA['."\n".
4646:): &done_proctor_js()."\n".
4647:): &deeplink_js()."\n".
4648:): '// ]]>'."\n".
4649:): '</script>'."\n";
1.522.2.19 raeburn 4650: my $readonly = 1;
4651: if ($parm_permission->{'edit'}) {
4652: undef($readonly);
4653: }
1.414 droeschl 4654: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 4655: text=>"Overview Mode"});
1.522.2.28.4. (raeburn 4656:): my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js);
1.298 albertel 4657: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 4658: $r->print($start_page.$breadcrumbs);
4659: $r->print('<form method="post" action="/adm/parmset?action=setoverview" name="parmform">');
4660:
1.208 www 4661: # Store modified
1.522.2.19 raeburn 4662: unless ($readonly) {
4663: &storedata($r,$crs,$dom);
4664: }
1.208 www 4665:
4666: # Read modified data
4667:
1.522.2.19 raeburn 4668: my ($resourcedata,$classlist)=&readdata($crs,$dom);
1.208 www 4669:
1.214 www 4670:
4671: my $sortorder=$env{'form.sortorder'};
4672: unless ($sortorder) { $sortorder='realmstudent'; }
4673: &sortmenu($r,$sortorder);
4674:
1.522.2.19 raeburn 4675: my $submitbutton = '<input type="submit" value="'.&mt('Save').'" />';
4676:
4677: if ($readonly) {
4678: $r->print('<p>'.$submitbutton.'</p>');
4679: }
4680:
4681:
1.208 www 4682: # List data
4683:
1.522.2.19 raeburn 4684: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist,$readonly);
1.208 www 4685:
1.522.2.19 raeburn 4686: $r->print(&tableend().'<p>');
4687: if ($foundkeys) {
4688: unless ($readonly) {
4689: $r->print('<p>'.$submitbutton.'</p>');
4690: }
4691: } else {
4692: $r->print('<p class="LC_info">'.&mt('There are no parameters.').'</p>');
4693: }
4694: $r->print('</form>'.&Apache::loncommon::end_page());
1.120 www 4695: }
1.121 www 4696:
1.333 albertel 4697: sub clean_parameters {
4698: my ($r) = @_;
4699: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4700: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
4701:
1.414 droeschl 4702: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
1.473 amueller 4703: text=>"Clean Parameters"});
1.333 albertel 4704: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
4705: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
4706: $r->print(<<ENDOVER);
4707: $start_page
4708: $breadcrumbs
4709: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
4710: ENDOVER
4711: # Store modified
4712:
4713: &storedata($r,$crs,$dom);
4714:
4715: # Read modified data
4716:
4717: my $resourcedata=&readdata($crs,$dom);
4718:
4719: # List data
4720:
4721: $r->print('<h3>'.
1.473 amueller 4722: &mt('These parameters refer to resources that do not exist.').
4723: '</h3>'.
4724: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
4725: '<br />');
1.333 albertel 4726: $r->print(&Apache::loncommon::start_data_table().
1.473 amueller 4727: '<tr>'.
4728: '<th>'.&mt('Delete').'</th>'.
4729: '<th>'.&mt('Parameter').'</th>'.
4730: '</tr>');
1.333 albertel 4731: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
1.473 amueller 4732: next if (!exists($resourcedata->{$thiskey.'.type'})
4733: && $thiskey=~/\.type$/);
4734: my %data = &parse_key($thiskey);
4735: if (1) { #exists($data{'realm_exists'})
4736: #&& !$data{'realm_exists'}) {
4737: $r->print(&Apache::loncommon::start_data_table_row().
4738: '<tr>'.
4739: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
4740:
4741: $r->print('<td>');
4742: my $display_value = $resourcedata->{$thiskey};
4743: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
4744: $display_value =
4745: &Apache::lonlocal::locallocaltime($display_value);
4746: }
1.470 raeburn 4747: my $parmitem = &standard_parameter_names($data{'parameter_name'});
4748: $parmitem = &mt($parmitem);
1.473 amueller 4749: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
4750: $parmitem,$resourcedata->{$thiskey}));
4751: $r->print('<br />');
4752: if ($data{'scope_type'} eq 'all') {
4753: $r->print(&mt('All users'));
4754: } elsif ($data{'scope_type'} eq 'user') {
4755: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
1.522.2.25 raeburn 4756: } elsif ($data{'scope_type'} eq 'secgroup') {
4757: $r->print(&mt('Group/Section: [_1]',$data{'scope'}));
1.473 amueller 4758: }
4759: $r->print('<br />');
4760: if ($data{'realm_type'} eq 'all') {
4761: $r->print(&mt('All Resources'));
4762: } elsif ($data{'realm_type'} eq 'folder') {
4763: $r->print(&mt('Folder: [_1]'),$data{'realm'});
4764: } elsif ($data{'realm_type'} eq 'symb') {
4765: my ($map,$resid,$url) =
4766: &Apache::lonnet::decode_symb($data{'realm'});
1.522.2.5 raeburn 4767: $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
4768: $url.' <br /> ',
4769: $resid.' <br /> ',$map));
1.473 amueller 4770: }
4771: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
4772: $r->print('</td></tr>');
1.446 bisitz 4773:
1.473 amueller 4774: }
1.333 albertel 4775: }
4776: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.473 amueller 4777: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.507 www 4778: '</p></form>');
4779: $r->print(&Apache::loncommon::end_page());
1.333 albertel 4780: }
4781:
1.390 www 4782: sub date_shift_one {
4783: my ($r) = @_;
4784: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4785: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4786: my $sec = $env{'request.course.sec'};
1.414 droeschl 4787: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 4788: text=>"Shifting Dates"});
1.522.2.27 raeburn 4789: my $submit_text = &mt('Shift all dates accordingly');
4790: if ($sec ne '') {
4791: my @groups;
4792: if ($env{'request.course.groups'} ne '') {
4793: @groups = split(/:/,$env{'request.course.groups'});
4794: }
4795: if (@groups) {
4796: $submit_text = &mt("Shift dates set just for your section/group(s), accordingly");
4797: } else {
4798: $submit_text = &mt("Shift dates set just for your section, accordingly");
4799: }
4800: }
1.390 www 4801: my $start_page=&Apache::loncommon::start_page('Shift Dates');
4802: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 4803: $r->print($start_page.$breadcrumbs);
1.522.2.8 raeburn 4804: $r->print('<form name="shiftform" method="post" action="">'.
1.390 www 4805: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
4806: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
4807: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
1.522.2.10 raeburn 4808: &Apache::lonhtmlcommon::date_setter('shiftform',
1.390 www 4809: 'timeshifted',
4810: $env{'form.timebase'},,
4811: '').
4812: '</td></tr></table>'.
4813: '<input type="hidden" name="action" value="dateshift2" />'.
4814: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
1.522.2.27 raeburn 4815: '<input type="submit" value="'.$submit_text.'" /></form>');
1.390 www 4816: $r->print(&Apache::loncommon::end_page());
4817: }
4818:
4819: sub date_shift_two {
4820: my ($r) = @_;
4821: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4822: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4823: my $sec = $env{'request.course.sec'};
1.414 droeschl 4824: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 4825: text=>"Shifting Dates"});
1.390 www 4826: my $start_page=&Apache::loncommon::start_page('Shift Dates');
4827: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 4828: $r->print($start_page.$breadcrumbs);
1.390 www 4829: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
1.522.2.27 raeburn 4830: $r->print('<h2>'.&mt('Shift Dates').'</h2>');
4831: if ($sec ne '') {
4832: my @groups;
4833: if ($env{'request.course.groups'} ne '') {
4834: @groups = split(/:/,$env{'request.course.groups'});
4835: }
4836: if (@groups) {
4837: $r->print('<p>'.
4838: &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]",
4839: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4840: &Apache::lonlocal::locallocaltime($timeshifted)).
4841: '</p>');
4842: } else {
4843: $r->print('<p>'.
4844: &mt("Shift dates set just for your section, such that [_1] becomes [_2]",
4845: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4846: &Apache::lonlocal::locallocaltime($timeshifted)).
4847: '</p>');
4848: }
4849: } else {
4850: $r->print('<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
4851: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4852: &Apache::lonlocal::locallocaltime($timeshifted)).
4853: '</p>');
4854: }
1.390 www 4855: my $delta=$timeshifted-$env{'form.timebase'};
1.522.2.27 raeburn 4856: my $numchanges = 0;
4857: my $result = &dateshift($delta,\$numchanges);
4858: if ($result eq 'ok') {
4859: $r->print(
4860: &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]',
4861: $numchanges)));
4862: } elsif ($result eq 'con_delayed') {
4863: $r->print(
4864: &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]',
4865: $numchanges)));
4866: } else {
4867: $r->print(
4868: &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1));
4869: }
1.522.2.13 raeburn 4870: $r->print(
4871: '<br /><br />'.
4872: &Apache::lonhtmlcommon::actionbox(
4873: ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));
1.390 www 4874: $r->print(&Apache::loncommon::end_page());
4875: }
4876:
1.333 albertel 4877: sub parse_key {
4878: my ($key) = @_;
4879: my %data;
4880: my ($middle,$part,$name)=
1.473 amueller 4881: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.333 albertel 4882: $data{'scope_type'} = 'all';
4883: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4884: $data{'scope'} = $1;
4885: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
4886: $data{'scope_type'} = 'user';
4887: $data{'scope'} = [$1,$2];
4888: } else {
1.522.2.25 raeburn 4889: $data{'scope_type'} = 'secgroup';
1.473 amueller 4890: }
4891: $middle=~s/^\[(.*)\]//;
1.333 albertel 4892: }
4893: $middle=~s/\.+$//;
4894: $middle=~s/^\.+//;
4895: $data{'realm_type'}='all';
4896: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4897: $data{'realm'} = $1;
4898: $data{'realm_type'} = 'folder';
4899: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
4900: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
1.333 albertel 4901: } elsif ($middle) {
1.473 amueller 4902: $data{'realm'} = $middle;
4903: $data{'realm_type'} = 'symb';
4904: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
4905: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
4906: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
1.333 albertel 4907: }
1.446 bisitz 4908:
1.333 albertel 4909: $data{'parameter_part'} = $part;
4910: $data{'parameter_name'} = $name;
4911:
4912: return %data;
4913: }
4914:
1.239 raeburn 4915:
1.416 jms 4916: sub header {
1.522.2.3 raeburn 4917: return &Apache::loncommon::start_page('Content and Problem Settings');
1.416 jms 4918: }
1.193 albertel 4919:
4920:
4921:
4922: sub print_main_menu {
4923: my ($r,$parm_permission)=@_;
4924: #
1.414 droeschl 4925: $r->print(&header());
1.522.2.3 raeburn 4926: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
1.522.2.19 raeburn 4927: my $crstype = &Apache::loncommon::course_type();
4928: my $lc_crstype = lc($crstype);
4929:
1.193 albertel 4930: $r->print(<<ENDMAINFORMHEAD);
4931: <form method="post" enctype="multipart/form-data"
4932: action="/adm/parmset" name="studentform">
4933: ENDMAINFORMHEAD
4934: #
1.195 albertel 4935: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4936: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 4937: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 4938: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.520 raeburn 4939: my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
1.522.2.19 raeburn 4940: my $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'});
4941: my $vpa = &Apache::lonnet::allowed('vpa',$env{'request.course.id'});
1.520 raeburn 4942: if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
4943: $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
4944: '/'.$env{'request.course.sec'});
4945: }
1.522.2.19 raeburn 4946: if ((!$vcb) && ($env{'request.course.sec'} ne '')) {
4947: $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'}.
4948: '/'.$env{'request.course.sec'});
4949: }
4950: my (%linktext,%linktitle,%url);
4951: if ($parm_permission->{'edit'}) {
4952: %linktext = (
4953: newoverview => 'Edit Resource Parameters - Overview Mode',
4954: settable => 'Edit Resource Parameters - Table Mode',
4955: setoverview => 'Modify Resource Parameters - Overview Mode',
4956: );
4957: %linktitle = (
4958: newoverview => 'Set/Modify resource parameters in overview mode.',
4959: settable => 'Set/Modify resource parameters in table mode.',
4960: setoverview => 'Set/Modify existing resource parameters in overview mode.',
4961: );
4962: } else {
4963: %linktext = (
4964: newoverview => 'View Resource Parameters - Overview Mode',
4965: settable => 'View Resource Parameters - Table Mode',
4966: setoverview => 'View Resource Parameters - Overview Mode',
4967: );
4968: %linktitle = (
4969: newoverview => 'Display resource parameters in overview mode.',
4970: settable => 'Display resource parameters in table mode.',
4971: setoverview => 'Display existing resource parameters in overview mode.',
4972: );
4973: }
4974: if ($mgr) {
4975: $linktext{'resettimes'} = 'Reset Student Access Times';
4976: $linktitle{'resettimes'} = "Reset access times for folders/maps, resources or the $lc_crstype.";
4977: $url{'resettimes'} = '/adm/helper/resettimes.helper';
4978: } elsif ($vgr) {
4979: $linktext{'resettimes'} = 'Display Student Access Times',
4980: $linktitle{'resettimes'} = "Display access times for folders/maps, resources or the $lc_crstype.",
4981: $url{'resettimes'} = '/adm/accesstimes';
4982: }
1.193 albertel 4983: my @menu =
1.507 www 4984: ( { categorytitle=>"Content Settings for this $crstype",
1.473 amueller 4985: items => [
4986: { linktext => 'Portfolio Metadata',
4987: url => '/adm/parmset?action=setrestrictmeta',
1.522.2.19 raeburn 4988: permission => $parm_permission->{'setrestrictmeta'},
1.477 raeburn 4989: linktitle => "Restrict metadata for this $lc_crstype." ,
1.473 amueller 4990: icon =>'contact-new.png' ,
4991: },
1.522.2.19 raeburn 4992: { linktext => $linktext{'resettimes'},
4993: url => $url{'resettimes'},
1.522.2.20 raeburn 4994: permission => ($vgr || $mgr),
1.522.2.19 raeburn 4995: linktitle => $linktitle{'resettimes'},
4996: icon => 'start-here.png',
1.473 amueller 4997: },
1.520 raeburn 4998: { linktext => 'Blocking Communication/Resource Access',
4999: url => '/adm/setblock',
1.522.2.19 raeburn 5000: permission => ($vcb || $dcm),
1.520 raeburn 5001: linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
5002: icon => 'comblock.png',
5003: },
1.473 amueller 5004: { linktext => 'Set Parameter Setting Default Actions',
5005: url => '/adm/parmset?action=setdefaults',
1.522.2.19 raeburn 5006: permission => $parm_permission->{'setdefaults'},
1.473 amueller 5007: linktitle =>'Set default actions for parameters.' ,
5008: icon => 'folder-new.png' ,
5009: }]},
5010: { categorytitle => 'New and Existing Parameter Settings for Resources',
5011: items => [
5012: { linktext => 'Edit Resource Parameters - Helper Mode',
5013: url => '/adm/helper/parameter.helper',
1.522.2.19 raeburn 5014: permission => $parm_permission->{'helper'},
1.473 amueller 5015: linktitle =>'Set/Modify resource parameters in helper mode.' ,
5016: icon => 'dialog-information.png' ,
5017: #help => 'Parameter_Helper',
5018: },
1.522.2.19 raeburn 5019: { linktext => $linktext{'newoverview'},
1.473 amueller 5020: url => '/adm/parmset?action=newoverview',
1.522.2.19 raeburn 5021: permission => $parm_permission->{'newoverview'},
5022: linktitle => $linktitle{'newoverview'},
5023: icon => 'edit-find.png',
1.473 amueller 5024: #help => 'Parameter_Overview',
5025: },
1.522.2.19 raeburn 5026: { linktext => $linktext{'settable'},
1.473 amueller 5027: url => '/adm/parmset?action=settable',
1.522.2.19 raeburn 5028: permission => $parm_permission->{'settable'},
5029: linktitle => $linktitle{'settable'},
5030: icon => 'edit-copy.png',
1.473 amueller 5031: #help => 'Table_Mode',
5032: }]},
1.417 droeschl 5033: { categorytitle => 'Existing Parameter Settings for Resources',
1.473 amueller 5034: items => [
1.522.2.19 raeburn 5035: { linktext => $linktext{'setoverview'},
1.473 amueller 5036: url => '/adm/parmset?action=setoverview',
1.522.2.19 raeburn 5037: permission => $parm_permission->{'setoverview'},
5038: linktitle => $linktitle{'setoverview'},
5039: icon => 'preferences-desktop-wallpaper.png',
1.473 amueller 5040: #help => 'Parameter_Overview',
5041: },
5042: { linktext => 'Change Log',
5043: url => '/adm/parmset?action=parameterchangelog',
1.522.2.19 raeburn 5044: permission => $parm_permission->{'parameterchangelog'},
1.477 raeburn 5045: linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
1.487 wenzelju 5046: icon => 'document-properties.png',
1.473 amueller 5047: }]}
1.193 albertel 5048: );
1.414 droeschl 5049: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.522.2.8 raeburn 5050: $r->print('</form>'.&Apache::loncommon::end_page());
1.193 albertel 5051: return;
5052: }
1.414 droeschl 5053:
1.416 jms 5054:
5055:
1.252 banghart 5056: sub output_row {
1.347 banghart 5057: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 5058: my $output;
1.263 banghart 5059: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
5060: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 5061: if (!defined($options)) {
1.254 banghart 5062: $options = 'active,stuadd';
1.261 banghart 5063: $values = '';
1.252 banghart 5064: }
1.337 banghart 5065: if (!($options =~ /deleted/)) {
5066: my @options= ( ['active', 'Show to student'],
1.418 schafran 5067: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 5068: ['choices','Provide choices for students to select from']);
1.473 amueller 5069: # ['onlyone','Student may select only one choice']);
1.337 banghart 5070: if ($added_flag) {
5071: push @options,['deleted', 'Delete Metadata Field'];
5072: }
1.351 banghart 5073: $output = &Apache::loncommon::start_data_table_row();
1.451 bisitz 5074: $output .= '<td><strong>'.$field_text.':</strong></td>';
1.351 banghart 5075: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 5076: foreach my $opt (@options) {
1.473 amueller 5077: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
5078: $output .= &Apache::loncommon::continue_data_table_row();
5079: $output .= '<td>'.(' ' x 5).'<label>
5080: <input type="checkbox" name="'.
5081: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
5082: &mt($opt->[1]).'</label></td>';
5083: $output .= &Apache::loncommon::end_data_table_row();
5084: }
1.351 banghart 5085: $output .= &Apache::loncommon::continue_data_table_row();
1.451 bisitz 5086: $output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
1.351 banghart 5087: $output .= &Apache::loncommon::end_data_table_row();
5088: my $multiple_checked;
5089: my $single_checked;
5090: if ($options =~ m/onlyone/) {
1.422 bisitz 5091: $multiple_checked = '';
1.423 bisitz 5092: $single_checked = ' checked="checked"';
1.351 banghart 5093: } else {
1.423 bisitz 5094: $multiple_checked = ' checked="checked"';
1.422 bisitz 5095: $single_checked = '';
1.351 banghart 5096: }
1.473 amueller 5097: $output .= &Apache::loncommon::continue_data_table_row();
5098: $output .= '<td>'.(' ' x 10).'
5099: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
5100: '.&mt('Student may select multiple choices from list').'</td>';
5101: $output .= &Apache::loncommon::end_data_table_row();
5102: $output .= &Apache::loncommon::continue_data_table_row();
5103: $output .= '<td>'.(' ' x 10).'
5104: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
5105: '.&mt('Student may select only one choice from list').'</td>';
5106: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 5107: }
5108: return ($output);
5109: }
1.416 jms 5110:
5111:
5112:
1.340 banghart 5113: sub order_meta_fields {
5114: my ($r)=@_;
5115: my $idx = 1;
5116: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5117: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 5118: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 5119: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 5120: text=>"Add Metadata Field"});
1.345 banghart 5121: &Apache::lonhtmlcommon::add_breadcrumb
5122: ({href=>"/adm/parmset?action=setrestrictmeta",
5123: text=>"Restrict Metadata"},
5124: {text=>"Order Metadata"});
5125: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 5126: if ($env{'form.storeorder'}) {
5127: my $newpos = $env{'form.newpos'} - 1;
5128: my $currentpos = $env{'form.currentpos'} - 1;
5129: my @neworder = ();
5130: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
5131: my $i;
1.341 banghart 5132: if ($newpos > $currentpos) {
1.340 banghart 5133: # moving stuff up
5134: for ($i=0;$i<$currentpos;$i++) {
1.473 amueller 5135: $neworder[$i]=$oldorder[$i];
1.340 banghart 5136: }
5137: for ($i=$currentpos;$i<$newpos;$i++) {
1.473 amueller 5138: $neworder[$i]=$oldorder[$i+1];
1.340 banghart 5139: }
5140: $neworder[$newpos]=$oldorder[$currentpos];
5141: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
1.473 amueller 5142: $neworder[$i]=$oldorder[$i];
1.340 banghart 5143: }
5144: } else {
5145: # moving stuff down
1.473 amueller 5146: for ($i=0;$i<$newpos;$i++) {
5147: $neworder[$i]=$oldorder[$i];
5148: }
5149: $neworder[$newpos]=$oldorder[$currentpos];
5150: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
5151: $neworder[$i]=$oldorder[$i-1];
5152: }
5153: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
5154: $neworder[$i]=$oldorder[$i];
5155: }
1.340 banghart 5156: }
1.473 amueller 5157: my $ordered_fields = join ",", @neworder;
1.343 banghart 5158: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 5159: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.473 amueller 5160: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 5161: }
1.357 raeburn 5162: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 5163: my $ordered_fields;
1.340 banghart 5164: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
5165: if (!@fields_in_order) {
5166: # no order found, pick sorted order then create metadata.addedorder key.
5167: foreach my $key (sort keys %$fields) {
5168: push @fields_in_order, $key;
1.341 banghart 5169: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 5170: }
1.341 banghart 5171: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 5172: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
5173: }
1.340 banghart 5174: $r->print('<table>');
5175: my $num_fields = scalar(@fields_in_order);
5176: foreach my $key (@fields_in_order) {
5177: $r->print('<tr><td>');
5178: $r->print('<form method="post" action="">');
1.522.2.8 raeburn 5179: $r->print('<select name="newpos" onchange="this.form.submit()">');
1.340 banghart 5180: for (my $i = 1;$i le $num_fields;$i ++) {
5181: if ($i eq $idx) {
5182: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
5183: } else {
5184: $r->print('<option value="'.$i.'">'.$i.'</option>');
5185: }
5186: }
5187: $r->print('</select></td><td>');
5188: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
5189: $r->print('<input type="hidden" name="storeorder" value="true" />');
5190: $r->print('</form>');
5191: $r->print($$fields{$key}.'</td></tr>');
5192: $idx ++;
5193: }
5194: $r->print('</table>');
5195: return 'ok';
5196: }
1.416 jms 5197:
5198:
1.359 banghart 5199: sub continue {
5200: my $output;
5201: $output .= '<form action="" method="post">';
5202: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
1.522.2.25 raeburn 5203: $output .= '<input type="submit" value="'.&mt('Continue').'" />';
1.359 banghart 5204: return ($output);
5205: }
1.416 jms 5206:
5207:
1.334 banghart 5208: sub addmetafield {
5209: my ($r)=@_;
1.414 droeschl 5210: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 5211: text=>"Add Metadata Field"});
1.334 banghart 5212: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
5213: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 5214: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5215: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 5216: if (exists($env{'form.undelete'})) {
1.358 banghart 5217: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 5218: foreach my $meta_field(@meta_fields) {
5219: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
5220: $options =~ s/deleted//;
5221: $options =~ s/,,/,/;
5222: my $put_result = &Apache::lonnet::put('environment',
5223: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
1.446 bisitz 5224:
1.522.2.25 raeburn 5225: $r->print(&mt('Undeleted Metadata Field [_1] with result [_2]',
5226: '<strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}.
5227: '</strong>',$put_result).
5228: '<br />');
1.339 banghart 5229: }
1.359 banghart 5230: $r->print(&continue());
1.339 banghart 5231: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 5232: my $meta_field = $env{'form.fieldname'};
5233: my $display_field = $env{'form.fieldname'};
5234: $meta_field =~ s/\W/_/g;
1.338 banghart 5235: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 5236: my $put_result = &Apache::lonnet::put('environment',
5237: {'metadata.'.$meta_field.'.values'=>"",
5238: 'metadata.'.$meta_field.'.added'=>"$display_field",
5239: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.522.2.25 raeburn 5240: $r->print(&mt('Added new Metadata Field [_1] with result [_2]',
5241: '<strong>'.$env{'form.fieldname'}.'</strong>',$put_result).
5242: '<br />');
1.359 banghart 5243: $r->print(&continue());
1.335 banghart 5244: } else {
1.357 raeburn 5245: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 5246: if ($fields) {
1.522.2.25 raeburn 5247: $r->print(&mt('You may undelete previously deleted fields.').
5248: '<br />'.
5249: &mt('Check those you wish to undelete and click Undelete.').
5250: '<br />');
1.339 banghart 5251: $r->print('<form method="post" action="">');
5252: foreach my $key(keys(%$fields)) {
1.358 banghart 5253: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 5254: }
5255: $r->print('<input type="submit" name="undelete" value="Undelete" />');
5256: $r->print('</form>');
5257: }
1.522.2.25 raeburn 5258: $r->print('<hr />'.
5259: &mt('[_1]Or[_2] you may enter a new metadata field name.',
5260: '<strong>','</strong>').
5261: '<form method="post" action="/adm/parmset?action=addmetadata">');
1.335 banghart 5262: $r->print('<input type="text" name="fieldname" /><br />');
1.522.2.25 raeburn 5263: $r->print('<input type="submit" value="'.&mt('Add Metadata Field').'" />');
1.334 banghart 5264: }
1.361 albertel 5265: $r->print('</form>');
1.334 banghart 5266: }
1.416 jms 5267:
5268:
5269:
1.259 banghart 5270: sub setrestrictmeta {
1.240 banghart 5271: my ($r)=@_;
1.242 banghart 5272: my $next_meta;
1.244 banghart 5273: my $output;
1.245 banghart 5274: my $item_num;
1.246 banghart 5275: my $put_result;
1.414 droeschl 5276: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
1.473 amueller 5277: text=>"Restrict Metadata"});
1.280 albertel 5278: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 5279: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 5280: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5281: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 5282: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 5283: my $save_field = '';
1.522.2.25 raeburn 5284: my %lt = &Apache::lonlocal::texthash(
5285: addm => 'Add Metadata Field',
5286: ordm => 'Order Metadata Fields',
5287: save => 'Save',
5288: );
1.259 banghart 5289: if ($env{'form.restrictmeta'}) {
1.254 banghart 5290: foreach my $field (sort(keys(%env))) {
1.252 banghart 5291: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 5292: my $options;
1.252 banghart 5293: my $meta_field = $1;
5294: my $meta_key = $2;
1.253 banghart 5295: if ($save_field ne $meta_field) {
1.252 banghart 5296: $save_field = $meta_field;
1.473 amueller 5297: if ($env{'form.'.$meta_field.'_stuadd'}) {
5298: $options.='stuadd,';
5299: }
5300: if ($env{'form.'.$meta_field.'_choices'}) {
5301: $options.='choices,';
5302: }
5303: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
5304: $options.='onlyone,';
5305: }
5306: if ($env{'form.'.$meta_field.'_active'}) {
5307: $options.='active,';
5308: }
5309: if ($env{'form.'.$meta_field.'_deleted'}) {
5310: $options.='deleted,';
5311: }
1.259 banghart 5312: my $name = $save_field;
1.253 banghart 5313: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 5314: {'metadata.'.$meta_field.'.options'=>$options,
5315: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 5316: },$dom,$crs);
1.252 banghart 5317: }
5318: }
5319: }
5320: }
1.296 albertel 5321: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.473 amueller 5322: {'freshen_cache' => 1});
1.335 banghart 5323: # Get the default metadata fields
1.258 albertel 5324: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 5325: # Now get possible added metadata fields
1.357 raeburn 5326: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.347 banghart 5327: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 5328: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 5329: if ($field ne 'courserestricted') {
1.473 amueller 5330: $output.= &output_row($r, $field, $metadata_fields{$field});
5331: }
1.255 banghart 5332: }
1.351 banghart 5333: my $buttons = (<<ENDButtons);
1.522.2.25 raeburn 5334: <input type="submit" name="restrictmeta" value="$lt{'save'}" />
1.351 banghart 5335: </form><br />
5336: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
1.522.2.25 raeburn 5337: <input type="submit" name="restrictmeta" value="$lt{'addm'}" />
1.351 banghart 5338: </form>
5339: <br />
5340: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
1.522.2.25 raeburn 5341: <input type="submit" name="restrictmeta" value="$lt{'ordm'}" />
1.351 banghart 5342: ENDButtons
1.337 banghart 5343: my $added_flag = 1;
1.335 banghart 5344: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.522.2.25 raeburn 5345: $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag);
1.335 banghart 5346: }
1.347 banghart 5347: $output .= &Apache::loncommon::end_data_table();
1.446 bisitz 5348: $r->print(<<ENDenv);
1.259 banghart 5349: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 5350: $output
1.351 banghart 5351: $buttons
1.340 banghart 5352: </form>
1.244 banghart 5353: ENDenv
1.280 albertel 5354: $r->print(&Apache::loncommon::end_page());
1.240 banghart 5355: return 'ok';
5356: }
1.416 jms 5357:
5358:
5359:
1.335 banghart 5360: sub get_added_meta_fieldnames {
1.357 raeburn 5361: my ($cid) = @_;
1.335 banghart 5362: my %fields;
5363: foreach my $key(%env) {
1.357 raeburn 5364: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 5365: my $field_name = $1;
5366: my ($display_field_name) = $env{$key};
5367: $fields{$field_name} = $display_field_name;
5368: }
5369: }
5370: return \%fields;
5371: }
1.416 jms 5372:
5373:
5374:
1.339 banghart 5375: sub get_deleted_meta_fieldnames {
1.357 raeburn 5376: my ($cid) = @_;
1.339 banghart 5377: my %fields;
5378: foreach my $key(%env) {
1.357 raeburn 5379: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 5380: my $field_name = $1;
5381: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
5382: my ($display_field_name) = $env{$key};
5383: $fields{$field_name} = $display_field_name;
5384: }
5385: }
5386: }
5387: return \%fields;
5388: }
1.220 www 5389: sub defaultsetter {
1.280 albertel 5390: my ($r) = @_;
5391:
1.414 droeschl 5392: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
1.473 amueller 5393: text=>"Set Defaults"});
1.446 bisitz 5394: my $start_page =
1.473 amueller 5395: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 5396: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.507 www 5397: $r->print($start_page.$breadcrumbs);
5398: $r->print('<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">');
1.280 albertel 5399:
5400: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5401: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 5402: my @ids=();
5403: my %typep=();
5404: my %keyp=();
5405: my %allparms=();
5406: my %allparts=();
5407: my %allmaps=();
5408: my %mapp=();
5409: my %symbp=();
5410: my %maptitles=();
5411: my %uris=();
5412: my %keyorder=&standardkeyorder();
5413: my %defkeytype=();
5414:
1.446 bisitz 5415: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 5416: \%mapp, \%symbp,\%maptitles,\%uris,
5417: \%keyorder,\%defkeytype);
1.224 www 5418: if ($env{'form.storerules'}) {
1.473 amueller 5419: my %newrules=();
5420: my @delrules=();
5421: my %triggers=();
5422: foreach my $key (keys(%env)) {
1.225 albertel 5423: if ($key=~/^form\.(\w+)\_action$/) {
1.473 amueller 5424: my $tempkey=$1;
5425: my $action=$env{$key};
1.226 www 5426: if ($action) {
1.473 amueller 5427: $newrules{$tempkey.'_action'}=$action;
5428: if ($action ne 'default') {
5429: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
5430: $triggers{$whichparm}.=$tempkey.':';
5431: }
5432: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
5433: if (&isdateparm($defkeytype{$tempkey})) {
5434: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
5435: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
5436: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
5437: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
5438: } else {
5439: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
5440: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
5441: }
5442: } else {
5443: push(@delrules,$tempkey.'_action');
5444: push(@delrules,$tempkey.'_type');
5445: push(@delrules,$tempkey.'_hours');
5446: push(@delrules,$tempkey.'_min');
5447: push(@delrules,$tempkey.'_sec');
5448: push(@delrules,$tempkey.'_value');
5449: }
5450: }
5451: }
5452: foreach my $key (keys %allparms) {
5453: $newrules{$key.'_triggers'}=$triggers{$key};
5454: }
5455: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
5456: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
5457: &resetrulescache();
1.224 www 5458: }
1.227 www 5459: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
1.473 amueller 5460: 'hours' => 'Hours',
5461: 'min' => 'Minutes',
5462: 'sec' => 'Seconds',
5463: 'yes' => 'Yes',
5464: 'no' => 'No');
1.222 www 5465: my @standardoptions=('','default');
5466: my @standarddisplay=('',&mt('Default value when manually setting'));
5467: my @dateoptions=('','default');
5468: my @datedisplay=('',&mt('Default value when manually setting'));
5469: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 5470: unless ($tempkey) { next; }
5471: push @standardoptions,'when_setting_'.$tempkey;
5472: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
5473: if (&isdateparm($defkeytype{$tempkey})) {
5474: push @dateoptions,'later_than_'.$tempkey;
5475: push @datedisplay,&mt('Automatically set later than ').$tempkey;
5476: push @dateoptions,'earlier_than_'.$tempkey;
5477: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
5478: }
1.222 www 5479: }
1.231 www 5480: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
1.473 amueller 5481: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 5482: $r->print("\n".&Apache::loncommon::start_data_table().
1.473 amueller 5483: &Apache::loncommon::start_data_table_header_row().
5484: "<th>".&mt('Rule for parameter').'</th><th>'.
5485: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
5486: &Apache::loncommon::end_data_table_header_row());
1.221 www 5487: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 5488: unless ($tempkey) { next; }
5489: $r->print("\n".&Apache::loncommon::start_data_table_row().
5490: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
5491: my $action=&rulescache($tempkey.'_action');
5492: $r->print('<select name="'.$tempkey.'_action">');
5493: if (&isdateparm($defkeytype{$tempkey})) {
5494: for (my $i=0;$i<=$#dateoptions;$i++) {
5495: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
5496: $r->print("\n<option value='$dateoptions[$i]'".
5497: ($dateoptions[$i] eq $action?' selected="selected"':'').
5498: ">$datedisplay[$i]</option>");
5499: }
5500: } else {
5501: for (my $i=0;$i<=$#standardoptions;$i++) {
5502: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
5503: $r->print("\n<option value='$standardoptions[$i]'".
5504: ($standardoptions[$i] eq $action?' selected="selected"':'').
5505: ">$standarddisplay[$i]</option>");
5506: }
5507: }
5508: $r->print('</select>');
5509: unless (&isdateparm($defkeytype{$tempkey})) {
5510: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
5511: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
5512: }
5513: $r->print("\n</td><td>\n");
1.222 www 5514:
1.221 www 5515: if (&isdateparm($defkeytype{$tempkey})) {
1.473 amueller 5516: my $days=&rulescache($tempkey.'_days');
5517: my $hours=&rulescache($tempkey.'_hours');
5518: my $min=&rulescache($tempkey.'_min');
5519: my $sec=&rulescache($tempkey.'_sec');
5520: $r->print(<<ENDINPUTDATE);
1.227 www 5521: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 5522: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
5523: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
5524: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 5525: ENDINPUTDATE
1.473 amueller 5526: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 5527: my $yeschecked='';
5528: my $nochecked='';
1.444 bisitz 5529: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
5530: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
1.222 www 5531:
1.473 amueller 5532: $r->print(<<ENDYESNO);
1.444 bisitz 5533: <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
5534: <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
1.221 www 5535: ENDYESNO
5536: } else {
1.473 amueller 5537: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
5538: }
1.318 albertel 5539: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 5540: }
1.318 albertel 5541: $r->print(&Apache::loncommon::end_data_table().
1.473 amueller 5542: "\n".'<input type="submit" name="storerules" value="'.
1.507 www 5543: &mt('Save').'" /></form>'."\n");
5544: $r->print(&Apache::loncommon::end_page());
1.220 www 5545: return;
5546: }
1.193 albertel 5547:
1.290 www 5548: sub components {
1.330 albertel 5549: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
5550:
5551: if ($typeflag) {
1.473 amueller 5552: $key=~s/\.type$//;
1.290 www 5553: }
1.330 albertel 5554:
5555: my ($middle,$part,$name)=
1.473 amueller 5556: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 5557: my $issection;
1.330 albertel 5558:
1.290 www 5559: my $section=&mt('All Students');
5560: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 5561: $issection=$1;
5562: $section=&mt('Group/Section').': '.$issection;
5563: $middle=~s/^\[(.*)\]//;
1.290 www 5564: }
5565: $middle=~s/\.+$//;
5566: $middle=~s/^\.+//;
1.291 www 5567: if ($uname) {
1.473 amueller 5568: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
5569: $issection='';
1.291 www 5570: }
1.316 albertel 5571: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.446 bisitz 5572: my $realmdescription=&mt('all resources');
1.290 www 5573: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 5574: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
5575: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
1.304 www 5576: } elsif ($middle) {
1.473 amueller 5577: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
5578: $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>';
5579: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 5580: }
1.291 www 5581: my $what=$part.'.'.$name;
1.330 albertel 5582: return ($realm,$section,$name,$part,
1.473 amueller 5583: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 5584: }
1.293 www 5585:
1.328 albertel 5586: my %standard_parms;
1.469 raeburn 5587: my %standard_parms_types;
1.416 jms 5588:
1.328 albertel 5589: sub load_parameter_names {
1.522.2.25 raeburn 5590: open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
1.328 albertel 5591: while (my $configline=<$config>) {
1.473 amueller 5592: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
5593: chomp($configline);
5594: my ($short,$plain)=split(/:/,$configline);
5595: my (undef,$name,$type)=split(/\&/,$short,3);
5596: if ($type eq 'display') {
5597: $standard_parms{$name} = $plain;
1.469 raeburn 5598: } elsif ($type eq 'type') {
5599: $standard_parms_types{$name} = $plain;
5600: }
1.328 albertel 5601: }
5602: close($config);
5603: $standard_parms{'int_pos'} = 'Positive Integer';
5604: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
1.522.2.25 raeburn 5605: $standard_parms{'scoreformat'} = 'Format for display of score';
1.328 albertel 5606: }
5607:
1.292 www 5608: sub standard_parameter_names {
5609: my ($name)=@_;
1.328 albertel 5610: if (!%standard_parms) {
1.473 amueller 5611: &load_parameter_names();
1.328 albertel 5612: }
1.292 www 5613: if ($standard_parms{$name}) {
1.473 amueller 5614: return $standard_parms{$name};
1.446 bisitz 5615: } else {
1.473 amueller 5616: return $name;
1.292 www 5617: }
5618: }
1.290 www 5619:
1.469 raeburn 5620: sub standard_parameter_types {
5621: my ($name)=@_;
5622: if (!%standard_parms_types) {
5623: &load_parameter_names();
5624: }
5625: if ($standard_parms_types{$name}) {
5626: return $standard_parms_types{$name};
5627: }
5628: return;
5629: }
1.309 www 5630:
1.285 albertel 5631: sub parm_change_log {
1.522.2.19 raeburn 5632: my ($r,$parm_permission)=@_;
1.414 droeschl 5633: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.473 amueller 5634: text=>"Parameter Change Log"});
1.522 raeburn 5635: my $js = '<script type="text/javascript">'."\n".
5636: '// <![CDATA['."\n".
5637: &Apache::loncommon::display_filter_js('parmslog')."\n".
5638: '// ]]>'."\n".
5639: '</script>'."\n";
5640: $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
1.327 albertel 5641: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
1.286 www 5642: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
1.473 amueller 5643: $env{'course.'.$env{'request.course.id'}.'.domain'},
5644: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 5645:
1.301 www 5646: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 5647:
1.522 raeburn 5648: $r->print('<div class="LC_left_float">'.
5649: '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
5650: '<form action="/adm/parmset?action=parameterchangelog"
1.327 albertel 5651: method="post" name="parameterlog">');
1.446 bisitz 5652:
1.311 albertel 5653: my %saveable_parameters = ('show' => 'scalar',);
5654: &Apache::loncommon::store_course_settings('parameter_log',
5655: \%saveable_parameters);
5656: &Apache::loncommon::restore_course_settings('parameter_log',
5657: \%saveable_parameters);
1.522 raeburn 5658: $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
5659: '<input type="submit" value="'.&mt('Display').'" />'.
5660: '</form></fieldset></div><br clear="all" />');
1.522.2.19 raeburn 5661: my $readonly = 1;
5662: if ($parm_permission->{'edit'}) {
5663: undef($readonly);
5664: }
1.291 www 5665: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
1.473 amueller 5666: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 5667: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1.473 amueller 5668: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
1.522.2.19 raeburn 5669: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th>');
5670: unless ($readonly) {
5671: $r->print('<th>'.&mt('Announce').'</th>');
5672: }
5673: $r->print(&Apache::loncommon::end_data_table_header_row());
1.309 www 5674: my $shown=0;
1.349 www 5675: my $folder='';
5676: if ($env{'form.displayfilter'} eq 'currentfolder') {
1.473 amueller 5677: my $last='';
5678: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
5679: &GDBM_READER(),0640)) {
5680: $last=$hash{'last_known'};
5681: untie(%hash);
5682: }
5683: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
1.349 www 5684: }
1.522.2.27 raeburn 5685: my $numgroups = 0;
5686: my @groups;
5687: if ($env{'request.course.groups'} ne '') {
5688: @groups = split(/:/,$env{'request.course.groups'});
5689: $numgroups = scalar(@groups);
5690: }
1.446 bisitz 5691: foreach my $id (sort
1.473 amueller 5692: {
5693: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
5694: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
5695: }
5696: my $aid = (split('00000',$a))[-1];
5697: my $bid = (split('00000',$b))[-1];
5698: return $bid<=>$aid;
5699: } (keys(%parmlog))) {
1.294 www 5700: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.473 amueller 5701: my $count = 0;
5702: my $time =
5703: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
5704: my $plainname =
5705: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
5706: $parmlog{$id}{'exe_udom'});
5707: my $about_me_link =
5708: &Apache::loncommon::aboutmewrapper($plainname,
5709: $parmlog{$id}{'exe_uname'},
5710: $parmlog{$id}{'exe_udom'});
5711: my $send_msg_link='';
1.522.2.19 raeburn 5712: if ((!$readonly) &&
5713: (($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
1.473 amueller 5714: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
5715: $send_msg_link ='<br />'.
5716: &Apache::loncommon::messagewrapper(&mt('Send message'),
5717: $parmlog{$id}{'exe_uname'},
5718: $parmlog{$id}{'exe_udom'});
5719: }
5720: my $row_start=&Apache::loncommon::start_data_table_row();
5721: my $makenewrow=0;
5722: my %istype=();
5723: my $output;
5724: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 5725: my $value=$parmlog{$id}{'logentry'}{$changed};
1.473 amueller 5726: my $typeflag = ($changed =~/\.type$/ &&
5727: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 5728: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.473 amueller 5729: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.522.2.24 raeburn 5730: if ($env{'request.course.sec'} ne '') {
1.522.2.27 raeburn 5731: next if (($issection ne '') && (!(($issection eq $env{'request.course.sec'}) ||
5732: ($numgroups && (grep(/^\Q$issection\E$/,@groups))))));
1.522.2.24 raeburn 5733: if ($uname ne '') {
5734: my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'});
5735: next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'}));
5736: }
5737: }
1.473 amueller 5738: if ($env{'form.displayfilter'} eq 'currentfolder') {
5739: if ($folder) {
5740: if ($middle!~/^\Q$folder\E/) { next; }
5741: }
5742: }
5743: if ($typeflag) {
5744: $istype{$parmname}=$value;
5745: if (!$env{'form.includetypes'}) { next; }
5746: }
5747: $count++;
5748: if ($makenewrow) {
5749: $output .= $row_start;
5750: } else {
5751: $makenewrow=1;
5752: }
1.470 raeburn 5753: my $parmitem = &standard_parameter_names($parmname);
1.473 amueller 5754: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
5755: &mt($parmitem).'</td><td>'.
5756: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
5757: my $stillactive=0;
5758: if ($parmlog{$id}{'delflag'}) {
5759: $output .= &mt('Deleted');
5760: } else {
5761: if ($typeflag) {
1.470 raeburn 5762: my $parmitem = &standard_parameter_names($value);
5763: $parmitem = &mt($parmitem);
1.473 amueller 5764: $output .= &mt('Type: [_1]',$parmitem);
5765: } else {
5766: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
5767: $uname,$udom,$issection,$issection,$courseopt);
1.469 raeburn 5768: my $showvalue = $value;
5769: if ($istype{$parmname} eq '') {
5770: my $type = &standard_parameter_types($parmname);
5771: if ($type ne '') {
5772: if (&isdateparm($type)) {
5773: $showvalue =
5774: &Apache::lonlocal::locallocaltime($value);
5775: }
5776: }
5777: } else {
1.473 amueller 5778: if (&isdateparm($istype{$parmname})) {
5779: $showvalue =
1.469 raeburn 5780: &Apache::lonlocal::locallocaltime($value);
1.473 amueller 5781: }
1.469 raeburn 5782: }
5783: $output .= $showvalue;
1.473 amueller 5784: if ($value ne $all[$level]) {
5785: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
5786: } else {
5787: $stillactive=1;
5788: }
5789: }
5790: }
1.522.2.19 raeburn 5791: $output .= '</td>';
5792:
5793: unless ($readonly) {
5794: $output .= '<td>';
5795: if ($stillactive) {
5796: my $parmitem = &standard_parameter_names($parmname);
5797: $parmitem = &mt($parmitem);
5798: my $title=&mt('Changed [_1]',$parmitem);
5799: my $description=&mt('Changed [_1] for [_2] to [_3]',
5800: $parmitem,$realmdescription,
5801: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
5802: if (($uname) && ($udom)) {
5803: $output .=
5804: &Apache::loncommon::messagewrapper('Notify User',
5805: $uname,$udom,$title,
5806: $description);
5807: } else {
5808: $output .=
5809: &Apache::lonrss::course_blog_link($id,$title,
5810: $description);
5811: }
5812: }
5813: $output .= '</td>';
5814: }
5815: $output .= &Apache::loncommon::end_data_table_row();
1.473 amueller 5816: }
1.349 www 5817: if ($env{'form.displayfilter'} eq 'containing') {
1.473 amueller 5818: my $wholeentry=$about_me_link.':'.
5819: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
5820: $output;
5821: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
5822: }
1.349 www 5823: if ($count) {
1.473 amueller 5824: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 5825: <td rowspan="'.$count.'">'.$about_me_link.
1.473 amueller 5826: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
5827: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
5828: $send_msg_link.'</td>'.$output);
5829: $shown++;
5830: }
5831: if (!($env{'form.show'} eq &mt('all')
5832: || $shown<=$env{'form.show'})) { last; }
1.286 www 5833: }
1.301 www 5834: $r->print(&Apache::loncommon::end_data_table());
1.284 www 5835: $r->print(&Apache::loncommon::end_page());
5836: }
5837:
1.437 raeburn 5838: sub update_slots {
5839: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
5840: my %slot=&Apache::lonnet::get_slot($slot_name);
5841: if (!keys(%slot)) {
5842: return 'error: slot does not exist';
5843: }
5844: my $max=$slot{'maxspace'};
5845: if (!defined($max)) { $max=99999; }
5846:
5847: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
5848: "^$slot_name\0");
5849: my ($tmp)=%consumed;
5850: if ($tmp=~/^error: 2 / ) {
5851: return 'error: unable to determine current slot status';
5852: }
5853: my $last=0;
5854: foreach my $key (keys(%consumed)) {
5855: my $num=(split('\0',$key))[1];
5856: if ($num > $last) { $last=$num; }
5857: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
5858: return 'ok';
5859: }
5860: }
5861:
5862: if (scalar(keys(%consumed)) >= $max) {
5863: return 'error: no space left in slot';
5864: }
5865: my $wanted=$last+1;
5866:
5867: my %reservation=('name' => $uname.':'.$udom,
5868: 'timestamp' => time,
5869: 'symb' => $symb);
5870:
5871: my $success=&Apache::lonnet::newput('slot_reservations',
5872: {"$slot_name\0$wanted" =>
5873: \%reservation},
5874: $cdom, $cnum);
1.438 raeburn 5875: if ($success eq 'ok') {
5876: my %storehash = (
5877: symb => $symb,
5878: slot => $slot_name,
5879: action => 'reserve',
5880: context => 'parameter',
5881: );
1.522.2.3 raeburn 5882: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.438 raeburn 5883: '',$uname,$udom,$cnum,$cdom);
5884:
1.522.2.3 raeburn 5885: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 5886: '',$uname,$udom,$uname,$udom);
5887: }
1.437 raeburn 5888: return $success;
5889: }
5890:
5891: sub delete_slots {
5892: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
5893: my $delresult;
5894: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
5895: $cnum, "^$slot_name\0");
5896: if (&Apache::lonnet::error(%consumed)) {
5897: return 'error: unable to determine current slot status';
5898: }
5899: my ($tmp)=%consumed;
5900: if ($tmp=~/^error: 2 /) {
5901: return 'error: unable to determine current slot status';
5902: }
5903: foreach my $key (keys(%consumed)) {
5904: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
5905: my $num=(split('\0',$key))[1];
5906: my $entry = $slot_name.'\0'.$num;
5907: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
5908: $cdom,$cnum);
5909: if ($delresult eq 'ok') {
5910: my %storehash = (
5911: symb => $symb,
5912: slot => $slot_name,
5913: action => 'release',
5914: context => 'parameter',
5915: );
1.522.2.3 raeburn 5916: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.437 raeburn 5917: 1,$uname,$udom,$cnum,$cdom);
1.522.2.3 raeburn 5918: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 5919: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 5920: }
5921: }
5922: }
5923: return $delresult;
5924: }
5925:
1.355 albertel 5926: sub check_for_course_info {
5927: my $navmap = Apache::lonnavmaps::navmap->new();
5928: return 1 if ($navmap);
5929: return 0;
5930: }
5931:
1.514 raeburn 5932: sub parameter_release_vars {
1.504 raeburn 5933: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5934: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
5935: my $chostname = &Apache::lonnet::hostname($chome);
5936: my ($cmajor,$cminor) =
5937: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
5938: return ($chostname,$cmajor,$cminor);
5939: }
5940:
1.514 raeburn 5941: sub parameter_releasecheck {
1.522.2.14 raeburn 5942: my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
1.504 raeburn 5943: my $needsnewer;
5944: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
5945: if (($cmajor < $needsmajor) ||
5946: ($cmajor == $needsmajor && $cminor < $needsminor)) {
5947: $needsnewer = 1;
5948: } else {
1.514 raeburn 5949: &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
1.504 raeburn 5950: }
5951: return $needsnewer;
5952: }
5953:
1.522.2.19 raeburn 5954: sub get_permission {
5955: my %permission;
5956: my $allowed = 0;
5957: return (\%permission,$allowed) unless ($env{'request.course.id'});
5958: if ((&Apache::lonnet::allowed('opa',$env{'request.course.id'})) ||
5959: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
5960: $env{'request.course.sec'}))) {
5961: %permission= (
5962: 'edit' => 1,
5963: 'set' => 1,
5964: 'setoverview' => 1,
5965: 'addmetadata' => 1,
5966: 'ordermetadata' => 1,
5967: 'setrestrictmeta' => 1,
5968: 'newoverview' => 1,
5969: 'setdefaults' => 1,
5970: 'settable' => 1,
5971: 'parameterchangelog' => 1,
5972: 'cleanparameters' => 1,
5973: 'dateshift1' => 1,
5974: 'dateshift2' => 1,
5975: 'helper' => 1,
5976: );
5977: } elsif ((&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) ||
5978: (&Apache::lonnet::allowed('vpa',$env{'request.course.id'}.'/'.
5979: $env{'request.course.sec'}))) {
5980: %permission = (
5981: 'set' => 1,
5982: 'settable' => 1,
5983: 'newoverview' => 1,
5984: 'setoverview' => 1,
5985: 'parameterchangelog' => 1,
5986: );
5987: }
5988: foreach my $perm (values(%permission)) {
5989: if ($perm) { $allowed=1; last; }
5990: }
5991: return (\%permission,$allowed);
5992: }
5993:
1.30 www 5994: sub handler {
1.43 albertel 5995: my $r=shift;
1.30 www 5996:
1.376 albertel 5997: &reset_caches();
5998:
1.414 droeschl 5999: &Apache::loncommon::content_type($r,'text/html');
6000: $r->send_http_header;
6001: return OK if $r->header_only;
6002:
1.193 albertel 6003: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.473 amueller 6004: ['action','state',
1.205 www 6005: 'pres_marker',
6006: 'pres_value',
1.206 www 6007: 'pres_type',
1.506 www 6008: 'filter','part',
1.390 www 6009: 'udom','uname','symb','serial','timebase']);
1.131 www 6010:
1.83 bowersj2 6011:
1.193 albertel 6012: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 6013: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
1.522.2.3 raeburn 6014: text=>"Content and Problem Settings",
1.473 amueller 6015: faq=>10,
6016: bug=>'Instructor Interface',
1.442 droeschl 6017: help =>
6018: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 6019:
1.30 www 6020: # ----------------------------------------------------- Needs to be in a course
1.522.2.19 raeburn 6021: my ($parm_permission,$allowed) = &get_permission();
1.355 albertel 6022: my $exists = &check_for_course_info();
6023:
1.522.2.19 raeburn 6024: if ($env{'request.course.id'} && $allowed && $exists) {
1.193 albertel 6025: #
6026: # Main switch on form.action and form.state, as appropriate
6027: #
6028: # Check first if coming from someone else headed directly for
6029: # the table mode
1.522.2.19 raeburn 6030: if (($parm_permission->{'set'}) &&
6031: ((($env{'form.command'} eq 'set') && ($env{'form.url'})
6032: && (!$env{'form.dis'})) || ($env{'form.symb'}))) {
6033: &assessparms($r,$parm_permission);
1.193 albertel 6034: } elsif (! exists($env{'form.action'})) {
6035: &print_main_menu($r,$parm_permission);
1.522.2.19 raeburn 6036: } elsif (!$parm_permission->{$env{'form.action'}}) {
6037: &print_main_menu($r,$parm_permission);
1.414 droeschl 6038: } elsif ($env{'form.action'} eq 'setoverview') {
1.522.2.19 raeburn 6039: &overview($r,$parm_permission);
6040: } elsif ($env{'form.action'} eq 'addmetadata') {
6041: &addmetafield($r);
6042: } elsif ($env{'form.action'} eq 'ordermetadata') {
6043: &order_meta_fields($r);
1.414 droeschl 6044: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.522.2.19 raeburn 6045: &setrestrictmeta($r);
1.414 droeschl 6046: } elsif ($env{'form.action'} eq 'newoverview') {
1.522.2.19 raeburn 6047: &newoverview($r,$parm_permission);
1.414 droeschl 6048: } elsif ($env{'form.action'} eq 'setdefaults') {
1.522.2.19 raeburn 6049: &defaultsetter($r);
6050: } elsif ($env{'form.action'} eq 'settable') {
6051: &assessparms($r,$parm_permission);
1.414 droeschl 6052: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.522.2.19 raeburn 6053: &parm_change_log($r,$parm_permission);
1.414 droeschl 6054: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.522.2.19 raeburn 6055: &clean_parameters($r);
1.414 droeschl 6056: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 6057: &date_shift_one($r);
1.414 droeschl 6058: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 6059: &date_shift_two($r);
1.446 bisitz 6060: }
1.43 albertel 6061: } else {
1.1 www 6062: # ----------------------------- Not in a course, or not allowed to modify parms
1.473 amueller 6063: if ($exists) {
6064: $env{'user.error.msg'}=
6065: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
6066: } else {
6067: $env{'user.error.msg'}=
6068: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
6069: }
6070: return HTTP_NOT_ACCEPTABLE;
1.43 albertel 6071: }
1.376 albertel 6072: &reset_caches();
6073:
1.43 albertel 6074: return OK;
1.1 www 6075: }
6076:
6077: 1;
6078: __END__
6079:
6080:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>