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