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