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