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