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