Annotation of loncom/interface/lonparmset.pm, revision 1.431
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.431 ! raeburn 4: # $Id: lonparmset.pm,v 1.430 2009/02/13 20:20:30 schafran 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:
39: lonparmset provides an interface to setting course parameters.
40:
41: =head1 DESCRIPTION
42:
43: This module sets coursewide and assessment parameters.
44:
45: =head1 INTERNAL SUBROUTINES
46:
1.416 jms 47: =over
1.59 matthew 48:
49: =pod
50:
1.416 jms 51: =item parmval()
1.59 matthew 52:
53: Figure out a cascading parameter.
54:
1.71 albertel 55: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 56: $id - a bighash Id number
1.71 albertel 57: $def - the resource's default value 'stupid emacs
58:
1.269 raeburn 59: 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 60:
1.306 albertel 61: 14- General Course
62: 13- Map or Folder level in course
1.269 raeburn 63: 12- resource default
64: 11- map default
1.306 albertel 65: 10- resource level in course
1.269 raeburn 66: 9 - General for section
67: 8 - Map or Folder level for section
68: 7 - resource level in section
69: 6 - General for group
70: 5 - Map or Folder level for group
71: 4 - resource level in group
1.71 albertel 72: 3 - General for specific student
1.82 www 73: 2 - Map or Folder level for specific student
1.71 albertel 74: 1 - resource level for specific student
1.2 www 75:
1.416 jms 76: =item parmval_by_symb()
77:
78: =item reset_caches()
79:
80: =item cacheparmhash()
81:
82: =item parmhash()
83:
84: =item symbcache()
85:
86: =item preset_defaults()
87:
88: =item date_sanity_info()
89:
90: =item storeparm()
91:
92: Store a parameter by symb
93:
94: Takes
95: - symb
96: - name of parameter
97: - level
98: - new value
99: - new type
100: - username
101: - userdomain
102:
103: =item log_parmset()
104:
105: =item storeparm_by_symb_inner()
106:
107: =item valout()
108:
109: Format a value for output.
110:
111: Inputs: $value, $type, $editable
112:
113: Returns: $value, formatted for output. If $type indicates it is a date,
114: localtime($value) is returned.
115: $editable will return an icon to click on
116:
117: =item plink()
118:
119: Produces a link anchor.
120:
121: Inputs: $type,$dis,$value,$marker,$return,$call
122:
123: Returns: scalar with html code for a link which will envoke the
124: javascript function 'pjump'.
125:
126: =item page_js()
127:
128: =item startpage()
129:
130: =item print_row()
131:
132: =item print_td()
133:
134: =item print_usergroups()
135:
136: =item parm_control_group()
137:
138: =item extractResourceInformation() :
139:
140: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
141:
142: Input: See list below:
143:
144: =item * B<ids> : An array that will contain all of the ids in the course.
145:
146: =item * B<typep> : hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
147:
148: =item * B<keyp> : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
149:
150: =item * B<allparms> : hash, name of parameter->display value (what is the display value?)
151:
152: =item * B<allparts> : hash, part identification->text representation of part, where the text representation is "[Part $part]"
153:
154: =item * B<allkeys> : hash, full key to part->display value (what's display value?)
155:
156: =item * B<allmaps> : hash, ???
157:
158: =item * B<fcat> : ???
159:
160: =item * B<defp> : hash, ???
161:
162: =item * B<mapp> : ??
163:
164: =item * B<symbp> : hash, id->full sym?
165:
166:
167:
168: =item isdateparm()
169:
170: =item parmmenu()
171:
172: =item partmenu()
173:
174: =item usermenu()
175:
176: =item displaymenu()
177:
178: =item mapmenu()
179:
180: =item levelmenu()
181:
182: =item sectionmenu()
183:
184: =item keysplit()
185:
186: =item keysinorder()
187:
188: =item keysinorder_bytype()
189:
190: =item keysindisplayorder()
191:
192: =item standardkeyorder()
193:
194: =item assessparms() :
195:
196: Show assessment data and parameters. This is a large routine that should
197: be simplified and shortened... someday.
198:
199: Inputs: $r
200:
201: Returns: nothing
202:
203: Variables used (guessed by Jeremy):
204:
205: =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.
206:
207: =item * B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
208:
209: =item * B<@catmarker> contains list of all possible parameters including part #s
210:
211: =item * B<$fullkeyp> contains the full part/id # for the extraction of proper parameters
212:
213: =item * B<$tempkeyp> contains part 0 only (no ids - ie, subparts)
214: When storing information, store as part 0
215: When requesting information, request from full part
216:
217: =item crsenv()
218:
219: Show and set course data and parameters. This is a large routine that should
220: be simplified and shortened... someday.
221:
222: Inputs: $r
223:
224: Returns: nothing
225:
226: =item can_modify_catsettings()
227:
228: =item assign_course_categories()
229:
230: =item tablestart()
231:
232: =item tableend()
233:
234: =item extractuser()
235:
236: =item parse_listdata_key()
237:
238: =item listdata()
239:
240: =item date_interval_selector()
241:
242: =item get_date_interval_from_form()
243:
244: =item default_selector()
245:
246: =item string_selector()
247:
248: =item dateshift()
249:
250: =item newoverview()
251:
252: =item secgroup_lister()
253:
254: =item overview()
255:
256: =item clean_parameters()
257:
258: =item date_shift_one()
259:
260: =item date_shift_two()
261:
262: =item parse_key()
263:
264: =item check_cloners() :
265:
266: Checks if new users included in list of allowed cloners
267: are valid users. Replaces supplied list with
268: cleaned list containing only users with valid usernames
269: and domains.
270:
271: Inputs: $clonelist, $oldcloner
272: where $clonelist is ref to array of requested cloners,
273: and $oldcloner is ref to array of currently allowed
274: cloners.
275:
276: Returns: string - comma separated list of requested
277: cloners (username:domain) who do not exist in system.
278:
279: =item change_clone() :
280:
281: Modifies the list of courses a user can clone (stored
282: in the user's environment.db file), called when a
283: change is made to the list of users allowed to clone
284: a course.
285:
286: Inputs: $action,$cloner
287: where $action is add or drop, and $cloner is identity of
288: user for whom cloning ability is to be changed in course.
289:
290:
291: =item check_cloners()
292:
293: =item change_clone()
294:
295: =item header()
296:
297: Output html header for page
298:
299: =item print_main_menu()
300:
301: =item output_row()
302:
303: Set portfolio metadata
304:
305: =item order_meta_fields()
306:
307: =item addmetafield()
308:
309: =item setrestrictmeta()
310:
311: =item get_added_meta_fieldnames()
312:
313: =item get_deleted_meta_fieldnames()
314:
315: =item defaultsetter()
316:
317: =item components()
318:
319: =item load_parameter_names()
320:
321: =item parm_change_log()
322:
323: =item handler() :
324:
325: Main handler. Calls &assessparms and &crsenv subroutines.
326:
327:
328: =back
329:
1.59 matthew 330: =cut
331:
1.416 jms 332: ###################################################################
333: ###################################################################
334:
335: package Apache::lonparmset;
336:
337: use strict;
338: use Apache::lonnet;
339: use Apache::Constants qw(:common :http REDIRECT);
340: use Apache::lonhtmlcommon();
341: use Apache::loncommon;
342: use GDBM_File;
343: use Apache::lonhomework;
344: use Apache::lonxml;
345: use Apache::lonlocal;
346: use Apache::lonnavmaps;
347: use Apache::longroup;
348: use Apache::lonrss;
349: use LONCAPA qw(:DEFAULT :match);
350:
351:
1.2 www 352: sub parmval {
1.275 raeburn 353: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
354: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
355: $cgroup,$courseopt);
1.201 www 356: }
357:
358: sub parmval_by_symb {
1.275 raeburn 359: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.200 www 360:
1.352 albertel 361: my $useropt;
362: if ($uname ne '' && $udom ne '') {
363: $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
364: }
1.200 www 365:
1.8 www 366: my $result='';
1.44 albertel 367: my @outpar=();
1.2 www 368: # ----------------------------------------------------- Cascading lookup scheme
1.201 www 369: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 370: $map = &Apache::lonnet::deversion($map);
1.10 www 371:
1.201 www 372: my $symbparm=$symb.'.'.$what;
373: my $mapparm=$map.'___(all).'.$what;
1.10 www 374:
1.269 raeburn 375: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
376: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
377: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
378:
1.190 albertel 379: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
380: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
381: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
382:
383: my $courselevel=$env{'request.course.id'}.'.'.$what;
384: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
385: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 386:
1.11 www 387:
1.182 albertel 388: # --------------------------------------------------------- first, check course
1.11 www 389:
1.200 www 390: if (defined($$courseopt{$courselevel})) {
1.269 raeburn 391: $outpar[14]=$$courseopt{$courselevel};
392: $result=14;
1.43 albertel 393: }
1.11 www 394:
1.200 www 395: if (defined($$courseopt{$courselevelm})) {
1.269 raeburn 396: $outpar[13]=$$courseopt{$courselevelm};
397: $result=13;
1.43 albertel 398: }
1.11 www 399:
1.182 albertel 400: # ------------------------------------------------------- second, check default
401:
1.269 raeburn 402: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 403:
404: # ------------------------------------------------------ third, check map parms
405:
1.376 albertel 406: my $thisparm=&parmhash($symbparm);
1.269 raeburn 407: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 408:
1.200 www 409: if (defined($$courseopt{$courselevelr})) {
1.269 raeburn 410: $outpar[10]=$$courseopt{$courselevelr};
411: $result=10;
1.43 albertel 412: }
1.11 www 413:
1.182 albertel 414: # ------------------------------------------------------ fourth, back to course
1.352 albertel 415: if ($csec ne '') {
1.200 www 416: if (defined($$courseopt{$seclevel})) {
1.269 raeburn 417: $outpar[9]=$$courseopt{$seclevel};
418: $result=9;
1.43 albertel 419: }
1.200 www 420: if (defined($$courseopt{$seclevelm})) {
1.269 raeburn 421: $outpar[8]=$$courseopt{$seclevelm};
422: $result=8;
1.43 albertel 423: }
424:
1.200 www 425: if (defined($$courseopt{$seclevelr})) {
1.269 raeburn 426: $outpar[7]=$$courseopt{$seclevelr};
427: $result=7;
1.43 albertel 428: }
429: }
1.275 raeburn 430: # ------------------------------------------------------ fifth, check course group
1.352 albertel 431: if ($cgroup ne '') {
1.269 raeburn 432: if (defined($$courseopt{$grplevel})) {
433: $outpar[6]=$$courseopt{$grplevel};
434: $result=6;
435: }
436: if (defined($$courseopt{$grplevelm})) {
437: $outpar[5]=$$courseopt{$grplevelm};
438: $result=5;
439: }
440: if (defined($$courseopt{$grplevelr})) {
441: $outpar[4]=$$courseopt{$grplevelr};
442: $result=4;
443: }
444: }
1.11 www 445:
1.182 albertel 446: # ---------------------------------------------------------- fifth, check user
1.11 www 447:
1.352 albertel 448: if ($uname ne '') {
1.200 www 449: if (defined($$useropt{$courselevel})) {
450: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 451: $result=3;
452: }
1.10 www 453:
1.200 www 454: if (defined($$useropt{$courselevelm})) {
455: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 456: $result=2;
457: }
1.2 www 458:
1.200 www 459: if (defined($$useropt{$courselevelr})) {
460: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 461: $result=1;
462: }
463: }
1.44 albertel 464: return ($result,@outpar);
1.2 www 465: }
466:
1.198 www 467:
468:
1.376 albertel 469: # --- Caches local to lonparmset
470:
471:
472: sub reset_caches {
473: &resetparmhash();
474: &resetsymbcache();
475: &resetrulescache();
1.203 www 476: }
477:
1.376 albertel 478: {
479: my $parmhashid;
480: my %parmhash;
481: sub resetparmhash {
482: undef($parmhashid);
483: undef(%parmhash);
484: }
485:
486: sub cacheparmhash {
487: if ($parmhashid eq $env{'request.course.fn'}) { return; }
488: my %parmhashfile;
489: if (tie(%parmhashfile,'GDBM_File',
490: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
491: %parmhash=%parmhashfile;
492: untie(%parmhashfile);
493: $parmhashid=$env{'request.course.fn'};
494: }
1.201 www 495: }
1.376 albertel 496:
497: sub parmhash {
498: my ($id) = @_;
499: &cacheparmhash();
500: return $parmhash{$id};
501: }
502: }
503:
504: {
505: my $symbsid;
506: my %symbs;
507: sub resetsymbcache {
508: undef($symbsid);
509: undef(%symbs);
510: }
511:
512: sub symbcache {
513: my $id=shift;
514: if ($symbsid ne $env{'request.course.id'}) {
515: undef(%symbs);
516: }
517: if (!$symbs{$id}) {
518: my $navmap = Apache::lonnavmaps::navmap->new();
519: if ($id=~/\./) {
520: my $resource=$navmap->getById($id);
521: $symbs{$id}=$resource->symb();
522: } else {
523: my $resource=$navmap->getByMapPc($id);
524: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
525: }
526: $symbsid=$env{'request.course.id'};
1.201 www 527: }
1.376 albertel 528: return $symbs{$id};
1.201 www 529: }
1.376 albertel 530: }
1.201 www 531:
1.376 albertel 532: {
533: my $rulesid;
534: my %rules;
535: sub resetrulescache {
536: undef($rulesid);
537: undef(%rules);
538: }
539:
540: sub rulescache {
541: my $id=shift;
542: if ($rulesid ne $env{'request.course.id'}
543: && !defined($rules{$id})) {
544: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
545: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
546: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
547: $rulesid=$env{'request.course.id'};
548: }
549: return $rules{$id};
1.221 www 550: }
551: }
552:
1.416 jms 553:
554:
1.229 www 555: sub preset_defaults {
556: my $type=shift;
557: if (&rulescache($type.'_action') eq 'default') {
558: # yes, there is something
559: return (&rulescache($type.'_hours'),
560: &rulescache($type.'_min'),
561: &rulescache($type.'_sec'),
562: &rulescache($type.'_value'));
563: } else {
564: # nothing there or something else
565: return ('','','','','');
566: }
567: }
568:
1.416 jms 569:
570:
1.277 www 571:
572: sub date_sanity_info {
573: my $checkdate=shift;
574: unless ($checkdate) { return ''; }
575: my $result='';
576: my $crsprefix='course.'.$env{'request.course.id'}.'.';
577: if ($env{$crsprefix.'default_enrollment_end_date'}) {
578: if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
1.413 bisitz 579: $result.='<div class="LC_warning">'
580: .&mt('After course enrollment end!')
581: .'</div>';
1.277 www 582: }
583: }
584: if ($env{$crsprefix.'default_enrollment_start_date'}) {
585: if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
1.413 bisitz 586: $result.='<div class="LC_warning">'
587: .&mt('Before course enrollment start!')
588: .'</div>';
1.277 www 589: }
590: }
1.413 bisitz 591: # Preparation for additional warnings about dates in the past/future.
592: # An improved, more context sensitive version is recommended,
593: # e.g. warn for due and answer dates which are defined before the corresponding open date, etc.
594: # if ($checkdate<time) {
595: # $result.='<div class="LC_info">'
596: # .'('.&mt('in the past').')'
597: # .'</div>';
598: # }
599: # if ($checkdate>time) {
600: # $result.='<div class="LC_info">'
601: # .'('.&mt('in the future').')'
602: # .'</div>';
603: # }
1.277 www 604: return $result;
605: }
606: ##################################################
1.186 www 607: ##################################################
608: #
1.197 www 609: # Store a parameter by ID
1.186 www 610: #
611: # Takes
612: # - resource id
613: # - name of parameter
614: # - level
615: # - new value
616: # - new type
1.187 www 617: # - username
618: # - userdomain
619:
1.186 www 620: sub storeparm {
1.269 raeburn 621: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 raeburn 622: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 623: }
624:
1.226 www 625: my %recstack;
1.197 www 626: sub storeparm_by_symb {
1.275 raeburn 627: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 628: unless ($recflag) {
629: # first time call
630: %recstack=();
631: $recflag=1;
632: }
633: # store parameter
634: &storeparm_by_symb_inner
1.269 raeburn 635: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 636: # don't do anything if parameter was reset
637: unless ($nval) { return; }
1.226 www 638: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
639: # remember that this was set
640: $recstack{$parm}=1;
641: # what does this trigger?
642: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
643: # don't backfire
644: unless ((!$triggered) || ($recstack{$triggered})) {
645: my $action=&rulescache($triggered.'_action');
646: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
647: # set triggered parameter on same level
648: my $newspnam=$prefix.$triggered;
1.227 www 649: my $newvalue='';
1.228 www 650: my $active=1;
651: if ($action=~/^when\_setting/) {
652: # are there restrictions?
653: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
654: $active=0;
655: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
656: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
657: }
658: }
659: $newvalue=&rulescache($triggered.'_value');
1.227 www 660: } else {
661: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
1.228 www 662: if ($action=~/^later\_than/) {
663: $newvalue=$nval+$totalsecs;
664: } else {
665: $newvalue=$nval-$totalsecs;
666: }
667: }
668: if ($active) {
669: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
1.275 raeburn 670: $uname,$udom,$csec,$recflag,$cgroup);
1.227 www 671: }
1.226 www 672: }
673: }
674: return '';
675: }
676:
1.293 www 677: sub log_parmset {
678: return &Apache::lonnet::instructor_log('parameterlog',@_);
1.284 www 679: }
680:
1.226 www 681: sub storeparm_by_symb_inner {
1.197 www 682: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 683: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 684: # ---------------------------------------------------------- Construct prefixes
1.186 www 685: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 686: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 687: $map = &Apache::lonnet::deversion($map);
688:
1.197 www 689: my $symbparm=$symb.'.'.$spnam;
690: my $mapparm=$map.'___(all).'.$spnam;
691:
1.269 raeburn 692: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
693: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
694: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
695:
1.190 albertel 696: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
697: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
698: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 699:
1.190 albertel 700: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
701: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
702: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 703:
704: my $storeunder='';
1.269 raeburn 705: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
706: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
707: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
708: if ($snum==9) { $storeunder=$seclevel; }
709: if ($snum==8) { $storeunder=$seclevelm; }
710: if ($snum==7) { $storeunder=$seclevelr; }
711: if ($snum==6) { $storeunder=$grplevel; }
712: if ($snum==5) { $storeunder=$grplevelm; }
713: if ($snum==4) { $storeunder=$grplevelr; }
714:
1.186 www 715:
716: my $delete;
717: if ($nval eq '') { $delete=1;}
718: my %storecontent = ($storeunder => $nval,
719: $storeunder.'.type' => $ntype);
720: my $reply='';
721: if ($snum>3) {
722: # ---------------------------------------------------------------- Store Course
723: #
1.200 www 724: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
725: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 726: # Expire sheets
727: &Apache::lonnet::expirespread('','','studentcalc');
1.269 raeburn 728: if (($snum==10) || ($snum==7) || ($snum==4)) {
1.197 www 729: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.269 raeburn 730: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
1.197 www 731: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 732: } else {
733: &Apache::lonnet::expirespread('','','assesscalc');
734: }
735: # Store parameter
736: if ($delete) {
737: $reply=&Apache::lonnet::del
1.200 www 738: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.290 www 739: &log_parmset(\%storecontent,1);
1.186 www 740: } else {
741: $reply=&Apache::lonnet::cput
1.200 www 742: ('resourcedata',\%storecontent,$cdom,$cnum);
1.290 www 743: &log_parmset(\%storecontent);
1.186 www 744: }
1.200 www 745: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 746: } else {
747: # ------------------------------------------------------------------ Store User
748: #
749: # Expire sheets
750: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
751: if ($snum==1) {
752: &Apache::lonnet::expirespread
1.197 www 753: ($uname,$udom,'assesscalc',$symb);
1.186 www 754: } elsif ($snum==2) {
755: &Apache::lonnet::expirespread
1.197 www 756: ($uname,$udom,'assesscalc',$map);
1.186 www 757: } else {
758: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
759: }
760: # Store parameter
761: if ($delete) {
762: $reply=&Apache::lonnet::del
763: ('resourcedata',[keys(%storecontent)],$udom,$uname);
1.290 www 764: &log_parmset(\%storecontent,1,$uname,$udom);
1.186 www 765: } else {
766: $reply=&Apache::lonnet::cput
767: ('resourcedata',\%storecontent,$udom,$uname);
1.290 www 768: &log_parmset(\%storecontent,0,$uname,$udom);
1.186 www 769: }
1.191 albertel 770: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 771: }
772:
773: if ($reply=~/^error\:(.*)/) {
1.314 albertel 774: return "<span class=\"LC_error\">Write Error: $1</span>";
1.186 www 775: }
776: return '';
777: }
778:
1.9 www 779:
780: sub valout {
1.320 www 781: my ($value,$type,$editable)=@_;
1.59 matthew 782: my $result = '';
783: # Values of zero are valid.
784: if (! $value && $value ne '0') {
1.320 www 785: if ($editable) {
1.324 www 786: $result = '<span class="LC_clickhere">*</span>';
1.320 www 787: } else {
788: $result=' ';
789: }
1.59 matthew 790: } else {
1.66 www 791: if ($type eq 'date_interval') {
792: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
1.413 bisitz 793: my @timer;
1.66 www 794: $year=$year-70;
795: $mday--;
796: if ($year) {
1.413 bisitz 797: # $result.=&mt('[quant,_1,yr]',$year).' ';
798: push(@timer,&mt('[quant,_1,yr]',$year));
1.66 www 799: }
800: if ($mon) {
1.413 bisitz 801: # $result.=&mt('[quant,_1,mth]',$mon).' ';
802: push(@timer,&mt('[quant,_1,mth]',$mon));
1.66 www 803: }
804: if ($mday) {
1.413 bisitz 805: # $result.=&mt('[quant,_1,day]',$mday).' ';
806: push(@timer,&mt('[quant,_1,day]',$mday));
1.66 www 807: }
808: if ($hour) {
1.413 bisitz 809: # $result.=&mt('[quant,_1,hr]',$hour).' ';
810: push(@timer,&mt('[quant,_1,hr]',$hour));
1.66 www 811: }
812: if ($min) {
1.413 bisitz 813: # $result.=&mt('[quant,_1,min]',$min).' ';
814: push(@timer,&mt('[quant,_1,min]',$min));
1.66 www 815: }
816: if ($sec) {
1.413 bisitz 817: # $result.=&mt('[quant,_1,sec]',$sec).' ';
818: push(@timer,&mt('[quant,_1,sec]',$sec));
1.66 www 819: }
1.413 bisitz 820: # $result=~s/\s+$//;
821: if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable
822: push(@timer,&mt('[quant,_1,sec]',0));
823: }
824: $result.=join(", ",@timer);
1.213 www 825: } elsif (&isdateparm($type)) {
1.361 albertel 826: $result = &Apache::lonlocal::locallocaltime($value).
827: &date_sanity_info($value);
1.59 matthew 828: } else {
829: $result = $value;
1.378 albertel 830: $result = &HTML::Entities::encode($result,'"<>&');
1.59 matthew 831: }
832: }
833: return $result;
1.9 www 834: }
835:
1.59 matthew 836:
1.5 www 837: sub plink {
838: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 839: my $winvalue=$value;
840: unless ($winvalue) {
1.213 www 841: if (&isdateparm($type)) {
1.190 albertel 842: $winvalue=$env{'form.recent_'.$type};
1.23 www 843: } else {
1.190 albertel 844: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 845: }
846: }
1.229 www 847: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
848: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
849: unless (defined($winvalue)) { $winvalue=$val; }
1.378 albertel 850: my $valout = &valout($value,$type,1);
1.429 raeburn 851: my $unencmarker = $marker;
1.378 albertel 852: foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
853: \$hour, \$min, \$sec) {
854: $$item = &HTML::Entities::encode($$item,'"<>&');
855: $$item =~ s/\'/\\\'/g;
856: }
1.429 raeburn 857: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'.
1.43 albertel 858: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.229 www 859: .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
1.378 albertel 860: $valout.'</a></td></tr></table>';
1.5 www 861: }
862:
1.280 albertel 863: sub page_js {
864:
1.81 www 865: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 866: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.280 albertel 867:
868: return(<<ENDJS);
869: <script type="text/javascript">
1.44 albertel 870:
871: function pclose() {
872: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
873: "height=350,width=350,scrollbars=no,menubar=no");
874: parmwin.close();
875: }
876:
1.88 matthew 877: $pjump_def
1.44 albertel 878:
879: function psub() {
880: pclose();
881: if (document.parmform.pres_marker.value!='') {
882: document.parmform.action+='#'+document.parmform.pres_marker.value;
883: var typedef=new Array();
884: typedef=document.parmform.pres_type.value.split('_');
885: if (document.parmform.pres_type.value!='') {
886: if (typedef[0]=='date') {
887: eval('document.parmform.recent_'+
888: document.parmform.pres_type.value+
889: '.value=document.parmform.pres_value.value;');
890: } else {
891: eval('document.parmform.recent_'+typedef[0]+
892: '.value=document.parmform.pres_value.value;');
893: }
894: }
895: document.parmform.submit();
896: } else {
897: document.parmform.pres_value.value='';
898: document.parmform.pres_marker.value='';
899: }
900: }
901:
1.57 albertel 902: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
903: var options = "width=" + w + ",height=" + h + ",";
904: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
905: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
906: var newWin = window.open(url, wdwName, options);
907: newWin.focus();
908: }
1.44 albertel 909: </script>
1.81 www 910: $selscript
1.280 albertel 911: ENDJS
912:
913: }
914: sub startpage {
915: my ($r) = @_;
1.281 albertel 916:
1.282 albertel 917: my %loaditems = ('onunload' => "pclose()",
1.283 albertel 918: 'onload' => "group_or_section('cgroup')",);
1.280 albertel 919:
1.414 droeschl 920: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
921: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
922: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
923: text=>"Problem Parameters"});
924: } else {
925: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
926: text=>"Table Mode",
927: help => 'Course_Setting_Parameters'});
928: }
1.281 albertel 929: my $start_page =
930: &Apache::loncommon::start_page('Set/Modify Course Parameters',
931: &page_js(),
1.282 albertel 932: {'add_entries' => \%loaditems,});
1.280 albertel 933: my $breadcrumbs =
1.321 www 934: &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode');
1.280 albertel 935: $r->print(<<ENDHEAD);
1.281 albertel 936: $start_page
1.193 albertel 937: $breadcrumbs
938: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.419 bisitz 939: <input type="hidden" value="" name="pres_value" />
940: <input type="hidden" value="" name="pres_type" />
941: <input type="hidden" value="" name="pres_marker" />
942: <input type="hidden" value="1" name="prevvisit" />
1.44 albertel 943: ENDHEAD
944: }
945:
1.209 www 946:
1.44 albertel 947: sub print_row {
1.201 www 948: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.275 raeburn 949: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
950: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
951: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
952: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 953: # get the values for the parameter in cascading order
954: # empty levels will remain empty
1.44 albertel 955: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.275 raeburn 956: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 957: # get the type for the parameters
958: # problem: these may not be set for all levels
959: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 raeburn 960: $$name{$which}.'.type',$rid,
961: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 962: # cascade down manually
1.182 albertel 963: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 964: for (my $i=14;$i>0;$i--) {
1.66 www 965: if ($typeoutpar[$i]) {
966: $cascadetype=$typeoutpar[$i];
967: } else {
968: $typeoutpar[$i]=$cascadetype;
969: }
970: }
1.57 albertel 971: my $parm=$$display{$which};
972:
1.203 www 973: if ($parmlev eq 'full') {
1.419 bisitz 974: $r->print('<td style="background-color:'.$defbgtwo.';" align="center">'
1.57 albertel 975: .$$part{$which}.'</td>');
976: } else {
977: $parm=~s|\[.*\]\s||g;
1.426 bisitz 978: $parm=&mt($parm);
1.57 albertel 979: }
1.231 www 980: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
981: if ($automatic) {
1.314 albertel 982: $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
1.231 www 983: }
1.427 bisitz 984: $r->print('<td>'.$parm.'</td>');
1.57 albertel 985:
1.44 albertel 986: my $thismarker=$which;
987: $thismarker=~s/^parameter\_//;
988: my $mprefix=$rid.'&'.$thismarker.'&';
1.275 raeburn 989: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
990: my ($othergrp,$grp_parm,$controlgrp);
1.44 albertel 991:
1.57 albertel 992: if ($parmlev eq 'general') {
993:
994: if ($uname) {
1.66 www 995: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 996: } elsif ($cgroup) {
997: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 998: } elsif ($csec) {
1.269 raeburn 999: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1000: } else {
1.269 raeburn 1001: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1002: }
1003: } elsif ($parmlev eq 'map') {
1004:
1005: if ($uname) {
1.66 www 1006: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 1007: } elsif ($cgroup) {
1008: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1009: } elsif ($csec) {
1.269 raeburn 1010: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1011: } else {
1.269 raeburn 1012: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1013: }
1014: } else {
1.275 raeburn 1015: if ($uname) {
1016: if (@{$usersgroups} > 1) {
1017: my ($coursereply,$grp_parm,$controlgrp);
1018: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
1019: &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
1020: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
1021: if ($coursereply && $result > 3) {
1022: if (defined($controlgrp)) {
1023: if ($cgroup ne $controlgrp) {
1024: $effective_parm = $grp_parm;
1025: $result = 0;
1026: }
1027: }
1028: }
1029: }
1030: }
1.57 albertel 1031:
1.269 raeburn 1032: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1033:
1.269 raeburn 1034: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1035: &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1036: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 1037: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1038:
1039: if ($csec) {
1.269 raeburn 1040: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1041: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1042: &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 1043: }
1.269 raeburn 1044:
1045: if ($cgroup) {
1046: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1047: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1048: &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1049: }
1.275 raeburn 1050:
1.203 www 1051: if ($uname) {
1.275 raeburn 1052: if ($othergrp) {
1053: $r->print($othergrp);
1054: }
1.203 www 1055: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1056: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1057: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1058: }
1.57 albertel 1059:
1060: } # end of $parmlev if/else
1.419 bisitz 1061: $r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.'</td>');
1.136 albertel 1062:
1.203 www 1063: if ($parmlev eq 'full') {
1.136 albertel 1064: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 1065: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 1066: my $sessionvaltype=$typeoutpar[$result];
1067: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.419 bisitz 1068: $r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'.
1.66 www 1069: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 1070: '</font></td>');
1.136 albertel 1071: }
1.44 albertel 1072: $r->print('</tr>');
1.57 albertel 1073: $r->print("\n");
1.44 albertel 1074: }
1.59 matthew 1075:
1.44 albertel 1076: sub print_td {
1.66 www 1077: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.419 bisitz 1078: $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).
1079: ';" align="center">');
1.269 raeburn 1080: if ($which<11 || $which > 12) {
1.114 www 1081: $r->print(&plink($$typeoutpar[$which],
1082: $$display{$value},$$outpar[$which],
1083: $mprefix."$which",'parmform.pres','psub'));
1084: } else {
1085: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
1086: }
1087: $r->print('</td>'."\n");
1.57 albertel 1088: }
1089:
1.275 raeburn 1090: sub print_usergroups {
1091: my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
1092: my $courseid = $env{'request.course.id'};
1093: my $output;
1094: my $symb = &symbcache($rid);
1095: my $symbparm=$symb.'.'.$what;
1096: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1097: my $mapparm=$map.'___(all).'.$what;
1098: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
1099: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
1100: $courseopt);
1101: my $bgcolor = $defbg;
1102: my $grp_parm;
1103: if (($coursereply) && ($cgroup ne $resultgroup)) {
1104: if ($result > 3) {
1.419 bisitz 1105: $bgcolor = '#AAFFAA';
1.275 raeburn 1106: $grp_parm = &valout($coursereply,$resulttype);
1107: }
1108: $grp_parm = &valout($coursereply,$resulttype);
1.419 bisitz 1109: $output = '<td style="background-color:'.$bgcolor.';" align="center">';
1.275 raeburn 1110: if ($resultgroup && $resultlevel) {
1111: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
1112: } else {
1113: $output .= ' ';
1114: }
1115: $output .= '</td>';
1116: } else {
1.419 bisitz 1117: $output .= '<td style="background-color:'.$bgcolor.';"> </td>';
1.275 raeburn 1118: }
1119: return ($coursereply,$output,$grp_parm,$resultgroup);
1120: }
1121:
1122: sub parm_control_group {
1123: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
1124: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
1125: my $grpfound = 0;
1126: my @levels = ($symbparm,$mapparm,$what);
1127: my @levelnames = ('resource','map/folder','general');
1128: foreach my $group (@{$usersgroups}) {
1129: if ($grpfound) { last; }
1130: for (my $i=0; $i<@levels; $i++) {
1131: my $item = $courseid.'.['.$group.'].'.$levels[$i];
1132: if (defined($$courseopt{$item})) {
1133: $coursereply = $$courseopt{$item};
1134: $resultitem = $item;
1135: $resultgroup = $group;
1136: $resultlevel = $levelnames[$i];
1137: $resulttype = $$courseopt{$item.'.type'};
1138: $grpfound = 1;
1139: last;
1140: }
1141: }
1142: }
1143: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
1144: }
1.201 www 1145:
1.63 bowersj2 1146:
1147:
1148: sub extractResourceInformation {
1149: my $ids = shift;
1150: my $typep = shift;
1151: my $keyp = shift;
1152: my $allparms = shift;
1153: my $allparts = shift;
1154: my $allmaps = shift;
1155: my $mapp = shift;
1156: my $symbp = shift;
1.82 www 1157: my $maptitles=shift;
1.196 www 1158: my $uris=shift;
1.210 www 1159: my $keyorder=shift;
1.211 www 1160: my $defkeytype=shift;
1.196 www 1161:
1.210 www 1162: my $keyordercnt=100;
1.63 bowersj2 1163:
1.196 www 1164: my $navmap = Apache::lonnavmaps::navmap->new();
1165: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
1166: foreach my $resource (@allres) {
1167: my $id=$resource->id();
1168: my ($mapid,$resid)=split(/\./,$id);
1169: if ($mapid eq '0') { next; }
1170: $$ids[$#$ids+1]=$id;
1171: my $srcf=$resource->src();
1172: $srcf=~/\.(\w+)$/;
1173: $$typep{$id}=$1;
1174: $$keyp{$id}='';
1175: $$uris{$id}=$srcf;
1.363 albertel 1176: foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
1177: next if ($key!~/^parameter_/);
1178:
1.209 www 1179: # Hidden parameters
1.363 albertel 1180: next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
1.209 www 1181: #
1182: # allparms is a hash of parameter names
1183: #
1.363 albertel 1184: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
1.375 albertel 1185: if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
1.363 albertel 1186: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
1.196 www 1187: my $parmdis = $display;
1.412 bisitz 1188: $parmdis =~ s/\s*\[Part.*$//g;
1.363 albertel 1189: $$allparms{$name}=$parmdis;
1190: if (ref($defkeytype)) {
1191: $$defkeytype{$name}=
1192: &Apache::lonnet::metadata($srcf,$key.'.type');
1193: }
1194: }
1195:
1.209 www 1196: #
1197: # allparts is a hash of all parts
1198: #
1.363 albertel 1199: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.410 bisitz 1200: $$allparts{$part} = &mt('Part: [_1]',$part);
1.209 www 1201: #
1202: # Remember all keys going with this resource
1203: #
1.363 albertel 1204: if ($$keyp{$id}) {
1205: $$keyp{$id}.=','.$key;
1206: } else {
1207: $$keyp{$id}=$key;
1208: }
1.210 www 1209: #
1210: # Put in order
1211: #
1.363 albertel 1212: unless ($$keyorder{$key}) {
1213: $$keyorder{$key}=$keyordercnt;
1214: $keyordercnt++;
1215: }
1216: }
1.210 www 1217:
1.363 albertel 1218:
1219: if (!exists($$mapp{$mapid})) {
1220: $$mapp{$id}=
1221: &Apache::lonnet::declutter($resource->enclosing_map_src());
1222: $$mapp{$mapid}=$$mapp{$id};
1223: $$allmaps{$mapid}=$$mapp{$id};
1224: if ($mapid eq '1') {
1.401 bisitz 1225: $$maptitles{$mapid}=&mt('Main Course Documents');
1.363 albertel 1226: } else {
1227: $$maptitles{$mapid}=
1228: &Apache::lonnet::gettitle($$mapp{$id});
1.63 bowersj2 1229: }
1.363 albertel 1230: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1231: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.196 www 1232: } else {
1.363 albertel 1233: $$mapp{$id} = $$mapp{$mapid};
1.196 www 1234: }
1235: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
1.63 bowersj2 1236: }
1237: }
1238:
1.208 www 1239:
1240:
1.213 www 1241: sub isdateparm {
1242: my $type=shift;
1243: return (($type=~/^date/) && (!($type eq 'date_interval')));
1244: }
1245:
1.208 www 1246: sub parmmenu {
1.211 www 1247: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 1248: my $tempkey;
1249: $r->print(<<ENDSCRIPT);
1250: <script type="text/javascript">
1251: function checkall(value, checkName) {
1252: for (i=0; i<document.forms.parmform.elements.length; i++) {
1253: ele = document.forms.parmform.elements[i];
1254: if (ele.name == checkName) {
1255: document.forms.parmform.elements[i].checked=value;
1256: }
1257: }
1258: }
1.210 www 1259:
1260: function checkthis(thisvalue, checkName) {
1261: for (i=0; i<document.forms.parmform.elements.length; i++) {
1262: ele = document.forms.parmform.elements[i];
1263: if (ele.name == checkName) {
1264: if (ele.value == thisvalue) {
1265: document.forms.parmform.elements[i].checked=true;
1266: }
1267: }
1268: }
1269: }
1270:
1271: function checkdates() {
1272: checkthis('duedate','pscat');
1273: checkthis('opendate','pscat');
1274: checkthis('answerdate','pscat');
1.218 www 1275: }
1276:
1277: function checkdisset() {
1278: checkthis('discussend','pscat');
1279: checkthis('discusshide','pscat');
1280: }
1281:
1282: function checkcontdates() {
1283: checkthis('contentopen','pscat');
1284: checkthis('contentclose','pscat');
1285: }
1286:
1.210 www 1287:
1288: function checkvisi() {
1289: checkthis('hiddenresource','pscat');
1290: checkthis('encrypturl','pscat');
1291: checkthis('problemstatus','pscat');
1292: checkthis('contentopen','pscat');
1293: checkthis('opendate','pscat');
1294: }
1295:
1296: function checkparts() {
1297: checkthis('hiddenparts','pscat');
1298: checkthis('display','pscat');
1299: checkthis('ordered','pscat');
1300: }
1301:
1302: function checkstandard() {
1303: checkall(false,'pscat');
1304: checkdates();
1305: checkthis('weight','pscat');
1306: checkthis('maxtries','pscat');
1307: }
1308:
1.208 www 1309: </script>
1310: ENDSCRIPT
1.209 www 1311: $r->print();
1.422 bisitz 1312: $r->print("\n".'<table id="LC_parm_overview_parm_menu"><tr>');
1.208 www 1313: my $cnt=0;
1.211 www 1314: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.419 bisitz 1315: $r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
1.208 www 1316: $r->print('value="'.$tempkey.'"');
1317: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1.422 bisitz 1318: $r->print(' checked="checked"');
1.208 www 1319: }
1.431 ! raeburn 1320: my $displaykey = &standard_parameter_names($tempkey);
! 1321: if ($displaykey eq '') {
! 1322: if ($$allparms{$tempkey}=~/\S/) {
! 1323: $displaykey = $$allparms{$tempkey};
! 1324: } else {
! 1325: $displaykey = $tempkey;
! 1326: }
1.428 raeburn 1327: }
1.431 ! raeburn 1328: $r->print(' />'.$displaykey.'</label></td>');
1.209 www 1329: $cnt++;
1330: if ($cnt==3) {
1331: $r->print("</tr>\n<tr>");
1332: $cnt=0;
1333: }
1.208 www 1334: }
1.410 bisitz 1335: $r->print('</tr>'
1.422 bisitz 1336: .'<tr id="LC_parm_overview_parm_menu_selectors">'
1.410 bisitz 1337: .'<td valign="top">'
1338: .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'
1339: .'<span class="LC_nobreak">'
1340: .'• <a href="javascript:checkall(true, \'pscat\')">'.&mt('Select All').'</a>'
1341: .'</span>'
1342: .'<br />'
1343: .'<span class="LC_nobreak">'
1344: .'• <a href="javascript:checkstandard()">'.&mt('Select Common Only').'</a>'
1345: .'</span>'
1346: .'<br />'
1347: .'<span class="LC_nobreak">'
1348: .'• <a href="javascript:checkall(false, \'pscat\')">'.&mt('Unselect All').'</a>'
1349: .'</span>'
1350: .'</fieldset>'
1351: .'</td>'
1352: .'<td colspan="2" valign="top">'
1353: .'<fieldset><legend><b>'.&mt('Add Selection for...').'</b></legend>'
1354: .'<span class="LC_nobreak">'
1355: .'• <a href="javascript:checkdates()">'.&mt('Problem Dates').'</a>'
1356: .'</span>'
1357: .'<span class="LC_nobreak">'
1358: .' • <a href="javascript:checkcontdates()">'.&mt('Content Dates').'</a>'
1359: .'</span>'
1360: # .'<br />'
1361: .'<span class="LC_nobreak">'
1362: .' • <a href="javascript:checkdisset()">'.&mt('Discussion Settings').'</a>'
1363: .'</span>'
1364: .'<span class="LC_nobreak">'
1365: .' • <a href="javascript:checkvisi()">'.&mt('Visibilities').'</a>'
1366: .'</span>'
1367: # .'<br />'
1368: .'<span class="LC_nobreak">'
1369: .' • <a href="javascript:checkparts()">'.&mt('Part Parameters').'</a>'
1370: .'</span>'
1371: .'</fieldset>'
1372: .'</td>'
1373: .'</tr></table>'
1374: );
1.208 www 1375: }
1376:
1.209 www 1377: sub partmenu {
1378: my ($r,$allparts,$psprt)=@_;
1.421 bisitz 1379: $r->print('<select multiple="multiple" name="psprt" size="8">');
1.208 www 1380: $r->print('<option value="all"');
1.401 bisitz 1381: $r->print(' selected="selected"') unless (@{$psprt});
1.208 www 1382: $r->print('>'.&mt('All Parts').'</option>');
1383: my %temphash=();
1384: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1385: foreach my $tempkey (sort {
1386: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1387: } keys(%{$allparts})) {
1.208 www 1388: unless ($tempkey =~ /\./) {
1389: $r->print('<option value="'.$tempkey.'"');
1390: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1.401 bisitz 1391: $r->print(' selected="selected"');
1.208 www 1392: }
1393: $r->print('>'.$$allparts{$tempkey}.'</option>');
1394: }
1395: }
1.209 www 1396: $r->print('</select>');
1397: }
1398:
1399: sub usermenu {
1.275 raeburn 1400: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1401: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1402: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1403: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.412 bisitz 1404:
1.209 www 1405: my $sections='';
1.300 albertel 1406: my %sectionhash = &Apache::loncommon::get_sections();
1407:
1.269 raeburn 1408: my $groups;
1.307 raeburn 1409: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1410:
1.412 bisitz 1411: my $g_s_header='';
1412: my $g_s_footer='';
1413:
1.300 albertel 1414: if (%sectionhash) {
1.412 bisitz 1415: $sections=&mt('Section:').' <select name="csec"';
1.299 albertel 1416: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 1417: $sections .= qq| onchange="group_or_section('csec')" |;
1418: }
1419: $sections .= '>';
1.275 raeburn 1420: foreach my $section ('',sort keys %sectionhash) {
1421: $sections.='<option value="'.$section.'" '.
1422: ($section eq $csec?'selected="selected"':'').'>'.$section.
1423: '</option>';
1.209 www 1424: }
1425: $sections.='</select>';
1.269 raeburn 1426: }
1.412 bisitz 1427:
1.300 albertel 1428: if (%sectionhash && %grouphash && $parmlev ne 'full') {
1.412 bisitz 1429: $sections .= ' '.&mt('or').' ';
1.269 raeburn 1430: $sections .= qq|
1431: <script type="text/javascript">
1432: function group_or_section(caller) {
1433: if (caller == "cgroup") {
1434: if (document.parmform.cgroup.selectedIndex != 0) {
1435: document.parmform.csec.selectedIndex = 0;
1436: }
1437: } else {
1438: if (document.parmform.csec.selectedIndex != 0) {
1439: document.parmform.cgroup.selectedIndex = 0;
1440: }
1441: }
1442: }
1443: </script>
1444: |;
1445: } else {
1446: $sections .= qq|
1447: <script type="text/javascript">
1448: function group_or_section(caller) {
1449: return;
1450: }
1451: </script>
1452: |;
1453: }
1.299 albertel 1454:
1455: if (%grouphash) {
1.412 bisitz 1456: $groups=&mt('Group:').' <select name="cgroup"';
1.300 albertel 1457: if (%sectionhash && $env{'form.action'} eq 'settable') {
1.269 raeburn 1458: $groups .= qq| onchange="group_or_section('cgroup')" |;
1459: }
1460: $groups .= '>';
1.275 raeburn 1461: foreach my $grp ('',sort keys %grouphash) {
1462: $groups.='<option value="'.$grp.'" ';
1463: if ($grp eq $cgroup) {
1464: unless ((defined($uname)) && ($grp eq '')) {
1465: $groups .= 'selected="selected" ';
1466: }
1467: } elsif (!defined($cgroup)) {
1468: if (@{$usersgroups} == 1) {
1469: if ($grp eq $$usersgroups[0]) {
1470: $groups .= 'selected="selected" ';
1471: }
1472: }
1473: }
1474: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1475: }
1476: $groups.='</select>';
1477: }
1.412 bisitz 1478:
1479: if (%sectionhash || %grouphash) {
1480: $g_s_header='<fieldset><legend>'.&mt('Group/Section').'</legend><div>';
1481: $g_s_footer='</div></fieldset>';
1482: }
1483:
1484: $r->print('<b>'
1485: .$g_s_header
1486: .$sections
1487: .$groups
1488: .$g_s_footer
1489: .'<fieldset><legend>'.&mt('User').'</legend><div>'
1490: .&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]'
1491: ,'<input type="text" value="'.$uname.'" size="12" name="uname" />'
1492: ,'<input type="text" value="'.$id.'" size="12" name="id" /> '
1493: ,$chooseopt)
1494: .'</div></fieldset>'
1495: .'</b>'
1496: );
1.209 www 1497: }
1498:
1499: sub displaymenu {
1.211 www 1500: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1501: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1502: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1503: &parmmenu($r,$allparms,$pscat,$keyorder);
1.412 bisitz 1504: $r->print('</td><td valign="top" align="center">');
1.209 www 1505: &partmenu($r,$allparts,$psprt);
1506: $r->print('</td></tr></table>');
1507: }
1508:
1509: sub mapmenu {
1510: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1511: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1512: $r->print('<select name="pschp">');
1513: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1514: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1515: $r->print('<option value="'.$_.'"');
1.401 bisitz 1516: if (($pschp eq $_)) { $r->print(' selected="selected"'); }
1.209 www 1517: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1518: }
1519: $r->print("</select>");
1520: }
1521:
1522: sub levelmenu {
1523: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1524: $r->print('<b>'.&mt('Select Parameter Level').
1525: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1526: $r->print('<select name="parmlev">');
1527: foreach (reverse sort keys %{$alllevs}) {
1528: $r->print('<option value="'.$$alllevs{$_}.'"');
1529: if ($parmlev eq $$alllevs{$_}) {
1.401 bisitz 1530: $r->print(' selected="selected"');
1.209 www 1531: }
1.401 bisitz 1532: $r->print('>'.&mt($_).'</option>');
1.208 www 1533: }
1.209 www 1534: $r->print("</select>");
1.208 www 1535: }
1536:
1.211 www 1537:
1538: sub sectionmenu {
1539: my ($r,$selectedsections)=@_;
1.300 albertel 1540: my %sectionhash = &Apache::loncommon::get_sections();
1541: return if (!%sectionhash);
1542:
1.421 bisitz 1543: $r->print('<select name="Section" multiple="multiple" size="8">');
1.300 albertel 1544: foreach my $s ('all',sort keys %sectionhash) {
1545: $r->print(' <option value="'.$s.'"');
1546: foreach (@{$selectedsections}) {
1547: if ($s eq $_) {
1.401 bisitz 1548: $r->print(' selected="selected"');
1.300 albertel 1549: last;
1.212 www 1550: }
1551: }
1.300 albertel 1552: $r->print('>'.$s."</option>\n");
1553: }
1554: $r->print("</select>\n");
1.269 raeburn 1555: }
1556:
1557: sub groupmenu {
1558: my ($r,$selectedgroups)=@_;
1.307 raeburn 1559: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1560: return if (!%grouphash);
1561:
1.421 bisitz 1562: $r->print('<select name="Group" multiple="multiple" size="8">');
1.299 albertel 1563: foreach my $group (sort(keys(%grouphash))) {
1564: $r->print(' <option value="'.$group.'"');
1565: foreach (@{$selectedgroups}) {
1566: if ($group eq $_) {
1.401 bisitz 1567: $r->print(' selected="selected"');
1.299 albertel 1568: last;
1569: }
1570: }
1571: $r->print('>'.$group."</option>\n");
1.211 www 1572: }
1.299 albertel 1573: $r->print("</select>\n");
1.211 www 1574: }
1575:
1.269 raeburn 1576:
1.210 www 1577: sub keysplit {
1578: my $keyp=shift;
1579: return (split(/\,/,$keyp));
1580: }
1581:
1582: sub keysinorder {
1583: my ($name,$keyorder)=@_;
1584: return sort {
1585: $$keyorder{$a} <=> $$keyorder{$b};
1586: } (keys %{$name});
1587: }
1588:
1.236 albertel 1589: sub keysinorder_bytype {
1590: my ($name,$keyorder)=@_;
1591: return sort {
1592: my $ta=(split('_',$a))[-1];
1593: my $tb=(split('_',$b))[-1];
1594: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1595: return ($a cmp $b);
1596: }
1597: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1598: } (keys %{$name});
1599: }
1600:
1.211 www 1601: sub keysindisplayorder {
1602: my ($name,$keyorder)=@_;
1603: return sort {
1604: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1605: } (keys %{$name});
1606: }
1607:
1.214 www 1608: sub sortmenu {
1609: my ($r,$sortorder)=@_;
1.236 albertel 1610: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1611: if ($sortorder eq 'realmstudent') {
1.422 bisitz 1612: $r->print(' checked="checked"');
1.214 www 1613: }
1614: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1615: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1616: if ($sortorder eq 'studentrealm') {
1.422 bisitz 1617: $r->print(' checked="checked"');
1.214 www 1618: }
1.236 albertel 1619: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1620: '</label>');
1.214 www 1621: }
1622:
1.211 www 1623: sub standardkeyorder {
1624: return ('parameter_0_opendate' => 1,
1625: 'parameter_0_duedate' => 2,
1626: 'parameter_0_answerdate' => 3,
1627: 'parameter_0_interval' => 4,
1628: 'parameter_0_weight' => 5,
1629: 'parameter_0_maxtries' => 6,
1630: 'parameter_0_hinttries' => 7,
1631: 'parameter_0_contentopen' => 8,
1632: 'parameter_0_contentclose' => 9,
1633: 'parameter_0_type' => 10,
1634: 'parameter_0_problemstatus' => 11,
1635: 'parameter_0_hiddenresource' => 12,
1636: 'parameter_0_hiddenparts' => 13,
1637: 'parameter_0_display' => 14,
1638: 'parameter_0_ordered' => 15,
1639: 'parameter_0_tol' => 16,
1640: 'parameter_0_sig' => 17,
1.218 www 1641: 'parameter_0_turnoffunit' => 18,
1642: 'parameter_0_discussend' => 19,
1643: 'parameter_0_discusshide' => 20);
1.211 www 1644: }
1645:
1.59 matthew 1646:
1.30 www 1647: sub assessparms {
1.1 www 1648:
1.43 albertel 1649: my $r=shift;
1.201 www 1650:
1651: my @ids=();
1652: my %symbp=();
1653: my %mapp=();
1654: my %typep=();
1655: my %keyp=();
1656: my %uris=();
1657: my %maptitles=();
1658:
1.2 www 1659: # -------------------------------------------------------- Variable declaration
1.209 www 1660:
1.129 www 1661: my %allmaps=();
1662: my %alllevs=();
1.57 albertel 1663:
1.187 www 1664: my $uname;
1665: my $udom;
1666: my $uhome;
1667: my $csec;
1.269 raeburn 1668: my $cgroup;
1.275 raeburn 1669: my @usersgroups = ();
1.187 www 1670:
1.190 albertel 1671: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1672:
1.57 albertel 1673: $alllevs{'Resource Level'}='full';
1.215 www 1674: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1675: $alllevs{'Course Level'}='general';
1676:
1677: my %allparms;
1678: my %allparts;
1.210 www 1679: #
1680: # Order in which these parameters will be displayed
1681: #
1.211 www 1682: my %keyorder=&standardkeyorder();
1683:
1.43 albertel 1684: @ids=();
1685: %symbp=();
1686: %typep=();
1687:
1688: my $message='';
1689:
1.190 albertel 1690: $csec=$env{'form.csec'};
1.269 raeburn 1691: $cgroup=$env{'form.cgroup'};
1.188 www 1692:
1.190 albertel 1693: if ($udom=$env{'form.udom'}) {
1694: } elsif ($udom=$env{'request.role.domain'}) {
1695: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1696: } else {
1697: $udom=$r->dir_config('lonDefDomain');
1698: }
1.43 albertel 1699:
1.134 albertel 1700: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1701: my $pschp=$env{'form.pschp'};
1.134 albertel 1702: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1703: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1704:
1.43 albertel 1705: my $pssymb='';
1.57 albertel 1706: my $parmlev='';
1707:
1.190 albertel 1708: unless ($env{'form.parmlev'}) {
1.57 albertel 1709: $parmlev = 'map';
1710: } else {
1.190 albertel 1711: $parmlev = $env{'form.parmlev'};
1.57 albertel 1712: }
1.26 www 1713:
1.29 www 1714: # ----------------------------------------------- Was this started from grades?
1715:
1.190 albertel 1716: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1717: && (!$env{'form.dis'})) {
1718: my $url=$env{'form.url'};
1.194 albertel 1719: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1720: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1721: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1722: $pschp='';
1.57 albertel 1723: $parmlev = 'full';
1.190 albertel 1724: } elsif ($env{'form.symb'}) {
1725: $pssymb=$env{'form.symb'};
1.92 albertel 1726: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1727: $pschp='';
1.57 albertel 1728: $parmlev = 'full';
1.43 albertel 1729: } else {
1.190 albertel 1730: $env{'form.url'}='';
1.43 albertel 1731: }
1732:
1.190 albertel 1733: my $id=$env{'form.id'};
1.43 albertel 1734: if (($id) && ($udom)) {
1735: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1736: if ($uname) {
1737: $id='';
1738: } else {
1739: $message=
1.314 albertel 1740: '<span class="LC_error">'.&mt("Unknown ID")." '$id' ".
1741: &mt('at domain')." '$udom'</span>";
1.43 albertel 1742: }
1743: } else {
1.190 albertel 1744: $uname=$env{'form.uname'};
1.43 albertel 1745: }
1746: unless ($udom) { $uname=''; }
1747: $uhome='';
1748: if ($uname) {
1749: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1750: if ($uhome eq 'no_host') {
1751: $message=
1.314 albertel 1752: '<span class="LC_error">'.&mt("Unknown user")." '$uname' ".
1753: &mt("at domain")." '$udom'</span>";
1.43 albertel 1754: $uname='';
1.12 www 1755: } else {
1.103 albertel 1756: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1757: $env{'request.course.id'});
1.269 raeburn 1758:
1.43 albertel 1759: if ($csec eq '-1') {
1.314 albertel 1760: $message='<span class="LC_error">'.
1.133 www 1761: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1.314 albertel 1762: &mt("not in this course")."</span>";
1.43 albertel 1763: $uname='';
1.190 albertel 1764: $csec=$env{'form.csec'};
1.269 raeburn 1765: $cgroup=$env{'form.cgroup'};
1.43 albertel 1766: } else {
1767: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1768: ('firstname','middlename','lastname','generation','id'));
1.133 www 1769: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1770: $name{'firstname'}.' '.$name{'middlename'}.' '
1771: .$name{'lastname'}.' '.$name{'generation'}.
1.336 albertel 1772: "<br />\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1773: }
1.297 raeburn 1774: @usersgroups = &Apache::lonnet::get_users_groups(
1.275 raeburn 1775: $udom,$uname,$env{'request.course.id'});
1.297 raeburn 1776: if (@usersgroups > 0) {
1.306 albertel 1777: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
1.275 raeburn 1778: $cgroup = $usersgroups[0];
1.297 raeburn 1779: }
1.269 raeburn 1780: }
1.12 www 1781: }
1.43 albertel 1782: }
1.2 www 1783:
1.43 albertel 1784: unless ($csec) { $csec=''; }
1.269 raeburn 1785: unless ($cgroup) { $cgroup=''; }
1.12 www 1786:
1.14 www 1787: # --------------------------------------------------------- Get all assessments
1.210 www 1788: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1789: \%mapp, \%symbp,\%maptitles,\%uris,
1790: \%keyorder);
1.63 bowersj2 1791:
1.57 albertel 1792: $mapp{'0.0'} = '';
1793: $symbp{'0.0'} = '';
1.99 albertel 1794:
1.14 www 1795: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1796: if ($env{'form.pres_marker'}) {
1.205 www 1797: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1798: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1799: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1800: for (my $i=0;$i<=$#markers;$i++) {
1801: $message.=&storeparm(split(/\&/,$markers[$i]),
1802: $values[$i],
1803: $types[$i],
1.269 raeburn 1804: $uname,$udom,$csec,$cgroup);
1.205 www 1805: }
1.68 www 1806: # ---------------------------------------------------------------- Done storing
1.130 www 1807: $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
1.68 www 1808: }
1.57 albertel 1809: #----------------------------------------------- if all selected, fill in array
1.209 www 1810: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1811: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1812: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1813: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1814:
1.209 www 1815: &startpage($r);
1.57 albertel 1816:
1.44 albertel 1817: foreach ('tolerance','date_default','date_start','date_end',
1818: 'date_interval','int','float','string') {
1819: $r->print('<input type="hidden" value="'.
1.378 albertel 1820: &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
1821: '" name="recent_'.$_.'" />');
1.44 albertel 1822: }
1.57 albertel 1823:
1.44 albertel 1824: if (!$pssymb) {
1.209 www 1825: $r->print('<table border="1"><tr><td>');
1826: &levelmenu($r,\%alllevs,$parmlev);
1.424 bisitz 1827: $r->print('</td>');
1.128 albertel 1828: if ($parmlev ne 'general') {
1.209 www 1829: $r->print('<td>');
1830: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1831: $r->print('</td>');
1.128 albertel 1832: }
1.424 bisitz 1833: $r->print('</tr></table>');
1.211 www 1834: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1835: } else {
1.125 www 1836: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.312 albertel 1837: my $title = &Apache::lonnet::gettitle($pssymb);
1838: $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource).
1839: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.238 www 1840: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1841: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1842: }
1.275 raeburn 1843: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.57 albertel 1844:
1.210 www 1845: $r->print('<p>'.$message.'</p>');
1846:
1.209 www 1847: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1848:
1849: my @temp_pscat;
1850: map {
1851: my $cat = $_;
1852: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1853: } @pscat;
1854:
1855: @pscat = @temp_pscat;
1856:
1.209 www 1857: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1858: # ----------------------------------------------------------------- Start Table
1.57 albertel 1859: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1860: my $csuname=$env{'user.name'};
1861: my $csudom=$env{'user.domain'};
1.57 albertel 1862:
1.203 www 1863: if ($parmlev eq 'full') {
1.57 albertel 1864: my $coursespan=$csec?8:5;
1.275 raeburn 1865: my $userspan=3;
1.269 raeburn 1866: if ($cgroup ne '') {
1867: $coursespan += 3;
1868: }
1869:
1.419 bisitz 1870: $r->print('<p><table border="2">');
1871: $r->print('<tr><td colspan="5"></td>');
1872: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
1.57 albertel 1873: if ($uname) {
1.275 raeburn 1874: if (@usersgroups > 1) {
1875: $userspan ++;
1876: }
1877: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1878: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1879: }
1.133 www 1880: my %lt=&Apache::lonlocal::texthash(
1881: 'pie' => "Parameter in Effect",
1882: 'csv' => "Current Session Value",
1883: 'at' => 'at',
1884: 'rl' => "Resource Level",
1885: 'ic' => 'in Course',
1886: 'aut' => "Assessment URL and Title",
1.143 albertel 1887: 'type' => 'Type',
1.133 www 1888: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1889: 'part' => 'Part',
1.133 www 1890: 'pn' => 'Parameter Name',
1891: 'def' => 'default',
1892: 'femof' => 'from Enclosing Map or Folder',
1893: 'gen' => 'general',
1894: 'foremf' => 'for Enclosing Map or Folder',
1895: 'fr' => 'for Resource'
1896: );
1.57 albertel 1897: $r->print(<<ENDTABLETWO);
1.419 bisitz 1898: <th rowspan="3">$lt{'pie'}</th>
1899: <th rowspan="3">$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>
1900: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
1901: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 1902:
1.10 www 1903: ENDTABLETWO
1.57 albertel 1904: if ($csec) {
1.419 bisitz 1905: $r->print('<th colspan="3">'.
1.269 raeburn 1906: &mt("in Section")." $csec</th>");
1907: }
1908: if ($cgroup) {
1.419 bisitz 1909: $r->print('<th colspan="3">'.
1.269 raeburn 1910: &mt("in Group")." $cgroup</th>");
1.57 albertel 1911: }
1912: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1913: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1914: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1915: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1916: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1917: ENDTABLEHEADFOUR
1.57 albertel 1918:
1919: if ($csec) {
1.130 www 1920: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1921: }
1922:
1.269 raeburn 1923: if ($cgroup) {
1924: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1925: }
1926:
1.57 albertel 1927: if ($uname) {
1.275 raeburn 1928: if (@usersgroups > 1) {
1929: $r->print('<th>'.&mt('Control by other group?').'</th>');
1930: }
1.130 www 1931: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1932: }
1933:
1934: $r->print('</tr>');
1935:
1936: my $defbgone='';
1937: my $defbgtwo='';
1.269 raeburn 1938: my $defbgthree = '';
1.57 albertel 1939:
1940: foreach (@ids) {
1941:
1942: my $rid=$_;
1943: my ($inmapid)=($rid=~/\.(\d+)$/);
1944:
1.152 albertel 1945: if ((!$pssymb &&
1946: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1947: ||
1948: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1949: # ------------------------------------------------------ Entry for one resource
1.419 bisitz 1950: if ($defbgone eq '#E0E099') {
1951: $defbgone='#E0E0DD';
1.57 albertel 1952: } else {
1.419 bisitz 1953: $defbgone='#E0E099';
1.57 albertel 1954: }
1.419 bisitz 1955: if ($defbgtwo eq '#FFFF99') {
1956: $defbgtwo='#FFFFDD';
1.57 albertel 1957: } else {
1.419 bisitz 1958: $defbgtwo='#FFFF99';
1.57 albertel 1959: }
1.419 bisitz 1960: if ($defbgthree eq '#FFBB99') {
1961: $defbgthree='#FFBBDD';
1.269 raeburn 1962: } else {
1.419 bisitz 1963: $defbgthree='#FFBB99';
1.269 raeburn 1964: }
1965:
1.57 albertel 1966: my $thistitle='';
1967: my %name= ();
1968: undef %name;
1969: my %part= ();
1970: my %display=();
1971: my %type= ();
1972: my %default=();
1.196 www 1973: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1974:
1.210 www 1975: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1976: my $tempkeyp = $_;
1977: if (grep $_ eq $tempkeyp, @catmarker) {
1978: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1979: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1980: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1981: unless ($display{$_}) { $display{$_}=''; }
1982: $display{$_}.=' ('.$name{$_}.')';
1983: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1984: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1985: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1986: }
1987: }
1988: my $totalparms=scalar keys %name;
1989: if ($totalparms>0) {
1990: my $firstrow=1;
1.274 albertel 1991: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 1992: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 1993: ' rowspan='.$totalparms.
1.419 bisitz 1994: '><tt><font size="-1">'.
1.57 albertel 1995: join(' / ',split(/\//,$uri)).
1996: '</font></tt><p><b>'.
1.154 albertel 1997: "<a href=\"javascript:openWindow('".
1.274 albertel 1998: &Apache::lonnet::clutter($uri).'?symb='.
1.308 www 1999: &escape($symbp{$rid}).
1.336 albertel 2000: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
2001: " target=\"_self\">$title");
1.57 albertel 2002:
2003: if ($thistitle) {
2004: $r->print(' ('.$thistitle.')');
2005: }
2006: $r->print('</a></b></td>');
1.419 bisitz 2007: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 2008: ' rowspan='.$totalparms.'>'.$typep{$rid}.
2009: '</td>');
2010:
1.419 bisitz 2011: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 2012: ' rowspan='.$totalparms.
1.238 www 2013: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 2014:
1.236 albertel 2015: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 2016: unless ($firstrow) {
2017: $r->print('<tr>');
2018: } else {
2019: undef $firstrow;
2020: }
1.201 www 2021: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 2022: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 2023: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 2024: $cgroup,\@usersgroups);
1.57 albertel 2025: }
2026: }
2027: }
2028: } # end foreach ids
1.43 albertel 2029: # -------------------------------------------------- End entry for one resource
1.57 albertel 2030: $r->print('</table>');
1.203 www 2031: } # end of full
1.57 albertel 2032: #--------------------------------------------------- Entry for parm level map
2033: if ($parmlev eq 'map') {
1.419 bisitz 2034: my $defbgone = '#E0E099';
2035: my $defbgtwo = '#FFFF99';
2036: my $defbgthree = '#FFBB99';
1.57 albertel 2037:
2038: my %maplist;
2039:
2040: if ($pschp eq 'all') {
2041: %maplist = %allmaps;
2042: } else {
2043: %maplist = ($pschp => $mapp{$pschp});
2044: }
2045:
2046: #-------------------------------------------- for each map, gather information
2047: my $mapid;
1.60 albertel 2048: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
2049: my $maptitle = $maplist{$mapid};
1.57 albertel 2050:
2051: #----------------------- loop through ids and get all parameter types for map
2052: #----------------------------------------- and associated information
2053: my %name = ();
2054: my %part = ();
2055: my %display = ();
2056: my %type = ();
2057: my %default = ();
2058: my $map = 0;
2059:
2060: # $r->print("Catmarker: @catmarker<br />\n");
2061:
2062: foreach (@ids) {
2063: ($map)=(/([\d]*?)\./);
2064: my $rid = $_;
2065:
2066: # $r->print("$mapid:$map: $rid <br /> \n");
2067:
2068: if ($map eq $mapid) {
1.196 www 2069: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2070: # $r->print("Keys: $keyp{$rid} <br />\n");
2071:
2072: #--------------------------------------------------------------------
2073: # @catmarker contains list of all possible parameters including part #s
2074: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2075: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2076: # When storing information, store as part 0
2077: # When requesting information, request from full part
2078: #-------------------------------------------------------------------
1.210 www 2079: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2080: my $tempkeyp = $_;
2081: my $fullkeyp = $tempkeyp;
1.73 albertel 2082: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 2083:
2084: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2085: $part{$tempkeyp}="0";
2086: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
2087: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2088: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2089: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 2090: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 2091: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2092: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2093: }
2094: } # end loop through keys
2095: }
2096: } # end loop through ids
2097:
2098: #---------------------------------------------------- print header information
1.133 www 2099: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 2100: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 2101: my $tmp="";
1.57 albertel 2102: if ($uname) {
1.267 albertel 2103: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 2104: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
2105: &mt('in')." \n";
1.57 albertel 2106: } else {
1.401 bisitz 2107: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 2108: }
1.269 raeburn 2109: if ($cgroup) {
1.401 bisitz 2110: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
2111: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2112: $csec = '';
2113: } elsif ($csec) {
1.401 bisitz 2114: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
2115: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2116: }
1.401 bisitz 2117: $r->print('<div align="center"><h4>'
2118: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 2119: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 2120: ,$tmp
2121: ,'<font color="red"><i>'.$coursename.'</i></font>'
2122: )
2123: ."<br /></h4>\n"
1.422 bisitz 2124: );
1.57 albertel 2125: #---------------------------------------------------------------- print table
1.419 bisitz 2126: $r->print('<p>'.&Apache::loncommon::start_data_table()
2127: .&Apache::loncommon::start_data_table_header_row()
2128: .'<th>'.&mt('Parameter Name').'</th>'
2129: .'<th>'.&mt('Default Value').'</th>'
2130: .'<th>'.&mt('Parameter in Effect').'</th>'
2131: .&Apache::loncommon::end_data_table_header_row()
2132: );
1.57 albertel 2133:
1.210 www 2134: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2135: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2136: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2137: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2138: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2139: }
1.422 bisitz 2140: $r->print(&Apache::loncommon::end_data_table().'</p>'
2141: .'</div>'
2142: );
1.57 albertel 2143: } # end each map
2144: } # end of $parmlev eq map
2145: #--------------------------------- Entry for parm level general (Course level)
2146: if ($parmlev eq 'general') {
1.419 bisitz 2147: my $defbgone = '#E0E099';
2148: my $defbgtwo = '#FFFF99';
2149: my $defbgthree = '#FFBB99';
1.57 albertel 2150:
2151: #-------------------------------------------- for each map, gather information
2152: my $mapid="0.0";
2153: #----------------------- loop through ids and get all parameter types for map
2154: #----------------------------------------- and associated information
2155: my %name = ();
2156: my %part = ();
2157: my %display = ();
2158: my %type = ();
2159: my %default = ();
2160:
2161: foreach (@ids) {
2162: my $rid = $_;
2163:
1.196 www 2164: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2165:
2166: #--------------------------------------------------------------------
2167: # @catmarker contains list of all possible parameters including part #s
2168: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2169: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2170: # When storing information, store as part 0
2171: # When requesting information, request from full part
2172: #-------------------------------------------------------------------
1.210 www 2173: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2174: my $tempkeyp = $_;
2175: my $fullkeyp = $tempkeyp;
1.73 albertel 2176: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 2177: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2178: $part{$tempkeyp}="0";
2179: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
2180: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2181: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2182: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 2183: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 2184: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2185: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2186: }
2187: } # end loop through keys
2188: } # end loop through ids
2189:
2190: #---------------------------------------------------- print header information
1.133 www 2191: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 2192: $r->print(<<ENDMAPONE);
1.419 bisitz 2193: <center>
2194: <h4>$setdef
1.135 albertel 2195: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 2196: ENDMAPONE
2197: if ($uname) {
1.267 albertel 2198: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2199: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2200: } else {
1.135 albertel 2201: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2202: }
2203:
1.135 albertel 2204: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2205: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2206: $r->print("</h4>\n");
1.57 albertel 2207: #---------------------------------------------------------------- print table
1.419 bisitz 2208: $r->print('<p>'.&Apache::loncommon::start_data_table()
2209: .&Apache::loncommon::start_data_table_header_row()
2210: .'<th>'.&mt('Parameter Name').'</th>'
2211: .'<th>'.&mt('Default Value').'</th>'
2212: .'<th>'.&mt('Parameter in Effect').'</th>'
2213: .&Apache::loncommon::end_data_table_header_row()
2214: );
1.57 albertel 2215:
1.210 www 2216: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2217: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2218: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2219: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2220: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2221: }
1.419 bisitz 2222: $r->print(&Apache::loncommon::end_data_table()
2223: .'</p>'
2224: .'</center>'
2225: );
1.57 albertel 2226: } # end of $parmlev eq general
1.43 albertel 2227: }
1.280 albertel 2228: $r->print('</form>'.&Apache::loncommon::end_page());
1.57 albertel 2229: } # end sub assessparms
1.30 www 2230:
1.59 matthew 2231:
2232:
1.30 www 2233: sub crsenv {
2234: my $r=shift;
2235: my $setoutput='';
1.280 albertel 2236:
1.414 droeschl 2237: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
2238: text=>"Course Environment"});
1.298 albertel 2239: my $breadcrumbs =
2240: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
1.190 albertel 2241: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2242: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 2243:
1.392 raeburn 2244: my (%crsinfo,$chome);
2245:
1.105 matthew 2246: #
2247: # Go through list of changes
1.190 albertel 2248: foreach (keys %env) {
1.105 matthew 2249: next if ($_!~/^form\.(.+)\_setparmval$/);
2250: my $name = $1;
1.190 albertel 2251: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 2252: if ($name eq 'newp') {
1.190 albertel 2253: $name = $env{'form.newp_name'};
1.105 matthew 2254: }
2255: if ($name eq 'url') {
2256: $value=~s/^\/res\///;
2257: my $bkuptime=time;
2258: my @tmp = &Apache::lonnet::get
2259: ('environment',['url'],$dom,$crs);
1.130 www 2260: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2261: &Apache::lonnet::put
2262: ('environment',
2263: {'top level map backup '.$bkuptime => $tmp[1] },
2264: $dom,$crs).
1.336 albertel 2265: '<br />';
1.105 matthew 2266: }
2267: #
2268: # Deal with modified default spreadsheets
2269: if ($name =~ /^spreadsheet_default_(classcalc|
2270: studentcalc|
2271: assesscalc)$/x) {
2272: my $sheettype = $1;
2273: if ($sheettype eq 'classcalc') {
2274: # no need to do anything since viewing the sheet will
2275: # cause it to be updated.
2276: } elsif ($sheettype eq 'studentcalc') {
2277: # expire all the student spreadsheets
2278: &Apache::lonnet::expirespread('','','studentcalc');
2279: } else {
2280: # expire all the assessment spreadsheets
2281: # this includes non-default spreadsheets, but better to
2282: # be safe than sorry.
2283: &Apache::lonnet::expirespread('','','assesscalc');
2284: # expire all the student spreadsheets
2285: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2286: }
1.105 matthew 2287: }
2288: #
1.107 matthew 2289: # Deal with the enrollment dates
2290: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2291: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2292: }
1.364 albertel 2293: #
2294: # Deal with the emails
2295: if ($name =~ /\.email$/) {
1.371 albertel 2296: foreach my $specifier (split(',',$value)) {
2297: my ($user,$sections_or_groups)=
2298: ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
2299: if (!$sections_or_groups) {
2300: $user = $specifier;
2301: }
2302: my ($name,$domain) = split(':',$user);
2303: if (!defined($user) || !defined($domain)) {
2304: $setoutput.= '<br /> <span class="LC_error">'.
1.425 schafran 2305: &mt("Invalid e-mail address specified, address must be of the form username:domain what was specified was ([_1])",$user).
1.371 albertel 2306: '</span>';
2307: undef($value);
2308: } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
2309: $setoutput.= '<br /> <span class="LC_error">'.
1.425 schafran 2310: &mt("Invalid e-mail address specified, user [_1] is unknown.",$name).
1.371 albertel 2311: '</span>';
2312: undef($value);
2313: }
1.364 albertel 2314: }
2315: }
1.178 raeburn 2316: # Get existing cloners
2317: my @oldcloner = ();
2318: if ($name eq 'cloners') {
2319: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2320: if ($clonenames{'cloners'} =~ /,/) {
2321: @oldcloner = split/,/,$clonenames{'cloners'};
2322: } else {
2323: $oldcloner[0] = $clonenames{'cloners'};
2324: }
2325: }
1.107 matthew 2326: #
1.105 matthew 2327: # Let the user know we made the changes
1.153 albertel 2328: if ($name && defined($value)) {
1.379 raeburn 2329: my %failed_cloners;
1.178 raeburn 2330: if ($name eq 'cloners') {
1.239 raeburn 2331: $value =~ s/\s//g;
1.178 raeburn 2332: $value =~ s/^,//;
2333: $value =~ s/,$//;
1.239 raeburn 2334: # check requested clones are valid users.
1.379 raeburn 2335: %failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2336: }
1.105 matthew 2337: my $put_result = &Apache::lonnet::put('environment',
2338: {$name=>$value},$dom,$crs);
2339: if ($put_result eq 'ok') {
1.392 raeburn 2340: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
2341: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2342: $setoutput .= &Apache::lonlocal::locallocaltime($value);
1.406 raeburn 2343: } elsif ($name eq 'categories') {
2344: $setoutput .= $env{'form.categories_display'};
1.392 raeburn 2345: } else {
2346: $setoutput .= $value;
2347: }
2348: $setoutput .= '</b>.<br />';
1.178 raeburn 2349: if ($name eq 'cloners') {
2350: &change_clone($value,\@oldcloner);
2351: }
1.382 raeburn 2352: # Update environment and nohist_courseids.db
1.402 raeburn 2353: if (($name eq 'description') || ($name eq 'cloners') ||
1.403 raeburn 2354: ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.392 raeburn 2355: if ($chome eq '') {
2356: %crsinfo =
2357: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
1.403 raeburn 2358: $crs,undef,undef,'.');
1.392 raeburn 2359: $chome = &Apache::lonnet::homeserver($crs,$dom);
2360: }
2361: }
1.179 raeburn 2362: if ($name eq 'description' && defined($value)) {
1.393 raeburn 2363: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
1.382 raeburn 2364: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2365: $crsinfo{$env{'request.course.id'}}{'description'} = $value;
1.392 raeburn 2366: my $putresult =
2367: &Apache::lonnet::courseidput($dom,\%crsinfo,
2368: $chome,'notime');
2369: }
2370: }
1.403 raeburn 2371: if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.402 raeburn 2372: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1.403 raeburn 2373: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
2374: $crsinfo{$env{'request.course.id'}}{$name} = $value;
1.402 raeburn 2375: my $putresult =
2376: &Apache::lonnet::courseidput($dom,\%crsinfo,
2377: $chome,'notime');
2378: }
2379: }
1.105 matthew 2380: } else {
1.130 www 2381: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2382: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2383: }
1.379 raeburn 2384: if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
2385: $setoutput.= &mt('Unable to include').': ';
2386: my @fails;
2387: my $num = 0;
2388: if (defined($failed_cloners{'format'})) {
2389: $fails[$num] .= '<b>'.$failed_cloners{'format'}.
2390: '</b>, '.&mt('reason').' - '.
2391: &mt('Invalid format');
2392: $num ++;
2393: }
2394: if (defined($failed_cloners{'domain'})) {
2395: $fails[$num] .= '<b>'.$failed_cloners{'domain'}.
2396: '</b>, '.&mt('reason').' - '.
2397: &mt('Domain does not exist');
2398: $num ++;
2399: }
2400: if (defined($failed_cloners{'newuser'})) {
2401: $fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</b>, '.&mt('reason').' - '.
2402: &mt('LON-CAPA user(s) do(es) not exist.').
2403: '.<br />'.&mt('Please ').
2404: ' <a href="/adm/createuser">'.
2405: &mt('add the user(s)').'</a>, '.
2406: &mt('and then return to the ').
2407: '<a href="/adm/parmset?action=crsenv">'.
2408: &mt('Course Parameters page').'</a> '.
2409: &mt('to add the new user(s) to the list of possible cloners');
2410: }
2411: $setoutput .= join('; ',@fails).'.<br />';
1.239 raeburn 2412: }
1.30 www 2413: }
1.38 harris41 2414: }
1.315 albertel 2415:
2416: my $start_table =&Apache::loncommon::start_data_table();
2417: my $start_header_row=&Apache::loncommon::start_data_table_header_row();
2418: my $end_header_row =&Apache::loncommon::end_data_table_header_row();
1.108 www 2419: # ------------------------- Re-init course environment entries for this session
2420:
1.302 albertel 2421: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2422: {'freshen_cache' => 1});
1.105 matthew 2423:
1.30 www 2424: # -------------------------------------------------------- Get parameters again
1.45 matthew 2425:
2426: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2427: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2428: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2429: my $output='';
1.403 raeburn 2430: my $can_categorize;
1.45 matthew 2431: if (! exists($values{'con_lost'})) {
1.30 www 2432: my %descriptions=
1.395 bisitz 2433: ('url' => '<b>'.&mt('Top Level Map').'</b><br />'.
1.46 matthew 2434: '<a href="javascript:openbrowser'.
1.47 matthew 2435: "('envform','url','sequence')\">".
1.314 albertel 2436: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1.395 bisitz 2437: &mt('Modification may make assessment data inaccessible!').
1.314 albertel 2438: '</span>',
1.140 sakharuk 2439: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2440: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2441: '</b><br />'.
1.395 bisitz 2442: '('.&mt('internal, optional').')',
2443: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br />'
2444: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'
2445: .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'
2446: .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'
2447: .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),
1.150 www 2448: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1.395 bisitz 2449: &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),
2450: 'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'
2451: .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'
2452: .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',
2453: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.
1.52 www 2454: '<a href="javascript:openbrowser'.
2455: "('envform','default_xml_style'".
1.336 albertel 2456: ",'sty')\">$SelectStyleFile</a><br />",
1.395 bisitz 2457: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'
2458: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2459: 'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',
2460: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'
2461: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2462: 'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',
2463: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'
2464: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2465: 'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',
2466: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'
2467: .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',
2468: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'
2469: .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '
2470: .&mt('Changes will not show until next login.').')',
2471: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'
2472: .'('.&mt('[_1]: students can view all sections. [_2]: students can only view their own section. blank or [_3] prevents student view.','"<tt>all</tt>"','"<tt>section</tt>"','"<tt>disabled</tt>"').')',
2473: 'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'
1.420 bisitz 2474: .'('.&mt("[_1] for link to each a listing of each student's files.",'"<tt>yes</tt>"').')',
1.395 bisitz 2475: 'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'
2476: .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',
2477: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').'</b><br />'
2478: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2479: .'("<tt>'.&mt('role,role,...').'</tt>") '
2480: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.118 matthew 2481: 'plc.users.denied' =>
1.141 sakharuk 2482: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.395 bisitz 2483: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.118 matthew 2484:
1.395 bisitz 2485: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'
2486: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')
2487: .'("<tt>'.&mt('role,role,...').'</tt>") '
2488: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2489: 'pch.users.denied' =>
1.141 sakharuk 2490: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.395 bisitz 2491: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.49 matthew 2492: 'spreadsheet_default_classcalc'
1.141 sakharuk 2493: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2494: '<a href="javascript:openbrowser'.
2495: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2496: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2497: 'spreadsheet_default_studentcalc'
1.395 bisitz 2498: => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.
1.50 matthew 2499: '<a href="javascript:openbrowser'.
2500: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2501: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2502: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2503: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2504: '<a href="javascript:openbrowser'.
2505: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2506: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2507: 'allow_limited_html_in_feedback'
1.141 sakharuk 2508: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.395 bisitz 2509: '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',
1.170 raeburn 2510: 'allow_discussion_post_editing'
1.395 bisitz 2511: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'
2512: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2513: .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'
2514: .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'
2515: .'('.&mt('Example: "<tt>st:001,st:002,in,cc</tt>" would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')',
1.89 albertel 2516: 'rndseed'
1.395 bisitz 2517: => '<b>'.&mt('Randomization algorithm used').'</b><br />'
2518: .'<span class="LC_error">'
2519: .&mt('Modifying this will make problems have different numbers and answers!')
2520: .'</span>',
1.151 albertel 2521: 'receiptalg'
2522: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2523: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2524: 'suppress_tries'
1.272 albertel 2525: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.395 bisitz 2526: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.113 sakharuk 2527: 'problem_stream_switch'
1.141 sakharuk 2528: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.395 bisitz 2529: ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',
1.161 sakharuk 2530: 'default_paper_size'
2531: => '<b>'.&mt('Default paper type').'</b><br />'.
2532: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2533: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2534: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.319 foxr 2535: 'print_header_format'
1.395 bisitz 2536: => ' <b>'.&mt('Print header format').'</b><br />'
2537: .&mt('Substitutions:<br />[_1]: student name, [_2]: course id, [_3]: assignment note. Numbers after the <tt>%</tt> limit the field size.','"<tt>%n</tt>"','"<tt>%c</tt>"','"<tt>%a</tt>"'),
1.217 albertel 2538: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2539: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.395 bisitz 2540: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'
2541: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',
1.140 sakharuk 2542: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2543: 'disable_receipt_display'
1.141 sakharuk 2544: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2545: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.313 albertel 2546: 'task_messages'
1.395 bisitz 2547: => '<b>'.&mt('Send message to student when clicking Done on Tasks').'</b><br /> ('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','"<tt>only_student</tt>"','"<tt>student_and_user_notes_screen</tt>"').')',
1.163 albertel 2548: 'disablesigfigs'
2549: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2550: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2551: 'disableexampointprint'
2552: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2553: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2554: 'externalsyllabus'
1.279 www 2555: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2556: 'tthoptions'
1.367 albertel 2557: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>',
2558:
2559: 'texengine'
1.395 bisitz 2560: => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'
1.420 bisitz 2561: .'('.&mt("[_1], [_2] (Convert to Images), [_3] (TeX to HTML), or blank for student's preference",'"<tt>jsMath</tt>"','"<tt>mimetex</tt>"','"<tt>tth</tt>"').')',
1.397 www 2562: 'timezone'
1.400 raeburn 2563: => '<b>'.&mt('Timezone in which the course takes place').'</b>',
1.392 raeburn 2564:
1.400 raeburn 2565: 'suppress_embed_prompt'
2566: => '<b>'.&mt('Suppress prompt to upload items referenced in a web page being uploaded to portfolio, when current role is student.').'</b><br />'.
1.402 raeburn 2567: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.403 raeburn 2568: 'hidefromcat'
1.402 raeburn 2569: => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
2570: ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',
1.403 raeburn 2571: 'categories'
2572: => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
2573: &mt('Display Categories').'</a>',
1.409 raeburn 2574: 'datelocale'
2575: => '<b>'.&mt('Locale used for course calendar').'</b>',
1.402 raeburn 2576: );
2577: my @Display_Order = ('url','description','courseid','cloners');
1.403 raeburn 2578: (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
2579: if ($can_toggle_cat) {
1.402 raeburn 2580: push(@Display_Order,'hidefromcat');
2581: }
1.403 raeburn 2582: if ($can_categorize) {
2583: push(@Display_Order,'categories');
2584: }
1.402 raeburn 2585: push (@Display_Order,('grading',
1.278 www 2586: 'externalsyllabus',
1.107 matthew 2587: 'default_xml_style','pageseparators',
1.402 raeburn 2588: 'question.email','question.email.text','comment.email',
2589: 'comment.email.text','policy.email','policy.email.text',
1.169 matthew 2590: 'student_classlist_view',
1.372 raeburn 2591: 'student_classlist_opt_in',
2592: 'student_classlist_portfiles',
1.118 matthew 2593: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2594: 'pch.roles.denied','pch.users.denied',
2595: 'allow_limited_html_in_feedback',
1.170 raeburn 2596: 'allow_discussion_post_editing',
1.108 www 2597: 'languages',
1.397 www 2598: 'timezone',
1.409 raeburn 2599: 'datelocale',
1.150 www 2600: 'nothideprivileged',
1.107 matthew 2601: 'rndseed',
1.151 albertel 2602: 'receiptalg',
1.107 matthew 2603: 'problem_stream_switch',
1.164 sakharuk 2604: 'suppress_tries',
1.400 raeburn 2605: 'suppress_embed_prompt',
1.161 sakharuk 2606: 'default_paper_size',
1.319 foxr 2607: 'print_header_format',
1.115 www 2608: 'disable_receipt_display',
1.107 matthew 2609: 'spreadsheet_default_classcalc',
2610: 'spreadsheet_default_studentcalc',
2611: 'spreadsheet_default_assesscalc',
2612: 'hideemptyrows',
2613: 'default_enrollment_start_date',
2614: 'default_enrollment_end_date',
1.163 albertel 2615: 'tthoptions',
1.367 albertel 2616: 'texengine',
1.251 albertel 2617: 'disablesigfigs',
1.313 albertel 2618: 'disableexampointprint',
1.402 raeburn 2619: 'task_messages','task_grading'));
1.107 matthew 2620: foreach my $parameter (sort(keys(%values))) {
1.405 raeburn 2621: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2622: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2623: || ($parameter eq 'type')) {
1.142 raeburn 2624: if (! $descriptions{$parameter}) {
2625: $descriptions{$parameter}=$parameter;
2626: push(@Display_Order,$parameter);
2627: }
2628: }
1.43 albertel 2629: }
1.315 albertel 2630:
1.107 matthew 2631: foreach my $parameter (@Display_Order) {
2632: my $description = $descriptions{$parameter};
1.51 matthew 2633: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2634: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2635: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2636: '.checked=true;"';
1.315 albertel 2637: $output .= &Apache::loncommon::start_data_table_row().
2638: '<td>'.$description.'</td>';
1.107 matthew 2639: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2640: $output .= '<td>'.
2641: &Apache::lonhtmlcommon::date_setter('envform',
2642: $parameter.'_value',
2643: $values{$parameter},
2644: $onchange).
2645: '</td>';
1.398 www 2646: } elsif ($parameter eq 'timezone') {
1.399 raeburn 2647: my $includeempty = 1;
2648: my $timezone = &Apache::lonlocal::gettimezone();
1.398 www 2649: $output .= '<td>'.
2650: &Apache::loncommon::select_timezone($parameter.'_value',
1.399 raeburn 2651: $timezone,
2652: $onchange,$includeempty).'</td>';
1.409 raeburn 2653: } elsif ($parameter eq 'datelocale') {
2654: my $includeempty = 1;
2655: my $locale_obj = &Apache::lonlocal::getdatelocale();
2656: my $currdatelocale;
2657: if (ref($locale_obj)) {
2658: $currdatelocale = $locale_obj->id();
2659: }
2660: $output .= '<td>'.
2661: &Apache::loncommon::select_datelocale($parameter.'_value',
2662: $currdatelocale,
2663: $onchange,$includeempty).'</td>';
1.406 raeburn 2664: } elsif ($parameter eq 'categories') {
2665: my $catdisplay;
2666: if ($values{'categories'} ne '') {
2667: my @curritems = split(/\&/,$values{'categories'});
2668: foreach my $item (@curritems) {
2669: my ($name,$parent,$pos) = split(/:/,$item);
2670: $catdisplay .= &unescape($name).'&';
2671: }
2672: $catdisplay =~ s/\&$//;
2673: }
2674: $output .= '<td>'.
2675: '<input type="hidden" name="categories_value" value="'.
2676: $values{'categories'}.'" />'.
2677: '<input type="textbox" name="categories_display" value="'.
2678: $catdisplay.'" readonly="readonly" size="40" /></td>';
1.107 matthew 2679: } else {
2680: $output .= '<td>'.
2681: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2682: $values{$parameter},
2683: 40,$onchange).'</td>';
2684: }
2685: $output .= '<td>'.
2686: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2687: '</td>';
1.315 albertel 2688: $output .= &Apache::loncommon::end_data_table_row()."\n";
1.51 matthew 2689: }
1.69 www 2690: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2691: '[\'envform\'].elements[\'newp_setparmval\']'.
2692: '.checked=true;"';
1.315 albertel 2693: $output.=&Apache::loncommon::start_data_table_row().
2694: '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.419 bisitz 2695: '<input type="text" size="40" name="newp_name" '.
1.51 matthew 2696: $onchange.' /></td><td>'.
1.419 bisitz 2697: '<input type="text" size="40" name="newp_value" '.
1.51 matthew 2698: $onchange.' /></td><td>'.
1.315 albertel 2699: '<input type="checkbox" name="newp_setparmval" /></td>'.
2700: &Apache::loncommon::end_data_table_row()."\n";
1.43 albertel 2701: }
1.157 sakharuk 2702: my %lt=&Apache::lonlocal::texthash(
2703: 'par' => 'Parameter',
2704: 'val' => 'Value',
1.395 bisitz 2705: 'set' => 'Set?',
2706: 'sav' => 'Save'
1.157 sakharuk 2707: );
2708:
1.140 sakharuk 2709: my $Parameter=&mt('Parameter');
2710: my $Value=&mt('Value');
1.141 sakharuk 2711: my $Set=&mt('Set');
1.403 raeburn 2712: my ($jscript,$categorize_js);
2713: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
2714: if ($can_categorize) {
2715: $categorize_js = <<ENDSCRIPT;
2716: function catsbrowser() {
2717: var catswin = null;
2718: var url = '/adm/parmset?action=categorizecourse';
2719: if (!catswin || catswin.closed) {
2720: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2721: } else {
2722: catswin.focus();
2723: }
2724: }
2725: ENDSCRIPT
2726: }
2727: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
2728: $browse_js."\n".$categorize_js."\n".'</script>';
1.280 albertel 2729: my $start_page =
1.323 albertel 2730: &Apache::loncommon::start_page('Set Course Environment',
1.403 raeburn 2731: $jscript);
1.280 albertel 2732: my $end_page =
2733: &Apache::loncommon::end_page();
1.315 albertel 2734: my $end_table=&Apache::loncommon::end_data_table();
1.280 albertel 2735: $r->print(<<ENDENV);
2736: $start_page
1.193 albertel 2737: $breadcrumbs
2738: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2739: $setoutput
1.395 bisitz 2740: <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>
1.315 albertel 2741: $start_table
2742: $start_header_row
1.395 bisitz 2743: <th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
1.315 albertel 2744: $end_header_row
1.30 www 2745: $output
1.315 albertel 2746: $end_table
1.395 bisitz 2747: <input type="submit" name="crsenv" value="$lt{'sav'}" />
1.30 www 2748: </form>
1.280 albertel 2749: $end_page
2750: ENDENV
1.30 www 2751: }
1.402 raeburn 2752:
1.403 raeburn 2753: sub can_modify_catsettings {
1.402 raeburn 2754: my ($dom) = @_;
2755: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.403 raeburn 2756: my ($can_toggle_cat,$can_categorize);
1.402 raeburn 2757: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2758: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2759: $can_toggle_cat = 1;
2760: }
1.403 raeburn 2761: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2762: $can_categorize = 1;
2763: }
2764: }
2765: return ($can_toggle_cat,$can_categorize);
2766: }
2767:
2768: sub assign_course_categories {
2769: my ($r) = @_;
2770: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2771: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2772: my $hascats = 0;
2773: my $cathash;
2774: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2775: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2776: $cathash = $domconf{'coursecategories'}{'cats'};
2777: if (ref($cathash) eq 'HASH') {
2778: $hascats = 1;
2779: }
1.402 raeburn 2780: }
1.403 raeburn 2781: my $catwin_js;
2782: if ($hascats) {
2783: my $alert = &mt('Use \"Save\" in the main window to save course categories');
2784: $catwin_js = <<ENDSCRIPT;
2785: <script type="text/javascript">
2786:
2787: function updateCategories() {
2788: var newcategories = '';
1.406 raeburn 2789: var unescapedcats = '';
1.403 raeburn 2790: if (document.chgcats.usecategory.length) {
2791: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2792: if (document.chgcats.usecategory[i].checked == true) {
2793: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1.406 raeburn 2794: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1.403 raeburn 2795: }
2796: }
2797: if (newcategories.length > 0) {
2798: newcategories = newcategories.slice(0,-1);
2799: }
1.406 raeburn 2800: if (unescapedcats.length > 0) {
1.408 raeburn 2801: unescapedcats = unescapedcats.slice(0,-3);
1.406 raeburn 2802: }
1.403 raeburn 2803: } else {
2804: if (document.chgcats.usecategory.checked == true) {
2805: newcategories = document.chgcats.usecategory.value;
1.406 raeburn 2806: unescapedcats = document.chgcats.catname.value;
1.403 raeburn 2807: }
2808: }
2809: opener.document.envform.categories_value.value = newcategories;
1.406 raeburn 2810: opener.document.envform.categories_display.value = unescapedcats;
1.403 raeburn 2811: opener.document.envform.categories_setparmval.checked = true;
2812: alert("$alert");
2813: self.close();
2814: return;
2815: }
2816:
2817: </script>
2818: ENDSCRIPT
2819: } else {
2820: my $onload;
2821: }
2822: my $start_page =
2823: &Apache::loncommon::start_page('Course Categories',$catwin_js,
2824: {'only_body' => 1,});
2825: my $end_page = &Apache::loncommon::end_page();
2826: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
2827: if ($hascats) {
2828: my %currsettings =
2829: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2830: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
2831: '<form name="chgcats" action="/adm/parmset" method="post">'."\n"
2832: .&Apache::loncommon::assign_categories_table($cathash,
2833: $currsettings{'categories'})."\n"
2834: .'<br /><input type="button" name="changes" value="'
2835: .&mt('Copy to main window').'" '
2836: .'onclick="javascript:updateCategories()" /></form><br />';
2837: } else {
2838: $categoriesform .= &mt('No categories defined for this domain');
2839: }
2840: $r->print($start_page.$categoriesform.$end_page);
2841: return;
1.402 raeburn 2842: }
2843:
1.120 www 2844: ##################################################
1.207 www 2845: # Overview mode
2846: ##################################################
1.124 www 2847: my $tableopen;
2848:
2849: sub tablestart {
2850: if ($tableopen) {
2851: return '';
2852: } else {
2853: $tableopen=1;
1.295 albertel 2854: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 2855: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2856: }
2857: }
2858:
2859: sub tableend {
2860: if ($tableopen) {
2861: $tableopen=0;
1.295 albertel 2862: return &Apache::loncommon::end_data_table();
1.124 www 2863: } else {
2864: return'';
2865: }
2866: }
2867:
1.207 www 2868: sub readdata {
2869: my ($crs,$dom)=@_;
2870: # Read coursedata
2871: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2872: # Read userdata
2873:
2874: my $classlist=&Apache::loncoursedata::get_classlist();
2875: foreach (keys %$classlist) {
1.350 albertel 2876: if ($_=~/^($match_username)\:($match_domain)$/) {
1.207 www 2877: my ($tuname,$tudom)=($1,$2);
2878: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2879: foreach my $userkey (keys %{$useropt}) {
2880: if ($userkey=~/^$env{'request.course.id'}/) {
2881: my $newkey=$userkey;
2882: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2883: $$resourcedata{$newkey}=$$useropt{$userkey};
2884: }
2885: }
2886: }
2887: }
2888: return $resourcedata;
2889: }
2890:
2891:
1.124 www 2892: # Setting
1.208 www 2893:
2894: sub storedata {
2895: my ($r,$crs,$dom)=@_;
1.207 www 2896: # Set userlevel immediately
2897: # Do an intermediate store of course level
2898: my $olddata=&readdata($crs,$dom);
1.124 www 2899: my %newdata=();
2900: undef %newdata;
2901: my @deldata=();
2902: undef @deldata;
1.190 albertel 2903: foreach (keys %env) {
1.124 www 2904: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2905: my $cmd=$1;
2906: my $thiskey=$2;
1.207 www 2907: my ($tuname,$tudom)=&extractuser($thiskey);
2908: my $tkey=$thiskey;
2909: if ($tuname) {
2910: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2911: }
1.385 albertel 2912: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.384 albertel 2913: my ($data, $typeof, $text);
2914: if ($cmd eq 'set') {
2915: $data=$env{$_};
2916: $typeof=$env{'form.typeof_'.$thiskey};
2917: $text = &mt('Saved modified parameter for');
2918: } elsif ($cmd eq 'datepointer') {
2919: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
2920: $typeof=$env{'form.typeof_'.$thiskey};
2921: $text = &mt('Saved modified date for');
1.385 albertel 2922: } elsif ($cmd eq 'dateinterval') {
2923: $data=&get_date_interval_from_form($thiskey);
2924: $typeof=$env{'form.typeof_'.$thiskey};
2925: $text = &mt('Saved modified date for');
1.384 albertel 2926: }
2927: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 2928: if ($tuname) {
1.212 www 2929: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2930: $tkey.'.type' => $typeof},
2931: $tudom,$tuname) eq 'ok') {
1.290 www 2932: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.384 albertel 2933: $r->print('<br />'.$text.' '.
1.207 www 2934: &Apache::loncommon::plainname($tuname,$tudom));
2935: } else {
1.314 albertel 2936: $r->print('<div class="LC_error">'.
1.365 albertel 2937: &mt('Error saving parameters').'</div>');
1.207 www 2938: }
2939: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2940: } else {
2941: $newdata{$thiskey}=$data;
1.212 www 2942: $newdata{$thiskey.'.type'}=$typeof;
2943: }
1.207 www 2944: }
1.124 www 2945: } elsif ($cmd eq 'del') {
1.207 www 2946: if ($tuname) {
2947: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 2948: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 2949: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2950: } else {
1.314 albertel 2951: $r->print('<div class="LC_error">'.
2952: &mt('Error deleting parameters').'</div>');
1.207 www 2953: }
2954: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2955: } else {
1.333 albertel 2956: push (@deldata,$thiskey,$thiskey.'.type');
1.207 www 2957: }
1.124 www 2958: }
2959: }
2960: }
1.207 www 2961: # Store all course level
1.144 www 2962: my $delentries=$#deldata+1;
2963: my @newdatakeys=keys %newdata;
2964: my $putentries=$#newdatakeys+1;
2965: if ($delentries) {
2966: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 2967: my %loghash=map { $_ => '' } @deldata;
2968: &log_parmset(\%loghash,1);
1.144 www 2969: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2970: } else {
1.314 albertel 2971: $r->print('<div class="LC_error">'.
2972: &mt('Error deleting parameters').'</div>');
1.144 www 2973: }
1.205 www 2974: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2975: }
2976: if ($putentries) {
2977: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 2978: &log_parmset(\%newdata,0);
1.365 albertel 2979: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2980: } else {
1.314 albertel 2981: $r->print('<div class="LC_error">'.
1.365 albertel 2982: &mt('Error saving parameters').'</div>');
1.144 www 2983: }
1.205 www 2984: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2985: }
1.208 www 2986: }
1.207 www 2987:
1.208 www 2988: sub extractuser {
2989: my $key=shift;
1.350 albertel 2990: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 2991: }
1.206 www 2992:
1.381 albertel 2993: sub parse_listdata_key {
2994: my ($key,$listdata) = @_;
2995: # split into student/section affected, and
2996: # the realm (folder/resource part and parameter
2997: my ($student,$realm) =
2998: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
2999: # if course wide student would be undefined
3000: if (!defined($student)) {
3001: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
3002: }
3003: # strip off the .type if it's not the Question type parameter
3004: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
3005: $realm=~s/\.type//;
3006: }
3007: # split into resource+part and parameter name
1.388 albertel 3008: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
3009: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 3010: return ($student,$res,$part,$parm);
3011: }
3012:
1.208 www 3013: sub listdata {
1.214 www 3014: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 3015: # Start list output
1.206 www 3016:
1.122 www 3017: my $oldsection='';
3018: my $oldrealm='';
3019: my $oldpart='';
1.123 www 3020: my $pointer=0;
1.124 www 3021: $tableopen=0;
1.145 www 3022: my $foundkeys=0;
1.248 albertel 3023: my %keyorder=&standardkeyorder();
1.381 albertel 3024:
1.214 www 3025: foreach my $thiskey (sort {
1.381 albertel 3026: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
3027: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
3028:
3029: # get the numerical order for the param
3030: $aparm=$keyorder{'parameter_0_'.$aparm};
3031: $bparm=$keyorder{'parameter_0_'.$bparm};
3032:
3033: my $result=0;
3034:
1.214 www 3035: if ($sortorder eq 'realmstudent') {
1.381 albertel 3036: if ($ares ne $bres ) {
3037: $result = ($ares cmp $bres);
3038: } elsif ($astudent ne $bstudent) {
3039: $result = ($astudent cmp $bstudent);
3040: } elsif ($apart ne $bpart ) {
3041: $result = ($apart cmp $bpart);
1.237 albertel 3042: }
1.381 albertel 3043: } else {
3044: if ($astudent ne $bstudent) {
3045: $result = ($astudent cmp $bstudent);
3046: } elsif ($ares ne $bres ) {
3047: $result = ($ares cmp $bres);
3048: } elsif ($apart ne $bpart ) {
3049: $result = ($apart cmp $bpart);
1.247 albertel 3050: }
1.381 albertel 3051: }
3052:
3053: if (!$result) {
3054: if (defined($aparm) && defined($bparm)) {
3055: $result = ($aparm <=> $bparm);
3056: } elsif (defined($aparm)) {
3057: $result = -1;
3058: } elsif (defined($bparm)) {
3059: $result = 1;
1.248 albertel 3060: }
1.214 www 3061: }
1.381 albertel 3062:
3063: $result;
1.214 www 3064: } keys %{$listdata}) {
1.381 albertel 3065:
1.211 www 3066: if ($$listdata{$thiskey.'.type'}) {
3067: my $thistype=$$listdata{$thiskey.'.type'};
3068: if ($$resourcedata{$thiskey.'.type'}) {
3069: $thistype=$$resourcedata{$thiskey.'.type'};
3070: }
1.207 www 3071: my ($middle,$part,$name)=
3072: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 3073: my $section=&mt('All Students');
1.207 www 3074: if ($middle=~/^\[(.*)\]/) {
1.206 www 3075: my $issection=$1;
1.350 albertel 3076: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
1.206 www 3077: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
3078: } else {
3079: $section=&mt('Group/Section').': '.$issection;
3080: }
1.207 www 3081: $middle=~s/^\[(.*)\]//;
1.122 www 3082: }
1.207 www 3083: $middle=~s/\.+$//;
3084: $middle=~s/^\.+//;
1.316 albertel 3085: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.122 www 3086: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 3087: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
1.122 www 3088: } elsif ($middle) {
1.174 albertel 3089: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 3090: $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>';
1.122 www 3091: }
1.214 www 3092: if ($sortorder eq 'realmstudent') {
3093: if ($realm ne $oldrealm) {
3094: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3095: $oldrealm=$realm;
3096: $oldsection='';
3097: }
3098: if ($section ne $oldsection) {
3099: $r->print(&tableend()."\n<h2>$section</h2>");
3100: $oldsection=$section;
3101: $oldpart='';
3102: }
3103: } else {
3104: if ($section ne $oldsection) {
3105: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3106: $oldsection=$section;
3107: $oldrealm='';
3108: }
3109: if ($realm ne $oldrealm) {
3110: $r->print(&tableend()."\n<h2>$realm</h2>");
3111: $oldrealm=$realm;
3112: $oldpart='';
3113: }
1.122 www 3114: }
3115: if ($part ne $oldpart) {
1.124 www 3116: $r->print(&tableend().
1.422 bisitz 3117: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
1.122 www 3118: $oldpart=$part;
3119: }
1.123 www 3120: #
3121: # Ready to print
3122: #
1.295 albertel 3123: $r->print(&tablestart().
3124: &Apache::loncommon::start_data_table_row().
3125: '<td><b>'.&standard_parameter_names($name).
1.293 www 3126: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 3127: $thiskey.'" /></td><td>');
1.145 www 3128: $foundkeys++;
1.213 www 3129: if (&isdateparm($thistype)) {
1.123 www 3130: my $jskey='key_'.$pointer;
3131: $pointer++;
3132: $r->print(
1.232 albertel 3133: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 3134: $jskey,
1.219 www 3135: $$resourcedata{$thiskey},
1.325 www 3136: '',1,'','').
1.277 www 3137: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3138: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3139: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3140: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 3141: );
1.385 albertel 3142: } elsif ($thistype eq 'date_interval') {
3143: $r->print(&date_interval_selector($thiskey,
3144: $$resourcedata{$thiskey}));
1.383 albertel 3145: } elsif ($thistype =~ m/^string/) {
3146: $r->print(&string_selector($thistype,$thiskey,
3147: $$resourcedata{$thiskey}));
1.123 www 3148: } else {
1.383 albertel 3149: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 3150: }
1.211 www 3151: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
1.423 bisitz 3152: $thistype.'" />');
1.295 albertel 3153: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 3154: }
1.121 www 3155: }
1.208 www 3156: return $foundkeys;
3157: }
3158:
1.385 albertel 3159:
3160: sub date_interval_selector {
3161: my ($thiskey, $showval) = @_;
3162: my $result;
3163: foreach my $which (['days', 86400, 31],
3164: ['hours', 3600, 23],
3165: ['minutes', 60, 59],
3166: ['seconds', 1, 59]) {
3167: my ($name, $factor, $max) = @{ $which };
3168: my $amount = int($showval/$factor);
3169: $showval %= $factor;
3170: my %select = ((map {$_ => $_} (0..$max)),
3171: 'select_form_order' => [0..$max]);
3172: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
3173: %select);
3174: $result .= ' '.&mt($name);
3175: }
3176: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3177: return $result;
3178:
3179: }
3180:
3181: sub get_date_interval_from_form {
3182: my ($key) = @_;
3183: my $seconds = 0;
3184: foreach my $which (['days', 86400],
3185: ['hours', 3600],
3186: ['minutes', 60],
3187: ['seconds', 1]) {
3188: my ($name, $factor) = @{ $which };
3189: if (defined($env{'form.'.$name.'_'.$key})) {
3190: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3191: }
3192: }
3193: return $seconds;
3194: }
3195:
3196:
1.383 albertel 3197: sub default_selector {
3198: my ($thiskey, $showval) = @_;
1.385 albertel 3199: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3200: }
3201:
3202: my %strings =
3203: (
3204: 'string_yesno'
3205: => [[ 'yes', 'Yes' ],
3206: [ 'no', 'No' ]],
3207: 'string_problemstatus'
3208: => [[ 'yes', 'Yes' ],
1.394 www 3209: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3210: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3211: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3212: );
3213:
3214:
3215: sub string_selector {
3216: my ($thistype, $thiskey, $showval) = @_;
3217:
3218: if (!exists($strings{$thistype})) {
3219: return &default_selector($thiskey,$showval);
3220: }
3221:
3222: my $result;
3223: foreach my $possibilities (@{ $strings{$thistype} }) {
3224: my ($name, $description) = @{ $possibilities };
3225: $result .= '<label><input type="radio" name="set_'.$thiskey.
3226: '" value="'.$name.'"';
3227: if ($showval eq $name) {
3228: $result .= ' checked="checked"';
3229: }
3230: $result .= ' />'.&mt($description).'</label> ';
3231: }
3232: return $result;
3233: }
3234:
1.389 www 3235: #
3236: # Shift all start and end dates by $shift
3237: #
3238:
3239: sub dateshift {
3240: my ($shift)=@_;
3241: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3242: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3243: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3244: # ugly retro fix for broken version of types
3245: foreach my $key (keys %data) {
3246: if ($key=~/\wtype$/) {
3247: my $newkey=$key;
3248: $newkey=~s/type$/\.type/;
3249: $data{$newkey}=$data{$key};
3250: delete $data{$key};
3251: }
3252: }
1.391 www 3253: my %storecontent=();
1.389 www 3254: # go through all parameters and look for dates
3255: foreach my $key (keys %data) {
3256: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3257: my $newdate=$data{$key}+$shift;
1.391 www 3258: $storecontent{$key}=$newdate;
1.389 www 3259: }
3260: }
1.391 www 3261: my $reply=&Apache::lonnet::cput
3262: ('resourcedata',\%storecontent,$dom,$crs);
3263: if ($reply eq 'ok') {
3264: &log_parmset(\%storecontent);
3265: }
3266: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3267: return $reply;
1.389 www 3268: }
3269:
1.208 www 3270: sub newoverview {
1.280 albertel 3271: my ($r) = @_;
3272:
1.208 www 3273: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3274: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3275: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3276: text=>"Overview Mode"});
1.280 albertel 3277: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3278: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3279: $r->print(<<ENDOVER);
1.280 albertel 3280: $start_page
1.208 www 3281: $breadcrumbs
1.232 albertel 3282: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3283: ENDOVER
1.211 www 3284: my @ids=();
3285: my %typep=();
3286: my %keyp=();
3287: my %allparms=();
3288: my %allparts=();
3289: my %allmaps=();
3290: my %mapp=();
3291: my %symbp=();
3292: my %maptitles=();
3293: my %uris=();
3294: my %keyorder=&standardkeyorder();
3295: my %defkeytype=();
3296:
3297: my %alllevs=();
3298: $alllevs{'Resource Level'}='full';
1.215 www 3299: $alllevs{'Map/Folder Level'}='map';
1.211 www 3300: $alllevs{'Course Level'}='general';
3301:
3302: my $csec=$env{'form.csec'};
1.269 raeburn 3303: my $cgroup=$env{'form.cgroup'};
1.211 www 3304:
3305: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3306: my $pschp=$env{'form.pschp'};
3307: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3308: if (!@psprt) { $psprt[0]='0'; }
3309:
3310: my @selected_sections =
3311: &Apache::loncommon::get_env_multiple('form.Section');
3312: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3313: foreach my $sec (@selected_sections) {
3314: if ($sec eq 'all') {
1.211 www 3315: @selected_sections = ('all');
3316: }
3317: }
1.269 raeburn 3318: my @selected_groups =
3319: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3320:
3321: my $pssymb='';
3322: my $parmlev='';
3323:
3324: unless ($env{'form.parmlev'}) {
3325: $parmlev = 'map';
3326: } else {
3327: $parmlev = $env{'form.parmlev'};
3328: }
3329:
3330: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3331: \%mapp, \%symbp,\%maptitles,\%uris,
3332: \%keyorder,\%defkeytype);
3333:
1.374 albertel 3334: if (grep {$_ eq 'all'} (@psprt)) {
3335: @psprt = keys(%allparts);
3336: }
1.211 www 3337: # Menu to select levels, etc
3338:
1.317 albertel 3339: $r->print('<table id="LC_parm_overview_scope">
3340: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3341: &levelmenu($r,\%alllevs,$parmlev);
3342: if ($parmlev ne 'general') {
1.317 albertel 3343: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3344: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3345: $r->print('</td>');
3346: }
3347: $r->print('</td></tr></table>');
3348:
1.317 albertel 3349: $r->print('<table id="LC_parm_overview_controls">
3350: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3351: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3352: $r->print('</td><td class="LC_parm_overview_restrictions">
3353: <table class="LC_parm_overview_restrictions">'.
3354: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3355: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3356: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3357: $r->print('</td><td>');
1.211 www 3358: §ionmenu($r,\@selected_sections);
1.317 albertel 3359: $r->print('</td><td>');
1.269 raeburn 3360: &groupmenu($r,\@selected_groups);
3361: $r->print('</td></tr></table>');
1.214 www 3362: $r->print('</td></tr></table>');
3363:
3364: my $sortorder=$env{'form.sortorder'};
3365: unless ($sortorder) { $sortorder='realmstudent'; }
3366: &sortmenu($r,$sortorder);
3367:
3368: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3369:
3370: # Build the list data hash from the specified parms
3371:
3372: my $listdata;
3373: %{$listdata}=();
3374:
3375: foreach my $cat (@pscat) {
1.269 raeburn 3376: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3377: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3378: }
3379:
1.212 www 3380: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3381:
1.212 www 3382: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3383:
3384: # Read modified data
3385:
3386: my $resourcedata=&readdata($crs,$dom);
3387:
3388: # List data
3389:
1.214 www 3390: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3391: }
3392: $r->print(&tableend().
1.365 albertel 3393: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3394: '</form>'.&Apache::loncommon::end_page());
1.208 www 3395: }
3396:
1.269 raeburn 3397: sub secgroup_lister {
3398: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3399: foreach my $item (@{$selections}) {
3400: foreach my $part (@{$psprt}) {
3401: my $rootparmkey=$env{'request.course.id'};
3402: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3403: $rootparmkey.='.['.$item.']';
3404: }
3405: if ($parmlev eq 'general') {
3406: # course-level parameter
3407: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3408: $$listdata{$newparmkey}=1;
3409: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3410: } elsif ($parmlev eq 'map') {
3411: # map-level parameter
3412: foreach my $mapid (keys %{$allmaps}) {
3413: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3414: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3415: $$listdata{$newparmkey}=1;
3416: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3417: }
3418: } else {
3419: # resource-level parameter
3420: foreach my $rid (@{$ids}) {
3421: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3422: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3423: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3424: $$listdata{$newparmkey}=1;
3425: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3426: }
3427: }
3428: }
3429: }
3430: }
3431:
1.208 www 3432: sub overview {
1.280 albertel 3433: my ($r) = @_;
1.208 www 3434: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3435: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3436:
1.414 droeschl 3437: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3438: text=>"Overview Mode"});
1.280 albertel 3439: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3440: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3441: $r->print(<<ENDOVER);
1.280 albertel 3442: $start_page
1.208 www 3443: $breadcrumbs
1.232 albertel 3444: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3445: ENDOVER
3446: # Store modified
3447:
3448: &storedata($r,$crs,$dom);
3449:
3450: # Read modified data
3451:
3452: my $resourcedata=&readdata($crs,$dom);
3453:
1.214 www 3454:
3455: my $sortorder=$env{'form.sortorder'};
3456: unless ($sortorder) { $sortorder='realmstudent'; }
3457: &sortmenu($r,$sortorder);
3458:
1.208 www 3459: # List data
3460:
1.214 www 3461: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3462:
1.145 www 3463: $r->print(&tableend().'<p>'.
1.430 schafran 3464: ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':&mt('There are no parameters.')).'</p></form>'.
1.280 albertel 3465: &Apache::loncommon::end_page());
1.120 www 3466: }
1.121 www 3467:
1.333 albertel 3468: sub clean_parameters {
3469: my ($r) = @_;
3470: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3471: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3472:
1.414 droeschl 3473: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
3474: text=>"Clean Parameters"});
1.333 albertel 3475: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3476: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3477: $r->print(<<ENDOVER);
3478: $start_page
3479: $breadcrumbs
3480: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3481: ENDOVER
3482: # Store modified
3483:
3484: &storedata($r,$crs,$dom);
3485:
3486: # Read modified data
3487:
3488: my $resourcedata=&readdata($crs,$dom);
3489:
3490: # List data
3491:
3492: $r->print('<h3>'.
3493: &mt('These parameters refer to resources that do not exist.').
3494: '</h3>'.
1.415 schafran 3495: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
1.333 albertel 3496: '<br />');
3497: $r->print(&Apache::loncommon::start_data_table().
3498: '<tr>'.
3499: '<th>'.&mt('Delete').'</th>'.
3500: '<th>'.&mt('Parameter').'</th>'.
3501: '</tr>');
3502: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3503: next if (!exists($resourcedata->{$thiskey.'.type'})
3504: && $thiskey=~/\.type$/);
3505: my %data = &parse_key($thiskey);
1.383 albertel 3506: if (1) { #exists($data{'realm_exists'})
3507: #&& !$data{'realm_exists'}) {
1.333 albertel 3508: $r->print(&Apache::loncommon::start_data_table_row().
3509: '<tr>'.
3510: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3511:
3512: $r->print('<td>');
1.362 albertel 3513: my $display_value = $resourcedata->{$thiskey};
3514: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3515: $display_value =
3516: &Apache::lonlocal::locallocaltime($display_value);
3517: }
1.333 albertel 3518: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3519: &standard_parameter_names($data{'parameter_name'}),
3520: $resourcedata->{$thiskey}));
3521: $r->print('<br />');
3522: if ($data{'scope_type'} eq 'all') {
3523: $r->print(&mt('All users'));
3524: } elsif ($data{'scope_type'} eq 'user') {
3525: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3526: } elsif ($data{'scope_type'} eq 'section') {
3527: $r->print(&mt('Section: [_1]',$data{'scope'}));
3528: } elsif ($data{'scope_type'} eq 'group') {
3529: $r->print(&mt('Group: [_1]',$data{'scope'}));
3530: }
3531: $r->print('<br />');
3532: if ($data{'realm_type'} eq 'all') {
3533: $r->print(&mt('All Resources'));
3534: } elsif ($data{'realm_type'} eq 'folder') {
3535: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3536: } elsif ($data{'realm_type'} eq 'symb') {
3537: my ($map,$resid,$url) =
3538: &Apache::lonnet::decode_symb($data{'realm'});
3539: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3540: $url,$resid,$map));
3541: }
1.362 albertel 3542: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3543: $r->print('</td></tr>');
3544:
3545: }
3546: }
3547: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.415 schafran 3548: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.333 albertel 3549: '</p></form>'.
3550: &Apache::loncommon::end_page());
3551: }
3552:
1.390 www 3553: sub date_shift_one {
3554: my ($r) = @_;
3555: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3556: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3557:
1.414 droeschl 3558: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
3559: text=>"Shifting Dates"});
1.390 www 3560: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3561: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3562: $r->print(<<ENDOVER);
3563: $start_page
3564: $breadcrumbs
3565: ENDOVER
3566: $r->print('<form name="shiftform" method="post">'.
3567: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3568: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3569: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3570: &Apache::lonhtmlcommon::date_setter('shiftform',
3571: 'timeshifted',
3572: $env{'form.timebase'},,
3573: '').
3574: '</td></tr></table>'.
3575: '<input type="hidden" name="action" value="dateshift2" />'.
3576: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3577: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3578: $r->print(&Apache::loncommon::end_page());
3579: }
3580:
3581: sub date_shift_two {
3582: my ($r) = @_;
3583: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3584: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3585: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
3586: text=>"Shifting Dates"});
1.390 www 3587: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3588: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3589: $r->print(<<ENDOVER);
3590: $start_page
3591: $breadcrumbs
3592: ENDOVER
3593: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3594: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3595: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3596: &Apache::lonlocal::locallocaltime($timeshifted)));
3597: my $delta=$timeshifted-$env{'form.timebase'};
3598: &dateshift($delta);
3599: $r->print(&Apache::loncommon::end_page());
3600: }
3601:
1.333 albertel 3602: sub parse_key {
3603: my ($key) = @_;
3604: my %data;
3605: my ($middle,$part,$name)=
3606: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3607: $data{'scope_type'} = 'all';
3608: if ($middle=~/^\[(.*)\]/) {
3609: $data{'scope'} = $1;
1.350 albertel 3610: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3611: $data{'scope_type'} = 'user';
3612: $data{'scope'} = [$1,$2];
3613: } else {
3614: #FIXME check for group scope
3615: $data{'scope_type'} = 'section';
3616: }
3617: $middle=~s/^\[(.*)\]//;
3618: }
3619: $middle=~s/\.+$//;
3620: $middle=~s/^\.+//;
3621: $data{'realm_type'}='all';
3622: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3623: $data{'realm'} = $1;
3624: $data{'realm_type'} = 'folder';
3625: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3626: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3627: } elsif ($middle) {
3628: $data{'realm'} = $middle;
3629: $data{'realm_type'} = 'symb';
3630: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3631: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3632: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3633: }
3634:
3635: $data{'parameter_part'} = $part;
3636: $data{'parameter_name'} = $name;
3637:
3638: return %data;
3639: }
3640:
1.239 raeburn 3641:
1.178 raeburn 3642:
1.239 raeburn 3643: sub extract_cloners {
3644: my ($clonelist,$allowclone) = @_;
3645: if ($clonelist =~ /,/) {
1.380 albertel 3646: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3647: } else {
3648: $$allowclone[0] = $clonelist;
3649: }
3650: }
3651:
3652: sub check_cloners {
3653: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3654: my ($clean_clonelist,%disallowed);
1.239 raeburn 3655: my @allowclone = ();
3656: &extract_cloners($$clonelist,\@allowclone);
3657: foreach my $currclone (@allowclone) {
1.380 albertel 3658: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3659: if ($currclone eq '*') {
3660: $clean_clonelist .= $currclone.',';
3661: } else {
3662: my ($uname,$udom) = split(/:/,$currclone);
3663: if ($uname eq '*') {
3664: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3665: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3666: $disallowed{'domain'} .= $currclone.',';
3667: } else {
3668: $clean_clonelist .= $currclone.',';
3669: }
3670: } else {
3671: $disallowed{'format'} .= $currclone.',';
3672: }
3673: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3674: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3675: } else {
1.379 raeburn 3676: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3677: $disallowed{'newuser'} .= $currclone.',';
3678: } else {
3679: $clean_clonelist .= $currclone.',';
3680: }
1.239 raeburn 3681: }
3682: }
3683: } else {
3684: $clean_clonelist .= $currclone.',';
3685: }
3686: }
1.379 raeburn 3687: foreach my $key (keys(%disallowed)) {
3688: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3689: }
3690: if ($clean_clonelist) {
3691: $clean_clonelist =~ s/,$//;
3692: }
3693: $$clonelist = $clean_clonelist;
1.379 raeburn 3694: return %disallowed;
3695: }
1.178 raeburn 3696:
3697: sub change_clone {
3698: my ($clonelist,$oldcloner) = @_;
3699: my ($uname,$udom);
1.190 albertel 3700: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3701: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3702: my $clone_crs = $cnum.':'.$cdom;
3703:
3704: if ($cnum && $cdom) {
1.239 raeburn 3705: my @allowclone;
3706: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 3707: foreach my $currclone (@allowclone) {
1.380 albertel 3708: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 3709: if ($currclone ne '*') {
1.380 albertel 3710: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 3711: if ($uname && $udom && $uname ne '*') {
3712: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3713: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3714: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3715: if ($currclonecrs{'cloneable'} eq '') {
3716: $currclonecrs{'cloneable'} = $clone_crs;
3717: } else {
3718: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3719: }
3720: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 3721: }
3722: }
3723: }
3724: }
3725: }
3726: }
3727: foreach my $oldclone (@$oldcloner) {
1.380 albertel 3728: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 3729: if ($oldclone ne '*') {
1.380 albertel 3730: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 3731: if ($uname && $udom && $uname ne '*' ) {
3732: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3733: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3734: my %newclonecrs = ();
3735: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3736: if ($currclonecrs{'cloneable'} =~ /,/) {
3737: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3738: foreach my $crs (@currclonecrs) {
3739: if ($crs ne $clone_crs) {
3740: $newclonecrs{'cloneable'} .= $crs.',';
3741: }
1.178 raeburn 3742: }
1.379 raeburn 3743: $newclonecrs{'cloneable'} =~ s/,$//;
3744: } else {
3745: $newclonecrs{'cloneable'} = '';
1.178 raeburn 3746: }
1.379 raeburn 3747: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 3748: }
3749: }
3750: }
3751: }
3752: }
3753: }
3754: }
3755: }
3756:
1.193 albertel 3757:
3758:
1.416 jms 3759: sub header {
3760: return &Apache::loncommon::start_page('Parameter Manager');
3761: }
1.193 albertel 3762:
3763:
3764:
3765: sub print_main_menu {
3766: my ($r,$parm_permission)=@_;
3767: #
1.414 droeschl 3768: $r->print(&header());
3769: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 3770: $r->print(<<ENDMAINFORMHEAD);
3771: <form method="post" enctype="multipart/form-data"
3772: action="/adm/parmset" name="studentform">
3773: ENDMAINFORMHEAD
3774: #
1.195 albertel 3775: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3776: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3777: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3778: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 3779:
1.417 droeschl 3780:
1.193 albertel 3781: my @menu =
1.417 droeschl 3782: ( { categorytitle=>'Settings for this Course',
1.414 droeschl 3783: items => [
1.417 droeschl 3784: { linktext => 'Course Environment',
1.414 droeschl 3785: url => '/adm/parmset?action=crsenv',
3786: permission => $parm_permission,
1.417 droeschl 3787: linktitle =>'Edit environment settings for this course.' ,
3788: icon => 'preferences-desktop-remote-desktop.png' ,
3789: #help => 'Course_Environment',
1.414 droeschl 3790: },
1.417 droeschl 3791: { linktext => 'Portfolio Metadata',
1.414 droeschl 3792: url => '/adm/parmset?action=setrestrictmeta',
3793: permission => $parm_permission,
1.417 droeschl 3794: linktitle => 'Restrict metadata for this course.' ,
3795: icon =>'contact-new.png' ,
1.414 droeschl 3796: },
3797: { linktext => 'Manage Course Slots',
3798: url => '/adm/slotrequest?command=showslots',
3799: permission => $vgr,
1.417 droeschl 3800: linktitle =>'Manage slots for this course.' ,
3801: icon => 'format-justify-fill.png' ,
1.414 droeschl 3802: },
3803: { linktext => 'Reset Student Access Times',
3804: url => '/adm/helper/resettimes.helper',
3805: permission => $mgr,
1.417 droeschl 3806: linktitle =>'Reset access times for folders/maps, resources or the course.' ,
3807: icon => 'start-here.png' ,
1.414 droeschl 3808: },
3809:
3810: { linktext => 'Set Parameter Setting Default Actions',
3811: url => '/adm/parmset?action=setdefaults',
3812: permission => $parm_permission,
1.417 droeschl 3813: linktitle =>'Set default actions for parameters.' ,
3814: icon => 'folder-new.png' ,
1.414 droeschl 3815: }]},
1.417 droeschl 3816: { categorytitle => 'New and Existing Parameter Settings for Resources',
1.414 droeschl 3817: items => [
1.417 droeschl 3818: { linktext => 'Edit Resource Parameters - Helper Mode',
1.414 droeschl 3819: url => '/adm/helper/parameter.helper',
3820: permission => $parm_permission,
1.417 droeschl 3821: linktitle =>'Set/Modify resource parameters in helper mode.' ,
3822: icon => 'dialog-information.png' ,
3823: #help => 'Parameter_Helper',
1.414 droeschl 3824: },
1.417 droeschl 3825: { linktext => 'Edit Resource Parameters - Overview Mode',
1.414 droeschl 3826: url => '/adm/parmset?action=newoverview',
3827: permission => $parm_permission,
1.417 droeschl 3828: linktitle =>'Set/Modify resource parameters in overview mode.' ,
3829: icon => 'edit-find.png' ,
3830: #help => 'Parameter_Overview',
1.414 droeschl 3831: },
1.417 droeschl 3832: { linktext => 'Edit Resource Parameters - Table Mode',
1.414 droeschl 3833: url => '/adm/parmset?action=settable',
3834: permission => $parm_permission,
1.417 droeschl 3835: linktitle =>'Set/Modify resource parameters in table mode.' ,
3836: icon => 'edit-copy.png' ,
3837: #help => 'Table_Mode',
1.414 droeschl 3838: }]},
1.417 droeschl 3839: { categorytitle => 'Existing Parameter Settings for Resources',
1.414 droeschl 3840: items => [
3841: { linktext => 'Modify Resource Parameters - Overview Mode',
3842: url => '/adm/parmset?action=setoverview',
3843: permission => $parm_permission,
1.417 droeschl 3844: linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
3845: icon => 'preferences-desktop-wallpaper.png' ,
3846: #help => 'Parameter_Overview',
1.414 droeschl 3847: },
1.417 droeschl 3848: { linktext => 'Change Log',
1.414 droeschl 3849: url => '/adm/parmset?action=parameterchangelog',
3850: permission => $parm_permission,
1.417 droeschl 3851: linktitle =>'View parameter and course blog posting/user notification change log.' ,
3852: icon => 'emblem-system.png' ,
1.414 droeschl 3853: }]}
1.193 albertel 3854: );
1.414 droeschl 3855: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.193 albertel 3856: return;
3857: }
1.414 droeschl 3858:
1.416 jms 3859:
3860:
1.252 banghart 3861: sub output_row {
1.347 banghart 3862: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3863: my $output;
1.263 banghart 3864: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3865: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3866: if (!defined($options)) {
1.254 banghart 3867: $options = 'active,stuadd';
1.261 banghart 3868: $values = '';
1.252 banghart 3869: }
1.337 banghart 3870: if (!($options =~ /deleted/)) {
3871: my @options= ( ['active', 'Show to student'],
1.418 schafran 3872: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 3873: ['choices','Provide choices for students to select from']);
3874: # ['onlyone','Student may select only one choice']);
1.337 banghart 3875: if ($added_flag) {
3876: push @options,['deleted', 'Delete Metadata Field'];
3877: }
1.351 banghart 3878: $output = &Apache::loncommon::start_data_table_row();
3879: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
3880: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3881: foreach my $opt (@options) {
3882: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 3883: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 3884: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
3885: <input type="checkbox" name="'.
3886: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3887: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 3888: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3889: }
1.351 banghart 3890: $output .= &Apache::loncommon::continue_data_table_row();
3891: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
3892: $output .= &Apache::loncommon::end_data_table_row();
3893: my $multiple_checked;
3894: my $single_checked;
3895: if ($options =~ m/onlyone/) {
1.422 bisitz 3896: $multiple_checked = '';
1.423 bisitz 3897: $single_checked = ' checked="checked"';
1.351 banghart 3898: } else {
1.423 bisitz 3899: $multiple_checked = ' checked="checked"';
1.422 bisitz 3900: $single_checked = '';
1.351 banghart 3901: }
3902: $output .= &Apache::loncommon::continue_data_table_row();
3903: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.423 bisitz 3904: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
1.418 schafran 3905: '.&mt('Student may select multiple choices from list').'</span></td>';
1.351 banghart 3906: $output .= &Apache::loncommon::end_data_table_row();
3907: $output .= &Apache::loncommon::continue_data_table_row();
3908: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.423 bisitz 3909: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
1.418 schafran 3910: '.&mt('Student may select only one choice from list').'</span></td>';
1.351 banghart 3911: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3912: }
3913: return ($output);
3914: }
1.416 jms 3915:
3916:
3917:
1.340 banghart 3918: sub order_meta_fields {
3919: my ($r)=@_;
3920: my $idx = 1;
3921: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3922: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3923: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 3924: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
3925: text=>"Add Metadata Field"});
1.345 banghart 3926: &Apache::lonhtmlcommon::add_breadcrumb
3927: ({href=>"/adm/parmset?action=setrestrictmeta",
3928: text=>"Restrict Metadata"},
3929: {text=>"Order Metadata"});
3930: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 3931: if ($env{'form.storeorder'}) {
3932: my $newpos = $env{'form.newpos'} - 1;
3933: my $currentpos = $env{'form.currentpos'} - 1;
3934: my @neworder = ();
3935: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3936: my $i;
1.341 banghart 3937: if ($newpos > $currentpos) {
1.340 banghart 3938: # moving stuff up
3939: for ($i=0;$i<$currentpos;$i++) {
3940: $neworder[$i]=$oldorder[$i];
3941: }
3942: for ($i=$currentpos;$i<$newpos;$i++) {
3943: $neworder[$i]=$oldorder[$i+1];
3944: }
3945: $neworder[$newpos]=$oldorder[$currentpos];
3946: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
3947: $neworder[$i]=$oldorder[$i];
3948: }
3949: } else {
3950: # moving stuff down
3951: for ($i=0;$i<$newpos;$i++) {
3952: $neworder[$i]=$oldorder[$i];
3953: }
3954: $neworder[$newpos]=$oldorder[$currentpos];
3955: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3956: $neworder[$i]=$oldorder[$i-1];
3957: }
3958: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3959: $neworder[$i]=$oldorder[$i];
3960: }
3961: }
3962: my $ordered_fields = join ",", @neworder;
1.343 banghart 3963: my $put_result = &Apache::lonnet::put('environment',
3964: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 3965: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3966: }
1.357 raeburn 3967: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3968: my $ordered_fields;
1.340 banghart 3969: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3970: if (!@fields_in_order) {
3971: # no order found, pick sorted order then create metadata.addedorder key.
3972: foreach my $key (sort keys %$fields) {
3973: push @fields_in_order, $key;
1.341 banghart 3974: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3975: }
1.341 banghart 3976: my $put_result = &Apache::lonnet::put('environment',
3977: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3978: }
1.340 banghart 3979: $r->print('<table>');
3980: my $num_fields = scalar(@fields_in_order);
3981: foreach my $key (@fields_in_order) {
3982: $r->print('<tr><td>');
3983: $r->print('<form method="post" action="">');
3984: $r->print('<select name="newpos" onChange="this.form.submit()">');
3985: for (my $i = 1;$i le $num_fields;$i ++) {
3986: if ($i eq $idx) {
3987: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3988: } else {
3989: $r->print('<option value="'.$i.'">'.$i.'</option>');
3990: }
3991: }
3992: $r->print('</select></td><td>');
3993: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3994: $r->print('<input type="hidden" name="storeorder" value="true" />');
3995: $r->print('</form>');
3996: $r->print($$fields{$key}.'</td></tr>');
3997: $idx ++;
3998: }
3999: $r->print('</table>');
4000: return 'ok';
4001: }
1.416 jms 4002:
4003:
1.359 banghart 4004: sub continue {
4005: my $output;
4006: $output .= '<form action="" method="post">';
4007: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
4008: $output .= '<input type="submit" value="Continue" />';
4009: return ($output);
4010: }
1.416 jms 4011:
4012:
1.334 banghart 4013: sub addmetafield {
4014: my ($r)=@_;
1.414 droeschl 4015: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4016: text=>"Add Metadata Field"});
1.334 banghart 4017: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
4018: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 4019: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4020: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 4021: if (exists($env{'form.undelete'})) {
1.358 banghart 4022: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 4023: foreach my $meta_field(@meta_fields) {
4024: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
4025: $options =~ s/deleted//;
4026: $options =~ s/,,/,/;
4027: my $put_result = &Apache::lonnet::put('environment',
4028: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
4029:
4030: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
4031: }
1.359 banghart 4032: $r->print(&continue());
1.339 banghart 4033: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 4034: my $meta_field = $env{'form.fieldname'};
4035: my $display_field = $env{'form.fieldname'};
4036: $meta_field =~ s/\W/_/g;
1.338 banghart 4037: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 4038: my $put_result = &Apache::lonnet::put('environment',
4039: {'metadata.'.$meta_field.'.values'=>"",
4040: 'metadata.'.$meta_field.'.added'=>"$display_field",
4041: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 4042: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
4043: $r->print(&continue());
1.335 banghart 4044: } else {
1.357 raeburn 4045: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 4046: if ($fields) {
4047: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
4048: $r->print('<form method="post" action="">');
4049: foreach my $key(keys(%$fields)) {
1.358 banghart 4050: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 4051: }
4052: $r->print('<input type="submit" name="undelete" value="Undelete" />');
4053: $r->print('</form>');
4054: }
4055: $r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.<form method="post" action="/adm/parmset?action=addmetadata"');
1.335 banghart 4056: $r->print('<input type="text" name="fieldname" /><br />');
4057: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4058: }
1.361 albertel 4059: $r->print('</form>');
1.334 banghart 4060: }
1.416 jms 4061:
4062:
4063:
1.259 banghart 4064: sub setrestrictmeta {
1.240 banghart 4065: my ($r)=@_;
1.242 banghart 4066: my $next_meta;
1.244 banghart 4067: my $output;
1.245 banghart 4068: my $item_num;
1.246 banghart 4069: my $put_result;
1.414 droeschl 4070: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4071: text=>"Restrict Metadata"});
1.280 albertel 4072: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4073: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4074: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4075: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4076: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4077: my $save_field = '';
1.259 banghart 4078: if ($env{'form.restrictmeta'}) {
1.254 banghart 4079: foreach my $field (sort(keys(%env))) {
1.252 banghart 4080: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4081: my $options;
1.252 banghart 4082: my $meta_field = $1;
4083: my $meta_key = $2;
1.253 banghart 4084: if ($save_field ne $meta_field) {
1.252 banghart 4085: $save_field = $meta_field;
1.253 banghart 4086: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 4087: $options.='stuadd,';
4088: }
1.351 banghart 4089: if ($env{'form.'.$meta_field.'_choices'}) {
4090: $options.='choices,';
4091: }
4092: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 4093: $options.='onlyone,';
4094: }
4095: if ($env{'form.'.$meta_field.'_active'}) {
4096: $options.='active,';
1.253 banghart 4097: }
1.337 banghart 4098: if ($env{'form.'.$meta_field.'_deleted'}) {
4099: $options.='deleted,';
4100: }
1.259 banghart 4101: my $name = $save_field;
1.253 banghart 4102: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4103: {'metadata.'.$meta_field.'.options'=>$options,
4104: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4105: },$dom,$crs);
1.252 banghart 4106: }
4107: }
4108: }
4109: }
1.296 albertel 4110: &Apache::lonnet::coursedescription($env{'request.course.id'},
4111: {'freshen_cache' => 1});
1.335 banghart 4112: # Get the default metadata fields
1.258 albertel 4113: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4114: # Now get possible added metadata fields
1.357 raeburn 4115: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4116: my $row_alt = 1;
1.347 banghart 4117: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4118: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4119: if ($field ne 'courserestricted') {
1.346 banghart 4120: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 4121: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 4122: }
1.255 banghart 4123: }
1.351 banghart 4124: my $buttons = (<<ENDButtons);
4125: <input type="submit" name="restrictmeta" value="Save" />
4126: </form><br />
4127: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4128: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4129: </form>
4130: <br />
4131: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4132: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4133: ENDButtons
1.337 banghart 4134: my $added_flag = 1;
1.335 banghart 4135: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4136: $row_alt = $row_alt ? 0 : 1;
4137: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4138: }
1.347 banghart 4139: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 4140: $r->print(<<ENDenv);
1.259 banghart 4141: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4142: $output
1.351 banghart 4143: $buttons
1.340 banghart 4144: </form>
1.244 banghart 4145: ENDenv
1.280 albertel 4146: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4147: return 'ok';
4148: }
1.416 jms 4149:
4150:
4151:
1.335 banghart 4152: sub get_added_meta_fieldnames {
1.357 raeburn 4153: my ($cid) = @_;
1.335 banghart 4154: my %fields;
4155: foreach my $key(%env) {
1.357 raeburn 4156: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4157: my $field_name = $1;
4158: my ($display_field_name) = $env{$key};
4159: $fields{$field_name} = $display_field_name;
4160: }
4161: }
4162: return \%fields;
4163: }
1.416 jms 4164:
4165:
4166:
1.339 banghart 4167: sub get_deleted_meta_fieldnames {
1.357 raeburn 4168: my ($cid) = @_;
1.339 banghart 4169: my %fields;
4170: foreach my $key(%env) {
1.357 raeburn 4171: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4172: my $field_name = $1;
4173: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4174: my ($display_field_name) = $env{$key};
4175: $fields{$field_name} = $display_field_name;
4176: }
4177: }
4178: }
4179: return \%fields;
4180: }
1.220 www 4181: sub defaultsetter {
1.280 albertel 4182: my ($r) = @_;
4183:
1.414 droeschl 4184: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4185: text=>"Set Defaults"});
1.280 albertel 4186: my $start_page =
4187: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4188: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4189: $r->print(<<ENDDEFHEAD);
1.280 albertel 4190: $start_page
1.220 www 4191: $breadcrumbs
4192: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4193: ENDDEFHEAD
1.280 albertel 4194:
4195: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4196: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4197: my @ids=();
4198: my %typep=();
4199: my %keyp=();
4200: my %allparms=();
4201: my %allparts=();
4202: my %allmaps=();
4203: my %mapp=();
4204: my %symbp=();
4205: my %maptitles=();
4206: my %uris=();
4207: my %keyorder=&standardkeyorder();
4208: my %defkeytype=();
4209:
4210: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4211: \%mapp, \%symbp,\%maptitles,\%uris,
4212: \%keyorder,\%defkeytype);
1.224 www 4213: if ($env{'form.storerules'}) {
4214: my %newrules=();
4215: my @delrules=();
1.226 www 4216: my %triggers=();
1.225 albertel 4217: foreach my $key (keys(%env)) {
4218: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4219: my $tempkey=$1;
1.226 www 4220: my $action=$env{$key};
4221: if ($action) {
4222: $newrules{$tempkey.'_action'}=$action;
4223: if ($action ne 'default') {
4224: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4225: $triggers{$whichparm}.=$tempkey.':';
4226: }
4227: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4228: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4229: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4230: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4231: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4232: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4233: } else {
4234: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4235: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4236: }
4237: } else {
1.225 albertel 4238: push(@delrules,$tempkey.'_action');
1.226 www 4239: push(@delrules,$tempkey.'_type');
1.225 albertel 4240: push(@delrules,$tempkey.'_hours');
4241: push(@delrules,$tempkey.'_min');
4242: push(@delrules,$tempkey.'_sec');
4243: push(@delrules,$tempkey.'_value');
1.224 www 4244: }
4245: }
4246: }
1.226 www 4247: foreach my $key (keys %allparms) {
4248: $newrules{$key.'_triggers'}=$triggers{$key};
4249: }
1.224 www 4250: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4251: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4252: &resetrulescache();
4253: }
1.227 www 4254: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4255: 'hours' => 'Hours',
1.221 www 4256: 'min' => 'Minutes',
4257: 'sec' => 'Seconds',
4258: 'yes' => 'Yes',
4259: 'no' => 'No');
1.222 www 4260: my @standardoptions=('','default');
4261: my @standarddisplay=('',&mt('Default value when manually setting'));
4262: my @dateoptions=('','default');
4263: my @datedisplay=('',&mt('Default value when manually setting'));
4264: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4265: unless ($tempkey) { next; }
4266: push @standardoptions,'when_setting_'.$tempkey;
4267: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4268: if (&isdateparm($defkeytype{$tempkey})) {
4269: push @dateoptions,'later_than_'.$tempkey;
4270: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4271: push @dateoptions,'earlier_than_'.$tempkey;
4272: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4273: }
4274: }
1.231 www 4275: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4276: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4277: $r->print("\n".&Apache::loncommon::start_data_table().
4278: &Apache::loncommon::start_data_table_header_row().
4279: "<th>".&mt('Rule for parameter').'</th><th>'.
4280: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4281: &Apache::loncommon::end_data_table_header_row());
1.221 www 4282: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4283: unless ($tempkey) { next; }
1.318 albertel 4284: $r->print("\n".&Apache::loncommon::start_data_table_row().
4285: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4286: my $action=&rulescache($tempkey.'_action');
4287: $r->print('<select name="'.$tempkey.'_action">');
4288: if (&isdateparm($defkeytype{$tempkey})) {
4289: for (my $i=0;$i<=$#dateoptions;$i++) {
4290: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4291: $r->print("\n<option value='$dateoptions[$i]'".
4292: ($dateoptions[$i] eq $action?' selected="selected"':'').
4293: ">$datedisplay[$i]</option>");
4294: }
4295: } else {
4296: for (my $i=0;$i<=$#standardoptions;$i++) {
4297: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4298: $r->print("\n<option value='$standardoptions[$i]'".
4299: ($standardoptions[$i] eq $action?' selected="selected"':'').
4300: ">$standarddisplay[$i]</option>");
4301: }
4302: }
4303: $r->print('</select>');
1.227 www 4304: unless (&isdateparm($defkeytype{$tempkey})) {
4305: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4306: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4307: }
1.222 www 4308: $r->print("\n</td><td>\n");
4309:
1.221 www 4310: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4311: my $days=&rulescache($tempkey.'_days');
1.222 www 4312: my $hours=&rulescache($tempkey.'_hours');
4313: my $min=&rulescache($tempkey.'_min');
4314: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4315: $r->print(<<ENDINPUTDATE);
1.227 www 4316: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4317: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4318: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4319: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4320: ENDINPUTDATE
4321: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4322: my $yeschecked='';
4323: my $nochecked='';
4324: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4325: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4326:
1.221 www 4327: $r->print(<<ENDYESNO);
1.224 www 4328: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4329: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4330: ENDYESNO
4331: } else {
1.224 www 4332: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4333: }
1.318 albertel 4334: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4335: }
1.318 albertel 4336: $r->print(&Apache::loncommon::end_data_table().
1.419 bisitz 4337: "\n".'<input type="submit" name="storerules" value="'.
1.430 schafran 4338: &mt('Save').'" /></form>'."\n".
1.280 albertel 4339: &Apache::loncommon::end_page());
1.220 www 4340: return;
4341: }
1.193 albertel 4342:
1.290 www 4343: sub components {
1.330 albertel 4344: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4345:
4346: if ($typeflag) {
1.290 www 4347: $key=~s/\.type$//;
4348: }
1.330 albertel 4349:
4350: my ($middle,$part,$name)=
4351: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4352: my $issection;
1.330 albertel 4353:
1.290 www 4354: my $section=&mt('All Students');
4355: if ($middle=~/^\[(.*)\]/) {
1.291 www 4356: $issection=$1;
4357: $section=&mt('Group/Section').': '.$issection;
1.290 www 4358: $middle=~s/^\[(.*)\]//;
4359: }
4360: $middle=~s/\.+$//;
4361: $middle=~s/^\.+//;
1.291 www 4362: if ($uname) {
4363: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4364: $issection='';
4365: }
1.316 albertel 4366: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4367: my $realmdescription=&mt('all resources');
1.290 www 4368: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4369: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
1.304 www 4370: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4371: } elsif ($middle) {
1.290 www 4372: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4373: $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>';
1.304 www 4374: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4375: }
1.291 www 4376: my $what=$part.'.'.$name;
1.330 albertel 4377: return ($realm,$section,$name,$part,
1.304 www 4378: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4379: }
1.293 www 4380:
1.328 albertel 4381: my %standard_parms;
1.416 jms 4382:
4383:
1.328 albertel 4384: sub load_parameter_names {
4385: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4386: while (my $configline=<$config>) {
4387: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4388: chomp($configline);
4389: my ($short,$plain)=split(/:/,$configline);
4390: my (undef,$name,$type)=split(/\&/,$short,3);
4391: if ($type eq 'display') {
4392: $standard_parms{$name} = $plain;
4393: }
4394: }
4395: close($config);
4396: $standard_parms{'int_pos'} = 'Positive Integer';
4397: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4398: %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
4399: }
4400:
1.292 www 4401: sub standard_parameter_names {
4402: my ($name)=@_;
1.328 albertel 4403: if (!%standard_parms) {
4404: &load_parameter_names();
4405: }
1.292 www 4406: if ($standard_parms{$name}) {
4407: return $standard_parms{$name};
4408: } else {
4409: return $name;
4410: }
4411: }
1.290 www 4412:
1.309 www 4413:
4414:
1.285 albertel 4415: sub parm_change_log {
1.284 www 4416: my ($r)=@_;
1.414 droeschl 4417: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
4418: text=>"Parameter Change Log"});
1.327 albertel 4419: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4420: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4421:
1.286 www 4422: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4423: $env{'course.'.$env{'request.course.id'}.'.domain'},
4424: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4425:
1.301 www 4426: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4427:
1.327 albertel 4428: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4429: method="post" name="parameterlog">');
1.311 albertel 4430:
4431: my %saveable_parameters = ('show' => 'scalar',);
4432: &Apache::loncommon::store_course_settings('parameter_log',
4433: \%saveable_parameters);
4434: &Apache::loncommon::restore_course_settings('parameter_log',
4435: \%saveable_parameters);
1.348 www 4436: $r->print(&Apache::loncommon::display_filter().
1.326 www 4437: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4438: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4439: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4440:
1.291 www 4441: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4442: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4443: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4444: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4445: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4446: &Apache::loncommon::end_data_table_header_row());
1.309 www 4447: my $shown=0;
1.349 www 4448: my $folder='';
4449: if ($env{'form.displayfilter'} eq 'currentfolder') {
4450: my $last='';
4451: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4452: &GDBM_READER(),0640)) {
4453: $last=$hash{'last_known'};
4454: untie(%hash);
4455: }
4456: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4457: }
1.356 albertel 4458: foreach my $id (sort
4459: {
4460: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4461: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4462: }
4463: my $aid = (split('00000',$a))[-1];
4464: my $bid = (split('00000',$b))[-1];
4465: return $bid<=>$aid;
4466: } (keys(%parmlog))) {
1.294 www 4467: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4468: my $count = 0;
1.288 albertel 4469: my $time =
1.294 www 4470: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4471: my $plainname =
1.294 www 4472: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4473: $parmlog{$id}{'exe_udom'});
1.288 albertel 4474: my $about_me_link =
1.289 www 4475: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4476: $parmlog{$id}{'exe_uname'},
4477: $parmlog{$id}{'exe_udom'});
1.293 www 4478: my $send_msg_link='';
1.294 www 4479: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4480: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4481: $send_msg_link ='<br />'.
1.288 albertel 4482: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4483: $parmlog{$id}{'exe_uname'},
4484: $parmlog{$id}{'exe_udom'});
1.288 albertel 4485: }
1.301 www 4486: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4487: my $makenewrow=0;
4488: my %istype=();
1.332 albertel 4489: my $output;
1.293 www 4490: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4491: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4492: my $typeflag = ($changed =~/\.type$/ &&
4493: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4494: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4495: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4496: if ($env{'form.displayfilter'} eq 'currentfolder') {
4497: if ($folder) {
4498: if ($middle!~/^\Q$folder\E/) { next; }
4499: }
4500: }
1.326 www 4501: if ($typeflag) {
1.329 albertel 4502: $istype{$parmname}=$value;
1.326 www 4503: if (!$env{'form.includetypes'}) { next; }
4504: }
1.332 albertel 4505: $count++;
4506: if ($makenewrow) {
4507: $output .= $row_start;
4508: } else {
4509: $makenewrow=1;
4510: }
4511: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 4512: &standard_parameter_names($parmname).'</td><td>'.
1.332 albertel 4513: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4514: my $stillactive=0;
1.332 albertel 4515: if ($parmlog{$id}{'delflag'}) {
4516: $output .= &mt('Deleted');
1.288 albertel 4517: } else {
1.290 www 4518: if ($typeflag) {
1.332 albertel 4519: $output .= &mt('Type: [_1]',&standard_parameter_names($value));
1.290 www 4520: } else {
1.291 www 4521: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4522: $uname,$udom,$issection,$issection,$courseopt);
4523: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4524: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4525: } else {
1.332 albertel 4526: $output .= $value;
1.291 www 4527: }
4528: if ($value ne $all[$level]) {
1.332 albertel 4529: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4530: } else {
4531: $stillactive=1;
4532: }
1.290 www 4533: }
1.288 albertel 4534: }
1.332 albertel 4535: $output .= '</td><td>';
1.291 www 4536: if ($stillactive) {
1.304 www 4537: my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
4538: my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
4539: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4540: if (($uname) && ($udom)) {
1.332 albertel 4541: $output .=
4542: &Apache::loncommon::messagewrapper('Notify User',
4543: $uname,$udom,$title,
4544: $description);
1.292 www 4545: } else {
1.332 albertel 4546: $output .=
4547: &Apache::lonrss::course_blog_link($id,$title,
4548: $description);
1.292 www 4549: }
1.291 www 4550: }
1.332 albertel 4551: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4552: }
1.349 www 4553: if ($env{'form.displayfilter'} eq 'containing') {
4554: my $wholeentry=$about_me_link.':'.
4555: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4556: $output;
4557: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4558: }
4559: if ($count) {
4560: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4561: <td rowspan="'.$count.'">'.$about_me_link.
4562: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4563: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4564: $send_msg_link.'</td>'.$output);
1.349 www 4565: $shown++;
4566: }
1.311 albertel 4567: if (!($env{'form.show'} eq &mt('all')
4568: || $shown<=$env{'form.show'})) { last; }
1.286 www 4569: }
1.301 www 4570: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4571: $r->print(&Apache::loncommon::end_page());
4572: }
4573:
1.355 albertel 4574: sub check_for_course_info {
4575: my $navmap = Apache::lonnavmaps::navmap->new();
4576: return 1 if ($navmap);
4577: return 0;
4578: }
4579:
1.259 banghart 4580:
1.30 www 4581: sub handler {
1.43 albertel 4582: my $r=shift;
1.30 www 4583:
1.376 albertel 4584: &reset_caches();
4585:
1.414 droeschl 4586: &Apache::loncommon::content_type($r,'text/html');
4587: $r->send_http_header;
4588: return OK if $r->header_only;
4589:
1.193 albertel 4590: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4591: ['action','state',
4592: 'pres_marker',
4593: 'pres_value',
1.206 www 4594: 'pres_type',
1.390 www 4595: 'udom','uname','symb','serial','timebase']);
1.131 www 4596:
1.83 bowersj2 4597:
1.193 albertel 4598: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4599: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4600: text=>"Parameter Manager",
1.204 www 4601: faq=>10,
1.324 www 4602: bug=>'Instructor Interface',
4603: help => 'Parameter_Manager'});
1.203 www 4604:
1.30 www 4605: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4606: my $parm_permission =
4607: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4608: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4609: $env{'request.course.sec'}));
1.355 albertel 4610: my $exists = &check_for_course_info();
4611:
4612: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4613: #
4614: # Main switch on form.action and form.state, as appropriate
4615: #
4616: # Check first if coming from someone else headed directly for
4617: # the table mode
4618: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
4619: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
4620: &assessparms($r);
4621: } elsif (! exists($env{'form.action'})) {
4622: &print_main_menu($r,$parm_permission);
1.414 droeschl 4623: } elsif ($env{'form.action'} eq 'crsenv') {
1.193 albertel 4624: &crsenv($r);
1.414 droeschl 4625: } elsif ($env{'form.action'} eq 'setoverview') {
1.121 www 4626: &overview($r);
1.414 droeschl 4627: } elsif ($env{'form.action'} eq 'addmetadata') {
1.334 banghart 4628: &addmetafield($r);
1.414 droeschl 4629: } elsif ($env{'form.action'} eq 'ordermetadata') {
1.340 banghart 4630: &order_meta_fields($r);
1.414 droeschl 4631: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.259 banghart 4632: &setrestrictmeta($r);
1.414 droeschl 4633: } elsif ($env{'form.action'} eq 'newoverview') {
1.208 www 4634: &newoverview($r);
1.414 droeschl 4635: } elsif ($env{'form.action'} eq 'setdefaults') {
1.220 www 4636: &defaultsetter($r);
1.414 droeschl 4637: } elsif ($env{'form.action'} eq 'settable') {
1.121 www 4638: &assessparms($r);
1.414 droeschl 4639: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.285 albertel 4640: &parm_change_log($r);
1.414 droeschl 4641: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.333 albertel 4642: &clean_parameters($r);
1.414 droeschl 4643: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 4644: &date_shift_one($r);
1.414 droeschl 4645: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 4646: &date_shift_two($r);
1.414 droeschl 4647: } elsif ($env{'form.action'} eq 'categorizecourse') {
1.403 raeburn 4648: &assign_course_categories($r);
4649: }
1.43 albertel 4650: } else {
1.1 www 4651: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 4652: if ($exists) {
4653: $env{'user.error.msg'}=
4654: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4655: } else {
4656: $env{'user.error.msg'}=
4657: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4658: }
1.43 albertel 4659: return HTTP_NOT_ACCEPTABLE;
4660: }
1.376 albertel 4661: &reset_caches();
4662:
1.43 albertel 4663: return OK;
1.1 www 4664: }
4665:
4666: 1;
4667: __END__
4668:
4669:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>