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