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