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