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