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