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