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