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