Annotation of loncom/interface/lonparmset.pm, revision 1.522.2.33
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.522.2.33! raeburn 4: # $Id: lonparmset.pm,v 1.522.2.32 2024/07/06 16:19:42 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:
1.522.2.33! raeburn 2448: # Hide parm selection and possibly table?
! 2449: my ($tablejs,$tabledivsty);
! 2450: if (((($env{'form.uname'} ne '') || ($env{'form.id'} ne '')) && ($uname eq '')) &&
! 2451: ($env{'form.dis'}) && ($pssymb eq '')) {
! 2452: $tablejs = 'document.getElementById('."'parmtable'".').style.display = "";';
! 2453: $tabledivsty = ' style="display:none"';
! 2454: }
1.459 bisitz 2455: $r->print(<<ENDPARMSELSCRIPT);
2456: <script type="text/javascript">
2457: // <![CDATA[
2458: function parmsel_show() {
2459: document.getElementById('parmsel').style.display = "";
2460: document.getElementById('parmsellink').style.display = "none";
1.522.2.33! raeburn 2461: $tablejs
1.459 bisitz 2462: }
2463: // ]]>
2464: </script>
2465: ENDPARMSELSCRIPT
1.474 amueller 2466:
1.445 neumanie 2467: if (!$pssymb) {
1.486 www 2468: my $parmselhiddenstyle=' style="display:none"';
2469: if($env{'form.hideparmsel'} eq 'hidden') {
2470: $r->print('<div id="parmsel"'.$parmselhiddenstyle.'>');
2471: } else {
2472: $r->print('<div id="parmsel">');
2473: }
2474:
1.491 bisitz 2475: # Step 1
1.522.2.2 raeburn 2476: $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'),'parmstep1'));
2477: $r->print('
1.474 amueller 2478: <script type="text/javascript">
1.522.2.2 raeburn 2479: // <![CDATA['.
2480: &showhide_js().'
1.474 amueller 2481: // ]]>
2482: </script>
1.522.2.2 raeburn 2483: ');
2484: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.209 www 2485: &levelmenu($r,\%alllevs,$parmlev);
1.491 bisitz 2486: $r->print(&Apache::lonhtmlcommon::row_closure());
1.522.2.30 raeburn 2487: &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev);
1.491 bisitz 2488: $r->print(&Apache::lonhtmlcommon::row_closure());
2489: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
2490: &partmenu($r,\%allparts,\@psprt);
1.474 amueller 2491: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2492: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2493:
2494: # Step 2
1.522.2.2 raeburn 2495: $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
1.522.2.25 raeburn 2496: &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
1.491 bisitz 2497:
2498: # Step 3
1.522.2.2 raeburn 2499: $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
1.486 www 2500: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.522.2.24 raeburn 2501: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
1.486 www 2502: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2503: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2504:
2505: # Update Display Button
1.486 www 2506: $r->print('<p>'
2507: .'<input type="submit" name="dis"'
1.511 www 2508: .' value="'.&mt('Update Display').'" />'
1.486 www 2509: .'<input type="hidden" name="hideparmsel" value="hidden" />'
2510: .'</p>');
2511: $r->print('</div>');
1.491 bisitz 2512:
1.486 www 2513: # Offer link to display parameter selection again
2514: $r->print('<p id="parmsellink"');
2515: if ($env{'form.hideparmsel'} ne 'hidden') {
2516: $r->print($parmselhiddenstyle);
2517: }
2518: $r->print('>'
2519: .'<a href="javascript:parmsel_show()">'
2520: .&mt('Change Parameter Selection')
2521: .'</a>'
2522: .'</p>');
1.44 albertel 2523: } else {
1.515 raeburn 2524: $r->print();
1.478 amueller 2525: # parameter screen for a single resource.
1.486 www 2526: my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.473 amueller 2527: my $title = &Apache::lonnet::gettitle($pssymb);
1.501 bisitz 2528: $r->print(&mt('Specific Resource: [_1] ([_2])',
2529: $title,'<span class="LC_filename">'.$resource.'</span>').
1.472 amueller 2530: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.486 www 2531: '<br />');
2532: $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));
2533: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.522.2.1 raeburn 2534: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')).
2535: '<label>'.
2536: '<input type="checkbox" name="psprt" value="all"'.
2537: ($env{'form.psprt'}?' checked="checked"':'').' />'.
2538: &mt('Show all parts').
2539: '</label></td></tr>');
1.522.2.24 raeburn 2540: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
1.486 www 2541: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2542: $r->print(&Apache::lonhtmlcommon::end_pick_box());
2543: $r->print('<p>'
1.459 bisitz 2544: .'<input type="submit" name="dis"'
1.511 www 2545: .' value="'.&mt('Update Display').'" />'
1.459 bisitz 2546: .'<input type="hidden" name="hideparmsel" value="hidden" />'
1.486 www 2547: .'</p>');
1.459 bisitz 2548: }
1.478 amueller 2549:
1.486 www 2550: # ----- End Parameter Selection
1.57 albertel 2551:
1.459 bisitz 2552: # Display Messages
2553: $r->print('<div>'.$message.'</div>');
1.210 www 2554:
1.57 albertel 2555:
2556: my @temp_pscat;
2557: map {
2558: my $cat = $_;
2559: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
2560: } @pscat;
2561:
2562: @pscat = @temp_pscat;
2563:
1.209 www 2564: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 2565: # ----------------------------------------------------------------- Start Table
1.57 albertel 2566: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 2567: my $csuname=$env{'user.name'};
2568: my $csudom=$env{'user.domain'};
1.522.2.19 raeburn 2569: my $readonly = 1;
2570: if ($parm_permission->{'edit'}) {
2571: undef($readonly);
2572: }
1.522.2.33! raeburn 2573: $r->print('<div id="parmtable"'.$tabledivsty.'>');
1.57 albertel 2574:
1.203 www 2575: if ($parmlev eq 'full') {
1.506 www 2576: #
2577: # This produces the cascading table output of parameters
2578: #
1.473 amueller 2579: my $coursespan=$csec?8:5;
2580: my $userspan=3;
2581: if ($cgroup ne '') {
2582: $coursespan += 3;
2583: }
2584:
1.517 www 2585: $r->print(&Apache::loncommon::start_data_table());
1.506 www 2586: #
2587: # This produces the headers
2588: #
1.473 amueller 2589: $r->print('<tr><td colspan="5"></td>');
2590: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
2591: if ($uname) {
2592: if (@usersgroups > 1) {
2593: $userspan ++;
2594: }
2595: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
2596: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
2597: }
2598: my %lt=&Apache::lonlocal::texthash(
2599: 'pie' => "Parameter in Effect",
2600: 'csv' => "Current Session Value",
1.472 amueller 2601: 'rl' => "Resource Level",
1.473 amueller 2602: 'ic' => 'in Course',
2603: 'aut' => "Assessment URL and Title",
2604: 'type' => 'Type',
2605: 'emof' => "Enclosing Map or Folder",
2606: 'part' => 'Part',
1.472 amueller 2607: 'pn' => 'Parameter Name',
1.473 amueller 2608: 'def' => 'default',
2609: 'femof' => 'from Enclosing Map or Folder',
2610: 'gen' => 'general',
2611: 'foremf' => 'for Enclosing Map or Folder',
2612: 'fr' => 'for Resource'
2613: );
2614: $r->print(<<ENDTABLETWO);
1.419 bisitz 2615: <th rowspan="3">$lt{'pie'}</th>
1.501 bisitz 2616: <th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>
1.419 bisitz 2617: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
2618: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 2619:
1.10 www 2620: ENDTABLETWO
1.473 amueller 2621: if ($csec) {
2622: $r->print('<th colspan="3">'.
2623: &mt("in Section")." $csec</th>");
2624: }
2625: if ($cgroup) {
1.419 bisitz 2626: $r->print('<th colspan="3">'.
1.472 amueller 2627: &mt("in Group")." $cgroup</th>");
1.473 amueller 2628: }
2629: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 2630: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
2631: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 2632: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
2633: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 2634: ENDTABLEHEADFOUR
1.57 albertel 2635:
1.473 amueller 2636: if ($csec) {
2637: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2638: }
2639:
2640: if ($cgroup) {
2641: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2642: }
2643:
2644: if ($uname) {
2645: if (@usersgroups > 1) {
2646: $r->print('<th>'.&mt('Control by other group?').'</th>');
2647: }
2648: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2649: }
2650:
2651: $r->print('</tr>');
1.506 www 2652: #
2653: # Done with the headers
2654: #
1.473 amueller 2655: my $defbgone='';
2656: my $defbgtwo='';
2657: my $defbgthree = '';
1.57 albertel 2658:
1.473 amueller 2659: foreach (@ids) {
1.57 albertel 2660:
1.473 amueller 2661: my $rid=$_;
1.57 albertel 2662: my ($inmapid)=($rid=~/\.(\d+)$/);
2663:
1.446 bisitz 2664: if ((!$pssymb &&
1.473 amueller 2665: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
2666: ||
2667: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 2668: # ------------------------------------------------------ Entry for one resource
1.473 amueller 2669: if ($defbgone eq '#E0E099') {
2670: $defbgone='#E0E0DD';
1.57 albertel 2671: } else {
1.419 bisitz 2672: $defbgone='#E0E099';
1.57 albertel 2673: }
1.419 bisitz 2674: if ($defbgtwo eq '#FFFF99') {
1.473 amueller 2675: $defbgtwo='#FFFFDD';
1.57 albertel 2676: } else {
1.473 amueller 2677: $defbgtwo='#FFFF99';
1.57 albertel 2678: }
1.419 bisitz 2679: if ($defbgthree eq '#FFBB99') {
2680: $defbgthree='#FFBBDD';
1.269 raeburn 2681: } else {
1.419 bisitz 2682: $defbgthree='#FFBB99';
1.269 raeburn 2683: }
2684:
1.57 albertel 2685: my $thistitle='';
2686: my %name= ();
2687: undef %name;
2688: my %part= ();
2689: my %display=();
2690: my %type= ();
2691: my %default=();
1.196 www 2692: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2693:
1.506 www 2694: my $filter=$env{'form.filter'};
1.210 www 2695: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2696: my $tempkeyp = $_;
2697: if (grep $_ eq $tempkeyp, @catmarker) {
1.506 www 2698: my $parmname=&Apache::lonnet::metadata($uri,$_.'.name');
2699: # We may only want certain parameters listed
2700: if ($filter) {
2701: unless ($filter=~/\Q$parmname\E/) { next; }
2702: }
2703: $name{$_}=$parmname;
1.57 albertel 2704: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1.506 www 2705:
1.433 raeburn 2706: my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
2707: if ($allparms{$name{$_}} ne '') {
2708: my $identifier;
2709: if ($parmdis =~ /(\s*\[Part.*)$/) {
2710: $identifier = $1;
2711: }
2712: $display{$_} = $allparms{$name{$_}}.$identifier;
2713: } else {
2714: $display{$_} = $parmdis;
2715: }
1.57 albertel 2716: unless ($display{$_}) { $display{$_}=''; }
2717: $display{$_}.=' ('.$name{$_}.')';
2718: $default{$_}=&Apache::lonnet::metadata($uri,$_);
2719: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
2720: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
2721: }
2722: }
2723: my $totalparms=scalar keys %name;
2724: if ($totalparms>0) {
1.473 amueller 2725: my $firstrow=1;
2726: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 2727: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 2728: ' rowspan='.$totalparms.
1.419 bisitz 2729: '><tt><font size="-1">'.
1.57 albertel 2730: join(' / ',split(/\//,$uri)).
2731: '</font></tt><p><b>'.
1.154 albertel 2732: "<a href=\"javascript:openWindow('".
1.473 amueller 2733: &Apache::lonnet::clutter($uri).'?symb='.
2734: &escape($symbp{$rid}).
1.336 albertel 2735: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
2736: " target=\"_self\">$title");
1.57 albertel 2737:
2738: if ($thistitle) {
1.473 amueller 2739: $r->print(' ('.$thistitle.')');
1.57 albertel 2740: }
2741: $r->print('</a></b></td>');
1.419 bisitz 2742: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 2743: ' rowspan='.$totalparms.'>'.$typep{$rid}.
2744: '</td>');
2745:
1.419 bisitz 2746: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 2747: ' rowspan='.$totalparms.
1.238 www 2748: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.512 foxr 2749: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 2750:
2751: unless ($firstrow) {
2752: $r->print('<tr>');
2753: } else {
2754: undef $firstrow;
2755: }
1.201 www 2756: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 2757: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 2758: $defbgthree,$parmlev,$uname,$udom,$csec,
1.522.2.19 raeburn 2759: $cgroup,\@usersgroups,$noeditgrp,$readonly);
1.57 albertel 2760: }
2761: }
2762: }
2763: } # end foreach ids
1.43 albertel 2764: # -------------------------------------------------- End entry for one resource
1.517 www 2765: $r->print(&Apache::loncommon::end_data_table);
1.203 www 2766: } # end of full
1.57 albertel 2767: #--------------------------------------------------- Entry for parm level map
2768: if ($parmlev eq 'map') {
1.419 bisitz 2769: my $defbgone = '#E0E099';
2770: my $defbgtwo = '#FFFF99';
2771: my $defbgthree = '#FFBB99';
1.57 albertel 2772:
2773: my %maplist;
2774:
2775: if ($pschp eq 'all') {
1.446 bisitz 2776: %maplist = %allmaps;
1.57 albertel 2777: } else {
2778: %maplist = ($pschp => $mapp{$pschp});
2779: }
2780:
2781: #-------------------------------------------- for each map, gather information
2782: my $mapid;
1.522.2.30 raeburn 2783: foreach $mapid (sort { $a <=> $b } keys(%maplist)) {
1.60 albertel 2784: my $maptitle = $maplist{$mapid};
1.57 albertel 2785:
2786: #----------------------- loop through ids and get all parameter types for map
2787: #----------------------------------------- and associated information
2788: my %name = ();
2789: my %part = ();
2790: my %display = ();
2791: my %type = ();
2792: my %default = ();
2793: my $map = 0;
2794:
1.473 amueller 2795: # $r->print("Catmarker: @catmarker<br />\n");
1.446 bisitz 2796:
1.57 albertel 2797: foreach (@ids) {
1.473 amueller 2798: ($map)=(/([\d]*?)\./);
2799: my $rid = $_;
1.446 bisitz 2800:
1.57 albertel 2801: # $r->print("$mapid:$map: $rid <br /> \n");
2802:
1.473 amueller 2803: if ($map eq $mapid) {
2804: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2805: # $r->print("Keys: $keyp{$rid} <br />\n");
2806:
2807: #--------------------------------------------------------------------
2808: # @catmarker contains list of all possible parameters including part #s
2809: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2810: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2811: # When storing information, store as part 0
2812: # When requesting information, request from full part
2813: #-------------------------------------------------------------------
1.473 amueller 2814: foreach (&keysplit($keyp{$rid})) {
2815: my $tempkeyp = $_;
2816: my $fullkeyp = $tempkeyp;
2817: $tempkeyp =~ s/_\w+_/_0_/;
2818:
2819: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2820: $part{$tempkeyp}="0";
2821: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
2822: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2823: if ($allparms{$name{$tempkeyp}} ne '') {
2824: my $identifier;
2825: if ($parmdis =~ /(\s*\[Part.*)$/) {
2826: $identifier = $1;
2827: }
2828: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2829: } else {
2830: $display{$tempkeyp} = $parmdis;
2831: }
2832: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2833: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
2834: $display{$tempkeyp} =~ s/_\w+_/_0_/;
2835: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2836: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2837: }
2838: } # end loop through keys
2839: }
1.57 albertel 2840: } # end loop through ids
1.446 bisitz 2841:
1.57 albertel 2842: #---------------------------------------------------- print header information
1.133 www 2843: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 2844: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 2845: my $tmp="";
1.57 albertel 2846: if ($uname) {
1.473 amueller 2847: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 2848: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
2849: &mt('in')." \n";
1.57 albertel 2850: } else {
1.401 bisitz 2851: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 2852: }
1.269 raeburn 2853: if ($cgroup) {
1.401 bisitz 2854: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
2855: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2856: $csec = '';
2857: } elsif ($csec) {
1.401 bisitz 2858: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
2859: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2860: }
1.401 bisitz 2861: $r->print('<div align="center"><h4>'
2862: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 2863: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 2864: ,$tmp
2865: ,'<font color="red"><i>'.$coursename.'</i></font>'
2866: )
2867: ."<br /></h4>\n"
1.422 bisitz 2868: );
1.57 albertel 2869: #---------------------------------------------------------------- print table
1.419 bisitz 2870: $r->print('<p>'.&Apache::loncommon::start_data_table()
2871: .&Apache::loncommon::start_data_table_header_row()
2872: .'<th>'.&mt('Parameter Name').'</th>'
2873: .'<th>'.&mt('Default Value').'</th>'
2874: .'<th>'.&mt('Parameter in Effect').'</th>'
2875: .&Apache::loncommon::end_data_table_header_row()
2876: );
1.57 albertel 2877:
1.473 amueller 2878: foreach (&keysinorder(\%name,\%keyorder)) {
2879: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2880: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2881: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1.522.2.19 raeburn 2882: $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
2883: $readonly);
1.57 albertel 2884: }
1.422 bisitz 2885: $r->print(&Apache::loncommon::end_data_table().'</p>'
2886: .'</div>'
2887: );
1.57 albertel 2888: } # end each map
2889: } # end of $parmlev eq map
2890: #--------------------------------- Entry for parm level general (Course level)
2891: if ($parmlev eq 'general') {
1.473 amueller 2892: my $defbgone = '#E0E099';
1.419 bisitz 2893: my $defbgtwo = '#FFFF99';
2894: my $defbgthree = '#FFBB99';
1.57 albertel 2895:
2896: #-------------------------------------------- for each map, gather information
2897: my $mapid="0.0";
2898: #----------------------- loop through ids and get all parameter types for map
2899: #----------------------------------------- and associated information
2900: my %name = ();
2901: my %part = ();
2902: my %display = ();
2903: my %type = ();
2904: my %default = ();
1.446 bisitz 2905:
1.57 albertel 2906: foreach (@ids) {
2907: my $rid = $_;
1.446 bisitz 2908:
1.196 www 2909: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2910:
2911: #--------------------------------------------------------------------
2912: # @catmarker contains list of all possible parameters including part #s
2913: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2914: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2915: # When storing information, store as part 0
2916: # When requesting information, request from full part
2917: #-------------------------------------------------------------------
1.473 amueller 2918: foreach (&keysplit($keyp{$rid})) {
2919: my $tempkeyp = $_;
2920: my $fullkeyp = $tempkeyp;
2921: $tempkeyp =~ s/_\w+_/_0_/;
2922: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2923: $part{$tempkeyp}="0";
2924: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
2925: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2926: if ($allparms{$name{$tempkeyp}} ne '') {
2927: my $identifier;
2928: if ($parmdis =~ /(\s*\[Part.*)$/) {
2929: $identifier = $1;
2930: }
2931: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2932: } else {
2933: $display{$tempkeyp} = $parmdis;
2934: }
2935: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2936: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
2937: $display{$tempkeyp} =~ s/_\w+_/_0_/;
2938: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2939: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2940: }
1.57 albertel 2941: } # end loop through keys
2942: } # end loop through ids
1.446 bisitz 2943:
1.57 albertel 2944: #---------------------------------------------------- print header information
1.473 amueller 2945: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 2946: $r->print(<<ENDMAPONE);
1.419 bisitz 2947: <center>
2948: <h4>$setdef
1.135 albertel 2949: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 2950: ENDMAPONE
2951: if ($uname) {
1.473 amueller 2952: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2953: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2954: } else {
1.135 albertel 2955: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2956: }
1.446 bisitz 2957:
1.135 albertel 2958: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2959: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2960: $r->print("</h4>\n");
1.57 albertel 2961: #---------------------------------------------------------------- print table
1.419 bisitz 2962: $r->print('<p>'.&Apache::loncommon::start_data_table()
2963: .&Apache::loncommon::start_data_table_header_row()
2964: .'<th>'.&mt('Parameter Name').'</th>'
2965: .'<th>'.&mt('Default Value').'</th>'
2966: .'<th>'.&mt('Parameter in Effect').'</th>'
2967: .&Apache::loncommon::end_data_table_header_row()
2968: );
1.57 albertel 2969:
1.473 amueller 2970: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2971: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2972: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.522.2.19 raeburn 2973: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2974: $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
2975: $readonly);
1.57 albertel 2976: }
1.419 bisitz 2977: $r->print(&Apache::loncommon::end_data_table()
2978: .'</p>'
2979: .'</center>'
2980: );
1.57 albertel 2981: } # end of $parmlev eq general
1.522.2.33! raeburn 2982: $r->print('</div>');
1.43 albertel 2983: }
1.507 www 2984: $r->print('</form>');
2985: $r->print(&Apache::loncommon::end_page());
1.57 albertel 2986: } # end sub assessparms
1.30 www 2987:
1.120 www 2988: ##################################################
1.207 www 2989: # Overview mode
2990: ##################################################
1.124 www 2991: my $tableopen;
2992:
2993: sub tablestart {
1.522.2.19 raeburn 2994: my ($readonly) = @_;
1.124 www 2995: if ($tableopen) {
1.522.2.19 raeburn 2996: return '';
1.124 www 2997: } else {
1.522.2.19 raeburn 2998: $tableopen=1;
2999: my $output = &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th>';
3000: if ($readonly) {
3001: $output .= '<th>'.&mt('Current value').'</th>';
3002: } else {
3003: $output .= '<th>'.&mt('Delete').'</th><th>'.&mt('Set to ...').'</th>';
3004: }
3005: $output .= '</tr>';
3006: return $output;
1.124 www 3007: }
3008: }
3009:
3010: sub tableend {
3011: if ($tableopen) {
1.473 amueller 3012: $tableopen=0;
3013: return &Apache::loncommon::end_data_table();
1.124 www 3014: } else {
1.473 amueller 3015: return'';
1.124 www 3016: }
3017: }
3018:
1.207 www 3019: sub readdata {
3020: my ($crs,$dom)=@_;
3021: # Read coursedata
3022: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
3023: # Read userdata
3024:
3025: my $classlist=&Apache::loncoursedata::get_classlist();
3026: foreach (keys %$classlist) {
1.350 albertel 3027: if ($_=~/^($match_username)\:($match_domain)$/) {
1.473 amueller 3028: my ($tuname,$tudom)=($1,$2);
3029: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
1.207 www 3030: foreach my $userkey (keys %{$useropt}) {
1.473 amueller 3031: if ($userkey=~/^$env{'request.course.id'}/) {
1.207 www 3032: my $newkey=$userkey;
1.473 amueller 3033: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
3034: $$resourcedata{$newkey}=$$useropt{$userkey};
3035: }
3036: }
3037: }
1.207 www 3038: }
1.522.2.19 raeburn 3039: if (wantarray) {
3040: return ($resourcedata,$classlist);
3041: } else {
3042: return $resourcedata;
3043: }
1.207 www 3044: }
3045:
3046:
1.124 www 3047: # Setting
1.208 www 3048:
3049: sub storedata {
3050: my ($r,$crs,$dom)=@_;
1.207 www 3051: # Set userlevel immediately
3052: # Do an intermediate store of course level
3053: my $olddata=&readdata($crs,$dom);
1.124 www 3054: my %newdata=();
3055: undef %newdata;
3056: my @deldata=();
3057: undef @deldata;
1.504 raeburn 3058: my ($got_chostname,$chostname,$cmajor,$cminor);
1.522.2.16 raeburn 3059: my $now = time;
1.504 raeburn 3060: foreach my $key (keys(%env)) {
3061: if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
1.473 amueller 3062: my $cmd=$1;
3063: my $thiskey=$2;
3064: my ($tuname,$tudom)=&extractuser($thiskey);
3065: my $tkey=$thiskey;
3066: if ($tuname) {
3067: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
3068: }
3069: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.522.2.16 raeburn 3070: my ($data, $typeof, $text, $name, $valchk);
1.473 amueller 3071: if ($cmd eq 'set') {
1.504 raeburn 3072: $data=$env{$key};
1.522.2.16 raeburn 3073: $valchk = $data;
1.473 amueller 3074: $typeof=$env{'form.typeof_'.$thiskey};
3075: $text = &mt('Saved modified parameter for');
1.504 raeburn 3076: if ($typeof eq 'string_questiontype') {
1.514 raeburn 3077: $name = 'type';
3078: } elsif ($typeof eq 'string_lenient') {
3079: $name = 'lenient';
1.521 raeburn 3080: } elsif ($typeof eq 'string_discussvote') {
3081: $name = 'discussvote';
1.522.2.7 raeburn 3082: } elsif ($typeof eq 'string_examcode') {
3083: $name = 'examcode';
1.522.2.16 raeburn 3084: if (&Apache::lonnet::validCODE($data)) {
3085: $valchk = 'valid';
3086: }
1.519 raeburn 3087: } elsif ($typeof eq 'string_yesno') {
3088: if ($thiskey =~ /\.retrypartial$/) {
3089: $name = 'retrypartial';
3090: }
1.514 raeburn 3091: }
1.522.2.16 raeburn 3092: } elsif ($cmd eq 'datepointer') {
3093: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
3094: $typeof=$env{'form.typeof_'.$thiskey};
3095: $text = &mt('Saved modified date for');
3096: if ($typeof eq 'date_start') {
3097: if ($thiskey =~ /\.printstartdate$/) {
3098: $name = 'printstartdate';
3099: if (($data) && ($data > $now)) {
3100: $valchk = 'future';
1.504 raeburn 3101: }
3102: }
1.522.2.16 raeburn 3103: } elsif ($typeof eq 'date_end') {
3104: if ($thiskey =~ /\.printenddate$/) {
3105: $name = 'printenddate';
3106: if (($data) && ($data < $now)) {
3107: $valchk = 'past';
3108: }
3109: }
3110: }
3111: } elsif ($cmd eq 'dateinterval') {
3112: $data=&get_date_interval_from_form($thiskey);
3113: $typeof=$env{'form.typeof_'.$thiskey};
3114: $text = &mt('Saved modified date for');
3115: }
3116: if ($name ne '') {
3117: my ($needsrelease,$needsnewer);
3118: $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"};
3119: if ($needsrelease) {
3120: unless ($got_chostname) {
3121: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
3122: $got_chostname = 1;
3123: }
3124: $needsnewer = ¶meter_releasecheck($name,$valchk,
3125: $needsrelease,
3126: $cmajor,$cminor);
1.504 raeburn 3127: if ($needsnewer) {
1.514 raeburn 3128: $r->print('<br />'.&oldversion_warning($name,$data,
3129: $chostname,$cmajor,
1.504 raeburn 3130: $cminor,$needsrelease));
3131: next;
3132: }
3133: }
1.473 amueller 3134: }
3135: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 3136: if ($tuname) {
1.473 amueller 3137: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
3138: $tkey.'.type' => $typeof},
3139: $tudom,$tuname) eq 'ok') {
3140: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
3141: $r->print('<br />'.$text.' '.
3142: &Apache::loncommon::plainname($tuname,$tudom));
3143: } else {
3144: $r->print('<div class="LC_error">'.
3145: &mt('Error saving parameters').'</div>');
3146: }
3147: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3148: } else {
3149: $newdata{$thiskey}=$data;
3150: $newdata{$thiskey.'.type'}=$typeof;
1.446 bisitz 3151: }
1.473 amueller 3152: }
3153: } elsif ($cmd eq 'del') {
3154: if ($tuname) {
3155: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
3156: &log_parmset({$tkey=>''},1,$tuname,$tudom);
3157: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
3158: } else {
3159: $r->print('<div class="LC_error">'.
3160: &mt('Error deleting parameters').'</div>');
3161: }
3162: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3163: } else {
3164: push (@deldata,$thiskey,$thiskey.'.type');
3165: }
3166: }
3167: }
1.124 www 3168: }
1.207 www 3169: # Store all course level
1.144 www 3170: my $delentries=$#deldata+1;
3171: my @newdatakeys=keys %newdata;
3172: my $putentries=$#newdatakeys+1;
3173: if ($delentries) {
1.473 amueller 3174: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
3175: my %loghash=map { $_ => '' } @deldata;
3176: &log_parmset(\%loghash,1);
1.522.2.18 raeburn 3177: $r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>');
1.473 amueller 3178: } else {
3179: $r->print('<div class="LC_error">'.
3180: &mt('Error deleting parameters').'</div>');
3181: }
3182: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3183: }
3184: if ($putentries) {
1.473 amueller 3185: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
3186: &log_parmset(\%newdata,0);
1.522.2.17 raeburn 3187: $r->print('<h3>'.&mt('Saved [quant,_1,parameter]',$putentries/2).'</h3>');
1.473 amueller 3188: } else {
3189: $r->print('<div class="LC_error">'.
3190: &mt('Error saving parameters').'</div>');
3191: }
3192: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3193: }
1.208 www 3194: }
1.207 www 3195:
1.208 www 3196: sub extractuser {
3197: my $key=shift;
1.350 albertel 3198: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 3199: }
1.206 www 3200:
1.381 albertel 3201: sub parse_listdata_key {
3202: my ($key,$listdata) = @_;
3203: # split into student/section affected, and
3204: # the realm (folder/resource part and parameter
1.446 bisitz 3205: my ($student,$realm) =
1.473 amueller 3206: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
1.381 albertel 3207: # if course wide student would be undefined
3208: if (!defined($student)) {
1.473 amueller 3209: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.381 albertel 3210: }
3211: # strip off the .type if it's not the Question type parameter
3212: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
1.473 amueller 3213: $realm=~s/\.type//;
1.381 albertel 3214: }
3215: # split into resource+part and parameter name
1.388 albertel 3216: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
3217: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 3218: return ($student,$res,$part,$parm);
3219: }
3220:
1.208 www 3221: sub listdata {
1.522.2.32 raeburn 3222: my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly,$parmlev)=@_;
1.207 www 3223: # Start list output
1.206 www 3224:
1.122 www 3225: my $oldsection='';
3226: my $oldrealm='';
3227: my $oldpart='';
1.123 www 3228: my $pointer=0;
1.124 www 3229: $tableopen=0;
1.145 www 3230: my $foundkeys=0;
1.248 albertel 3231: my %keyorder=&standardkeyorder();
1.522.2.27 raeburn 3232: my $readonlyall = $readonly;
1.381 albertel 3233:
1.522.2.24 raeburn 3234: my ($secidx,%grouphash);
3235: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3236: $secidx = &Apache::loncoursedata::CL_SECTION();
3237: if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
3238: %grouphash = &Apache::longroup::coursegroups();
3239: } elsif ($env{'request.course.groups'} ne '') {
3240: map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
3241: }
3242: }
3243:
1.214 www 3244: foreach my $thiskey (sort {
1.473 amueller 3245: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
3246: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
1.381 albertel 3247:
1.473 amueller 3248: # get the numerical order for the param
3249: $aparm=$keyorder{'parameter_0_'.$aparm};
3250: $bparm=$keyorder{'parameter_0_'.$bparm};
1.381 albertel 3251:
1.473 amueller 3252: my $result=0;
1.381 albertel 3253:
1.473 amueller 3254: if ($sortorder eq 'realmstudent') {
1.381 albertel 3255: if ($ares ne $bres ) {
1.473 amueller 3256: $result = ($ares cmp $bres);
1.446 bisitz 3257: } elsif ($astudent ne $bstudent) {
1.473 amueller 3258: $result = ($astudent cmp $bstudent);
3259: } elsif ($apart ne $bpart ) {
3260: $result = ($apart cmp $bpart);
3261: }
3262: } else {
3263: if ($astudent ne $bstudent) {
3264: $result = ($astudent cmp $bstudent);
3265: } elsif ($ares ne $bres ) {
3266: $result = ($ares cmp $bres);
3267: } elsif ($apart ne $bpart ) {
3268: $result = ($apart cmp $bpart);
3269: }
3270: }
1.446 bisitz 3271:
1.473 amueller 3272: if (!$result) {
1.381 albertel 3273: if (defined($aparm) && defined($bparm)) {
1.473 amueller 3274: $result = ($aparm <=> $bparm);
1.381 albertel 3275: } elsif (defined($aparm)) {
1.473 amueller 3276: $result = -1;
1.381 albertel 3277: } elsif (defined($bparm)) {
1.473 amueller 3278: $result = 1;
3279: }
3280: }
1.381 albertel 3281:
1.473 amueller 3282: $result;
1.214 www 3283: } keys %{$listdata}) {
1.381 albertel 3284:
1.473 amueller 3285: if ($$listdata{$thiskey.'.type'}) {
1.522.2.24 raeburn 3286: my $thistype=$$listdata{$thiskey.'.type'};
3287: if ($$resourcedata{$thiskey.'.type'}) {
3288: $thistype=$$resourcedata{$thiskey.'.type'};
1.473 amueller 3289: }
3290: my ($middle,$part,$name)=
3291: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3292: my $section=&mt('All Students');
1.522.2.27 raeburn 3293: $readonly = $readonlyall;
1.522.2.28 raeburn 3294: my $userscope;
3295: my $showval = $$resourcedata{$thiskey};
1.473 amueller 3296: if ($middle=~/^\[(.*)\]/) {
1.522.2.24 raeburn 3297: my $issection=$1;
3298: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
3299: my ($stuname,$studom) = ($1,$2);
3300: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3301: if (ref($classlist) eq 'HASH') {
3302: if (ref($classlist->{$stuname.':'.$studom}) eq 'ARRAY') {
3303: next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'});
3304: }
3305: }
3306: }
3307: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
1.522.2.28 raeburn 3308: $userscope = 1;
1.522.2.24 raeburn 3309: } else {
3310: if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3311: if (exists($grouphash{$issection})) {
3312: $section=&mt('Group').': '.$issection;
3313: } elsif ($issection eq $env{'request.course.sec'}) {
3314: $section = &mt('Section').': '.$issection;
3315: } else {
3316: next;
3317: }
3318: } else {
3319: $section=&mt('Group/Section').': '.$issection;
3320: }
3321: }
3322: $middle=~s/^\[(.*)\]//;
3323: } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
3324: $readonly = 1;
1.473 amueller 3325: }
3326: $middle=~s/\.+$//;
3327: $middle=~s/^\.+//;
3328: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.522.2.24 raeburn 3329:
1.473 amueller 3330: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3331: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
3332: } elsif ($middle) {
3333: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.522.2.30 raeburn 3334: next if (($url =~ /\.(page|sequence)$/) && ($parmlev eq 'full') && ($caller eq 'newoverview'));
1.473 amueller 3335: $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>';
3336: }
3337: if ($sortorder eq 'realmstudent') {
3338: if ($realm ne $oldrealm) {
3339: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3340: $oldrealm=$realm;
3341: $oldsection='';
3342: }
3343: if ($section ne $oldsection) {
3344: $r->print(&tableend()."\n<h2>$section</h2>");
3345: $oldsection=$section;
3346: $oldpart='';
3347: }
3348: } else {
3349: if ($section ne $oldsection) {
3350: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3351: $oldsection=$section;
3352: $oldrealm='';
3353: }
3354: if ($realm ne $oldrealm) {
3355: $r->print(&tableend()."\n<h2>$realm</h2>");
3356: $oldrealm=$realm;
3357: $oldpart='';
3358: }
3359: }
3360: if ($part ne $oldpart) {
3361: $r->print(&tableend().
3362: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
3363: $oldpart=$part;
3364: }
1.123 www 3365: #
3366: # Ready to print
3367: #
1.470 raeburn 3368: my $parmitem = &standard_parameter_names($name);
1.522.2.19 raeburn 3369: $r->print(&tablestart($readonly).
1.473 amueller 3370: &Apache::loncommon::start_data_table_row().
3371: '<td><b>'.&mt($parmitem).
1.522.2.19 raeburn 3372: '</b></td>');
3373: unless ($readonly) {
1.522.2.28 raeburn 3374: my $disabled;
3375: if (($name eq 'availablestudent') &&
3376: (($showval eq '') || ($userscope))) {
3377: $disabled = ' disabled="disabled"';
3378: }
1.522.2.19 raeburn 3379: $r->print('<td><input type="checkbox" name="del_'.
1.522.2.28 raeburn 3380: $thiskey.'"'.$disabled.' /></td>');
1.522.2.19 raeburn 3381: }
3382: $r->print('<td>');
1.473 amueller 3383: $foundkeys++;
3384: if (&isdateparm($thistype)) {
1.522.2.19 raeburn 3385: my $jskey='key_'.$pointer;
3386: my $state;
3387: $pointer++;
3388: if ($readonly) {
3389: $state = 'disabled';
3390: }
3391: $r->print(
3392: &Apache::lonhtmlcommon::date_setter('parmform',
3393: $jskey,
3394: $$resourcedata{$thiskey},
3395: '',1,$state));
3396: unless ($readonly) {
3397: $r->print(
1.277 www 3398: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3399: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3400: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3401: &date_sanity_info($$resourcedata{$thiskey})
1.473 amueller 3402: );
1.522.2.19 raeburn 3403: }
1.473 amueller 3404: } elsif ($thistype eq 'date_interval') {
1.522.2.19 raeburn 3405: $r->print(&date_interval_selector($thiskey,
3406: $$resourcedata{$thiskey},$readonly));
1.473 amueller 3407: } elsif ($thistype =~ m/^string/) {
1.522.2.28 raeburn 3408: if ($name eq 'availablestudent') {
3409: $readonly = 1;
3410: }
1.522.2.19 raeburn 3411: $r->print(&string_selector($thistype,$thiskey,
3412: $$resourcedata{$thiskey},$name,$readonly));
1.473 amueller 3413: } else {
1.522.2.19 raeburn 3414: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
1.473 amueller 3415: }
1.522.2.19 raeburn 3416: unless ($readonly) {
3417: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
3418: $thistype.'" />');
1.522.2.20 raeburn 3419: }
1.473 amueller 3420: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
3421: }
1.121 www 3422: }
1.208 www 3423: return $foundkeys;
3424: }
3425:
1.385 albertel 3426:
3427: sub date_interval_selector {
1.522.2.19 raeburn 3428: my ($thiskey, $showval, $readonly) = @_;
1.385 albertel 3429: my $result;
1.522.2.30 raeburn 3430: my $currval = $showval;
1.385 albertel 3431: foreach my $which (['days', 86400, 31],
1.473 amueller 3432: ['hours', 3600, 23],
3433: ['minutes', 60, 59],
3434: ['seconds', 1, 59]) {
1.522.2.30 raeburn 3435: my ($name, $factor, $max) = @{ $which };
3436: my $amount = int($showval/$factor);
3437: $showval %= $factor;
3438: my %select = ((map {$_ => $_} (0..$max)),
3439: 'select_form_order' => [0..$max]);
3440: if ($currval eq '') {
3441: unshift(@{$select{'select_form_order'}},'');
3442: $select{''} = '';
3443: $amount = '';
3444: }
3445: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
3446: \%select,'',$readonly);
3447: $result .= ' '.&mt($name);
1.385 albertel 3448: }
1.522.2.19 raeburn 3449: unless ($readonly) {
3450: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3451: }
1.385 albertel 3452: return $result;
3453:
3454: }
3455:
3456: sub get_date_interval_from_form {
3457: my ($key) = @_;
3458: my $seconds = 0;
1.522.2.30 raeburn 3459: my $numnotnull = 0;
1.385 albertel 3460: foreach my $which (['days', 86400],
1.473 amueller 3461: ['hours', 3600],
3462: ['minutes', 60],
3463: ['seconds', 1]) {
1.522.2.30 raeburn 3464: my ($name, $factor) = @{ $which };
3465: if (defined($env{'form.'.$name.'_'.$key})) {
3466: unless ($env{'form.'.$name.'_'.$key} eq '') {
3467: $numnotnull ++;
3468: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3469: }
3470: }
1.385 albertel 3471: }
1.522.2.30 raeburn 3472: return if (!$numnotnull);
1.385 albertel 3473: return $seconds;
3474: }
3475:
3476:
1.383 albertel 3477: sub default_selector {
1.522.2.19 raeburn 3478: my ($thiskey, $showval, $readonly) = @_;
3479: my $disabled;
3480: if ($readonly) {
3481: $disabled = ' disabled="disabled"';
3482: }
3483: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'"'.$disabled.' />';
1.383 albertel 3484: }
3485:
1.446 bisitz 3486: my %strings =
1.383 albertel 3487: (
3488: 'string_yesno'
3489: => [[ 'yes', 'Yes' ],
1.473 amueller 3490: [ 'no', 'No' ]],
1.383 albertel 3491: 'string_problemstatus'
3492: => [[ 'yes', 'Yes' ],
1.473 amueller 3493: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
3494: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3495: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
1.504 raeburn 3496: 'string_questiontype'
3497: => [[ 'problem', 'Standard Problem'],
3498: [ 'survey', 'Survey'],
3499: [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'],
3500: [ 'exam', 'Exam'],
3501: [ 'anonsurvey', 'Anonymous Survey'],
3502: [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'],
3503: [ 'practice', 'Practice'],
3504: [ 'surveycred', 'Survey (credit for submission)']],
1.514 raeburn 3505: 'string_lenient'
3506: => [['yes', 'Yes' ],
3507: [ 'no', 'No' ],
1.521 raeburn 3508: [ 'default', 'Default - only bubblesheet grading is lenient' ]],
3509: 'string_discussvote'
3510: => [['yes','Yes'],
3511: ['notended','Yes, unless discussion ended'],
3512: ['no','No']],
1.383 albertel 3513: );
3514:
1.505 raeburn 3515: sub standard_string_options {
3516: my ($string_type) = @_;
3517: if (ref($strings{$string_type}) eq 'ARRAY') {
3518: return $strings{$string_type};
3519: }
3520: return;
3521: }
1.383 albertel 3522:
3523: sub string_selector {
1.522.2.19 raeburn 3524: my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
1.446 bisitz 3525:
1.383 albertel 3526: if (!exists($strings{$thistype})) {
1.522.2.19 raeburn 3527: return &default_selector($thiskey,$showval,$readonly);
1.383 albertel 3528: }
3529:
1.504 raeburn 3530: my %skiptype;
1.514 raeburn 3531: if (($thistype eq 'string_questiontype') ||
1.519 raeburn 3532: ($thistype eq 'string_lenient') ||
1.521 raeburn 3533: ($thistype eq 'string_discussvote') ||
1.519 raeburn 3534: ($name eq 'retrypartial')) {
1.504 raeburn 3535: my ($got_chostname,$chostname,$cmajor,$cminor);
3536: foreach my $possibilities (@{ $strings{$thistype} }) {
3537: next unless (ref($possibilities) eq 'ARRAY');
1.514 raeburn 3538: my ($parmval, $description) = @{ $possibilities };
3539: my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"};
1.504 raeburn 3540: if ($needsrelease) {
3541: unless ($got_chostname) {
1.514 raeburn 3542: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
1.504 raeburn 3543: $got_chostname = 1;
3544: }
1.514 raeburn 3545: my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease,
1.522.2.14 raeburn 3546: $cmajor,$cminor);
1.504 raeburn 3547: if ($needsnewer) {
1.514 raeburn 3548: $skiptype{$parmval} = 1;
1.504 raeburn 3549: }
3550: }
3551: }
3552: }
1.522.2.19 raeburn 3553:
3554: my ($result,$disabled);
1.504 raeburn 3555:
1.522.2.19 raeburn 3556: if ($readonly) {
3557: $disabled = ' disabled="disabled"';
3558: }
1.504 raeburn 3559: my $numinrow = 3;
3560: if ($thistype eq 'string_problemstatus') {
3561: $numinrow = 2;
3562: } elsif ($thistype eq 'string_questiontype') {
3563: if (keys(%skiptype) > 0) {
3564: $numinrow = 4;
3565: }
3566: }
3567: my $rem;
3568: if (ref($strings{$thistype}) eq 'ARRAY') {
3569: my $i=0;
3570: foreach my $possibilities (@{ $strings{$thistype} }) {
3571: next unless (ref($possibilities) eq 'ARRAY');
3572: my ($name, $description) = @{ $possibilities };
3573: next if ($skiptype{$name});
3574: $rem = $i%($numinrow);
3575: if ($rem == 0) {
3576: if ($i > 0) {
3577: $result .= '</tr>';
3578: }
3579: $result .= '<tr>';
3580: }
3581: $result .= '<td class="LC_left_item">'.
3582: '<span class="LC_nobreak"><label>'.
3583: '<input type="radio" name="set_'.$thiskey.
1.522.2.19 raeburn 3584: '" value="'.$name.'"'.$disabled;
1.504 raeburn 3585: if ($showval eq $name) {
3586: $result .= ' checked="checked"';
3587: }
3588: $result .= ' />'.&mt($description).'</label></span></td>';
3589: $i++;
3590: }
3591: $rem = @{ $strings{$thistype} }%($numinrow);
3592: my $colsleft = $numinrow - $rem;
3593: if ($colsleft > 1 ) {
3594: $result .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3595: ' </td>';
3596: } elsif ($colsleft == 1) {
3597: $result .= '<td class="LC_left_item"> </td>';
3598: }
3599: $result .= '</tr>';
1.473 amueller 3600: }
1.504 raeburn 3601: if ($result) {
3602: $result = '<table border="0">'.$result.'</table>';
1.383 albertel 3603: }
3604: return $result;
3605: }
3606:
1.389 www 3607: #
3608: # Shift all start and end dates by $shift
3609: #
3610:
3611: sub dateshift {
1.522.2.27 raeburn 3612: my ($shift,$numchanges)=@_;
1.389 www 3613: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3614: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 3615: my $sec = $env{'request.course.sec'};
3616: my $secgrpregex;
3617: if ($sec ne '') {
3618: my @groups;
3619: if ($env{'request.course.groups'} ne '') {
3620: @groups = split(/:/,$env{'request.course.groups'});
3621: }
3622: if (@groups) {
3623: $secgrpregex = '(?:'.join('|',($sec,@groups)).')';
3624: } else {
3625: $secgrpregex = $sec;
3626: }
3627: }
1.389 www 3628: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3629: # ugly retro fix for broken version of types
3630: foreach my $key (keys %data) {
3631: if ($key=~/\wtype$/) {
3632: my $newkey=$key;
3633: $newkey=~s/type$/\.type/;
3634: $data{$newkey}=$data{$key};
3635: delete $data{$key};
3636: }
3637: }
1.391 www 3638: my %storecontent=();
1.389 www 3639: # go through all parameters and look for dates
3640: foreach my $key (keys %data) {
3641: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
1.522.2.27 raeburn 3642: if ($sec ne '') {
3643: next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./);
3644: }
1.389 www 3645: my $newdate=$data{$key}+$shift;
1.522.2.27 raeburn 3646: $$numchanges ++;
1.391 www 3647: $storecontent{$key}=$newdate;
1.389 www 3648: }
3649: }
1.391 www 3650: my $reply=&Apache::lonnet::cput
3651: ('resourcedata',\%storecontent,$dom,$crs);
3652: if ($reply eq 'ok') {
3653: &log_parmset(\%storecontent);
3654: }
3655: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3656: return $reply;
1.389 www 3657: }
3658:
1.208 www 3659: sub newoverview {
1.522.2.19 raeburn 3660: my ($r,$parm_permission) = @_;
1.280 albertel 3661:
1.208 www 3662: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3663: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.19 raeburn 3664: my $readonly = 1;
3665: if ($parm_permission->{'edit'}) {
3666: undef($readonly);
3667: }
1.414 droeschl 3668: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 3669: text=>"Overview Mode"});
1.522.2.2 raeburn 3670:
3671: my %loaditems = (
3672: 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1');",
3673: );
3674: my $js = '
3675: <script type="text/javascript">
3676: // <![CDATA[
3677: '.
3678: &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n".
3679: &showhide_js()."\n".
3680: '// ]]>
3681: </script>
3682: ';
3683: my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
3684: {'add_entries' => \%loaditems,});
1.298 albertel 3685: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 3686: $r->print($start_page.$breadcrumbs);
1.208 www 3687: $r->print(<<ENDOVER);
1.232 albertel 3688: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3689: ENDOVER
1.211 www 3690: my @ids=();
3691: my %typep=();
3692: my %keyp=();
3693: my %allparms=();
3694: my %allparts=();
3695: my %allmaps=();
3696: my %mapp=();
3697: my %symbp=();
3698: my %maptitles=();
3699: my %uris=();
3700: my %keyorder=&standardkeyorder();
3701: my %defkeytype=();
3702:
3703: my %alllevs=();
3704: $alllevs{'Resource Level'}='full';
1.215 www 3705: $alllevs{'Map/Folder Level'}='map';
1.211 www 3706: $alllevs{'Course Level'}='general';
3707:
3708: my $csec=$env{'form.csec'};
1.269 raeburn 3709: my $cgroup=$env{'form.cgroup'};
1.211 www 3710:
3711: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3712: my $pschp=$env{'form.pschp'};
1.506 www 3713:
1.211 www 3714: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.522.2.1 raeburn 3715: if (!@psprt) { $psprt[0]='0'; }
1.211 www 3716:
1.446 bisitz 3717: my @selected_sections =
1.473 amueller 3718: &Apache::loncommon::get_env_multiple('form.Section');
1.211 www 3719: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3720: foreach my $sec (@selected_sections) {
3721: if ($sec eq 'all') {
1.211 www 3722: @selected_sections = ('all');
3723: }
3724: }
1.522.2.24 raeburn 3725: if ($env{'request.course.sec'} ne '') {
3726: @selected_sections = ($env{'request.course.sec'});
3727: }
1.269 raeburn 3728: my @selected_groups =
3729: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3730:
3731: my $pssymb='';
3732: my $parmlev='';
1.446 bisitz 3733:
1.211 www 3734: unless ($env{'form.parmlev'}) {
3735: $parmlev = 'map';
3736: } else {
3737: $parmlev = $env{'form.parmlev'};
3738: }
3739:
1.446 bisitz 3740: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 3741: \%mapp, \%symbp,\%maptitles,\%uris,
3742: \%keyorder,\%defkeytype);
1.211 www 3743:
1.374 albertel 3744: if (grep {$_ eq 'all'} (@psprt)) {
1.481 amueller 3745: @psprt = keys(%allparts);
1.374 albertel 3746: }
1.211 www 3747: # Menu to select levels, etc
3748:
1.456 bisitz 3749: $r->print('<div class="LC_Box">');
1.445 neumanie 3750: #$r->print('<h2 class="LC_hcell">Step 1</h2>');
1.452 bisitz 3751: $r->print('<div>');
1.522.2.2 raeburn 3752: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.211 www 3753: &levelmenu($r,\%alllevs,$parmlev);
1.522.2.30 raeburn 3754: $r->print(&Apache::lonhtmlcommon::row_closure());
3755: &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev);
1.447 bisitz 3756: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 3757: $r->print(&Apache::lonhtmlcommon::end_pick_box());
3758: $r->print('</div></div>');
1.446 bisitz 3759:
1.456 bisitz 3760: $r->print('<div class="LC_Box">');
1.452 bisitz 3761: $r->print('<div>');
1.510 www 3762: &displaymenu($r,\%allparms,\@pscat,\%keyorder);
1.453 schualex 3763: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.446 bisitz 3764: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
1.522.2.24 raeburn 3765: my $sectionselector = §ionmenu(\@selected_sections);
3766: my $groupselector = &groupmenu(\@selected_groups);
1.481 amueller 3767: $r->print('<table>'.
1.522.2.24 raeburn 3768: '<tr><th>'.&mt('Parts').'</th>');
3769: if ($sectionselector) {
3770: $r->print('<th>'.&mt('Section(s)').'</th>');
3771: }
3772: if ($groupselector) {
3773: $r->print('<th>'.&mt('Group(s)').'</th>');
3774: }
3775: $r->print('</tr><tr><td>');
1.211 www 3776: &partmenu($r,\%allparts,\@psprt);
1.522.2.24 raeburn 3777: $r->print('</td>');
3778: if ($sectionselector) {
3779: $r->print('<td>'.$sectionselector.'</td>');
3780: }
3781: if ($groupselector) {
3782: $r->print('<td>'.$groupselector.'</td>');
3783: }
3784: $r->print('</tr></table>');
1.447 bisitz 3785: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 3786: $r->print(&Apache::lonhtmlcommon::end_pick_box());
3787: $r->print('</div></div>');
3788:
1.456 bisitz 3789: $r->print('<div class="LC_Box">');
1.452 bisitz 3790: $r->print('<div>');
1.214 www 3791: my $sortorder=$env{'form.sortorder'};
3792: unless ($sortorder) { $sortorder='realmstudent'; }
3793: &sortmenu($r,$sortorder);
1.445 neumanie 3794: $r->print('</div></div>');
1.446 bisitz 3795:
1.214 www 3796: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.446 bisitz 3797:
1.211 www 3798: # Build the list data hash from the specified parms
3799:
3800: my $listdata;
3801: %{$listdata}=();
3802:
3803: foreach my $cat (@pscat) {
1.269 raeburn 3804: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3805: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3806: }
3807:
1.212 www 3808: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3809:
1.481 amueller 3810: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3811:
3812: # Read modified data
3813:
1.481 amueller 3814: my $resourcedata=&readdata($crs,$dom);
1.211 www 3815:
3816: # List data
3817:
1.522.2.32 raeburn 3818: &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly,$parmlev);
1.522.2.19 raeburn 3819: }
3820: $r->print(&tableend());
3821: unless ($readonly) {
3822: $r->print(((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':''));
1.211 www 3823: }
1.522.2.19 raeburn 3824: $r->print('</form>');
1.507 www 3825: $r->print(&Apache::loncommon::end_page());
1.208 www 3826: }
3827:
1.269 raeburn 3828: sub secgroup_lister {
3829: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3830: foreach my $item (@{$selections}) {
3831: foreach my $part (@{$psprt}) {
3832: my $rootparmkey=$env{'request.course.id'};
3833: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3834: $rootparmkey.='.['.$item.']';
3835: }
3836: if ($parmlev eq 'general') {
3837: # course-level parameter
3838: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3839: $$listdata{$newparmkey}=1;
3840: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3841: } elsif ($parmlev eq 'map') {
3842: # map-level parameter
3843: foreach my $mapid (keys %{$allmaps}) {
3844: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3845: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3846: $$listdata{$newparmkey}=1;
3847: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3848: }
3849: } else {
3850: # resource-level parameter
3851: foreach my $rid (@{$ids}) {
3852: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3853: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3854: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3855: $$listdata{$newparmkey}=1;
3856: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3857: }
3858: }
3859: }
3860: }
3861: }
3862:
1.208 www 3863: sub overview {
1.522.2.19 raeburn 3864: my ($r,$parm_permission) = @_;
1.208 www 3865: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3866: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.19 raeburn 3867: my $readonly = 1;
3868: if ($parm_permission->{'edit'}) {
3869: undef($readonly);
3870: }
1.414 droeschl 3871: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 3872: text=>"Overview Mode"});
1.280 albertel 3873: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3874: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 3875: $r->print($start_page.$breadcrumbs);
3876: $r->print('<form method="post" action="/adm/parmset?action=setoverview" name="parmform">');
3877:
1.208 www 3878: # Store modified
1.522.2.19 raeburn 3879: unless ($readonly) {
3880: &storedata($r,$crs,$dom);
3881: }
1.208 www 3882:
3883: # Read modified data
3884:
1.522.2.19 raeburn 3885: my ($resourcedata,$classlist)=&readdata($crs,$dom);
1.208 www 3886:
1.214 www 3887:
3888: my $sortorder=$env{'form.sortorder'};
3889: unless ($sortorder) { $sortorder='realmstudent'; }
3890: &sortmenu($r,$sortorder);
3891:
1.522.2.19 raeburn 3892: my $submitbutton = '<input type="submit" value="'.&mt('Save').'" />';
3893:
3894: if ($readonly) {
3895: $r->print('<p>'.$submitbutton.'</p>');
3896: }
3897:
3898:
1.208 www 3899: # List data
3900:
1.522.2.19 raeburn 3901: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist,$readonly);
1.208 www 3902:
1.522.2.19 raeburn 3903: $r->print(&tableend().'<p>');
3904: if ($foundkeys) {
3905: unless ($readonly) {
3906: $r->print('<p>'.$submitbutton.'</p>');
3907: }
3908: } else {
3909: $r->print('<p class="LC_info">'.&mt('There are no parameters.').'</p>');
3910: }
3911: $r->print('</form>'.&Apache::loncommon::end_page());
1.120 www 3912: }
1.121 www 3913:
1.333 albertel 3914: sub clean_parameters {
3915: my ($r) = @_;
3916: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3917: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3918:
1.414 droeschl 3919: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
1.473 amueller 3920: text=>"Clean Parameters"});
1.333 albertel 3921: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3922: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3923: $r->print(<<ENDOVER);
3924: $start_page
3925: $breadcrumbs
3926: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3927: ENDOVER
3928: # Store modified
3929:
3930: &storedata($r,$crs,$dom);
3931:
3932: # Read modified data
3933:
3934: my $resourcedata=&readdata($crs,$dom);
3935:
3936: # List data
3937:
3938: $r->print('<h3>'.
1.473 amueller 3939: &mt('These parameters refer to resources that do not exist.').
3940: '</h3>'.
3941: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
3942: '<br />');
1.333 albertel 3943: $r->print(&Apache::loncommon::start_data_table().
1.473 amueller 3944: '<tr>'.
3945: '<th>'.&mt('Delete').'</th>'.
3946: '<th>'.&mt('Parameter').'</th>'.
3947: '</tr>');
1.333 albertel 3948: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
1.473 amueller 3949: next if (!exists($resourcedata->{$thiskey.'.type'})
3950: && $thiskey=~/\.type$/);
3951: my %data = &parse_key($thiskey);
3952: if (1) { #exists($data{'realm_exists'})
3953: #&& !$data{'realm_exists'}) {
3954: $r->print(&Apache::loncommon::start_data_table_row().
3955: '<tr>'.
3956: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3957:
3958: $r->print('<td>');
3959: my $display_value = $resourcedata->{$thiskey};
3960: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3961: $display_value =
3962: &Apache::lonlocal::locallocaltime($display_value);
3963: }
1.470 raeburn 3964: my $parmitem = &standard_parameter_names($data{'parameter_name'});
3965: $parmitem = &mt($parmitem);
1.473 amueller 3966: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3967: $parmitem,$resourcedata->{$thiskey}));
3968: $r->print('<br />');
3969: if ($data{'scope_type'} eq 'all') {
3970: $r->print(&mt('All users'));
3971: } elsif ($data{'scope_type'} eq 'user') {
3972: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
1.522.2.25 raeburn 3973: } elsif ($data{'scope_type'} eq 'secgroup') {
3974: $r->print(&mt('Group/Section: [_1]',$data{'scope'}));
1.473 amueller 3975: }
3976: $r->print('<br />');
3977: if ($data{'realm_type'} eq 'all') {
3978: $r->print(&mt('All Resources'));
3979: } elsif ($data{'realm_type'} eq 'folder') {
3980: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3981: } elsif ($data{'realm_type'} eq 'symb') {
3982: my ($map,$resid,$url) =
3983: &Apache::lonnet::decode_symb($data{'realm'});
1.522.2.5 raeburn 3984: $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
3985: $url.' <br /> ',
3986: $resid.' <br /> ',$map));
1.473 amueller 3987: }
3988: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
3989: $r->print('</td></tr>');
1.446 bisitz 3990:
1.473 amueller 3991: }
1.333 albertel 3992: }
3993: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.473 amueller 3994: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.507 www 3995: '</p></form>');
3996: $r->print(&Apache::loncommon::end_page());
1.333 albertel 3997: }
3998:
1.390 www 3999: sub date_shift_one {
4000: my ($r) = @_;
4001: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4002: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4003: my $sec = $env{'request.course.sec'};
1.414 droeschl 4004: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 4005: text=>"Shifting Dates"});
1.522.2.27 raeburn 4006: my $submit_text = &mt('Shift all dates accordingly');
4007: if ($sec ne '') {
4008: my @groups;
4009: if ($env{'request.course.groups'} ne '') {
4010: @groups = split(/:/,$env{'request.course.groups'});
4011: }
4012: if (@groups) {
4013: $submit_text = &mt("Shift dates set just for your section/group(s), accordingly");
4014: } else {
4015: $submit_text = &mt("Shift dates set just for your section, accordingly");
4016: }
4017: }
1.390 www 4018: my $start_page=&Apache::loncommon::start_page('Shift Dates');
4019: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 4020: $r->print($start_page.$breadcrumbs);
1.522.2.8 raeburn 4021: $r->print('<form name="shiftform" method="post" action="">'.
1.390 www 4022: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
4023: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
4024: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
1.522.2.10 raeburn 4025: &Apache::lonhtmlcommon::date_setter('shiftform',
1.390 www 4026: 'timeshifted',
4027: $env{'form.timebase'},,
4028: '').
4029: '</td></tr></table>'.
4030: '<input type="hidden" name="action" value="dateshift2" />'.
4031: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
1.522.2.27 raeburn 4032: '<input type="submit" value="'.$submit_text.'" /></form>');
1.390 www 4033: $r->print(&Apache::loncommon::end_page());
4034: }
4035:
4036: sub date_shift_two {
4037: my ($r) = @_;
4038: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4039: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.522.2.27 raeburn 4040: my $sec = $env{'request.course.sec'};
1.414 droeschl 4041: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 4042: text=>"Shifting Dates"});
1.390 www 4043: my $start_page=&Apache::loncommon::start_page('Shift Dates');
4044: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 4045: $r->print($start_page.$breadcrumbs);
1.390 www 4046: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
1.522.2.27 raeburn 4047: $r->print('<h2>'.&mt('Shift Dates').'</h2>');
4048: if ($sec ne '') {
4049: my @groups;
4050: if ($env{'request.course.groups'} ne '') {
4051: @groups = split(/:/,$env{'request.course.groups'});
4052: }
4053: if (@groups) {
4054: $r->print('<p>'.
4055: &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]",
4056: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4057: &Apache::lonlocal::locallocaltime($timeshifted)).
4058: '</p>');
4059: } else {
4060: $r->print('<p>'.
4061: &mt("Shift dates set just for your section, such that [_1] becomes [_2]",
4062: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4063: &Apache::lonlocal::locallocaltime($timeshifted)).
4064: '</p>');
4065: }
4066: } else {
4067: $r->print('<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
4068: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
4069: &Apache::lonlocal::locallocaltime($timeshifted)).
4070: '</p>');
4071: }
1.390 www 4072: my $delta=$timeshifted-$env{'form.timebase'};
1.522.2.27 raeburn 4073: my $numchanges = 0;
4074: my $result = &dateshift($delta,\$numchanges);
4075: if ($result eq 'ok') {
4076: $r->print(
4077: &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]',
4078: $numchanges)));
4079: } elsif ($result eq 'con_delayed') {
4080: $r->print(
4081: &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]',
4082: $numchanges)));
4083: } else {
4084: $r->print(
4085: &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1));
4086: }
1.522.2.13 raeburn 4087: $r->print(
4088: '<br /><br />'.
4089: &Apache::lonhtmlcommon::actionbox(
4090: ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));
1.390 www 4091: $r->print(&Apache::loncommon::end_page());
4092: }
4093:
1.333 albertel 4094: sub parse_key {
4095: my ($key) = @_;
4096: my %data;
4097: my ($middle,$part,$name)=
1.473 amueller 4098: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.333 albertel 4099: $data{'scope_type'} = 'all';
4100: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4101: $data{'scope'} = $1;
4102: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
4103: $data{'scope_type'} = 'user';
4104: $data{'scope'} = [$1,$2];
4105: } else {
1.522.2.25 raeburn 4106: $data{'scope_type'} = 'secgroup';
1.473 amueller 4107: }
4108: $middle=~s/^\[(.*)\]//;
1.333 albertel 4109: }
4110: $middle=~s/\.+$//;
4111: $middle=~s/^\.+//;
4112: $data{'realm_type'}='all';
4113: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4114: $data{'realm'} = $1;
4115: $data{'realm_type'} = 'folder';
4116: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
4117: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
1.333 albertel 4118: } elsif ($middle) {
1.473 amueller 4119: $data{'realm'} = $middle;
4120: $data{'realm_type'} = 'symb';
4121: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
4122: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
4123: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
1.333 albertel 4124: }
1.446 bisitz 4125:
1.333 albertel 4126: $data{'parameter_part'} = $part;
4127: $data{'parameter_name'} = $name;
4128:
4129: return %data;
4130: }
4131:
1.239 raeburn 4132:
1.416 jms 4133: sub header {
1.522.2.3 raeburn 4134: return &Apache::loncommon::start_page('Content and Problem Settings');
1.416 jms 4135: }
1.193 albertel 4136:
4137:
4138:
4139: sub print_main_menu {
4140: my ($r,$parm_permission)=@_;
4141: #
1.414 droeschl 4142: $r->print(&header());
1.522.2.3 raeburn 4143: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
1.522.2.19 raeburn 4144: my $crstype = &Apache::loncommon::course_type();
4145: my $lc_crstype = lc($crstype);
4146:
1.193 albertel 4147: $r->print(<<ENDMAINFORMHEAD);
4148: <form method="post" enctype="multipart/form-data"
4149: action="/adm/parmset" name="studentform">
4150: ENDMAINFORMHEAD
4151: #
1.195 albertel 4152: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4153: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 4154: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 4155: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.520 raeburn 4156: my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
1.522.2.19 raeburn 4157: my $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'});
4158: my $vpa = &Apache::lonnet::allowed('vpa',$env{'request.course.id'});
1.520 raeburn 4159: if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
4160: $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
4161: '/'.$env{'request.course.sec'});
4162: }
1.522.2.19 raeburn 4163: if ((!$vcb) && ($env{'request.course.sec'} ne '')) {
4164: $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'}.
4165: '/'.$env{'request.course.sec'});
4166: }
4167: my (%linktext,%linktitle,%url);
4168: if ($parm_permission->{'edit'}) {
4169: %linktext = (
4170: newoverview => 'Edit Resource Parameters - Overview Mode',
4171: settable => 'Edit Resource Parameters - Table Mode',
4172: setoverview => 'Modify Resource Parameters - Overview Mode',
4173: );
4174: %linktitle = (
4175: newoverview => 'Set/Modify resource parameters in overview mode.',
4176: settable => 'Set/Modify resource parameters in table mode.',
4177: setoverview => 'Set/Modify existing resource parameters in overview mode.',
4178: );
4179: } else {
4180: %linktext = (
4181: newoverview => 'View Resource Parameters - Overview Mode',
4182: settable => 'View Resource Parameters - Table Mode',
4183: setoverview => 'View Resource Parameters - Overview Mode',
4184: );
4185: %linktitle = (
4186: newoverview => 'Display resource parameters in overview mode.',
4187: settable => 'Display resource parameters in table mode.',
4188: setoverview => 'Display existing resource parameters in overview mode.',
4189: );
4190: }
4191: if ($mgr) {
4192: $linktext{'resettimes'} = 'Reset Student Access Times';
4193: $linktitle{'resettimes'} = "Reset access times for folders/maps, resources or the $lc_crstype.";
4194: $url{'resettimes'} = '/adm/helper/resettimes.helper';
4195: } elsif ($vgr) {
4196: $linktext{'resettimes'} = 'Display Student Access Times',
4197: $linktitle{'resettimes'} = "Display access times for folders/maps, resources or the $lc_crstype.",
4198: $url{'resettimes'} = '/adm/accesstimes';
4199: }
1.193 albertel 4200: my @menu =
1.507 www 4201: ( { categorytitle=>"Content Settings for this $crstype",
1.473 amueller 4202: items => [
4203: { linktext => 'Portfolio Metadata',
4204: url => '/adm/parmset?action=setrestrictmeta',
1.522.2.19 raeburn 4205: permission => $parm_permission->{'setrestrictmeta'},
1.477 raeburn 4206: linktitle => "Restrict metadata for this $lc_crstype." ,
1.473 amueller 4207: icon =>'contact-new.png' ,
4208: },
1.522.2.19 raeburn 4209: { linktext => $linktext{'resettimes'},
4210: url => $url{'resettimes'},
1.522.2.20 raeburn 4211: permission => ($vgr || $mgr),
1.522.2.19 raeburn 4212: linktitle => $linktitle{'resettimes'},
4213: icon => 'start-here.png',
1.473 amueller 4214: },
1.520 raeburn 4215: { linktext => 'Blocking Communication/Resource Access',
4216: url => '/adm/setblock',
1.522.2.19 raeburn 4217: permission => ($vcb || $dcm),
1.520 raeburn 4218: linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
4219: icon => 'comblock.png',
4220: },
1.473 amueller 4221: { linktext => 'Set Parameter Setting Default Actions',
4222: url => '/adm/parmset?action=setdefaults',
1.522.2.19 raeburn 4223: permission => $parm_permission->{'setdefaults'},
1.473 amueller 4224: linktitle =>'Set default actions for parameters.' ,
4225: icon => 'folder-new.png' ,
4226: }]},
4227: { categorytitle => 'New and Existing Parameter Settings for Resources',
4228: items => [
4229: { linktext => 'Edit Resource Parameters - Helper Mode',
4230: url => '/adm/helper/parameter.helper',
1.522.2.19 raeburn 4231: permission => $parm_permission->{'helper'},
1.473 amueller 4232: linktitle =>'Set/Modify resource parameters in helper mode.' ,
4233: icon => 'dialog-information.png' ,
4234: #help => 'Parameter_Helper',
4235: },
1.522.2.19 raeburn 4236: { linktext => $linktext{'newoverview'},
1.473 amueller 4237: url => '/adm/parmset?action=newoverview',
1.522.2.19 raeburn 4238: permission => $parm_permission->{'newoverview'},
4239: linktitle => $linktitle{'newoverview'},
4240: icon => 'edit-find.png',
1.473 amueller 4241: #help => 'Parameter_Overview',
4242: },
1.522.2.19 raeburn 4243: { linktext => $linktext{'settable'},
1.473 amueller 4244: url => '/adm/parmset?action=settable',
1.522.2.19 raeburn 4245: permission => $parm_permission->{'settable'},
4246: linktitle => $linktitle{'settable'},
4247: icon => 'edit-copy.png',
1.473 amueller 4248: #help => 'Table_Mode',
4249: }]},
1.417 droeschl 4250: { categorytitle => 'Existing Parameter Settings for Resources',
1.473 amueller 4251: items => [
1.522.2.19 raeburn 4252: { linktext => $linktext{'setoverview'},
1.473 amueller 4253: url => '/adm/parmset?action=setoverview',
1.522.2.19 raeburn 4254: permission => $parm_permission->{'setoverview'},
4255: linktitle => $linktitle{'setoverview'},
4256: icon => 'preferences-desktop-wallpaper.png',
1.473 amueller 4257: #help => 'Parameter_Overview',
4258: },
4259: { linktext => 'Change Log',
4260: url => '/adm/parmset?action=parameterchangelog',
1.522.2.19 raeburn 4261: permission => $parm_permission->{'parameterchangelog'},
1.477 raeburn 4262: linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
1.487 wenzelju 4263: icon => 'document-properties.png',
1.473 amueller 4264: }]}
1.193 albertel 4265: );
1.414 droeschl 4266: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.522.2.8 raeburn 4267: $r->print('</form>'.&Apache::loncommon::end_page());
1.193 albertel 4268: return;
4269: }
1.414 droeschl 4270:
1.416 jms 4271:
4272:
1.252 banghart 4273: sub output_row {
1.347 banghart 4274: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 4275: my $output;
1.263 banghart 4276: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
4277: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 4278: if (!defined($options)) {
1.254 banghart 4279: $options = 'active,stuadd';
1.261 banghart 4280: $values = '';
1.252 banghart 4281: }
1.337 banghart 4282: if (!($options =~ /deleted/)) {
4283: my @options= ( ['active', 'Show to student'],
1.418 schafran 4284: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 4285: ['choices','Provide choices for students to select from']);
1.473 amueller 4286: # ['onlyone','Student may select only one choice']);
1.337 banghart 4287: if ($added_flag) {
4288: push @options,['deleted', 'Delete Metadata Field'];
4289: }
1.351 banghart 4290: $output = &Apache::loncommon::start_data_table_row();
1.451 bisitz 4291: $output .= '<td><strong>'.$field_text.':</strong></td>';
1.351 banghart 4292: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 4293: foreach my $opt (@options) {
1.473 amueller 4294: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
4295: $output .= &Apache::loncommon::continue_data_table_row();
4296: $output .= '<td>'.(' ' x 5).'<label>
4297: <input type="checkbox" name="'.
4298: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
4299: &mt($opt->[1]).'</label></td>';
4300: $output .= &Apache::loncommon::end_data_table_row();
4301: }
1.351 banghart 4302: $output .= &Apache::loncommon::continue_data_table_row();
1.451 bisitz 4303: $output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
1.351 banghart 4304: $output .= &Apache::loncommon::end_data_table_row();
4305: my $multiple_checked;
4306: my $single_checked;
4307: if ($options =~ m/onlyone/) {
1.422 bisitz 4308: $multiple_checked = '';
1.423 bisitz 4309: $single_checked = ' checked="checked"';
1.351 banghart 4310: } else {
1.423 bisitz 4311: $multiple_checked = ' checked="checked"';
1.422 bisitz 4312: $single_checked = '';
1.351 banghart 4313: }
1.473 amueller 4314: $output .= &Apache::loncommon::continue_data_table_row();
4315: $output .= '<td>'.(' ' x 10).'
4316: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
4317: '.&mt('Student may select multiple choices from list').'</td>';
4318: $output .= &Apache::loncommon::end_data_table_row();
4319: $output .= &Apache::loncommon::continue_data_table_row();
4320: $output .= '<td>'.(' ' x 10).'
4321: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
4322: '.&mt('Student may select only one choice from list').'</td>';
4323: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 4324: }
4325: return ($output);
4326: }
1.416 jms 4327:
4328:
4329:
1.340 banghart 4330: sub order_meta_fields {
4331: my ($r)=@_;
4332: my $idx = 1;
4333: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4334: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 4335: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 4336: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 4337: text=>"Add Metadata Field"});
1.345 banghart 4338: &Apache::lonhtmlcommon::add_breadcrumb
4339: ({href=>"/adm/parmset?action=setrestrictmeta",
4340: text=>"Restrict Metadata"},
4341: {text=>"Order Metadata"});
4342: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 4343: if ($env{'form.storeorder'}) {
4344: my $newpos = $env{'form.newpos'} - 1;
4345: my $currentpos = $env{'form.currentpos'} - 1;
4346: my @neworder = ();
4347: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
4348: my $i;
1.341 banghart 4349: if ($newpos > $currentpos) {
1.340 banghart 4350: # moving stuff up
4351: for ($i=0;$i<$currentpos;$i++) {
1.473 amueller 4352: $neworder[$i]=$oldorder[$i];
1.340 banghart 4353: }
4354: for ($i=$currentpos;$i<$newpos;$i++) {
1.473 amueller 4355: $neworder[$i]=$oldorder[$i+1];
1.340 banghart 4356: }
4357: $neworder[$newpos]=$oldorder[$currentpos];
4358: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
1.473 amueller 4359: $neworder[$i]=$oldorder[$i];
1.340 banghart 4360: }
4361: } else {
4362: # moving stuff down
1.473 amueller 4363: for ($i=0;$i<$newpos;$i++) {
4364: $neworder[$i]=$oldorder[$i];
4365: }
4366: $neworder[$newpos]=$oldorder[$currentpos];
4367: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
4368: $neworder[$i]=$oldorder[$i-1];
4369: }
4370: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
4371: $neworder[$i]=$oldorder[$i];
4372: }
1.340 banghart 4373: }
1.473 amueller 4374: my $ordered_fields = join ",", @neworder;
1.343 banghart 4375: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 4376: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.473 amueller 4377: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 4378: }
1.357 raeburn 4379: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 4380: my $ordered_fields;
1.340 banghart 4381: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
4382: if (!@fields_in_order) {
4383: # no order found, pick sorted order then create metadata.addedorder key.
4384: foreach my $key (sort keys %$fields) {
4385: push @fields_in_order, $key;
1.341 banghart 4386: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 4387: }
1.341 banghart 4388: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 4389: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
4390: }
1.340 banghart 4391: $r->print('<table>');
4392: my $num_fields = scalar(@fields_in_order);
4393: foreach my $key (@fields_in_order) {
4394: $r->print('<tr><td>');
4395: $r->print('<form method="post" action="">');
1.522.2.8 raeburn 4396: $r->print('<select name="newpos" onchange="this.form.submit()">');
1.340 banghart 4397: for (my $i = 1;$i le $num_fields;$i ++) {
4398: if ($i eq $idx) {
4399: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
4400: } else {
4401: $r->print('<option value="'.$i.'">'.$i.'</option>');
4402: }
4403: }
4404: $r->print('</select></td><td>');
4405: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
4406: $r->print('<input type="hidden" name="storeorder" value="true" />');
4407: $r->print('</form>');
4408: $r->print($$fields{$key}.'</td></tr>');
4409: $idx ++;
4410: }
4411: $r->print('</table>');
4412: return 'ok';
4413: }
1.416 jms 4414:
4415:
1.359 banghart 4416: sub continue {
4417: my $output;
4418: $output .= '<form action="" method="post">';
4419: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
1.522.2.25 raeburn 4420: $output .= '<input type="submit" value="'.&mt('Continue').'" />';
1.359 banghart 4421: return ($output);
4422: }
1.416 jms 4423:
4424:
1.334 banghart 4425: sub addmetafield {
4426: my ($r)=@_;
1.414 droeschl 4427: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 4428: text=>"Add Metadata Field"});
1.334 banghart 4429: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
4430: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 4431: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4432: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 4433: if (exists($env{'form.undelete'})) {
1.358 banghart 4434: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 4435: foreach my $meta_field(@meta_fields) {
4436: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
4437: $options =~ s/deleted//;
4438: $options =~ s/,,/,/;
4439: my $put_result = &Apache::lonnet::put('environment',
4440: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
1.446 bisitz 4441:
1.522.2.25 raeburn 4442: $r->print(&mt('Undeleted Metadata Field [_1] with result [_2]',
4443: '<strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}.
4444: '</strong>',$put_result).
4445: '<br />');
1.339 banghart 4446: }
1.359 banghart 4447: $r->print(&continue());
1.339 banghart 4448: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 4449: my $meta_field = $env{'form.fieldname'};
4450: my $display_field = $env{'form.fieldname'};
4451: $meta_field =~ s/\W/_/g;
1.338 banghart 4452: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 4453: my $put_result = &Apache::lonnet::put('environment',
4454: {'metadata.'.$meta_field.'.values'=>"",
4455: 'metadata.'.$meta_field.'.added'=>"$display_field",
4456: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.522.2.25 raeburn 4457: $r->print(&mt('Added new Metadata Field [_1] with result [_2]',
4458: '<strong>'.$env{'form.fieldname'}.'</strong>',$put_result).
4459: '<br />');
1.359 banghart 4460: $r->print(&continue());
1.335 banghart 4461: } else {
1.357 raeburn 4462: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 4463: if ($fields) {
1.522.2.25 raeburn 4464: $r->print(&mt('You may undelete previously deleted fields.').
4465: '<br />'.
4466: &mt('Check those you wish to undelete and click Undelete.').
4467: '<br />');
1.339 banghart 4468: $r->print('<form method="post" action="">');
4469: foreach my $key(keys(%$fields)) {
1.358 banghart 4470: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 4471: }
4472: $r->print('<input type="submit" name="undelete" value="Undelete" />');
4473: $r->print('</form>');
4474: }
1.522.2.25 raeburn 4475: $r->print('<hr />'.
4476: &mt('[_1]Or[_2] you may enter a new metadata field name.',
4477: '<strong>','</strong>').
4478: '<form method="post" action="/adm/parmset?action=addmetadata">');
1.335 banghart 4479: $r->print('<input type="text" name="fieldname" /><br />');
1.522.2.25 raeburn 4480: $r->print('<input type="submit" value="'.&mt('Add Metadata Field').'" />');
1.334 banghart 4481: }
1.361 albertel 4482: $r->print('</form>');
1.334 banghart 4483: }
1.416 jms 4484:
4485:
4486:
1.259 banghart 4487: sub setrestrictmeta {
1.240 banghart 4488: my ($r)=@_;
1.242 banghart 4489: my $next_meta;
1.244 banghart 4490: my $output;
1.245 banghart 4491: my $item_num;
1.246 banghart 4492: my $put_result;
1.414 droeschl 4493: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
1.473 amueller 4494: text=>"Restrict Metadata"});
1.280 albertel 4495: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4496: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4497: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4498: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4499: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4500: my $save_field = '';
1.522.2.25 raeburn 4501: my %lt = &Apache::lonlocal::texthash(
4502: addm => 'Add Metadata Field',
4503: ordm => 'Order Metadata Fields',
4504: save => 'Save',
4505: );
1.259 banghart 4506: if ($env{'form.restrictmeta'}) {
1.254 banghart 4507: foreach my $field (sort(keys(%env))) {
1.252 banghart 4508: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4509: my $options;
1.252 banghart 4510: my $meta_field = $1;
4511: my $meta_key = $2;
1.253 banghart 4512: if ($save_field ne $meta_field) {
1.252 banghart 4513: $save_field = $meta_field;
1.473 amueller 4514: if ($env{'form.'.$meta_field.'_stuadd'}) {
4515: $options.='stuadd,';
4516: }
4517: if ($env{'form.'.$meta_field.'_choices'}) {
4518: $options.='choices,';
4519: }
4520: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
4521: $options.='onlyone,';
4522: }
4523: if ($env{'form.'.$meta_field.'_active'}) {
4524: $options.='active,';
4525: }
4526: if ($env{'form.'.$meta_field.'_deleted'}) {
4527: $options.='deleted,';
4528: }
1.259 banghart 4529: my $name = $save_field;
1.253 banghart 4530: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4531: {'metadata.'.$meta_field.'.options'=>$options,
4532: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4533: },$dom,$crs);
1.252 banghart 4534: }
4535: }
4536: }
4537: }
1.296 albertel 4538: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.473 amueller 4539: {'freshen_cache' => 1});
1.335 banghart 4540: # Get the default metadata fields
1.258 albertel 4541: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4542: # Now get possible added metadata fields
1.357 raeburn 4543: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.347 banghart 4544: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4545: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4546: if ($field ne 'courserestricted') {
1.473 amueller 4547: $output.= &output_row($r, $field, $metadata_fields{$field});
4548: }
1.255 banghart 4549: }
1.351 banghart 4550: my $buttons = (<<ENDButtons);
1.522.2.25 raeburn 4551: <input type="submit" name="restrictmeta" value="$lt{'save'}" />
1.351 banghart 4552: </form><br />
4553: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
1.522.2.25 raeburn 4554: <input type="submit" name="restrictmeta" value="$lt{'addm'}" />
1.351 banghart 4555: </form>
4556: <br />
4557: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
1.522.2.25 raeburn 4558: <input type="submit" name="restrictmeta" value="$lt{'ordm'}" />
1.351 banghart 4559: ENDButtons
1.337 banghart 4560: my $added_flag = 1;
1.335 banghart 4561: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.522.2.25 raeburn 4562: $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag);
1.335 banghart 4563: }
1.347 banghart 4564: $output .= &Apache::loncommon::end_data_table();
1.446 bisitz 4565: $r->print(<<ENDenv);
1.259 banghart 4566: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4567: $output
1.351 banghart 4568: $buttons
1.340 banghart 4569: </form>
1.244 banghart 4570: ENDenv
1.280 albertel 4571: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4572: return 'ok';
4573: }
1.416 jms 4574:
4575:
4576:
1.335 banghart 4577: sub get_added_meta_fieldnames {
1.357 raeburn 4578: my ($cid) = @_;
1.335 banghart 4579: my %fields;
4580: foreach my $key(%env) {
1.357 raeburn 4581: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4582: my $field_name = $1;
4583: my ($display_field_name) = $env{$key};
4584: $fields{$field_name} = $display_field_name;
4585: }
4586: }
4587: return \%fields;
4588: }
1.416 jms 4589:
4590:
4591:
1.339 banghart 4592: sub get_deleted_meta_fieldnames {
1.357 raeburn 4593: my ($cid) = @_;
1.339 banghart 4594: my %fields;
4595: foreach my $key(%env) {
1.357 raeburn 4596: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4597: my $field_name = $1;
4598: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4599: my ($display_field_name) = $env{$key};
4600: $fields{$field_name} = $display_field_name;
4601: }
4602: }
4603: }
4604: return \%fields;
4605: }
1.220 www 4606: sub defaultsetter {
1.280 albertel 4607: my ($r) = @_;
4608:
1.414 droeschl 4609: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
1.473 amueller 4610: text=>"Set Defaults"});
1.446 bisitz 4611: my $start_page =
1.473 amueller 4612: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4613: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.507 www 4614: $r->print($start_page.$breadcrumbs);
4615: $r->print('<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">');
1.280 albertel 4616:
4617: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4618: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4619: my @ids=();
4620: my %typep=();
4621: my %keyp=();
4622: my %allparms=();
4623: my %allparts=();
4624: my %allmaps=();
4625: my %mapp=();
4626: my %symbp=();
4627: my %maptitles=();
4628: my %uris=();
4629: my %keyorder=&standardkeyorder();
4630: my %defkeytype=();
4631:
1.446 bisitz 4632: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 4633: \%mapp, \%symbp,\%maptitles,\%uris,
4634: \%keyorder,\%defkeytype);
1.224 www 4635: if ($env{'form.storerules'}) {
1.473 amueller 4636: my %newrules=();
4637: my @delrules=();
4638: my %triggers=();
4639: foreach my $key (keys(%env)) {
1.225 albertel 4640: if ($key=~/^form\.(\w+)\_action$/) {
1.473 amueller 4641: my $tempkey=$1;
4642: my $action=$env{$key};
1.226 www 4643: if ($action) {
1.473 amueller 4644: $newrules{$tempkey.'_action'}=$action;
4645: if ($action ne 'default') {
4646: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4647: $triggers{$whichparm}.=$tempkey.':';
4648: }
4649: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
4650: if (&isdateparm($defkeytype{$tempkey})) {
4651: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
4652: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4653: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4654: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4655: } else {
4656: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
4657: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
4658: }
4659: } else {
4660: push(@delrules,$tempkey.'_action');
4661: push(@delrules,$tempkey.'_type');
4662: push(@delrules,$tempkey.'_hours');
4663: push(@delrules,$tempkey.'_min');
4664: push(@delrules,$tempkey.'_sec');
4665: push(@delrules,$tempkey.'_value');
4666: }
4667: }
4668: }
4669: foreach my $key (keys %allparms) {
4670: $newrules{$key.'_triggers'}=$triggers{$key};
4671: }
4672: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4673: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4674: &resetrulescache();
1.224 www 4675: }
1.227 www 4676: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
1.473 amueller 4677: 'hours' => 'Hours',
4678: 'min' => 'Minutes',
4679: 'sec' => 'Seconds',
4680: 'yes' => 'Yes',
4681: 'no' => 'No');
1.222 www 4682: my @standardoptions=('','default');
4683: my @standarddisplay=('',&mt('Default value when manually setting'));
4684: my @dateoptions=('','default');
4685: my @datedisplay=('',&mt('Default value when manually setting'));
4686: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4687: unless ($tempkey) { next; }
4688: push @standardoptions,'when_setting_'.$tempkey;
4689: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4690: if (&isdateparm($defkeytype{$tempkey})) {
4691: push @dateoptions,'later_than_'.$tempkey;
4692: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4693: push @dateoptions,'earlier_than_'.$tempkey;
4694: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4695: }
1.222 www 4696: }
1.231 www 4697: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
1.473 amueller 4698: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4699: $r->print("\n".&Apache::loncommon::start_data_table().
1.473 amueller 4700: &Apache::loncommon::start_data_table_header_row().
4701: "<th>".&mt('Rule for parameter').'</th><th>'.
4702: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4703: &Apache::loncommon::end_data_table_header_row());
1.221 www 4704: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4705: unless ($tempkey) { next; }
4706: $r->print("\n".&Apache::loncommon::start_data_table_row().
4707: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
4708: my $action=&rulescache($tempkey.'_action');
4709: $r->print('<select name="'.$tempkey.'_action">');
4710: if (&isdateparm($defkeytype{$tempkey})) {
4711: for (my $i=0;$i<=$#dateoptions;$i++) {
4712: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4713: $r->print("\n<option value='$dateoptions[$i]'".
4714: ($dateoptions[$i] eq $action?' selected="selected"':'').
4715: ">$datedisplay[$i]</option>");
4716: }
4717: } else {
4718: for (my $i=0;$i<=$#standardoptions;$i++) {
4719: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4720: $r->print("\n<option value='$standardoptions[$i]'".
4721: ($standardoptions[$i] eq $action?' selected="selected"':'').
4722: ">$standarddisplay[$i]</option>");
4723: }
4724: }
4725: $r->print('</select>');
4726: unless (&isdateparm($defkeytype{$tempkey})) {
4727: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4728: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4729: }
4730: $r->print("\n</td><td>\n");
1.222 www 4731:
1.221 www 4732: if (&isdateparm($defkeytype{$tempkey})) {
1.473 amueller 4733: my $days=&rulescache($tempkey.'_days');
4734: my $hours=&rulescache($tempkey.'_hours');
4735: my $min=&rulescache($tempkey.'_min');
4736: my $sec=&rulescache($tempkey.'_sec');
4737: $r->print(<<ENDINPUTDATE);
1.227 www 4738: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4739: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4740: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4741: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4742: ENDINPUTDATE
1.473 amueller 4743: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4744: my $yeschecked='';
4745: my $nochecked='';
1.444 bisitz 4746: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
4747: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
1.222 www 4748:
1.473 amueller 4749: $r->print(<<ENDYESNO);
1.444 bisitz 4750: <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
4751: <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
1.221 www 4752: ENDYESNO
4753: } else {
1.473 amueller 4754: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
4755: }
1.318 albertel 4756: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4757: }
1.318 albertel 4758: $r->print(&Apache::loncommon::end_data_table().
1.473 amueller 4759: "\n".'<input type="submit" name="storerules" value="'.
1.507 www 4760: &mt('Save').'" /></form>'."\n");
4761: $r->print(&Apache::loncommon::end_page());
1.220 www 4762: return;
4763: }
1.193 albertel 4764:
1.290 www 4765: sub components {
1.330 albertel 4766: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4767:
4768: if ($typeflag) {
1.473 amueller 4769: $key=~s/\.type$//;
1.290 www 4770: }
1.330 albertel 4771:
4772: my ($middle,$part,$name)=
1.473 amueller 4773: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4774: my $issection;
1.330 albertel 4775:
1.290 www 4776: my $section=&mt('All Students');
4777: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4778: $issection=$1;
4779: $section=&mt('Group/Section').': '.$issection;
4780: $middle=~s/^\[(.*)\]//;
1.290 www 4781: }
4782: $middle=~s/\.+$//;
4783: $middle=~s/^\.+//;
1.291 www 4784: if ($uname) {
1.473 amueller 4785: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4786: $issection='';
1.291 www 4787: }
1.316 albertel 4788: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.446 bisitz 4789: my $realmdescription=&mt('all resources');
1.290 www 4790: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4791: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
4792: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
1.304 www 4793: } elsif ($middle) {
1.473 amueller 4794: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
4795: $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>';
4796: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4797: }
1.291 www 4798: my $what=$part.'.'.$name;
1.330 albertel 4799: return ($realm,$section,$name,$part,
1.473 amueller 4800: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4801: }
1.293 www 4802:
1.328 albertel 4803: my %standard_parms;
1.469 raeburn 4804: my %standard_parms_types;
1.416 jms 4805:
1.328 albertel 4806: sub load_parameter_names {
1.522.2.25 raeburn 4807: open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
1.328 albertel 4808: while (my $configline=<$config>) {
1.473 amueller 4809: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4810: chomp($configline);
4811: my ($short,$plain)=split(/:/,$configline);
4812: my (undef,$name,$type)=split(/\&/,$short,3);
4813: if ($type eq 'display') {
4814: $standard_parms{$name} = $plain;
1.469 raeburn 4815: } elsif ($type eq 'type') {
4816: $standard_parms_types{$name} = $plain;
4817: }
1.328 albertel 4818: }
4819: close($config);
4820: $standard_parms{'int_pos'} = 'Positive Integer';
4821: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
1.522.2.25 raeburn 4822: $standard_parms{'scoreformat'} = 'Format for display of score';
1.328 albertel 4823: }
4824:
1.292 www 4825: sub standard_parameter_names {
4826: my ($name)=@_;
1.328 albertel 4827: if (!%standard_parms) {
1.473 amueller 4828: &load_parameter_names();
1.328 albertel 4829: }
1.292 www 4830: if ($standard_parms{$name}) {
1.473 amueller 4831: return $standard_parms{$name};
1.446 bisitz 4832: } else {
1.473 amueller 4833: return $name;
1.292 www 4834: }
4835: }
1.290 www 4836:
1.469 raeburn 4837: sub standard_parameter_types {
4838: my ($name)=@_;
4839: if (!%standard_parms_types) {
4840: &load_parameter_names();
4841: }
4842: if ($standard_parms_types{$name}) {
4843: return $standard_parms_types{$name};
4844: }
4845: return;
4846: }
1.309 www 4847:
1.285 albertel 4848: sub parm_change_log {
1.522.2.19 raeburn 4849: my ($r,$parm_permission)=@_;
1.414 droeschl 4850: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.473 amueller 4851: text=>"Parameter Change Log"});
1.522 raeburn 4852: my $js = '<script type="text/javascript">'."\n".
4853: '// <![CDATA['."\n".
4854: &Apache::loncommon::display_filter_js('parmslog')."\n".
4855: '// ]]>'."\n".
4856: '</script>'."\n";
4857: $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
1.327 albertel 4858: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
1.286 www 4859: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
1.473 amueller 4860: $env{'course.'.$env{'request.course.id'}.'.domain'},
4861: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4862:
1.301 www 4863: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4864:
1.522 raeburn 4865: $r->print('<div class="LC_left_float">'.
4866: '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
4867: '<form action="/adm/parmset?action=parameterchangelog"
1.327 albertel 4868: method="post" name="parameterlog">');
1.446 bisitz 4869:
1.311 albertel 4870: my %saveable_parameters = ('show' => 'scalar',);
4871: &Apache::loncommon::store_course_settings('parameter_log',
4872: \%saveable_parameters);
4873: &Apache::loncommon::restore_course_settings('parameter_log',
4874: \%saveable_parameters);
1.522 raeburn 4875: $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
4876: '<input type="submit" value="'.&mt('Display').'" />'.
4877: '</form></fieldset></div><br clear="all" />');
1.522.2.19 raeburn 4878: my $readonly = 1;
4879: if ($parm_permission->{'edit'}) {
4880: undef($readonly);
4881: }
1.291 www 4882: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
1.473 amueller 4883: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4884: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1.473 amueller 4885: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
1.522.2.19 raeburn 4886: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th>');
4887: unless ($readonly) {
4888: $r->print('<th>'.&mt('Announce').'</th>');
4889: }
4890: $r->print(&Apache::loncommon::end_data_table_header_row());
1.309 www 4891: my $shown=0;
1.349 www 4892: my $folder='';
4893: if ($env{'form.displayfilter'} eq 'currentfolder') {
1.473 amueller 4894: my $last='';
4895: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4896: &GDBM_READER(),0640)) {
4897: $last=$hash{'last_known'};
4898: untie(%hash);
4899: }
4900: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
1.349 www 4901: }
1.522.2.27 raeburn 4902: my $numgroups = 0;
4903: my @groups;
4904: if ($env{'request.course.groups'} ne '') {
4905: @groups = split(/:/,$env{'request.course.groups'});
4906: $numgroups = scalar(@groups);
4907: }
1.446 bisitz 4908: foreach my $id (sort
1.473 amueller 4909: {
4910: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4911: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4912: }
4913: my $aid = (split('00000',$a))[-1];
4914: my $bid = (split('00000',$b))[-1];
4915: return $bid<=>$aid;
4916: } (keys(%parmlog))) {
1.294 www 4917: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.473 amueller 4918: my $count = 0;
4919: my $time =
4920: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
4921: my $plainname =
4922: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4923: $parmlog{$id}{'exe_udom'});
4924: my $about_me_link =
4925: &Apache::loncommon::aboutmewrapper($plainname,
4926: $parmlog{$id}{'exe_uname'},
4927: $parmlog{$id}{'exe_udom'});
4928: my $send_msg_link='';
1.522.2.19 raeburn 4929: if ((!$readonly) &&
4930: (($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
1.473 amueller 4931: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
4932: $send_msg_link ='<br />'.
4933: &Apache::loncommon::messagewrapper(&mt('Send message'),
4934: $parmlog{$id}{'exe_uname'},
4935: $parmlog{$id}{'exe_udom'});
4936: }
4937: my $row_start=&Apache::loncommon::start_data_table_row();
4938: my $makenewrow=0;
4939: my %istype=();
4940: my $output;
4941: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4942: my $value=$parmlog{$id}{'logentry'}{$changed};
1.473 amueller 4943: my $typeflag = ($changed =~/\.type$/ &&
4944: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4945: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.473 amueller 4946: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.522.2.24 raeburn 4947: if ($env{'request.course.sec'} ne '') {
1.522.2.27 raeburn 4948: next if (($issection ne '') && (!(($issection eq $env{'request.course.sec'}) ||
4949: ($numgroups && (grep(/^\Q$issection\E$/,@groups))))));
1.522.2.24 raeburn 4950: if ($uname ne '') {
4951: my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'});
4952: next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'}));
4953: }
4954: }
1.473 amueller 4955: if ($env{'form.displayfilter'} eq 'currentfolder') {
4956: if ($folder) {
4957: if ($middle!~/^\Q$folder\E/) { next; }
4958: }
4959: }
4960: if ($typeflag) {
4961: $istype{$parmname}=$value;
4962: if (!$env{'form.includetypes'}) { next; }
4963: }
4964: $count++;
4965: if ($makenewrow) {
4966: $output .= $row_start;
4967: } else {
4968: $makenewrow=1;
4969: }
1.470 raeburn 4970: my $parmitem = &standard_parameter_names($parmname);
1.473 amueller 4971: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
4972: &mt($parmitem).'</td><td>'.
4973: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
4974: my $stillactive=0;
4975: if ($parmlog{$id}{'delflag'}) {
4976: $output .= &mt('Deleted');
4977: } else {
4978: if ($typeflag) {
1.470 raeburn 4979: my $parmitem = &standard_parameter_names($value);
4980: $parmitem = &mt($parmitem);
1.473 amueller 4981: $output .= &mt('Type: [_1]',$parmitem);
4982: } else {
4983: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4984: $uname,$udom,$issection,$issection,$courseopt);
1.469 raeburn 4985: my $showvalue = $value;
4986: if ($istype{$parmname} eq '') {
4987: my $type = &standard_parameter_types($parmname);
4988: if ($type ne '') {
4989: if (&isdateparm($type)) {
4990: $showvalue =
4991: &Apache::lonlocal::locallocaltime($value);
4992: }
4993: }
4994: } else {
1.473 amueller 4995: if (&isdateparm($istype{$parmname})) {
4996: $showvalue =
1.469 raeburn 4997: &Apache::lonlocal::locallocaltime($value);
1.473 amueller 4998: }
1.469 raeburn 4999: }
5000: $output .= $showvalue;
1.473 amueller 5001: if ($value ne $all[$level]) {
5002: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
5003: } else {
5004: $stillactive=1;
5005: }
5006: }
5007: }
1.522.2.19 raeburn 5008: $output .= '</td>';
5009:
5010: unless ($readonly) {
5011: $output .= '<td>';
5012: if ($stillactive) {
5013: my $parmitem = &standard_parameter_names($parmname);
5014: $parmitem = &mt($parmitem);
5015: my $title=&mt('Changed [_1]',$parmitem);
5016: my $description=&mt('Changed [_1] for [_2] to [_3]',
5017: $parmitem,$realmdescription,
5018: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
5019: if (($uname) && ($udom)) {
5020: $output .=
5021: &Apache::loncommon::messagewrapper('Notify User',
5022: $uname,$udom,$title,
5023: $description);
5024: } else {
5025: $output .=
5026: &Apache::lonrss::course_blog_link($id,$title,
5027: $description);
5028: }
5029: }
5030: $output .= '</td>';
5031: }
5032: $output .= &Apache::loncommon::end_data_table_row();
1.473 amueller 5033: }
1.349 www 5034: if ($env{'form.displayfilter'} eq 'containing') {
1.473 amueller 5035: my $wholeentry=$about_me_link.':'.
5036: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
5037: $output;
5038: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
5039: }
1.349 www 5040: if ($count) {
1.473 amueller 5041: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 5042: <td rowspan="'.$count.'">'.$about_me_link.
1.473 amueller 5043: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
5044: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
5045: $send_msg_link.'</td>'.$output);
5046: $shown++;
5047: }
5048: if (!($env{'form.show'} eq &mt('all')
5049: || $shown<=$env{'form.show'})) { last; }
1.286 www 5050: }
1.301 www 5051: $r->print(&Apache::loncommon::end_data_table());
1.284 www 5052: $r->print(&Apache::loncommon::end_page());
5053: }
5054:
1.437 raeburn 5055: sub update_slots {
5056: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
5057: my %slot=&Apache::lonnet::get_slot($slot_name);
5058: if (!keys(%slot)) {
5059: return 'error: slot does not exist';
5060: }
5061: my $max=$slot{'maxspace'};
5062: if (!defined($max)) { $max=99999; }
5063:
5064: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
5065: "^$slot_name\0");
5066: my ($tmp)=%consumed;
5067: if ($tmp=~/^error: 2 / ) {
5068: return 'error: unable to determine current slot status';
5069: }
5070: my $last=0;
5071: foreach my $key (keys(%consumed)) {
5072: my $num=(split('\0',$key))[1];
5073: if ($num > $last) { $last=$num; }
5074: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
5075: return 'ok';
5076: }
5077: }
5078:
5079: if (scalar(keys(%consumed)) >= $max) {
5080: return 'error: no space left in slot';
5081: }
5082: my $wanted=$last+1;
5083:
5084: my %reservation=('name' => $uname.':'.$udom,
5085: 'timestamp' => time,
5086: 'symb' => $symb);
5087:
5088: my $success=&Apache::lonnet::newput('slot_reservations',
5089: {"$slot_name\0$wanted" =>
5090: \%reservation},
5091: $cdom, $cnum);
1.438 raeburn 5092: if ($success eq 'ok') {
5093: my %storehash = (
5094: symb => $symb,
5095: slot => $slot_name,
5096: action => 'reserve',
5097: context => 'parameter',
5098: );
1.522.2.3 raeburn 5099: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.438 raeburn 5100: '',$uname,$udom,$cnum,$cdom);
5101:
1.522.2.3 raeburn 5102: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 5103: '',$uname,$udom,$uname,$udom);
5104: }
1.437 raeburn 5105: return $success;
5106: }
5107:
5108: sub delete_slots {
5109: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
5110: my $delresult;
5111: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
5112: $cnum, "^$slot_name\0");
5113: if (&Apache::lonnet::error(%consumed)) {
5114: return 'error: unable to determine current slot status';
5115: }
5116: my ($tmp)=%consumed;
5117: if ($tmp=~/^error: 2 /) {
5118: return 'error: unable to determine current slot status';
5119: }
5120: foreach my $key (keys(%consumed)) {
5121: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
5122: my $num=(split('\0',$key))[1];
5123: my $entry = $slot_name.'\0'.$num;
5124: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
5125: $cdom,$cnum);
5126: if ($delresult eq 'ok') {
5127: my %storehash = (
5128: symb => $symb,
5129: slot => $slot_name,
5130: action => 'release',
5131: context => 'parameter',
5132: );
1.522.2.3 raeburn 5133: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.437 raeburn 5134: 1,$uname,$udom,$cnum,$cdom);
1.522.2.3 raeburn 5135: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 5136: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 5137: }
5138: }
5139: }
5140: return $delresult;
5141: }
5142:
1.355 albertel 5143: sub check_for_course_info {
5144: my $navmap = Apache::lonnavmaps::navmap->new();
5145: return 1 if ($navmap);
5146: return 0;
5147: }
5148:
1.514 raeburn 5149: sub parameter_release_vars {
1.504 raeburn 5150: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5151: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
5152: my $chostname = &Apache::lonnet::hostname($chome);
5153: my ($cmajor,$cminor) =
5154: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
5155: return ($chostname,$cmajor,$cminor);
5156: }
5157:
1.514 raeburn 5158: sub parameter_releasecheck {
1.522.2.14 raeburn 5159: my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
1.504 raeburn 5160: my $needsnewer;
5161: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
5162: if (($cmajor < $needsmajor) ||
5163: ($cmajor == $needsmajor && $cminor < $needsminor)) {
5164: $needsnewer = 1;
5165: } else {
1.514 raeburn 5166: &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
1.504 raeburn 5167: }
5168: return $needsnewer;
5169: }
5170:
5171: sub oldversion_warning {
1.514 raeburn 5172: my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
1.504 raeburn 5173: my $desc;
1.514 raeburn 5174: my %stringtypes = (
1.519 raeburn 5175: type => 'string_questiontype',
5176: lenient => 'string_lenient',
5177: retrypartial => 'string_yesno',
1.521 raeburn 5178: discussvote => 'string_discussvote',
1.522.2.7 raeburn 5179: examcode => 'string_examcode',
1.514 raeburn 5180: );
5181: if (exists($stringtypes{$name})) {
1.522.2.7 raeburn 5182: if ($name eq 'examcode') {
5183: $desc = $value;
5184: } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
1.514 raeburn 5185: foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
5186: next unless (ref($possibilities) eq 'ARRAY');
5187: my ($parmval, $description) = @{ $possibilities };
5188: if ($parmval eq $value) {
5189: $desc = $description;
5190: last;
5191: }
1.504 raeburn 5192: }
5193: }
1.522.2.16 raeburn 5194: } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
5195: my $now = time;
5196: if ($value =~ /^\d+$/) {
5197: if ($name eq 'printstartdate') {
5198: if ($value > $now) {
5199: $desc = &Apache::lonlocal::locallocaltime($value);
5200: }
5201: } elsif ($name eq 'printenddate') {
5202: if ($value < $now) {
5203: $desc = &Apache::lonlocal::locallocaltime($value);
5204: }
5205: }
5206: }
1.504 raeburn 5207: }
1.514 raeburn 5208: my $standard_name = &standard_parameter_names($name);
1.504 raeburn 5209: return '<p class="LC_warning">'.
1.514 raeburn 5210: &mt('[_1] was [_2]not[_3] set to [_4].',
5211: $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
1.504 raeburn 5212: &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
5213: $cmajor.'.'.$cminor,$chostname,
5214: $needsrelease).
5215: '</p>';
5216: }
1.259 banghart 5217:
1.522.2.19 raeburn 5218: sub get_permission {
5219: my %permission;
5220: my $allowed = 0;
5221: return (\%permission,$allowed) unless ($env{'request.course.id'});
5222: if ((&Apache::lonnet::allowed('opa',$env{'request.course.id'})) ||
5223: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
5224: $env{'request.course.sec'}))) {
5225: %permission= (
5226: 'edit' => 1,
5227: 'set' => 1,
5228: 'setoverview' => 1,
5229: 'addmetadata' => 1,
5230: 'ordermetadata' => 1,
5231: 'setrestrictmeta' => 1,
5232: 'newoverview' => 1,
5233: 'setdefaults' => 1,
5234: 'settable' => 1,
5235: 'parameterchangelog' => 1,
5236: 'cleanparameters' => 1,
5237: 'dateshift1' => 1,
5238: 'dateshift2' => 1,
5239: 'helper' => 1,
5240: );
5241: } elsif ((&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) ||
5242: (&Apache::lonnet::allowed('vpa',$env{'request.course.id'}.'/'.
5243: $env{'request.course.sec'}))) {
5244: %permission = (
5245: 'set' => 1,
5246: 'settable' => 1,
5247: 'newoverview' => 1,
5248: 'setoverview' => 1,
5249: 'parameterchangelog' => 1,
5250: );
5251: }
5252: foreach my $perm (values(%permission)) {
5253: if ($perm) { $allowed=1; last; }
5254: }
5255: return (\%permission,$allowed);
5256: }
5257:
1.30 www 5258: sub handler {
1.43 albertel 5259: my $r=shift;
1.30 www 5260:
1.376 albertel 5261: &reset_caches();
5262:
1.414 droeschl 5263: &Apache::loncommon::content_type($r,'text/html');
5264: $r->send_http_header;
5265: return OK if $r->header_only;
5266:
1.193 albertel 5267: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.473 amueller 5268: ['action','state',
1.205 www 5269: 'pres_marker',
5270: 'pres_value',
1.206 www 5271: 'pres_type',
1.506 www 5272: 'filter','part',
1.390 www 5273: 'udom','uname','symb','serial','timebase']);
1.131 www 5274:
1.83 bowersj2 5275:
1.193 albertel 5276: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 5277: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
1.522.2.3 raeburn 5278: text=>"Content and Problem Settings",
1.473 amueller 5279: faq=>10,
5280: bug=>'Instructor Interface',
1.442 droeschl 5281: help =>
5282: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 5283:
1.30 www 5284: # ----------------------------------------------------- Needs to be in a course
1.522.2.19 raeburn 5285: my ($parm_permission,$allowed) = &get_permission();
1.355 albertel 5286: my $exists = &check_for_course_info();
5287:
1.522.2.19 raeburn 5288: if ($env{'request.course.id'} && $allowed && $exists) {
1.193 albertel 5289: #
5290: # Main switch on form.action and form.state, as appropriate
5291: #
5292: # Check first if coming from someone else headed directly for
5293: # the table mode
1.522.2.19 raeburn 5294: if (($parm_permission->{'set'}) &&
5295: ((($env{'form.command'} eq 'set') && ($env{'form.url'})
5296: && (!$env{'form.dis'})) || ($env{'form.symb'}))) {
5297: &assessparms($r,$parm_permission);
1.193 albertel 5298: } elsif (! exists($env{'form.action'})) {
5299: &print_main_menu($r,$parm_permission);
1.522.2.19 raeburn 5300: } elsif (!$parm_permission->{$env{'form.action'}}) {
5301: &print_main_menu($r,$parm_permission);
1.414 droeschl 5302: } elsif ($env{'form.action'} eq 'setoverview') {
1.522.2.19 raeburn 5303: &overview($r,$parm_permission);
5304: } elsif ($env{'form.action'} eq 'addmetadata') {
5305: &addmetafield($r);
5306: } elsif ($env{'form.action'} eq 'ordermetadata') {
5307: &order_meta_fields($r);
1.414 droeschl 5308: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.522.2.19 raeburn 5309: &setrestrictmeta($r);
1.414 droeschl 5310: } elsif ($env{'form.action'} eq 'newoverview') {
1.522.2.19 raeburn 5311: &newoverview($r,$parm_permission);
1.414 droeschl 5312: } elsif ($env{'form.action'} eq 'setdefaults') {
1.522.2.19 raeburn 5313: &defaultsetter($r);
5314: } elsif ($env{'form.action'} eq 'settable') {
5315: &assessparms($r,$parm_permission);
1.414 droeschl 5316: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.522.2.19 raeburn 5317: &parm_change_log($r,$parm_permission);
1.414 droeschl 5318: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.522.2.19 raeburn 5319: &clean_parameters($r);
1.414 droeschl 5320: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 5321: &date_shift_one($r);
1.414 droeschl 5322: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 5323: &date_shift_two($r);
1.446 bisitz 5324: }
1.43 albertel 5325: } else {
1.1 www 5326: # ----------------------------- Not in a course, or not allowed to modify parms
1.473 amueller 5327: if ($exists) {
5328: $env{'user.error.msg'}=
5329: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
5330: } else {
5331: $env{'user.error.msg'}=
5332: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
5333: }
5334: return HTTP_NOT_ACCEPTABLE;
1.43 albertel 5335: }
1.376 albertel 5336: &reset_caches();
5337:
1.43 albertel 5338: return OK;
1.1 www 5339: }
5340:
5341: 1;
5342: __END__
5343:
5344:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>