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