Annotation of loncom/interface/lonparmset.pm, revision 1.443
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.443 ! neumanie 4: # $Id: lonparmset.pm,v 1.442 2009/04/05 17:31:04 droeschl 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>');
1.433 raeburn 976: } else {
1.57 albertel 977: $parm=~s|\[.*\]\s||g;
978: }
1.231 www 979: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
980: if ($automatic) {
1.314 albertel 981: $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
1.231 www 982: }
1.427 bisitz 983: $r->print('<td>'.$parm.'</td>');
1.57 albertel 984:
1.44 albertel 985: my $thismarker=$which;
986: $thismarker=~s/^parameter\_//;
987: my $mprefix=$rid.'&'.$thismarker.'&';
1.275 raeburn 988: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
989: my ($othergrp,$grp_parm,$controlgrp);
1.44 albertel 990:
1.57 albertel 991: if ($parmlev eq 'general') {
992:
993: if ($uname) {
1.66 www 994: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 995: } elsif ($cgroup) {
996: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 997: } elsif ($csec) {
1.269 raeburn 998: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 999: } else {
1.269 raeburn 1000: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1001: }
1002: } elsif ($parmlev eq 'map') {
1003:
1004: if ($uname) {
1.66 www 1005: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 1006: } elsif ($cgroup) {
1007: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1008: } elsif ($csec) {
1.269 raeburn 1009: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1010: } else {
1.269 raeburn 1011: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1012: }
1013: } else {
1.275 raeburn 1014: if ($uname) {
1015: if (@{$usersgroups} > 1) {
1016: my ($coursereply,$grp_parm,$controlgrp);
1017: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
1018: &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
1019: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
1020: if ($coursereply && $result > 3) {
1021: if (defined($controlgrp)) {
1022: if ($cgroup ne $controlgrp) {
1023: $effective_parm = $grp_parm;
1024: $result = 0;
1025: }
1026: }
1027: }
1028: }
1029: }
1.57 albertel 1030:
1.269 raeburn 1031: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 1032:
1.269 raeburn 1033: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1034: &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1035: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 1036: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1037:
1038: if ($csec) {
1.269 raeburn 1039: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1040: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1041: &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 1042: }
1.269 raeburn 1043:
1044: if ($cgroup) {
1045: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1046: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1047: &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1048: }
1.275 raeburn 1049:
1.203 www 1050: if ($uname) {
1.275 raeburn 1051: if ($othergrp) {
1052: $r->print($othergrp);
1053: }
1.203 www 1054: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1055: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1056: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1057: }
1.57 albertel 1058:
1059: } # end of $parmlev if/else
1.419 bisitz 1060: $r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.'</td>');
1.136 albertel 1061:
1.203 www 1062: if ($parmlev eq 'full') {
1.136 albertel 1063: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 1064: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 1065: my $sessionvaltype=$typeoutpar[$result];
1066: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.419 bisitz 1067: $r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'.
1.66 www 1068: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 1069: '</font></td>');
1.136 albertel 1070: }
1.44 albertel 1071: $r->print('</tr>');
1.57 albertel 1072: $r->print("\n");
1.44 albertel 1073: }
1.59 matthew 1074:
1.44 albertel 1075: sub print_td {
1.66 www 1076: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.419 bisitz 1077: $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).
1078: ';" align="center">');
1.437 raeburn 1079: my $nolink = 0;
1080: if ($which == 11 || $which == 12) {
1081: $nolink = 1;
1082: } elsif ($mprefix =~ /availablestudent\&$/) {
1083: if ($which > 3) {
1084: $nolink = 1;
1085: }
1086: }
1087: if ($nolink) {
1088: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
1.114 www 1089: } else {
1.437 raeburn 1090: $r->print(&plink($$typeoutpar[$which],
1091: $$display{$value},$$outpar[$which],
1092: $mprefix."$which",'parmform.pres','psub'));
1.114 www 1093: }
1094: $r->print('</td>'."\n");
1.57 albertel 1095: }
1096:
1.275 raeburn 1097: sub print_usergroups {
1098: my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
1099: my $courseid = $env{'request.course.id'};
1100: my $output;
1101: my $symb = &symbcache($rid);
1102: my $symbparm=$symb.'.'.$what;
1103: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1104: my $mapparm=$map.'___(all).'.$what;
1105: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
1106: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
1107: $courseopt);
1108: my $bgcolor = $defbg;
1109: my $grp_parm;
1110: if (($coursereply) && ($cgroup ne $resultgroup)) {
1111: if ($result > 3) {
1.419 bisitz 1112: $bgcolor = '#AAFFAA';
1.275 raeburn 1113: $grp_parm = &valout($coursereply,$resulttype);
1114: }
1115: $grp_parm = &valout($coursereply,$resulttype);
1.419 bisitz 1116: $output = '<td style="background-color:'.$bgcolor.';" align="center">';
1.275 raeburn 1117: if ($resultgroup && $resultlevel) {
1118: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
1119: } else {
1120: $output .= ' ';
1121: }
1122: $output .= '</td>';
1123: } else {
1.419 bisitz 1124: $output .= '<td style="background-color:'.$bgcolor.';"> </td>';
1.275 raeburn 1125: }
1126: return ($coursereply,$output,$grp_parm,$resultgroup);
1127: }
1128:
1129: sub parm_control_group {
1130: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
1131: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
1132: my $grpfound = 0;
1133: my @levels = ($symbparm,$mapparm,$what);
1134: my @levelnames = ('resource','map/folder','general');
1135: foreach my $group (@{$usersgroups}) {
1136: if ($grpfound) { last; }
1137: for (my $i=0; $i<@levels; $i++) {
1138: my $item = $courseid.'.['.$group.'].'.$levels[$i];
1139: if (defined($$courseopt{$item})) {
1140: $coursereply = $$courseopt{$item};
1141: $resultitem = $item;
1142: $resultgroup = $group;
1143: $resultlevel = $levelnames[$i];
1144: $resulttype = $$courseopt{$item.'.type'};
1145: $grpfound = 1;
1146: last;
1147: }
1148: }
1149: }
1150: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
1151: }
1.201 www 1152:
1.63 bowersj2 1153:
1154:
1155: sub extractResourceInformation {
1156: my $ids = shift;
1157: my $typep = shift;
1158: my $keyp = shift;
1159: my $allparms = shift;
1160: my $allparts = shift;
1161: my $allmaps = shift;
1162: my $mapp = shift;
1163: my $symbp = shift;
1.82 www 1164: my $maptitles=shift;
1.196 www 1165: my $uris=shift;
1.210 www 1166: my $keyorder=shift;
1.211 www 1167: my $defkeytype=shift;
1.196 www 1168:
1.210 www 1169: my $keyordercnt=100;
1.63 bowersj2 1170:
1.196 www 1171: my $navmap = Apache::lonnavmaps::navmap->new();
1172: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
1173: foreach my $resource (@allres) {
1174: my $id=$resource->id();
1175: my ($mapid,$resid)=split(/\./,$id);
1176: if ($mapid eq '0') { next; }
1177: $$ids[$#$ids+1]=$id;
1178: my $srcf=$resource->src();
1179: $srcf=~/\.(\w+)$/;
1180: $$typep{$id}=$1;
1181: $$keyp{$id}='';
1182: $$uris{$id}=$srcf;
1.363 albertel 1183: foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
1184: next if ($key!~/^parameter_/);
1185:
1.209 www 1186: # Hidden parameters
1.363 albertel 1187: next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
1.209 www 1188: #
1189: # allparms is a hash of parameter names
1190: #
1.363 albertel 1191: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
1.375 albertel 1192: if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
1.432 raeburn 1193: my ($display,$parmdis);
1194: $display = &standard_parameter_names($name);
1195: if ($display eq '') {
1196: $display= &Apache::lonnet::metadata($srcf,$key.'.display');
1197: $parmdis = $display;
1198: $parmdis =~ s/\s*\[Part.*$//g;
1199: } else {
1200: $parmdis = $display;
1201: }
1.363 albertel 1202: $$allparms{$name}=$parmdis;
1203: if (ref($defkeytype)) {
1204: $$defkeytype{$name}=
1205: &Apache::lonnet::metadata($srcf,$key.'.type');
1206: }
1207: }
1208:
1.209 www 1209: #
1210: # allparts is a hash of all parts
1211: #
1.363 albertel 1212: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.410 bisitz 1213: $$allparts{$part} = &mt('Part: [_1]',$part);
1.209 www 1214: #
1215: # Remember all keys going with this resource
1216: #
1.363 albertel 1217: if ($$keyp{$id}) {
1218: $$keyp{$id}.=','.$key;
1219: } else {
1220: $$keyp{$id}=$key;
1221: }
1.210 www 1222: #
1223: # Put in order
1224: #
1.363 albertel 1225: unless ($$keyorder{$key}) {
1226: $$keyorder{$key}=$keyordercnt;
1227: $keyordercnt++;
1228: }
1229: }
1.210 www 1230:
1.363 albertel 1231:
1232: if (!exists($$mapp{$mapid})) {
1233: $$mapp{$id}=
1234: &Apache::lonnet::declutter($resource->enclosing_map_src());
1235: $$mapp{$mapid}=$$mapp{$id};
1236: $$allmaps{$mapid}=$$mapp{$id};
1237: if ($mapid eq '1') {
1.401 bisitz 1238: $$maptitles{$mapid}=&mt('Main Course Documents');
1.363 albertel 1239: } else {
1240: $$maptitles{$mapid}=
1241: &Apache::lonnet::gettitle($$mapp{$id});
1.63 bowersj2 1242: }
1.363 albertel 1243: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1244: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.196 www 1245: } else {
1.363 albertel 1246: $$mapp{$id} = $$mapp{$mapid};
1.196 www 1247: }
1248: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
1.63 bowersj2 1249: }
1250: }
1251:
1.208 www 1252:
1253:
1.213 www 1254: sub isdateparm {
1255: my $type=shift;
1256: return (($type=~/^date/) && (!($type eq 'date_interval')));
1257: }
1258:
1.208 www 1259: sub parmmenu {
1.211 www 1260: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 1261: my $tempkey;
1262: $r->print(<<ENDSCRIPT);
1263: <script type="text/javascript">
1264: function checkall(value, checkName) {
1265: for (i=0; i<document.forms.parmform.elements.length; i++) {
1266: ele = document.forms.parmform.elements[i];
1267: if (ele.name == checkName) {
1268: document.forms.parmform.elements[i].checked=value;
1269: }
1270: }
1271: }
1.210 www 1272:
1273: function checkthis(thisvalue, checkName) {
1274: for (i=0; i<document.forms.parmform.elements.length; i++) {
1275: ele = document.forms.parmform.elements[i];
1276: if (ele.name == checkName) {
1277: if (ele.value == thisvalue) {
1278: document.forms.parmform.elements[i].checked=true;
1279: }
1280: }
1281: }
1282: }
1283:
1284: function checkdates() {
1285: checkthis('duedate','pscat');
1286: checkthis('opendate','pscat');
1287: checkthis('answerdate','pscat');
1.218 www 1288: }
1289:
1290: function checkdisset() {
1291: checkthis('discussend','pscat');
1292: checkthis('discusshide','pscat');
1293: }
1294:
1295: function checkcontdates() {
1296: checkthis('contentopen','pscat');
1297: checkthis('contentclose','pscat');
1298: }
1299:
1.210 www 1300:
1301: function checkvisi() {
1302: checkthis('hiddenresource','pscat');
1303: checkthis('encrypturl','pscat');
1304: checkthis('problemstatus','pscat');
1305: checkthis('contentopen','pscat');
1306: checkthis('opendate','pscat');
1307: }
1308:
1309: function checkparts() {
1310: checkthis('hiddenparts','pscat');
1311: checkthis('display','pscat');
1312: checkthis('ordered','pscat');
1313: }
1314:
1315: function checkstandard() {
1316: checkall(false,'pscat');
1317: checkdates();
1318: checkthis('weight','pscat');
1319: checkthis('maxtries','pscat');
1320: }
1321:
1.208 www 1322: </script>
1323: ENDSCRIPT
1.209 www 1324: $r->print();
1.443 ! neumanie 1325: $r->print('<tr>');
! 1326: $r->print('<td style="width:350px;border:1pt solid;font-weight:bold;color:#000000;background-color:#ccccff;vertical-align:top;">');
! 1327: $r->print('<blockquote>'.&mt('Select Parameters to View').'</blockquote>');
! 1328: $r->print('</td>');
! 1329: $r->print('<td style="width:700px; border:1pt solid;padding-left:10px"><blockquote>');
1.422 bisitz 1330: $r->print("\n".'<table id="LC_parm_overview_parm_menu"><tr>');
1.208 www 1331: my $cnt=0;
1.211 www 1332: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.419 bisitz 1333: $r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
1.208 www 1334: $r->print('value="'.$tempkey.'"');
1335: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1.422 bisitz 1336: $r->print(' checked="checked"');
1.208 www 1337: }
1.432 raeburn 1338: $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
1339: : $tempkey)
1340: .'</label></td>');
1.209 www 1341: $cnt++;
1342: if ($cnt==3) {
1343: $r->print("</tr>\n<tr>");
1344: $cnt=0;
1345: }
1.208 www 1346: }
1.410 bisitz 1347: $r->print('</tr>'
1.422 bisitz 1348: .'<tr id="LC_parm_overview_parm_menu_selectors">'
1.410 bisitz 1349: .'<td valign="top">'
1350: .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'
1351: .'<span class="LC_nobreak">'
1352: .'• <a href="javascript:checkall(true, \'pscat\')">'.&mt('Select All').'</a>'
1353: .'</span>'
1354: .'<br />'
1355: .'<span class="LC_nobreak">'
1356: .'• <a href="javascript:checkstandard()">'.&mt('Select Common Only').'</a>'
1357: .'</span>'
1358: .'<br />'
1359: .'<span class="LC_nobreak">'
1360: .'• <a href="javascript:checkall(false, \'pscat\')">'.&mt('Unselect All').'</a>'
1361: .'</span>'
1362: .'</fieldset>'
1363: .'</td>'
1364: .'<td colspan="2" valign="top">'
1365: .'<fieldset><legend><b>'.&mt('Add Selection for...').'</b></legend>'
1366: .'<span class="LC_nobreak">'
1367: .'• <a href="javascript:checkdates()">'.&mt('Problem Dates').'</a>'
1368: .'</span>'
1369: .'<span class="LC_nobreak">'
1370: .' • <a href="javascript:checkcontdates()">'.&mt('Content Dates').'</a>'
1371: .'</span>'
1372: # .'<br />'
1373: .'<span class="LC_nobreak">'
1374: .' • <a href="javascript:checkdisset()">'.&mt('Discussion Settings').'</a>'
1375: .'</span>'
1376: .'<span class="LC_nobreak">'
1377: .' • <a href="javascript:checkvisi()">'.&mt('Visibilities').'</a>'
1378: .'</span>'
1379: # .'<br />'
1380: .'<span class="LC_nobreak">'
1381: .' • <a href="javascript:checkparts()">'.&mt('Part Parameters').'</a>'
1382: .'</span>'
1383: .'</fieldset>'
1384: .'</td>'
1385: .'</tr></table>'
1386: );
1.443 ! neumanie 1387: $r->print('</blockquote></td></tr>');
1.208 www 1388: }
1389:
1.209 www 1390: sub partmenu {
1391: my ($r,$allparts,$psprt)=@_;
1.443 ! neumanie 1392: $r->print('<tr>');
! 1393: $r->print('<td style="width:350px;border:1pt solid;font-weight:bold;color:#000000;background-color:#ccccff;vertical-align:top;">');
! 1394: $r->print('<blockquote>'. &mt('Select Parts to View').'</blockquote>');
! 1395: $r->print('</td>');
! 1396: $r->print('<td style="width:700px; border:1pt solid;padding-left:10px"><blockquote>');
1.421 bisitz 1397: $r->print('<select multiple="multiple" name="psprt" size="8">');
1.208 www 1398: $r->print('<option value="all"');
1.401 bisitz 1399: $r->print(' selected="selected"') unless (@{$psprt});
1.208 www 1400: $r->print('>'.&mt('All Parts').'</option>');
1401: my %temphash=();
1402: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1403: foreach my $tempkey (sort {
1404: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1405: } keys(%{$allparts})) {
1.208 www 1406: unless ($tempkey =~ /\./) {
1407: $r->print('<option value="'.$tempkey.'"');
1408: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1.401 bisitz 1409: $r->print(' selected="selected"');
1.208 www 1410: }
1411: $r->print('>'.$$allparts{$tempkey}.'</option>');
1412: }
1413: }
1.209 www 1414: $r->print('</select>');
1.443 ! neumanie 1415: $r->print('</blockquote></td></tr>');
1.209 www 1416: }
1417:
1418: sub usermenu {
1.275 raeburn 1419: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1420: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1421: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1422: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.412 bisitz 1423:
1.209 www 1424: my $sections='';
1.300 albertel 1425: my %sectionhash = &Apache::loncommon::get_sections();
1426:
1.269 raeburn 1427: my $groups;
1.307 raeburn 1428: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1429:
1.412 bisitz 1430: my $g_s_header='';
1431: my $g_s_footer='';
1.443 ! neumanie 1432:
1.300 albertel 1433: if (%sectionhash) {
1.412 bisitz 1434: $sections=&mt('Section:').' <select name="csec"';
1.299 albertel 1435: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 1436: $sections .= qq| onchange="group_or_section('csec')" |;
1437: }
1438: $sections .= '>';
1.275 raeburn 1439: foreach my $section ('',sort keys %sectionhash) {
1440: $sections.='<option value="'.$section.'" '.
1441: ($section eq $csec?'selected="selected"':'').'>'.$section.
1442: '</option>';
1.209 www 1443: }
1444: $sections.='</select>';
1.269 raeburn 1445: }
1.412 bisitz 1446:
1.300 albertel 1447: if (%sectionhash && %grouphash && $parmlev ne 'full') {
1.412 bisitz 1448: $sections .= ' '.&mt('or').' ';
1.269 raeburn 1449: $sections .= qq|
1450: <script type="text/javascript">
1451: function group_or_section(caller) {
1452: if (caller == "cgroup") {
1453: if (document.parmform.cgroup.selectedIndex != 0) {
1454: document.parmform.csec.selectedIndex = 0;
1455: }
1456: } else {
1457: if (document.parmform.csec.selectedIndex != 0) {
1458: document.parmform.cgroup.selectedIndex = 0;
1459: }
1460: }
1461: }
1462: </script>
1463: |;
1464: } else {
1465: $sections .= qq|
1466: <script type="text/javascript">
1467: function group_or_section(caller) {
1468: return;
1469: }
1470: </script>
1471: |;
1472: }
1.299 albertel 1473:
1474: if (%grouphash) {
1.412 bisitz 1475: $groups=&mt('Group:').' <select name="cgroup"';
1.300 albertel 1476: if (%sectionhash && $env{'form.action'} eq 'settable') {
1.269 raeburn 1477: $groups .= qq| onchange="group_or_section('cgroup')" |;
1478: }
1479: $groups .= '>';
1.275 raeburn 1480: foreach my $grp ('',sort keys %grouphash) {
1481: $groups.='<option value="'.$grp.'" ';
1482: if ($grp eq $cgroup) {
1483: unless ((defined($uname)) && ($grp eq '')) {
1484: $groups .= 'selected="selected" ';
1485: }
1486: } elsif (!defined($cgroup)) {
1487: if (@{$usersgroups} == 1) {
1488: if ($grp eq $$usersgroups[0]) {
1489: $groups .= 'selected="selected" ';
1490: }
1491: }
1492: }
1493: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1494: }
1495: $groups.='</select>';
1496: }
1.412 bisitz 1497:
1.443 ! neumanie 1498: if (%sectionhash || %grouphash) {
! 1499: $r->print('<tr>');
! 1500: $r->print('<td style="width:350px;border:1pt solid;font-weight:bold;color:#000000;background-color:#ccccff;vertical-align:top;">');
! 1501: $r->print('<blockquote>'.&mt('Group/Section').'</blockquote>');
! 1502: $r->print('</td>');
! 1503: $r->print('<td style="width:700px; border:1pt solid;padding-left:10px"><blockquote>');
! 1504: $r->print($sections.$groups);
! 1505: $r->print('</blockquote></td></tr>');
! 1506: }
! 1507: $r->print('<tr>');
! 1508: $r->print('<td style="width:350px;border:1pt solid;font-weight:bold;color:#000000;background-color:#ccccff;vertical-align:top;">');
! 1509: $r->print('<blockquote>'. &mt('User').'</blockquote>');
! 1510: $r->print('</td>');
! 1511: $r->print('<td style="width:700px; border:1pt solid;padding-left:10px"><blockquote>');
! 1512:
! 1513: $r->print(&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]'
1.412 bisitz 1514: ,'<input type="text" value="'.$uname.'" size="12" name="uname" />'
1515: ,'<input type="text" value="'.$id.'" size="12" name="id" /> '
1.443 ! neumanie 1516: ,$chooseopt));
! 1517:
! 1518: $r->print('</blockquote></td></tr>');
1.209 www 1519: }
1520:
1521: sub displaymenu {
1.211 www 1522: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.443 ! neumanie 1523: $r->print('<div class="LC_ContentBoxSpecial">');
! 1524: $r->print('<h2 class="LC_hcell">Step 2</h2>');
! 1525: $r->print('<blockquote>');
! 1526: $r->print('<table border="0" style="border-style:solid;border-collapse:seperate;text-align:left;margin-left:auto;margin-right:auto;border-spacing:0pt;">');
! 1527:
! 1528: #$r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'. &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1529: &parmmenu($r,$allparms,$pscat,$keyorder);
1.443 ! neumanie 1530:
1.209 www 1531: &partmenu($r,$allparts,$psprt);
1.443 ! neumanie 1532: $r->print('</table></blockquote></div>');
1.209 www 1533: }
1534:
1.443 ! neumanie 1535: sub mapmenu {##
! 1536: my ($r,$allmaps,$pschp,$maptitles)=@_;
! 1537: $r->print('<tr>');
! 1538: $r->print('<td style="width:350px;border:1pt solid;font-weight:bold;color:#000000;background-color:#ccccff;vertical-align:top;">');
! 1539: $r->print('<blockquote>'.&mt('Select Enclosing Map or Folder').'</blockquote>');
! 1540: $r->print('</td>');
! 1541: $r->print('<td style="width:700px; border:1pt solid;padding-left:10px"><blockquote>');
1.209 www 1542: $r->print('<select name="pschp">');
1543: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1544: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1545: $r->print('<option value="'.$_.'"');
1.401 bisitz 1546: if (($pschp eq $_)) { $r->print(' selected="selected"'); }
1.209 www 1547: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1548: }
1549: $r->print("</select>");
1.443 ! neumanie 1550: $r->print('</blockquote></td></tr>');
1.209 www 1551: }
1552:
1553: sub levelmenu {
1.443 ! neumanie 1554: my ($r,$alllevs,$parmlev)=@_;
! 1555: $r->print('<tr>');
! 1556: $r->print('<td style="width:350px;border:1pt solid;font-weight:bold;color:#000000;background-color:#ccccff;vertical-align:top;">');
! 1557: $r->print('<blockquote>'.&mt('Select Parameter Level').&Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</blockquote>');
! 1558: $r->print('</td>');
! 1559: $r->print('<td style="width:700px; border:1pt solid;padding-left:10px"><blockquote>');
1.209 www 1560: $r->print('<select name="parmlev">');
1561: foreach (reverse sort keys %{$alllevs}) {
1562: $r->print('<option value="'.$$alllevs{$_}.'"');
1563: if ($parmlev eq $$alllevs{$_}) {
1.401 bisitz 1564: $r->print(' selected="selected"');
1.209 www 1565: }
1.401 bisitz 1566: $r->print('>'.&mt($_).'</option>');
1.208 www 1567: }
1.209 www 1568: $r->print("</select>");
1.443 ! neumanie 1569: $r->print('</blockquote></td></tr>');
1.208 www 1570: }
1571:
1.211 www 1572:
1573: sub sectionmenu {
1574: my ($r,$selectedsections)=@_;
1.300 albertel 1575: my %sectionhash = &Apache::loncommon::get_sections();
1576: return if (!%sectionhash);
1577:
1.421 bisitz 1578: $r->print('<select name="Section" multiple="multiple" size="8">');
1.300 albertel 1579: foreach my $s ('all',sort keys %sectionhash) {
1580: $r->print(' <option value="'.$s.'"');
1581: foreach (@{$selectedsections}) {
1582: if ($s eq $_) {
1.401 bisitz 1583: $r->print(' selected="selected"');
1.300 albertel 1584: last;
1.212 www 1585: }
1586: }
1.300 albertel 1587: $r->print('>'.$s."</option>\n");
1588: }
1589: $r->print("</select>\n");
1.269 raeburn 1590: }
1591:
1592: sub groupmenu {
1593: my ($r,$selectedgroups)=@_;
1.307 raeburn 1594: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1595: return if (!%grouphash);
1596:
1.421 bisitz 1597: $r->print('<select name="Group" multiple="multiple" size="8">');
1.299 albertel 1598: foreach my $group (sort(keys(%grouphash))) {
1599: $r->print(' <option value="'.$group.'"');
1600: foreach (@{$selectedgroups}) {
1601: if ($group eq $_) {
1.401 bisitz 1602: $r->print(' selected="selected"');
1.299 albertel 1603: last;
1604: }
1605: }
1606: $r->print('>'.$group."</option>\n");
1.211 www 1607: }
1.299 albertel 1608: $r->print("</select>\n");
1.211 www 1609: }
1610:
1.269 raeburn 1611:
1.210 www 1612: sub keysplit {
1613: my $keyp=shift;
1614: return (split(/\,/,$keyp));
1615: }
1616:
1617: sub keysinorder {
1618: my ($name,$keyorder)=@_;
1619: return sort {
1620: $$keyorder{$a} <=> $$keyorder{$b};
1621: } (keys %{$name});
1622: }
1623:
1.236 albertel 1624: sub keysinorder_bytype {
1625: my ($name,$keyorder)=@_;
1626: return sort {
1627: my $ta=(split('_',$a))[-1];
1628: my $tb=(split('_',$b))[-1];
1629: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1630: return ($a cmp $b);
1631: }
1632: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1633: } (keys %{$name});
1634: }
1635:
1.211 www 1636: sub keysindisplayorder {
1637: my ($name,$keyorder)=@_;
1638: return sort {
1639: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1640: } (keys %{$name});
1641: }
1642:
1.214 www 1643: sub sortmenu {
1644: my ($r,$sortorder)=@_;
1.236 albertel 1645: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1646: if ($sortorder eq 'realmstudent') {
1.422 bisitz 1647: $r->print(' checked="checked"');
1.214 www 1648: }
1649: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1650: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1651: if ($sortorder eq 'studentrealm') {
1.422 bisitz 1652: $r->print(' checked="checked"');
1.214 www 1653: }
1.236 albertel 1654: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1655: '</label>');
1.214 www 1656: }
1657:
1.211 www 1658: sub standardkeyorder {
1659: return ('parameter_0_opendate' => 1,
1660: 'parameter_0_duedate' => 2,
1661: 'parameter_0_answerdate' => 3,
1662: 'parameter_0_interval' => 4,
1663: 'parameter_0_weight' => 5,
1664: 'parameter_0_maxtries' => 6,
1665: 'parameter_0_hinttries' => 7,
1666: 'parameter_0_contentopen' => 8,
1667: 'parameter_0_contentclose' => 9,
1668: 'parameter_0_type' => 10,
1669: 'parameter_0_problemstatus' => 11,
1670: 'parameter_0_hiddenresource' => 12,
1671: 'parameter_0_hiddenparts' => 13,
1672: 'parameter_0_display' => 14,
1673: 'parameter_0_ordered' => 15,
1674: 'parameter_0_tol' => 16,
1675: 'parameter_0_sig' => 17,
1.218 www 1676: 'parameter_0_turnoffunit' => 18,
1677: 'parameter_0_discussend' => 19,
1678: 'parameter_0_discusshide' => 20);
1.211 www 1679: }
1680:
1.59 matthew 1681:
1.30 www 1682: sub assessparms {
1.1 www 1683:
1.43 albertel 1684: my $r=shift;
1.201 www 1685:
1686: my @ids=();
1687: my %symbp=();
1688: my %mapp=();
1689: my %typep=();
1690: my %keyp=();
1691: my %uris=();
1692: my %maptitles=();
1693:
1.2 www 1694: # -------------------------------------------------------- Variable declaration
1.209 www 1695:
1.129 www 1696: my %allmaps=();
1697: my %alllevs=();
1.57 albertel 1698:
1.187 www 1699: my $uname;
1700: my $udom;
1701: my $uhome;
1702: my $csec;
1.269 raeburn 1703: my $cgroup;
1.275 raeburn 1704: my @usersgroups = ();
1.187 www 1705:
1.190 albertel 1706: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1707:
1.57 albertel 1708: $alllevs{'Resource Level'}='full';
1.215 www 1709: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1710: $alllevs{'Course Level'}='general';
1711:
1712: my %allparms;
1713: my %allparts;
1.210 www 1714: #
1715: # Order in which these parameters will be displayed
1716: #
1.211 www 1717: my %keyorder=&standardkeyorder();
1718:
1.43 albertel 1719: @ids=();
1720: %symbp=();
1721: %typep=();
1722:
1723: my $message='';
1724:
1.190 albertel 1725: $csec=$env{'form.csec'};
1.269 raeburn 1726: $cgroup=$env{'form.cgroup'};
1.188 www 1727:
1.190 albertel 1728: if ($udom=$env{'form.udom'}) {
1729: } elsif ($udom=$env{'request.role.domain'}) {
1730: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1731: } else {
1732: $udom=$r->dir_config('lonDefDomain');
1733: }
1.43 albertel 1734:
1.134 albertel 1735: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1736: my $pschp=$env{'form.pschp'};
1.134 albertel 1737: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1738: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1739:
1.43 albertel 1740: my $pssymb='';
1.57 albertel 1741: my $parmlev='';
1742:
1.190 albertel 1743: unless ($env{'form.parmlev'}) {
1.57 albertel 1744: $parmlev = 'map';
1745: } else {
1.190 albertel 1746: $parmlev = $env{'form.parmlev'};
1.57 albertel 1747: }
1.26 www 1748:
1.29 www 1749: # ----------------------------------------------- Was this started from grades?
1750:
1.190 albertel 1751: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1752: && (!$env{'form.dis'})) {
1753: my $url=$env{'form.url'};
1.194 albertel 1754: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1755: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1756: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1757: $pschp='';
1.57 albertel 1758: $parmlev = 'full';
1.190 albertel 1759: } elsif ($env{'form.symb'}) {
1760: $pssymb=$env{'form.symb'};
1.92 albertel 1761: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1762: $pschp='';
1.57 albertel 1763: $parmlev = 'full';
1.43 albertel 1764: } else {
1.190 albertel 1765: $env{'form.url'}='';
1.43 albertel 1766: }
1767:
1.190 albertel 1768: my $id=$env{'form.id'};
1.43 albertel 1769: if (($id) && ($udom)) {
1770: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1771: if ($uname) {
1772: $id='';
1773: } else {
1774: $message=
1.314 albertel 1775: '<span class="LC_error">'.&mt("Unknown ID")." '$id' ".
1776: &mt('at domain')." '$udom'</span>";
1.43 albertel 1777: }
1778: } else {
1.190 albertel 1779: $uname=$env{'form.uname'};
1.43 albertel 1780: }
1781: unless ($udom) { $uname=''; }
1782: $uhome='';
1783: if ($uname) {
1784: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1785: if ($uhome eq 'no_host') {
1786: $message=
1.314 albertel 1787: '<span class="LC_error">'.&mt("Unknown user")." '$uname' ".
1788: &mt("at domain")." '$udom'</span>";
1.43 albertel 1789: $uname='';
1.12 www 1790: } else {
1.103 albertel 1791: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1792: $env{'request.course.id'});
1.269 raeburn 1793:
1.43 albertel 1794: if ($csec eq '-1') {
1.314 albertel 1795: $message='<span class="LC_error">'.
1.133 www 1796: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1.314 albertel 1797: &mt("not in this course")."</span>";
1.43 albertel 1798: $uname='';
1.190 albertel 1799: $csec=$env{'form.csec'};
1.269 raeburn 1800: $cgroup=$env{'form.cgroup'};
1.43 albertel 1801: } else {
1802: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1803: ('firstname','middlename','lastname','generation','id'));
1.133 www 1804: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1805: $name{'firstname'}.' '.$name{'middlename'}.' '
1806: .$name{'lastname'}.' '.$name{'generation'}.
1.336 albertel 1807: "<br />\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1808: }
1.297 raeburn 1809: @usersgroups = &Apache::lonnet::get_users_groups(
1.275 raeburn 1810: $udom,$uname,$env{'request.course.id'});
1.297 raeburn 1811: if (@usersgroups > 0) {
1.306 albertel 1812: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
1.275 raeburn 1813: $cgroup = $usersgroups[0];
1.297 raeburn 1814: }
1.269 raeburn 1815: }
1.12 www 1816: }
1.43 albertel 1817: }
1.2 www 1818:
1.43 albertel 1819: unless ($csec) { $csec=''; }
1.269 raeburn 1820: unless ($cgroup) { $cgroup=''; }
1.12 www 1821:
1.14 www 1822: # --------------------------------------------------------- Get all assessments
1.210 www 1823: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1824: \%mapp, \%symbp,\%maptitles,\%uris,
1825: \%keyorder);
1.63 bowersj2 1826:
1.57 albertel 1827: $mapp{'0.0'} = '';
1828: $symbp{'0.0'} = '';
1.99 albertel 1829:
1.14 www 1830: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1831: if ($env{'form.pres_marker'}) {
1.205 www 1832: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1833: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1834: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1835: for (my $i=0;$i<=$#markers;$i++) {
1.437 raeburn 1836: if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
1837: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1838: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1839: my (@ok_slots,@fail_slots,@del_slots);
1840: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1841: my ($level,@all) =
1842: &parmval_by_symb('0.availablestudent',$pssymb,'',$uname,$udom,
1843: $csec,$cgroup,$courseopt);
1844: foreach my $slot_name (split(/:/,$values[$i])) {
1845: next if ($slot_name eq '');
1846: if (&update_slots($slot_name,$cdom,$cnum,$pssymb,$uname,$udom) eq 'ok') {
1847: push(@ok_slots,$slot_name);
1848:
1849: } else {
1850: push(@fail_slots,$slot_name);
1851: }
1852: }
1853: if (@ok_slots) {
1854: $values[$i] = join(':',@ok_slots);
1855: } else {
1856: $values[$i] = '';
1857: }
1858: if ($all[$level] ne '') {
1859: my @existing = split(/:/,$all[$level]);
1860: foreach my $slot_name (@existing) {
1861: if (!grep(/^\Q$slot_name\E$/,split(/:/,$values[$i]))) {
1862: if (&delete_slots($slot_name,$cdom,$cnum,$uname,$udom,$pssymb) eq 'ok') {
1863: push(@del_slots,$slot_name);
1864: }
1865: }
1866: }
1867: }
1868: }
1.205 www 1869: $message.=&storeparm(split(/\&/,$markers[$i]),
1870: $values[$i],
1871: $types[$i],
1.269 raeburn 1872: $uname,$udom,$csec,$cgroup);
1.205 www 1873: }
1.68 www 1874: # ---------------------------------------------------------------- Done storing
1.130 www 1875: $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 1876: }
1.57 albertel 1877: #----------------------------------------------- if all selected, fill in array
1.209 www 1878: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1879: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1880: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1881: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1882:
1.209 www 1883: &startpage($r);
1.57 albertel 1884:
1.44 albertel 1885: foreach ('tolerance','date_default','date_start','date_end',
1886: 'date_interval','int','float','string') {
1887: $r->print('<input type="hidden" value="'.
1.378 albertel 1888: &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
1889: '" name="recent_'.$_.'" />');
1.44 albertel 1890: }
1.57 albertel 1891:
1.443 ! neumanie 1892: if (!$pssymb) {
! 1893: $r->print('<div class="LC_ContentBoxSpecial">');
! 1894: $r->print('<h2 class="LC_hcell">Step 1</h2>');
! 1895: $r->print('<blockquote>');
! 1896: $r->print('<table border="0" style="border-style:solid;border-collapse:seperate;text-align:left;margin-left:auto;margin-right:auto;border-spacing:0pt;">');
1.209 www 1897: &levelmenu($r,\%alllevs,$parmlev);
1.443 ! neumanie 1898:
1.128 albertel 1899: if ($parmlev ne 'general') {
1.443 ! neumanie 1900:
1.209 www 1901: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1.443 ! neumanie 1902:
1.128 albertel 1903: }
1.443 ! neumanie 1904: $r->print('</table>');
! 1905: $r->print('</blockquote>');
! 1906: $r->print('</div>');
1.211 www 1907: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1908: } else {
1.125 www 1909: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.312 albertel 1910: my $title = &Apache::lonnet::gettitle($pssymb);
1911: $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource).
1912: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.238 www 1913: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1914: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1915: }
1.443 ! neumanie 1916: $r->print('<div class="LC_ContentBoxSpecial">');
! 1917: $r->print('<h2 class="LC_hcell">Step 3</h2>');
! 1918: $r->print('<blockquote>');
! 1919: $r->print('<table border="0" style="border-style:solid;border-collapse:seperate;text-align:left;margin-left:auto;margin-right:auto;border-spacing:0pt;">');
1.275 raeburn 1920: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.443 ! neumanie 1921: $r->print('</table>');
! 1922: $r->print('</blockquote>');
! 1923: $r->print('</div>');
1.57 albertel 1924:
1.210 www 1925: $r->print('<p>'.$message.'</p>');
1926:
1.209 www 1927: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1928:
1929: my @temp_pscat;
1930: map {
1931: my $cat = $_;
1932: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1933: } @pscat;
1934:
1935: @pscat = @temp_pscat;
1936:
1.209 www 1937: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1938: # ----------------------------------------------------------------- Start Table
1.57 albertel 1939: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1940: my $csuname=$env{'user.name'};
1941: my $csudom=$env{'user.domain'};
1.57 albertel 1942:
1.203 www 1943: if ($parmlev eq 'full') {
1.57 albertel 1944: my $coursespan=$csec?8:5;
1.275 raeburn 1945: my $userspan=3;
1.269 raeburn 1946: if ($cgroup ne '') {
1947: $coursespan += 3;
1948: }
1949:
1.419 bisitz 1950: $r->print('<p><table border="2">');
1951: $r->print('<tr><td colspan="5"></td>');
1952: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
1.57 albertel 1953: if ($uname) {
1.275 raeburn 1954: if (@usersgroups > 1) {
1955: $userspan ++;
1956: }
1957: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1958: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1959: }
1.133 www 1960: my %lt=&Apache::lonlocal::texthash(
1961: 'pie' => "Parameter in Effect",
1962: 'csv' => "Current Session Value",
1963: 'at' => 'at',
1964: 'rl' => "Resource Level",
1965: 'ic' => 'in Course',
1966: 'aut' => "Assessment URL and Title",
1.143 albertel 1967: 'type' => 'Type',
1.133 www 1968: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1969: 'part' => 'Part',
1.133 www 1970: 'pn' => 'Parameter Name',
1971: 'def' => 'default',
1972: 'femof' => 'from Enclosing Map or Folder',
1973: 'gen' => 'general',
1974: 'foremf' => 'for Enclosing Map or Folder',
1975: 'fr' => 'for Resource'
1976: );
1.57 albertel 1977: $r->print(<<ENDTABLETWO);
1.419 bisitz 1978: <th rowspan="3">$lt{'pie'}</th>
1979: <th rowspan="3">$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>
1980: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
1981: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 1982:
1.10 www 1983: ENDTABLETWO
1.57 albertel 1984: if ($csec) {
1.419 bisitz 1985: $r->print('<th colspan="3">'.
1.269 raeburn 1986: &mt("in Section")." $csec</th>");
1987: }
1988: if ($cgroup) {
1.419 bisitz 1989: $r->print('<th colspan="3">'.
1.269 raeburn 1990: &mt("in Group")." $cgroup</th>");
1.57 albertel 1991: }
1992: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1993: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1994: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1995: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1996: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1997: ENDTABLEHEADFOUR
1.57 albertel 1998:
1999: if ($csec) {
1.130 www 2000: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 2001: }
2002:
1.269 raeburn 2003: if ($cgroup) {
2004: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2005: }
2006:
1.57 albertel 2007: if ($uname) {
1.275 raeburn 2008: if (@usersgroups > 1) {
2009: $r->print('<th>'.&mt('Control by other group?').'</th>');
2010: }
1.130 www 2011: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 2012: }
2013:
2014: $r->print('</tr>');
2015:
2016: my $defbgone='';
2017: my $defbgtwo='';
1.269 raeburn 2018: my $defbgthree = '';
1.57 albertel 2019:
2020: foreach (@ids) {
2021:
2022: my $rid=$_;
2023: my ($inmapid)=($rid=~/\.(\d+)$/);
2024:
1.152 albertel 2025: if ((!$pssymb &&
2026: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
2027: ||
2028: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 2029: # ------------------------------------------------------ Entry for one resource
1.419 bisitz 2030: if ($defbgone eq '#E0E099') {
2031: $defbgone='#E0E0DD';
1.57 albertel 2032: } else {
1.419 bisitz 2033: $defbgone='#E0E099';
1.57 albertel 2034: }
1.419 bisitz 2035: if ($defbgtwo eq '#FFFF99') {
2036: $defbgtwo='#FFFFDD';
1.57 albertel 2037: } else {
1.419 bisitz 2038: $defbgtwo='#FFFF99';
1.57 albertel 2039: }
1.419 bisitz 2040: if ($defbgthree eq '#FFBB99') {
2041: $defbgthree='#FFBBDD';
1.269 raeburn 2042: } else {
1.419 bisitz 2043: $defbgthree='#FFBB99';
1.269 raeburn 2044: }
2045:
1.57 albertel 2046: my $thistitle='';
2047: my %name= ();
2048: undef %name;
2049: my %part= ();
2050: my %display=();
2051: my %type= ();
2052: my %default=();
1.196 www 2053: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2054:
1.210 www 2055: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2056: my $tempkeyp = $_;
2057: if (grep $_ eq $tempkeyp, @catmarker) {
2058: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
2059: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1.433 raeburn 2060: my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
2061: if ($allparms{$name{$_}} ne '') {
2062: my $identifier;
2063: if ($parmdis =~ /(\s*\[Part.*)$/) {
2064: $identifier = $1;
2065: }
2066: $display{$_} = $allparms{$name{$_}}.$identifier;
2067: } else {
2068: $display{$_} = $parmdis;
2069: }
1.57 albertel 2070: unless ($display{$_}) { $display{$_}=''; }
2071: $display{$_}.=' ('.$name{$_}.')';
2072: $default{$_}=&Apache::lonnet::metadata($uri,$_);
2073: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
2074: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
2075: }
2076: }
2077: my $totalparms=scalar keys %name;
2078: if ($totalparms>0) {
2079: my $firstrow=1;
1.274 albertel 2080: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 2081: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 2082: ' rowspan='.$totalparms.
1.419 bisitz 2083: '><tt><font size="-1">'.
1.57 albertel 2084: join(' / ',split(/\//,$uri)).
2085: '</font></tt><p><b>'.
1.154 albertel 2086: "<a href=\"javascript:openWindow('".
1.274 albertel 2087: &Apache::lonnet::clutter($uri).'?symb='.
1.308 www 2088: &escape($symbp{$rid}).
1.336 albertel 2089: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
2090: " target=\"_self\">$title");
1.57 albertel 2091:
2092: if ($thistitle) {
2093: $r->print(' ('.$thistitle.')');
2094: }
2095: $r->print('</a></b></td>');
1.419 bisitz 2096: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 2097: ' rowspan='.$totalparms.'>'.$typep{$rid}.
2098: '</td>');
2099:
1.419 bisitz 2100: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 2101: ' rowspan='.$totalparms.
1.238 www 2102: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 2103:
1.236 albertel 2104: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 2105: unless ($firstrow) {
2106: $r->print('<tr>');
2107: } else {
2108: undef $firstrow;
2109: }
1.201 www 2110: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 2111: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 2112: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 2113: $cgroup,\@usersgroups);
1.57 albertel 2114: }
2115: }
2116: }
2117: } # end foreach ids
1.43 albertel 2118: # -------------------------------------------------- End entry for one resource
1.57 albertel 2119: $r->print('</table>');
1.203 www 2120: } # end of full
1.57 albertel 2121: #--------------------------------------------------- Entry for parm level map
2122: if ($parmlev eq 'map') {
1.419 bisitz 2123: my $defbgone = '#E0E099';
2124: my $defbgtwo = '#FFFF99';
2125: my $defbgthree = '#FFBB99';
1.57 albertel 2126:
2127: my %maplist;
2128:
2129: if ($pschp eq 'all') {
2130: %maplist = %allmaps;
2131: } else {
2132: %maplist = ($pschp => $mapp{$pschp});
2133: }
2134:
2135: #-------------------------------------------- for each map, gather information
2136: my $mapid;
1.60 albertel 2137: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
2138: my $maptitle = $maplist{$mapid};
1.57 albertel 2139:
2140: #----------------------- loop through ids and get all parameter types for map
2141: #----------------------------------------- and associated information
2142: my %name = ();
2143: my %part = ();
2144: my %display = ();
2145: my %type = ();
2146: my %default = ();
2147: my $map = 0;
2148:
2149: # $r->print("Catmarker: @catmarker<br />\n");
2150:
2151: foreach (@ids) {
2152: ($map)=(/([\d]*?)\./);
2153: my $rid = $_;
2154:
2155: # $r->print("$mapid:$map: $rid <br /> \n");
2156:
2157: if ($map eq $mapid) {
1.196 www 2158: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2159: # $r->print("Keys: $keyp{$rid} <br />\n");
2160:
2161: #--------------------------------------------------------------------
2162: # @catmarker contains list of all possible parameters including part #s
2163: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2164: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2165: # When storing information, store as part 0
2166: # When requesting information, request from full part
2167: #-------------------------------------------------------------------
1.210 www 2168: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2169: my $tempkeyp = $_;
2170: my $fullkeyp = $tempkeyp;
1.73 albertel 2171: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 2172:
2173: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2174: $part{$tempkeyp}="0";
2175: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1.433 raeburn 2176: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2177: if ($allparms{$name{$tempkeyp}} ne '') {
2178: my $identifier;
2179: if ($parmdis =~ /(\s*\[Part.*)$/) {
2180: $identifier = $1;
2181: }
2182: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2183: } else {
2184: $display{$tempkeyp} = $parmdis;
2185: }
1.57 albertel 2186: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2187: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 2188: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 2189: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2190: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2191: }
2192: } # end loop through keys
2193: }
2194: } # end loop through ids
2195:
2196: #---------------------------------------------------- print header information
1.133 www 2197: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 2198: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 2199: my $tmp="";
1.57 albertel 2200: if ($uname) {
1.267 albertel 2201: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 2202: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
2203: &mt('in')." \n";
1.57 albertel 2204: } else {
1.401 bisitz 2205: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 2206: }
1.269 raeburn 2207: if ($cgroup) {
1.401 bisitz 2208: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
2209: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2210: $csec = '';
2211: } elsif ($csec) {
1.401 bisitz 2212: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
2213: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2214: }
1.401 bisitz 2215: $r->print('<div align="center"><h4>'
2216: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 2217: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 2218: ,$tmp
2219: ,'<font color="red"><i>'.$coursename.'</i></font>'
2220: )
2221: ."<br /></h4>\n"
1.422 bisitz 2222: );
1.57 albertel 2223: #---------------------------------------------------------------- print table
1.419 bisitz 2224: $r->print('<p>'.&Apache::loncommon::start_data_table()
2225: .&Apache::loncommon::start_data_table_header_row()
2226: .'<th>'.&mt('Parameter Name').'</th>'
2227: .'<th>'.&mt('Default Value').'</th>'
2228: .'<th>'.&mt('Parameter in Effect').'</th>'
2229: .&Apache::loncommon::end_data_table_header_row()
2230: );
1.57 albertel 2231:
1.210 www 2232: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2233: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2234: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2235: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2236: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2237: }
1.422 bisitz 2238: $r->print(&Apache::loncommon::end_data_table().'</p>'
2239: .'</div>'
2240: );
1.57 albertel 2241: } # end each map
2242: } # end of $parmlev eq map
2243: #--------------------------------- Entry for parm level general (Course level)
2244: if ($parmlev eq 'general') {
1.419 bisitz 2245: my $defbgone = '#E0E099';
2246: my $defbgtwo = '#FFFF99';
2247: my $defbgthree = '#FFBB99';
1.57 albertel 2248:
2249: #-------------------------------------------- for each map, gather information
2250: my $mapid="0.0";
2251: #----------------------- loop through ids and get all parameter types for map
2252: #----------------------------------------- and associated information
2253: my %name = ();
2254: my %part = ();
2255: my %display = ();
2256: my %type = ();
2257: my %default = ();
2258:
2259: foreach (@ids) {
2260: my $rid = $_;
2261:
1.196 www 2262: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2263:
2264: #--------------------------------------------------------------------
2265: # @catmarker contains list of all possible parameters including part #s
2266: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2267: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2268: # When storing information, store as part 0
2269: # When requesting information, request from full part
2270: #-------------------------------------------------------------------
1.210 www 2271: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2272: my $tempkeyp = $_;
2273: my $fullkeyp = $tempkeyp;
1.73 albertel 2274: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 2275: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2276: $part{$tempkeyp}="0";
2277: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1.433 raeburn 2278: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2279: if ($allparms{$name{$tempkeyp}} ne '') {
2280: my $identifier;
2281: if ($parmdis =~ /(\s*\[Part.*)$/) {
2282: $identifier = $1;
2283: }
2284: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2285: } else {
2286: $display{$tempkeyp} = $parmdis;
2287: }
1.57 albertel 2288: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2289: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 2290: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 2291: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2292: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2293: }
2294: } # end loop through keys
2295: } # end loop through ids
2296:
2297: #---------------------------------------------------- print header information
1.133 www 2298: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 2299: $r->print(<<ENDMAPONE);
1.419 bisitz 2300: <center>
2301: <h4>$setdef
1.135 albertel 2302: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 2303: ENDMAPONE
2304: if ($uname) {
1.267 albertel 2305: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2306: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2307: } else {
1.135 albertel 2308: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2309: }
2310:
1.135 albertel 2311: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2312: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2313: $r->print("</h4>\n");
1.57 albertel 2314: #---------------------------------------------------------------- print table
1.419 bisitz 2315: $r->print('<p>'.&Apache::loncommon::start_data_table()
2316: .&Apache::loncommon::start_data_table_header_row()
2317: .'<th>'.&mt('Parameter Name').'</th>'
2318: .'<th>'.&mt('Default Value').'</th>'
2319: .'<th>'.&mt('Parameter in Effect').'</th>'
2320: .&Apache::loncommon::end_data_table_header_row()
2321: );
1.57 albertel 2322:
1.210 www 2323: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2324: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2325: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2326: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2327: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2328: }
1.419 bisitz 2329: $r->print(&Apache::loncommon::end_data_table()
2330: .'</p>'
2331: .'</center>'
2332: );
1.57 albertel 2333: } # end of $parmlev eq general
1.43 albertel 2334: }
1.280 albertel 2335: $r->print('</form>'.&Apache::loncommon::end_page());
1.57 albertel 2336: } # end sub assessparms
1.30 www 2337:
1.59 matthew 2338:
2339:
1.30 www 2340: sub crsenv {
2341: my $r=shift;
2342: my $setoutput='';
1.280 albertel 2343:
1.414 droeschl 2344: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
2345: text=>"Course Environment"});
1.298 albertel 2346: my $breadcrumbs =
2347: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
1.190 albertel 2348: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2349: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 2350:
1.392 raeburn 2351: my (%crsinfo,$chome);
1.436 raeburn 2352: my $crstype = &Apache::loncommon::course_type();
1.392 raeburn 2353:
1.105 matthew 2354: #
2355: # Go through list of changes
1.190 albertel 2356: foreach (keys %env) {
1.105 matthew 2357: next if ($_!~/^form\.(.+)\_setparmval$/);
2358: my $name = $1;
1.190 albertel 2359: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 2360: if ($name eq 'newp') {
1.190 albertel 2361: $name = $env{'form.newp_name'};
1.105 matthew 2362: }
1.436 raeburn 2363: if ($name =~ /^rolenames_([^_]+)$/) {
2364: $name = $1.'.plaintext';
2365: my $standardtitle =
2366: &Apache::lonnet::plaintext($1,$crstype,$env{'request.course.id'},1);
2367: my %adv_roles =
2368: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2369: if ($value ne '') {
2370: foreach my $role (keys(%adv_roles)) {
2371: if ($role =~ m{^cr/$match_domain/$match_name/\Q$value\E$}) {
2372: $setoutput.= '<span class="LC_error">'.
2373: &mt('Requested replacement title for [_1] role is already used as the name of a custom role ([_2]).',$standardtitle,$value).
2374: '</span><br />';
2375: undef($value);
2376: }
2377: }
2378: }
2379: }
1.105 matthew 2380: if ($name eq 'url') {
2381: $value=~s/^\/res\///;
2382: my $bkuptime=time;
2383: my @tmp = &Apache::lonnet::get
2384: ('environment',['url'],$dom,$crs);
1.130 www 2385: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2386: &Apache::lonnet::put
2387: ('environment',
2388: {'top level map backup '.$bkuptime => $tmp[1] },
2389: $dom,$crs).
1.336 albertel 2390: '<br />';
1.105 matthew 2391: }
2392: #
2393: # Deal with modified default spreadsheets
2394: if ($name =~ /^spreadsheet_default_(classcalc|
2395: studentcalc|
2396: assesscalc)$/x) {
2397: my $sheettype = $1;
2398: if ($sheettype eq 'classcalc') {
2399: # no need to do anything since viewing the sheet will
2400: # cause it to be updated.
2401: } elsif ($sheettype eq 'studentcalc') {
2402: # expire all the student spreadsheets
2403: &Apache::lonnet::expirespread('','','studentcalc');
2404: } else {
2405: # expire all the assessment spreadsheets
2406: # this includes non-default spreadsheets, but better to
2407: # be safe than sorry.
2408: &Apache::lonnet::expirespread('','','assesscalc');
2409: # expire all the student spreadsheets
2410: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2411: }
1.105 matthew 2412: }
2413: #
1.107 matthew 2414: # Deal with the enrollment dates
2415: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2416: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2417: }
1.364 albertel 2418: #
2419: # Deal with the emails
2420: if ($name =~ /\.email$/) {
1.371 albertel 2421: foreach my $specifier (split(',',$value)) {
2422: my ($user,$sections_or_groups)=
2423: ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
2424: if (!$sections_or_groups) {
2425: $user = $specifier;
2426: }
2427: my ($name,$domain) = split(':',$user);
2428: if (!defined($user) || !defined($domain)) {
2429: $setoutput.= '<br /> <span class="LC_error">'.
1.425 schafran 2430: &mt("Invalid e-mail address specified, address must be of the form username:domain what was specified was ([_1])",$user).
1.371 albertel 2431: '</span>';
2432: undef($value);
2433: } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
2434: $setoutput.= '<br /> <span class="LC_error">'.
1.425 schafran 2435: &mt("Invalid e-mail address specified, user [_1] is unknown.",$name).
1.371 albertel 2436: '</span>';
2437: undef($value);
2438: }
1.364 albertel 2439: }
2440: }
1.178 raeburn 2441: # Get existing cloners
2442: my @oldcloner = ();
2443: if ($name eq 'cloners') {
2444: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2445: if ($clonenames{'cloners'} =~ /,/) {
2446: @oldcloner = split/,/,$clonenames{'cloners'};
2447: } else {
2448: $oldcloner[0] = $clonenames{'cloners'};
2449: }
2450: }
1.107 matthew 2451: #
1.105 matthew 2452: # Let the user know we made the changes
1.153 albertel 2453: if ($name && defined($value)) {
1.379 raeburn 2454: my %failed_cloners;
1.178 raeburn 2455: if ($name eq 'cloners') {
1.239 raeburn 2456: $value =~ s/\s//g;
1.178 raeburn 2457: $value =~ s/^,//;
2458: $value =~ s/,$//;
1.239 raeburn 2459: # check requested clones are valid users.
1.379 raeburn 2460: %failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2461: }
1.105 matthew 2462: my $put_result = &Apache::lonnet::put('environment',
2463: {$name=>$value},$dom,$crs);
2464: if ($put_result eq 'ok') {
1.392 raeburn 2465: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
2466: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2467: $setoutput .= &Apache::lonlocal::locallocaltime($value);
1.406 raeburn 2468: } elsif ($name eq 'categories') {
2469: $setoutput .= $env{'form.categories_display'};
1.392 raeburn 2470: } else {
2471: $setoutput .= $value;
2472: }
2473: $setoutput .= '</b>.<br />';
1.178 raeburn 2474: if ($name eq 'cloners') {
2475: &change_clone($value,\@oldcloner);
2476: }
1.382 raeburn 2477: # Update environment and nohist_courseids.db
1.402 raeburn 2478: if (($name eq 'description') || ($name eq 'cloners') ||
1.403 raeburn 2479: ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.392 raeburn 2480: if ($chome eq '') {
2481: %crsinfo =
2482: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
1.403 raeburn 2483: $crs,undef,undef,'.');
1.392 raeburn 2484: $chome = &Apache::lonnet::homeserver($crs,$dom);
2485: }
2486: }
1.179 raeburn 2487: if ($name eq 'description' && defined($value)) {
1.393 raeburn 2488: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
1.382 raeburn 2489: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2490: $crsinfo{$env{'request.course.id'}}{'description'} = $value;
1.392 raeburn 2491: my $putresult =
2492: &Apache::lonnet::courseidput($dom,\%crsinfo,
2493: $chome,'notime');
2494: }
2495: }
1.403 raeburn 2496: if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.402 raeburn 2497: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1.403 raeburn 2498: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
2499: $crsinfo{$env{'request.course.id'}}{$name} = $value;
1.402 raeburn 2500: my $putresult =
2501: &Apache::lonnet::courseidput($dom,\%crsinfo,
2502: $chome,'notime');
2503: }
2504: }
1.105 matthew 2505: } else {
1.130 www 2506: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2507: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2508: }
1.379 raeburn 2509: if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
2510: $setoutput.= &mt('Unable to include').': ';
2511: my @fails;
2512: my $num = 0;
2513: if (defined($failed_cloners{'format'})) {
2514: $fails[$num] .= '<b>'.$failed_cloners{'format'}.
2515: '</b>, '.&mt('reason').' - '.
2516: &mt('Invalid format');
2517: $num ++;
2518: }
2519: if (defined($failed_cloners{'domain'})) {
2520: $fails[$num] .= '<b>'.$failed_cloners{'domain'}.
2521: '</b>, '.&mt('reason').' - '.
2522: &mt('Domain does not exist');
2523: $num ++;
2524: }
2525: if (defined($failed_cloners{'newuser'})) {
2526: $fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</b>, '.&mt('reason').' - '.
2527: &mt('LON-CAPA user(s) do(es) not exist.').
2528: '.<br />'.&mt('Please ').
2529: ' <a href="/adm/createuser">'.
2530: &mt('add the user(s)').'</a>, '.
2531: &mt('and then return to the ').
2532: '<a href="/adm/parmset?action=crsenv">'.
2533: &mt('Course Parameters page').'</a> '.
2534: &mt('to add the new user(s) to the list of possible cloners');
2535: }
2536: $setoutput .= join('; ',@fails).'.<br />';
1.239 raeburn 2537: }
1.30 www 2538: }
1.38 harris41 2539: }
1.315 albertel 2540:
1.108 www 2541: # ------------------------- Re-init course environment entries for this session
2542:
1.302 albertel 2543: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2544: {'freshen_cache' => 1});
1.105 matthew 2545:
1.30 www 2546: # -------------------------------------------------------- Get parameters again
1.45 matthew 2547:
2548: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2549: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2550: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2551: my $output='';
1.439 bisitz 2552: my $output_SB = ''; # will be replaced by "$output" when all changes are done
1.403 raeburn 2553: my $can_categorize;
1.439 bisitz 2554: my %lt=&Apache::lonlocal::texthash(
2555: 'par' => 'Parameter',
2556: 'val' => 'Value',
2557: 'set' => 'Set?',
2558: 'sav' => 'Save',
2559: );
1.45 matthew 2560: if (! exists($values{'con_lost'})) {
1.30 www 2561: my %descriptions=
1.395 bisitz 2562: ('url' => '<b>'.&mt('Top Level Map').'</b><br />'.
1.46 matthew 2563: '<a href="javascript:openbrowser'.
1.47 matthew 2564: "('envform','url','sequence')\">".
1.314 albertel 2565: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1.395 bisitz 2566: &mt('Modification may make assessment data inaccessible!').
1.314 albertel 2567: '</span>',
1.440 bisitz 2568: 'description' => '<b>'.&mt('Course Title').'</b>',
1.158 sakharuk 2569: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2570: '</b><br />'.
1.395 bisitz 2571: '('.&mt('internal, optional').')',
2572: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br />'
2573: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'
2574: .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'
2575: .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'
2576: .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),
1.150 www 2577: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1.395 bisitz 2578: &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),
2579: 'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'
2580: .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'
2581: .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',
2582: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.
1.52 www 2583: '<a href="javascript:openbrowser'.
2584: "('envform','default_xml_style'".
1.336 albertel 2585: ",'sty')\">$SelectStyleFile</a><br />",
1.395 bisitz 2586: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'
2587: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2588: 'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',
2589: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'
2590: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2591: 'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',
2592: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'
2593: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2594: 'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',
2595: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'
2596: .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',
2597: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'
2598: .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '
2599: .&mt('Changes will not show until next login.').')',
2600: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'
2601: .'('.&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>"').')',
2602: 'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'
1.420 bisitz 2603: .'('.&mt("[_1] for link to each a listing of each student's files.",'"<tt>yes</tt>"').')',
1.395 bisitz 2604: 'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'
2605: .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',
1.435 hauer 2606: 'plc.roles.denied'=> '<b>'.&mt('Disallow chat room use for Roles').'</b><br />'
1.395 bisitz 2607: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2608: .'("<tt>'.&mt('role,role,...').'</tt>") '
2609: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.118 matthew 2610: 'plc.users.denied' =>
1.435 hauer 2611: '<b>'.&mt('Disallow chat room use for Users').'</b><br />'.
1.395 bisitz 2612: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.118 matthew 2613:
1.395 bisitz 2614: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'
2615: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')
2616: .'("<tt>'.&mt('role,role,...').'</tt>") '
2617: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2618: 'pch.users.denied' =>
1.141 sakharuk 2619: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.395 bisitz 2620: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.49 matthew 2621: 'spreadsheet_default_classcalc'
1.141 sakharuk 2622: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2623: '<a href="javascript:openbrowser'.
2624: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2625: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2626: 'spreadsheet_default_studentcalc'
1.395 bisitz 2627: => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.
1.50 matthew 2628: '<a href="javascript:openbrowser'.
2629: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2630: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2631: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2632: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2633: '<a href="javascript:openbrowser'.
2634: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2635: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2636: 'allow_limited_html_in_feedback'
1.141 sakharuk 2637: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.395 bisitz 2638: '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',
1.170 raeburn 2639: 'allow_discussion_post_editing'
1.395 bisitz 2640: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'
2641: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2642: .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'
2643: .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'
2644: .'('.&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 2645: 'rndseed'
1.395 bisitz 2646: => '<b>'.&mt('Randomization algorithm used').'</b><br />'
2647: .'<span class="LC_error">'
2648: .&mt('Modifying this will make problems have different numbers and answers!')
2649: .'</span>',
1.151 albertel 2650: 'receiptalg'
2651: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2652: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2653: 'suppress_tries'
1.272 albertel 2654: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.395 bisitz 2655: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.113 sakharuk 2656: 'problem_stream_switch'
1.141 sakharuk 2657: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.395 bisitz 2658: ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',
1.161 sakharuk 2659: 'default_paper_size'
2660: => '<b>'.&mt('Default paper type').'</b><br />'.
2661: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2662: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2663: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.319 foxr 2664: 'print_header_format'
1.395 bisitz 2665: => ' <b>'.&mt('Print header format').'</b><br />'
2666: .&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 2667: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2668: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.395 bisitz 2669: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'
2670: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',
1.140 sakharuk 2671: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2672: 'disable_receipt_display'
1.141 sakharuk 2673: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2674: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.313 albertel 2675: 'task_messages'
1.395 bisitz 2676: => '<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 2677: 'disablesigfigs'
2678: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2679: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2680: 'disableexampointprint'
2681: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2682: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2683: 'externalsyllabus'
1.279 www 2684: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2685: 'tthoptions'
1.434 biermanm 2686: => '<b>'.&mt('Default set of options to pass to tth/m when converting TeX').'</b>',
1.367 albertel 2687:
2688: 'texengine'
1.395 bisitz 2689: => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'
1.420 bisitz 2690: .'('.&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 2691: 'timezone'
1.400 raeburn 2692: => '<b>'.&mt('Timezone in which the course takes place').'</b>',
1.392 raeburn 2693:
1.400 raeburn 2694: 'suppress_embed_prompt'
2695: => '<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 2696: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.403 raeburn 2697: 'hidefromcat'
1.402 raeburn 2698: => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
2699: ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',
1.403 raeburn 2700: 'categories'
2701: => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
2702: &mt('Display Categories').'</a>',
1.409 raeburn 2703: 'datelocale'
2704: => '<b>'.&mt('Locale used for course calendar').'</b>',
1.436 raeburn 2705: 'rolenames'
2706: => '<b>'.&mt('Replacement titles for standard course roles').'</b><br />'.
2707: '('.&mt('To replace the standard title for a course role, enter the title you wish to use, otherwise leave blank.').')',
1.402 raeburn 2708: );
1.439 bisitz 2709:
2710:
2711: # ----------------------------------------------------------------
2712: # Begin: New Version with Parameter Categories
2713:
2714: sub parameter_row {
1.441 bisitz 2715: # Create parameter row for course environment screen
2716:
1.439 bisitz 2717: my ($parameter, $description) = @_;
2718:
1.441 bisitz 2719: # Start Parameter Row
2720: my $output = &Apache::loncommon::start_data_table_row();
2721:
2722: # Column 1/3: Descriptive text of current parameter
2723: $output .= '<td>'.$description.'</td>';
1.439 bisitz 2724:
2725: # Column 2/3: Input field (Sometimes special field(s), depending on parameter)
1.441 bisitz 2726:
1.439 bisitz 2727: # onchange is javascript to automatically check the 'Set' button.
2728: my $onchange = 'onFocus="javascript:window.document.forms'
2729: ."['envform'].elements['".$parameter."_setparmval']"
2730: .'.checked=true;"';
1.107 matthew 2731: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2732: $output .= '<td>'.
2733: &Apache::lonhtmlcommon::date_setter('envform',
2734: $parameter.'_value',
2735: $values{$parameter},
2736: $onchange).
2737: '</td>';
1.398 www 2738: } elsif ($parameter eq 'timezone') {
1.399 raeburn 2739: my $includeempty = 1;
2740: my $timezone = &Apache::lonlocal::gettimezone();
1.398 www 2741: $output .= '<td>'.
2742: &Apache::loncommon::select_timezone($parameter.'_value',
1.399 raeburn 2743: $timezone,
2744: $onchange,$includeempty).'</td>';
1.409 raeburn 2745: } elsif ($parameter eq 'datelocale') {
2746: my $includeempty = 1;
2747: my $locale_obj = &Apache::lonlocal::getdatelocale();
2748: my $currdatelocale;
2749: if (ref($locale_obj)) {
2750: $currdatelocale = $locale_obj->id();
2751: }
2752: $output .= '<td>'.
2753: &Apache::loncommon::select_datelocale($parameter.'_value',
2754: $currdatelocale,
1.436 raeburn 2755: $onchange,$includeempty).'</td>';
2756: } elsif ($parameter eq 'rolenames') {
2757: $output.= '<td><table>';
2758: foreach my $role ('cc','in','ta','ep','ad','st') {
2759: my $onchange = 'onFocus="javascript:window.document.forms'.
2760: "['envform'].elements['".
2761: $parameter.'_'.$role."_setparmval']".
2762: '.checked=true;"';
2763: $output.= '<tr><td>'.&Apache::lonnet::plaintext($role,$crstype,undef,1).
2764: '</td><td>'.
2765: &Apache::lonhtmlcommon::textbox($parameter.'_'.$role.'_value',
2766: $values{$role.'.plaintext'},
2767: 15,$onchange).
2768: '</td></tr>';
2769: }
2770: $output .= '</table></td><td><table>';
2771: foreach my $role ('cc','in','ta','ep','ad','st') {
2772: $output .= '<tr><td>'.&Apache::lonhtmlcommon::checkbox($parameter.'_'.$role.'_setparmval').
2773: '</td></tr>';
2774: }
2775: $output .= '</table></td>';
1.406 raeburn 2776: } elsif ($parameter eq 'categories') {
2777: my $catdisplay;
2778: if ($values{'categories'} ne '') {
2779: my @curritems = split(/\&/,$values{'categories'});
2780: foreach my $item (@curritems) {
2781: my ($name,$parent,$pos) = split(/:/,$item);
2782: $catdisplay .= &unescape($name).'&';
2783: }
2784: $catdisplay =~ s/\&$//;
2785: }
2786: $output .= '<td>'.
2787: '<input type="hidden" name="categories_value" value="'.
2788: $values{'categories'}.'" />'.
2789: '<input type="textbox" name="categories_display" value="'.
2790: $catdisplay.'" readonly="readonly" size="40" /></td>';
1.439 bisitz 2791: } else { # Display default textbox in all other cases
2792: $output .= '<td>'
2793: .&Apache::lonhtmlcommon::textbox($parameter.'_value',
2794: $values{$parameter},
2795: 40,
2796: $onchange)
2797: .'</td>';
1.107 matthew 2798: }
1.439 bisitz 2799:
2800: # Column 3/3: Check Box (in most cases)
2801: unless ($parameter eq 'rolenames') {
2802: $output .= '<td>'
2803: .&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval')
2804: .'</td>';
2805: }
1.441 bisitz 2806:
2807: # End Parameter Row
1.439 bisitz 2808: $output .= &Apache::loncommon::end_data_table_row();
2809:
2810: return $output;
1.441 bisitz 2811: } # End sub parameter_row
1.439 bisitz 2812:
2813:
2814: # Parameter Category Names
2815: my %parm_cat_names = &Apache::lonlocal::texthash (
2816: 'cat_0' => 'Parameter Category Zero',
2817: 'cat_1' => 'Parameter Category One',
2818: 'cat_2' => 'Parameter Category Two',
2819: 'cat_3' => 'Parameter Category Three',
2820: 'cat_4' => 'Parameter Category Four',
2821: 'cat_5' => 'Parameter Category Five',
2822: 'cat_6' => 'Parameter Category Six',
2823: 'cat_7' => 'Parameter Category Seven',
2824: 'cat_can' => 'Parameter Category Can',
2825: 'cat_custom' => 'Parameter Category Custom',
2826: );
2827:
1.441 bisitz 2828: # Display Order of Parameter Categories
2829: my @Display_Order = (
2830: 'cat_0',
2831: 'cat_1',
2832: 'cat_2',
2833: 'cat_3',
2834: 'cat_4',
2835: 'cat_5',
2836: 'cat_6',
2837: 'cat_7',
2838: 'cat_can',
2839: 'cat_custom',
2840: );
2841:
1.439 bisitz 2842: # Link Parameter Categories with Parameters
1.441 bisitz 2843: # Order of parameters is display order
1.439 bisitz 2844: my %parm_cat_parms = (
2845: 'cat_0' => [
2846: 'url',
2847: 'description',
2848: 'courseid',
2849: 'cloners'
2850: ],
2851: 'cat_1' => [
2852: 'grading',
2853: 'externalsyllabus',
2854: 'default_xml_style',
2855: 'pageseparators'
2856: ],
2857: 'cat_2' => [
2858: 'question.email',
2859: 'question.email.text',
2860: 'comment.email',
2861: 'comment.email.text',
2862: 'policy.email',
2863: 'policy.email.text',
2864: ],
2865: 'cat_3' => [
2866: 'student_classlist_view',
2867: 'student_classlist_opt_in',
2868: 'student_classlist_portfiles',
2869: 'plc.roles.denied',
2870: 'plc.users.denied',
2871: 'pch.roles.denied',
2872: 'pch.users.denied',
2873: 'allow_limited_html_in_feedback',
2874: 'allow_discussion_post_editing',
2875: ],
2876: 'cat_4' => [
2877: 'languages',
2878: 'timezone',
2879: 'datelocale',
2880: 'rolenames',
2881: 'nothideprivileged',
2882: 'rndseed',
2883: 'receiptalg',
2884: 'problem_stream_switch',
2885: 'suppress_tries',
2886: 'suppress_embed_prompt',
2887: 'default_paper_size',
2888: 'print_header_format',
2889: 'disable_receipt_display',
2890: ],
2891: 'cat_5' => [
2892: 'spreadsheet_default_classcalc',
2893: 'spreadsheet_default_studentcalc',
2894: 'spreadsheet_default_assesscalc',
2895: 'hideemptyrows',
2896: ],
2897: 'cat_6' => [
2898: 'default_enrollment_start_date',
2899: 'default_enrollment_end_date',
2900: ],
2901: 'cat_7' => [
2902: 'tthoptions',
2903: 'texengine',
2904: 'disablesigfigs',
2905: 'disableexampointprint',
2906: 'task_messages',
2907: 'task_grading',
2908: ],
2909: );
2910:
2911: # Add special parameters depending on special context to parameter categories hash
2912: my @can_cats;
2913: (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
2914: if ($can_toggle_cat) {
2915: push(@can_cats,'hidefromcat');
2916: }
2917: if ($can_categorize) {
2918: push(@can_cats,'categories');
2919: }
2920: $parm_cat_parms{'cat_can'} = [@can_cats];
2921:
1.441 bisitz 2922: # Add custom parameters to custom parameter category
1.439 bisitz 2923: my @custom_cats;
2924: foreach my $parameter (sort(keys(%values))) {
2925: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2926: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2927: || ($parameter eq 'type') ||
2928: ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
2929: if (! $descriptions{$parameter}) {
2930: $descriptions{$parameter}=$parameter;
2931: push(@custom_cats,$parameter);
2932: }
2933: }
2934: }
2935: $parm_cat_parms{'cat_custom'} = [@custom_cats];
2936:
2937:
1.441 bisitz 2938: # Display Course Parameter Overview
1.439 bisitz 2939: # Provide hyperlinks to detailed parameter settings
2940: $output_SB .= '<a name="parmlist" />'
1.441 bisitz 2941: .'<div class="LC_ContentBoxSpecial">'
2942: .'<h2 class="LC_hcell">'.&mt('Course Parameter Overview').'</h2>'
1.439 bisitz 2943: .'<ul>';
1.441 bisitz 2944: foreach my $catkey (@Display_Order) {
2945: if (!@{$parm_cat_parms{$catkey}}) { next; } # Only display non-empty categories
1.439 bisitz 2946: $output_SB .= '<li>'
2947: .'<a href="#parmlist_'.$catkey.'">'
2948: .$parm_cat_names{$catkey}
2949: .'</a>'
2950: .'</li>';
2951: }
2952: $output_SB .= '</ul>'
2953: .'</div>';
2954:
2955:
2956: my $buttons='<div align="right">'
2957: .'<input type="submit" name="crsenv" value="'.&mt('Save All').'" />'
1.441 bisitz 2958: .'<br /><a href="#parmlist">'.&mt('Back to Course Parameter Overview').'</a>'
1.439 bisitz 2959: .'</div>';
2960:
1.441 bisitz 2961: # Display all Parameters grouped by categories
1.439 bisitz 2962: $output_SB .= '<h2>'.&mt('Course Parameters').'</h2>';
2963:
1.441 bisitz 2964: foreach my $catkey (@Display_Order) {
2965: if (!@{$parm_cat_parms{$catkey}}) { next; } # Only display non-empty categories
1.439 bisitz 2966: $output_SB .= &Apache::loncommon::start_data_table();
2967: $output_SB .= &Apache::loncommon::start_data_table_empty_row()
2968: .'<td colspan="3">'
2969: .'<a name="parmlist_'.$catkey.'" />'
2970: .'<h3>'.$parm_cat_names{$catkey}.'</h3>'
2971: .'</td>'
2972: .&Apache::loncommon::end_data_table_empty_row
2973: .&Apache::loncommon::start_data_table_header_row()
2974: .'<th>'.$lt{'par'}.'</th><th>'.$lt{'val'}.'</th><th>'.$lt{'set'}.'</th>'
2975: .&Apache::loncommon::end_data_table_header_row();
2976:
2977: foreach my $parameter (@{$parm_cat_parms{$catkey}}) {
2978: my $description = $descriptions{$parameter};
2979: $output_SB .= ¶meter_row($parameter, $description);
2980: }
1.441 bisitz 2981: # Add special row to custom category
2982: # Offer possibilty to create a new environment variable
2983: if ($catkey eq 'cat_custom') {
2984: my $onchange = 'onFocus="javascript:window.document.forms'
2985: .'[\'envform\'].elements[\'newp_setparmval\']'
2986: .'.checked=true;"';
2987: $output_SB .= &Apache::loncommon::start_data_table_row()
2988: .'<td>'
2989: .'<i>'.&mt('Create New Environment Variable').'</i><br />'
2990: .'<input type="text" size="40" name="newp_name" '.$onchange.' />'
2991: .'</td><td>'
2992: .'<input type="text" size="40" name="newp_value" '.$onchange.' />'
2993: .'</td><td>'
2994: .'<input type="checkbox" name="newp_setparmval" /></td>'
2995: .&Apache::loncommon::end_data_table_row();
2996: }
2997: # Add buttons row at end of each category
1.439 bisitz 2998: $output_SB .= &Apache::loncommon::start_data_table_empty_row()
2999: .'<td colspan="3">'
3000: .$buttons
3001: .'</td>'
3002: .&Apache::loncommon::end_data_table_empty_row;
1.441 bisitz 3003:
1.439 bisitz 3004: $output_SB .= &Apache::loncommon::end_data_table()
3005: . '<br />';
3006: }
3007:
3008: # End: New Version with Parameter Categories
3009: # ----------------------------------------------------------------
3010:
3011:
1.441 bisitz 3012: }
3013:
1.403 raeburn 3014: my ($jscript,$categorize_js);
3015: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
3016: if ($can_categorize) {
3017: $categorize_js = <<ENDSCRIPT;
3018: function catsbrowser() {
3019: var catswin = null;
3020: var url = '/adm/parmset?action=categorizecourse';
3021: if (!catswin || catswin.closed) {
3022: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3023: } else {
3024: catswin.focus();
3025: }
3026: }
3027: ENDSCRIPT
3028: }
3029: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
3030: $browse_js."\n".$categorize_js."\n".'</script>';
1.280 albertel 3031: my $start_page =
1.323 albertel 3032: &Apache::loncommon::start_page('Set Course Environment',
1.403 raeburn 3033: $jscript);
1.280 albertel 3034: my $end_page =
3035: &Apache::loncommon::end_page();
3036: $r->print(<<ENDENV);
3037: $start_page
1.193 albertel 3038: $breadcrumbs
3039: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 3040: $setoutput
1.439 bisitz 3041: $output_SB
1.30 www 3042: </form>
1.280 albertel 3043: $end_page
3044: ENDENV
1.30 www 3045: }
1.402 raeburn 3046:
1.403 raeburn 3047: sub can_modify_catsettings {
1.402 raeburn 3048: my ($dom) = @_;
3049: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.403 raeburn 3050: my ($can_toggle_cat,$can_categorize);
1.402 raeburn 3051: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3052: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
3053: $can_toggle_cat = 1;
3054: }
1.403 raeburn 3055: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
3056: $can_categorize = 1;
3057: }
3058: }
3059: return ($can_toggle_cat,$can_categorize);
3060: }
3061:
3062: sub assign_course_categories {
3063: my ($r) = @_;
3064: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3065: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3066: my $hascats = 0;
3067: my $cathash;
3068: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
3069: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3070: $cathash = $domconf{'coursecategories'}{'cats'};
3071: if (ref($cathash) eq 'HASH') {
3072: $hascats = 1;
3073: }
1.402 raeburn 3074: }
1.403 raeburn 3075: my $catwin_js;
3076: if ($hascats) {
3077: my $alert = &mt('Use \"Save\" in the main window to save course categories');
3078: $catwin_js = <<ENDSCRIPT;
3079: <script type="text/javascript">
3080:
3081: function updateCategories() {
3082: var newcategories = '';
1.406 raeburn 3083: var unescapedcats = '';
1.403 raeburn 3084: if (document.chgcats.usecategory.length) {
3085: for (var i=0; i<document.chgcats.usecategory.length; i++) {
3086: if (document.chgcats.usecategory[i].checked == true) {
3087: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1.406 raeburn 3088: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1.403 raeburn 3089: }
3090: }
3091: if (newcategories.length > 0) {
3092: newcategories = newcategories.slice(0,-1);
3093: }
1.406 raeburn 3094: if (unescapedcats.length > 0) {
1.408 raeburn 3095: unescapedcats = unescapedcats.slice(0,-3);
1.406 raeburn 3096: }
1.403 raeburn 3097: } else {
3098: if (document.chgcats.usecategory.checked == true) {
3099: newcategories = document.chgcats.usecategory.value;
1.406 raeburn 3100: unescapedcats = document.chgcats.catname.value;
1.403 raeburn 3101: }
3102: }
3103: opener.document.envform.categories_value.value = newcategories;
1.406 raeburn 3104: opener.document.envform.categories_display.value = unescapedcats;
1.403 raeburn 3105: opener.document.envform.categories_setparmval.checked = true;
3106: alert("$alert");
3107: self.close();
3108: return;
3109: }
3110:
3111: </script>
3112: ENDSCRIPT
3113: } else {
3114: my $onload;
3115: }
3116: my $start_page =
3117: &Apache::loncommon::start_page('Course Categories',$catwin_js,
3118: {'only_body' => 1,});
3119: my $end_page = &Apache::loncommon::end_page();
3120: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
3121: if ($hascats) {
3122: my %currsettings =
3123: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
3124: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
3125: '<form name="chgcats" action="/adm/parmset" method="post">'."\n"
3126: .&Apache::loncommon::assign_categories_table($cathash,
3127: $currsettings{'categories'})."\n"
3128: .'<br /><input type="button" name="changes" value="'
3129: .&mt('Copy to main window').'" '
3130: .'onclick="javascript:updateCategories()" /></form><br />';
3131: } else {
3132: $categoriesform .= &mt('No categories defined for this domain');
3133: }
3134: $r->print($start_page.$categoriesform.$end_page);
3135: return;
1.402 raeburn 3136: }
3137:
1.120 www 3138: ##################################################
1.207 www 3139: # Overview mode
3140: ##################################################
1.124 www 3141: my $tableopen;
3142:
3143: sub tablestart {
3144: if ($tableopen) {
3145: return '';
3146: } else {
3147: $tableopen=1;
1.295 albertel 3148: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 3149: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 3150: }
3151: }
3152:
3153: sub tableend {
3154: if ($tableopen) {
3155: $tableopen=0;
1.295 albertel 3156: return &Apache::loncommon::end_data_table();
1.124 www 3157: } else {
3158: return'';
3159: }
3160: }
3161:
1.207 www 3162: sub readdata {
3163: my ($crs,$dom)=@_;
3164: # Read coursedata
3165: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
3166: # Read userdata
3167:
3168: my $classlist=&Apache::loncoursedata::get_classlist();
3169: foreach (keys %$classlist) {
1.350 albertel 3170: if ($_=~/^($match_username)\:($match_domain)$/) {
1.207 www 3171: my ($tuname,$tudom)=($1,$2);
3172: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
3173: foreach my $userkey (keys %{$useropt}) {
3174: if ($userkey=~/^$env{'request.course.id'}/) {
3175: my $newkey=$userkey;
3176: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
3177: $$resourcedata{$newkey}=$$useropt{$userkey};
3178: }
3179: }
3180: }
3181: }
3182: return $resourcedata;
3183: }
3184:
3185:
1.124 www 3186: # Setting
1.208 www 3187:
3188: sub storedata {
3189: my ($r,$crs,$dom)=@_;
1.207 www 3190: # Set userlevel immediately
3191: # Do an intermediate store of course level
3192: my $olddata=&readdata($crs,$dom);
1.124 www 3193: my %newdata=();
3194: undef %newdata;
3195: my @deldata=();
3196: undef @deldata;
1.190 albertel 3197: foreach (keys %env) {
1.124 www 3198: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
3199: my $cmd=$1;
3200: my $thiskey=$2;
1.207 www 3201: my ($tuname,$tudom)=&extractuser($thiskey);
3202: my $tkey=$thiskey;
3203: if ($tuname) {
3204: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
3205: }
1.385 albertel 3206: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.384 albertel 3207: my ($data, $typeof, $text);
3208: if ($cmd eq 'set') {
3209: $data=$env{$_};
3210: $typeof=$env{'form.typeof_'.$thiskey};
3211: $text = &mt('Saved modified parameter for');
3212: } elsif ($cmd eq 'datepointer') {
3213: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
3214: $typeof=$env{'form.typeof_'.$thiskey};
3215: $text = &mt('Saved modified date for');
1.385 albertel 3216: } elsif ($cmd eq 'dateinterval') {
3217: $data=&get_date_interval_from_form($thiskey);
3218: $typeof=$env{'form.typeof_'.$thiskey};
3219: $text = &mt('Saved modified date for');
1.384 albertel 3220: }
3221: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 3222: if ($tuname) {
1.212 www 3223: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
3224: $tkey.'.type' => $typeof},
3225: $tudom,$tuname) eq 'ok') {
1.290 www 3226: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.384 albertel 3227: $r->print('<br />'.$text.' '.
1.207 www 3228: &Apache::loncommon::plainname($tuname,$tudom));
3229: } else {
1.314 albertel 3230: $r->print('<div class="LC_error">'.
1.365 albertel 3231: &mt('Error saving parameters').'</div>');
1.207 www 3232: }
3233: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3234: } else {
3235: $newdata{$thiskey}=$data;
1.212 www 3236: $newdata{$thiskey.'.type'}=$typeof;
3237: }
1.207 www 3238: }
1.124 www 3239: } elsif ($cmd eq 'del') {
1.207 www 3240: if ($tuname) {
3241: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 3242: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 3243: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
3244: } else {
1.314 albertel 3245: $r->print('<div class="LC_error">'.
3246: &mt('Error deleting parameters').'</div>');
1.207 www 3247: }
3248: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
3249: } else {
1.333 albertel 3250: push (@deldata,$thiskey,$thiskey.'.type');
1.207 www 3251: }
1.124 www 3252: }
3253: }
3254: }
1.207 www 3255: # Store all course level
1.144 www 3256: my $delentries=$#deldata+1;
3257: my @newdatakeys=keys %newdata;
3258: my $putentries=$#newdatakeys+1;
3259: if ($delentries) {
3260: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 3261: my %loghash=map { $_ => '' } @deldata;
3262: &log_parmset(\%loghash,1);
1.144 www 3263: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
3264: } else {
1.314 albertel 3265: $r->print('<div class="LC_error">'.
3266: &mt('Error deleting parameters').'</div>');
1.144 www 3267: }
1.205 www 3268: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3269: }
3270: if ($putentries) {
3271: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 3272: &log_parmset(\%newdata,0);
1.365 albertel 3273: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 3274: } else {
1.314 albertel 3275: $r->print('<div class="LC_error">'.
1.365 albertel 3276: &mt('Error saving parameters').'</div>');
1.144 www 3277: }
1.205 www 3278: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 3279: }
1.208 www 3280: }
1.207 www 3281:
1.208 www 3282: sub extractuser {
3283: my $key=shift;
1.350 albertel 3284: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 3285: }
1.206 www 3286:
1.381 albertel 3287: sub parse_listdata_key {
3288: my ($key,$listdata) = @_;
3289: # split into student/section affected, and
3290: # the realm (folder/resource part and parameter
3291: my ($student,$realm) =
3292: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
3293: # if course wide student would be undefined
3294: if (!defined($student)) {
3295: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
3296: }
3297: # strip off the .type if it's not the Question type parameter
3298: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
3299: $realm=~s/\.type//;
3300: }
3301: # split into resource+part and parameter name
1.388 albertel 3302: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
3303: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 3304: return ($student,$res,$part,$parm);
3305: }
3306:
1.208 www 3307: sub listdata {
1.214 www 3308: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 3309: # Start list output
1.206 www 3310:
1.122 www 3311: my $oldsection='';
3312: my $oldrealm='';
3313: my $oldpart='';
1.123 www 3314: my $pointer=0;
1.124 www 3315: $tableopen=0;
1.145 www 3316: my $foundkeys=0;
1.248 albertel 3317: my %keyorder=&standardkeyorder();
1.381 albertel 3318:
1.214 www 3319: foreach my $thiskey (sort {
1.381 albertel 3320: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
3321: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
3322:
3323: # get the numerical order for the param
3324: $aparm=$keyorder{'parameter_0_'.$aparm};
3325: $bparm=$keyorder{'parameter_0_'.$bparm};
3326:
3327: my $result=0;
3328:
1.214 www 3329: if ($sortorder eq 'realmstudent') {
1.381 albertel 3330: if ($ares ne $bres ) {
3331: $result = ($ares cmp $bres);
3332: } elsif ($astudent ne $bstudent) {
3333: $result = ($astudent cmp $bstudent);
3334: } elsif ($apart ne $bpart ) {
3335: $result = ($apart cmp $bpart);
1.237 albertel 3336: }
1.381 albertel 3337: } else {
3338: if ($astudent ne $bstudent) {
3339: $result = ($astudent cmp $bstudent);
3340: } elsif ($ares ne $bres ) {
3341: $result = ($ares cmp $bres);
3342: } elsif ($apart ne $bpart ) {
3343: $result = ($apart cmp $bpart);
1.247 albertel 3344: }
1.381 albertel 3345: }
3346:
3347: if (!$result) {
3348: if (defined($aparm) && defined($bparm)) {
3349: $result = ($aparm <=> $bparm);
3350: } elsif (defined($aparm)) {
3351: $result = -1;
3352: } elsif (defined($bparm)) {
3353: $result = 1;
1.248 albertel 3354: }
1.214 www 3355: }
1.381 albertel 3356:
3357: $result;
1.214 www 3358: } keys %{$listdata}) {
1.381 albertel 3359:
1.211 www 3360: if ($$listdata{$thiskey.'.type'}) {
3361: my $thistype=$$listdata{$thiskey.'.type'};
3362: if ($$resourcedata{$thiskey.'.type'}) {
3363: $thistype=$$resourcedata{$thiskey.'.type'};
3364: }
1.207 www 3365: my ($middle,$part,$name)=
3366: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 3367: my $section=&mt('All Students');
1.207 www 3368: if ($middle=~/^\[(.*)\]/) {
1.206 www 3369: my $issection=$1;
1.350 albertel 3370: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
1.206 www 3371: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
3372: } else {
3373: $section=&mt('Group/Section').': '.$issection;
3374: }
1.207 www 3375: $middle=~s/^\[(.*)\]//;
1.122 www 3376: }
1.207 www 3377: $middle=~s/\.+$//;
3378: $middle=~s/^\.+//;
1.316 albertel 3379: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.122 www 3380: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 3381: $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 3382: } elsif ($middle) {
1.174 albertel 3383: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 3384: $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 3385: }
1.214 www 3386: if ($sortorder eq 'realmstudent') {
3387: if ($realm ne $oldrealm) {
3388: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3389: $oldrealm=$realm;
3390: $oldsection='';
3391: }
3392: if ($section ne $oldsection) {
3393: $r->print(&tableend()."\n<h2>$section</h2>");
3394: $oldsection=$section;
3395: $oldpart='';
3396: }
3397: } else {
3398: if ($section ne $oldsection) {
3399: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3400: $oldsection=$section;
3401: $oldrealm='';
3402: }
3403: if ($realm ne $oldrealm) {
3404: $r->print(&tableend()."\n<h2>$realm</h2>");
3405: $oldrealm=$realm;
3406: $oldpart='';
3407: }
1.122 www 3408: }
3409: if ($part ne $oldpart) {
1.124 www 3410: $r->print(&tableend().
1.422 bisitz 3411: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
1.122 www 3412: $oldpart=$part;
3413: }
1.123 www 3414: #
3415: # Ready to print
3416: #
1.295 albertel 3417: $r->print(&tablestart().
3418: &Apache::loncommon::start_data_table_row().
3419: '<td><b>'.&standard_parameter_names($name).
1.293 www 3420: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 3421: $thiskey.'" /></td><td>');
1.145 www 3422: $foundkeys++;
1.213 www 3423: if (&isdateparm($thistype)) {
1.123 www 3424: my $jskey='key_'.$pointer;
3425: $pointer++;
3426: $r->print(
1.232 albertel 3427: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 3428: $jskey,
1.219 www 3429: $$resourcedata{$thiskey},
1.325 www 3430: '',1,'','').
1.277 www 3431: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3432: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3433: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3434: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 3435: );
1.385 albertel 3436: } elsif ($thistype eq 'date_interval') {
3437: $r->print(&date_interval_selector($thiskey,
3438: $$resourcedata{$thiskey}));
1.383 albertel 3439: } elsif ($thistype =~ m/^string/) {
3440: $r->print(&string_selector($thistype,$thiskey,
3441: $$resourcedata{$thiskey}));
1.123 www 3442: } else {
1.383 albertel 3443: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 3444: }
1.211 www 3445: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
1.423 bisitz 3446: $thistype.'" />');
1.295 albertel 3447: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 3448: }
1.121 www 3449: }
1.208 www 3450: return $foundkeys;
3451: }
3452:
1.385 albertel 3453:
3454: sub date_interval_selector {
3455: my ($thiskey, $showval) = @_;
3456: my $result;
3457: foreach my $which (['days', 86400, 31],
3458: ['hours', 3600, 23],
3459: ['minutes', 60, 59],
3460: ['seconds', 1, 59]) {
3461: my ($name, $factor, $max) = @{ $which };
3462: my $amount = int($showval/$factor);
3463: $showval %= $factor;
3464: my %select = ((map {$_ => $_} (0..$max)),
3465: 'select_form_order' => [0..$max]);
3466: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
3467: %select);
3468: $result .= ' '.&mt($name);
3469: }
3470: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3471: return $result;
3472:
3473: }
3474:
3475: sub get_date_interval_from_form {
3476: my ($key) = @_;
3477: my $seconds = 0;
3478: foreach my $which (['days', 86400],
3479: ['hours', 3600],
3480: ['minutes', 60],
3481: ['seconds', 1]) {
3482: my ($name, $factor) = @{ $which };
3483: if (defined($env{'form.'.$name.'_'.$key})) {
3484: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3485: }
3486: }
3487: return $seconds;
3488: }
3489:
3490:
1.383 albertel 3491: sub default_selector {
3492: my ($thiskey, $showval) = @_;
1.385 albertel 3493: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3494: }
3495:
3496: my %strings =
3497: (
3498: 'string_yesno'
3499: => [[ 'yes', 'Yes' ],
3500: [ 'no', 'No' ]],
3501: 'string_problemstatus'
3502: => [[ 'yes', 'Yes' ],
1.394 www 3503: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3504: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3505: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3506: );
3507:
3508:
3509: sub string_selector {
3510: my ($thistype, $thiskey, $showval) = @_;
3511:
3512: if (!exists($strings{$thistype})) {
3513: return &default_selector($thiskey,$showval);
3514: }
3515:
3516: my $result;
3517: foreach my $possibilities (@{ $strings{$thistype} }) {
3518: my ($name, $description) = @{ $possibilities };
3519: $result .= '<label><input type="radio" name="set_'.$thiskey.
3520: '" value="'.$name.'"';
3521: if ($showval eq $name) {
3522: $result .= ' checked="checked"';
3523: }
3524: $result .= ' />'.&mt($description).'</label> ';
3525: }
3526: return $result;
3527: }
3528:
1.389 www 3529: #
3530: # Shift all start and end dates by $shift
3531: #
3532:
3533: sub dateshift {
3534: my ($shift)=@_;
3535: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3536: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3537: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3538: # ugly retro fix for broken version of types
3539: foreach my $key (keys %data) {
3540: if ($key=~/\wtype$/) {
3541: my $newkey=$key;
3542: $newkey=~s/type$/\.type/;
3543: $data{$newkey}=$data{$key};
3544: delete $data{$key};
3545: }
3546: }
1.391 www 3547: my %storecontent=();
1.389 www 3548: # go through all parameters and look for dates
3549: foreach my $key (keys %data) {
3550: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3551: my $newdate=$data{$key}+$shift;
1.391 www 3552: $storecontent{$key}=$newdate;
1.389 www 3553: }
3554: }
1.391 www 3555: my $reply=&Apache::lonnet::cput
3556: ('resourcedata',\%storecontent,$dom,$crs);
3557: if ($reply eq 'ok') {
3558: &log_parmset(\%storecontent);
3559: }
3560: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3561: return $reply;
1.389 www 3562: }
3563:
1.208 www 3564: sub newoverview {
1.280 albertel 3565: my ($r) = @_;
3566:
1.208 www 3567: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3568: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3569: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3570: text=>"Overview Mode"});
1.280 albertel 3571: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3572: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3573: $r->print(<<ENDOVER);
1.280 albertel 3574: $start_page
1.208 www 3575: $breadcrumbs
1.232 albertel 3576: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3577: ENDOVER
1.211 www 3578: my @ids=();
3579: my %typep=();
3580: my %keyp=();
3581: my %allparms=();
3582: my %allparts=();
3583: my %allmaps=();
3584: my %mapp=();
3585: my %symbp=();
3586: my %maptitles=();
3587: my %uris=();
3588: my %keyorder=&standardkeyorder();
3589: my %defkeytype=();
3590:
3591: my %alllevs=();
3592: $alllevs{'Resource Level'}='full';
1.215 www 3593: $alllevs{'Map/Folder Level'}='map';
1.211 www 3594: $alllevs{'Course Level'}='general';
3595:
3596: my $csec=$env{'form.csec'};
1.269 raeburn 3597: my $cgroup=$env{'form.cgroup'};
1.211 www 3598:
3599: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3600: my $pschp=$env{'form.pschp'};
3601: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3602: if (!@psprt) { $psprt[0]='0'; }
3603:
3604: my @selected_sections =
3605: &Apache::loncommon::get_env_multiple('form.Section');
3606: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3607: foreach my $sec (@selected_sections) {
3608: if ($sec eq 'all') {
1.211 www 3609: @selected_sections = ('all');
3610: }
3611: }
1.269 raeburn 3612: my @selected_groups =
3613: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3614:
3615: my $pssymb='';
3616: my $parmlev='';
3617:
3618: unless ($env{'form.parmlev'}) {
3619: $parmlev = 'map';
3620: } else {
3621: $parmlev = $env{'form.parmlev'};
3622: }
3623:
3624: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3625: \%mapp, \%symbp,\%maptitles,\%uris,
3626: \%keyorder,\%defkeytype);
3627:
1.374 albertel 3628: if (grep {$_ eq 'all'} (@psprt)) {
3629: @psprt = keys(%allparts);
3630: }
1.211 www 3631: # Menu to select levels, etc
3632:
1.317 albertel 3633: $r->print('<table id="LC_parm_overview_scope">
3634: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3635: &levelmenu($r,\%alllevs,$parmlev);
3636: if ($parmlev ne 'general') {
1.317 albertel 3637: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3638: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3639: $r->print('</td>');
3640: }
3641: $r->print('</td></tr></table>');
3642:
1.317 albertel 3643: $r->print('<table id="LC_parm_overview_controls">
3644: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3645: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3646: $r->print('</td><td class="LC_parm_overview_restrictions">
3647: <table class="LC_parm_overview_restrictions">'.
3648: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3649: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3650: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3651: $r->print('</td><td>');
1.211 www 3652: §ionmenu($r,\@selected_sections);
1.317 albertel 3653: $r->print('</td><td>');
1.269 raeburn 3654: &groupmenu($r,\@selected_groups);
3655: $r->print('</td></tr></table>');
1.214 www 3656: $r->print('</td></tr></table>');
3657:
3658: my $sortorder=$env{'form.sortorder'};
3659: unless ($sortorder) { $sortorder='realmstudent'; }
3660: &sortmenu($r,$sortorder);
3661:
3662: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3663:
3664: # Build the list data hash from the specified parms
3665:
3666: my $listdata;
3667: %{$listdata}=();
3668:
3669: foreach my $cat (@pscat) {
1.269 raeburn 3670: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3671: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3672: }
3673:
1.212 www 3674: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3675:
1.212 www 3676: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3677:
3678: # Read modified data
3679:
3680: my $resourcedata=&readdata($crs,$dom);
3681:
3682: # List data
3683:
1.214 www 3684: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3685: }
3686: $r->print(&tableend().
1.365 albertel 3687: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3688: '</form>'.&Apache::loncommon::end_page());
1.208 www 3689: }
3690:
1.269 raeburn 3691: sub secgroup_lister {
3692: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3693: foreach my $item (@{$selections}) {
3694: foreach my $part (@{$psprt}) {
3695: my $rootparmkey=$env{'request.course.id'};
3696: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3697: $rootparmkey.='.['.$item.']';
3698: }
3699: if ($parmlev eq 'general') {
3700: # course-level parameter
3701: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3702: $$listdata{$newparmkey}=1;
3703: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3704: } elsif ($parmlev eq 'map') {
3705: # map-level parameter
3706: foreach my $mapid (keys %{$allmaps}) {
3707: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3708: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3709: $$listdata{$newparmkey}=1;
3710: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3711: }
3712: } else {
3713: # resource-level parameter
3714: foreach my $rid (@{$ids}) {
3715: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3716: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3717: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3718: $$listdata{$newparmkey}=1;
3719: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3720: }
3721: }
3722: }
3723: }
3724: }
3725:
1.208 www 3726: sub overview {
1.280 albertel 3727: my ($r) = @_;
1.208 www 3728: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3729: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3730:
1.414 droeschl 3731: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3732: text=>"Overview Mode"});
1.280 albertel 3733: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3734: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3735: $r->print(<<ENDOVER);
1.280 albertel 3736: $start_page
1.208 www 3737: $breadcrumbs
1.232 albertel 3738: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3739: ENDOVER
3740: # Store modified
3741:
3742: &storedata($r,$crs,$dom);
3743:
3744: # Read modified data
3745:
3746: my $resourcedata=&readdata($crs,$dom);
3747:
1.214 www 3748:
3749: my $sortorder=$env{'form.sortorder'};
3750: unless ($sortorder) { $sortorder='realmstudent'; }
3751: &sortmenu($r,$sortorder);
3752:
1.208 www 3753: # List data
3754:
1.214 www 3755: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3756:
1.145 www 3757: $r->print(&tableend().'<p>'.
1.430 schafran 3758: ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':&mt('There are no parameters.')).'</p></form>'.
1.280 albertel 3759: &Apache::loncommon::end_page());
1.120 www 3760: }
1.121 www 3761:
1.333 albertel 3762: sub clean_parameters {
3763: my ($r) = @_;
3764: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3765: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3766:
1.414 droeschl 3767: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
3768: text=>"Clean Parameters"});
1.333 albertel 3769: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3770: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3771: $r->print(<<ENDOVER);
3772: $start_page
3773: $breadcrumbs
3774: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3775: ENDOVER
3776: # Store modified
3777:
3778: &storedata($r,$crs,$dom);
3779:
3780: # Read modified data
3781:
3782: my $resourcedata=&readdata($crs,$dom);
3783:
3784: # List data
3785:
3786: $r->print('<h3>'.
3787: &mt('These parameters refer to resources that do not exist.').
3788: '</h3>'.
1.415 schafran 3789: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
1.333 albertel 3790: '<br />');
3791: $r->print(&Apache::loncommon::start_data_table().
3792: '<tr>'.
3793: '<th>'.&mt('Delete').'</th>'.
3794: '<th>'.&mt('Parameter').'</th>'.
3795: '</tr>');
3796: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3797: next if (!exists($resourcedata->{$thiskey.'.type'})
3798: && $thiskey=~/\.type$/);
3799: my %data = &parse_key($thiskey);
1.383 albertel 3800: if (1) { #exists($data{'realm_exists'})
3801: #&& !$data{'realm_exists'}) {
1.333 albertel 3802: $r->print(&Apache::loncommon::start_data_table_row().
3803: '<tr>'.
3804: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3805:
3806: $r->print('<td>');
1.362 albertel 3807: my $display_value = $resourcedata->{$thiskey};
3808: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3809: $display_value =
3810: &Apache::lonlocal::locallocaltime($display_value);
3811: }
1.333 albertel 3812: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3813: &standard_parameter_names($data{'parameter_name'}),
3814: $resourcedata->{$thiskey}));
3815: $r->print('<br />');
3816: if ($data{'scope_type'} eq 'all') {
3817: $r->print(&mt('All users'));
3818: } elsif ($data{'scope_type'} eq 'user') {
3819: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3820: } elsif ($data{'scope_type'} eq 'section') {
3821: $r->print(&mt('Section: [_1]',$data{'scope'}));
3822: } elsif ($data{'scope_type'} eq 'group') {
3823: $r->print(&mt('Group: [_1]',$data{'scope'}));
3824: }
3825: $r->print('<br />');
3826: if ($data{'realm_type'} eq 'all') {
3827: $r->print(&mt('All Resources'));
3828: } elsif ($data{'realm_type'} eq 'folder') {
3829: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3830: } elsif ($data{'realm_type'} eq 'symb') {
3831: my ($map,$resid,$url) =
3832: &Apache::lonnet::decode_symb($data{'realm'});
3833: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3834: $url,$resid,$map));
3835: }
1.362 albertel 3836: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3837: $r->print('</td></tr>');
3838:
3839: }
3840: }
3841: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.415 schafran 3842: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.333 albertel 3843: '</p></form>'.
3844: &Apache::loncommon::end_page());
3845: }
3846:
1.390 www 3847: sub date_shift_one {
3848: my ($r) = @_;
3849: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3850: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3851:
1.414 droeschl 3852: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
3853: text=>"Shifting Dates"});
1.390 www 3854: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3855: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3856: $r->print(<<ENDOVER);
3857: $start_page
3858: $breadcrumbs
3859: ENDOVER
3860: $r->print('<form name="shiftform" method="post">'.
3861: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3862: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3863: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3864: &Apache::lonhtmlcommon::date_setter('shiftform',
3865: 'timeshifted',
3866: $env{'form.timebase'},,
3867: '').
3868: '</td></tr></table>'.
3869: '<input type="hidden" name="action" value="dateshift2" />'.
3870: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3871: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3872: $r->print(&Apache::loncommon::end_page());
3873: }
3874:
3875: sub date_shift_two {
3876: my ($r) = @_;
3877: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3878: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3879: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
3880: text=>"Shifting Dates"});
1.390 www 3881: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3882: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3883: $r->print(<<ENDOVER);
3884: $start_page
3885: $breadcrumbs
3886: ENDOVER
3887: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3888: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3889: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3890: &Apache::lonlocal::locallocaltime($timeshifted)));
3891: my $delta=$timeshifted-$env{'form.timebase'};
3892: &dateshift($delta);
3893: $r->print(&Apache::loncommon::end_page());
3894: }
3895:
1.333 albertel 3896: sub parse_key {
3897: my ($key) = @_;
3898: my %data;
3899: my ($middle,$part,$name)=
3900: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3901: $data{'scope_type'} = 'all';
3902: if ($middle=~/^\[(.*)\]/) {
3903: $data{'scope'} = $1;
1.350 albertel 3904: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3905: $data{'scope_type'} = 'user';
3906: $data{'scope'} = [$1,$2];
3907: } else {
3908: #FIXME check for group scope
3909: $data{'scope_type'} = 'section';
3910: }
3911: $middle=~s/^\[(.*)\]//;
3912: }
3913: $middle=~s/\.+$//;
3914: $middle=~s/^\.+//;
3915: $data{'realm_type'}='all';
3916: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3917: $data{'realm'} = $1;
3918: $data{'realm_type'} = 'folder';
3919: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3920: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3921: } elsif ($middle) {
3922: $data{'realm'} = $middle;
3923: $data{'realm_type'} = 'symb';
3924: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3925: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3926: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3927: }
3928:
3929: $data{'parameter_part'} = $part;
3930: $data{'parameter_name'} = $name;
3931:
3932: return %data;
3933: }
3934:
1.239 raeburn 3935:
1.178 raeburn 3936:
1.239 raeburn 3937: sub extract_cloners {
3938: my ($clonelist,$allowclone) = @_;
3939: if ($clonelist =~ /,/) {
1.380 albertel 3940: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3941: } else {
3942: $$allowclone[0] = $clonelist;
3943: }
3944: }
3945:
3946: sub check_cloners {
3947: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3948: my ($clean_clonelist,%disallowed);
1.239 raeburn 3949: my @allowclone = ();
3950: &extract_cloners($$clonelist,\@allowclone);
3951: foreach my $currclone (@allowclone) {
1.380 albertel 3952: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3953: if ($currclone eq '*') {
3954: $clean_clonelist .= $currclone.',';
3955: } else {
3956: my ($uname,$udom) = split(/:/,$currclone);
3957: if ($uname eq '*') {
3958: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3959: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3960: $disallowed{'domain'} .= $currclone.',';
3961: } else {
3962: $clean_clonelist .= $currclone.',';
3963: }
3964: } else {
3965: $disallowed{'format'} .= $currclone.',';
3966: }
3967: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3968: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3969: } else {
1.379 raeburn 3970: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3971: $disallowed{'newuser'} .= $currclone.',';
3972: } else {
3973: $clean_clonelist .= $currclone.',';
3974: }
1.239 raeburn 3975: }
3976: }
3977: } else {
3978: $clean_clonelist .= $currclone.',';
3979: }
3980: }
1.379 raeburn 3981: foreach my $key (keys(%disallowed)) {
3982: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3983: }
3984: if ($clean_clonelist) {
3985: $clean_clonelist =~ s/,$//;
3986: }
3987: $$clonelist = $clean_clonelist;
1.379 raeburn 3988: return %disallowed;
3989: }
1.178 raeburn 3990:
3991: sub change_clone {
3992: my ($clonelist,$oldcloner) = @_;
3993: my ($uname,$udom);
1.190 albertel 3994: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3995: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3996: my $clone_crs = $cnum.':'.$cdom;
3997:
3998: if ($cnum && $cdom) {
1.239 raeburn 3999: my @allowclone;
4000: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 4001: foreach my $currclone (@allowclone) {
1.380 albertel 4002: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 4003: if ($currclone ne '*') {
1.380 albertel 4004: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 4005: if ($uname && $udom && $uname ne '*') {
4006: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4007: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4008: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
4009: if ($currclonecrs{'cloneable'} eq '') {
4010: $currclonecrs{'cloneable'} = $clone_crs;
4011: } else {
4012: $currclonecrs{'cloneable'} .= ','.$clone_crs;
4013: }
4014: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 4015: }
4016: }
4017: }
4018: }
4019: }
4020: }
4021: foreach my $oldclone (@$oldcloner) {
1.380 albertel 4022: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 4023: if ($oldclone ne '*') {
1.380 albertel 4024: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 4025: if ($uname && $udom && $uname ne '*' ) {
4026: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4027: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4028: my %newclonecrs = ();
4029: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
4030: if ($currclonecrs{'cloneable'} =~ /,/) {
4031: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
4032: foreach my $crs (@currclonecrs) {
4033: if ($crs ne $clone_crs) {
4034: $newclonecrs{'cloneable'} .= $crs.',';
4035: }
1.178 raeburn 4036: }
1.379 raeburn 4037: $newclonecrs{'cloneable'} =~ s/,$//;
4038: } else {
4039: $newclonecrs{'cloneable'} = '';
1.178 raeburn 4040: }
1.379 raeburn 4041: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 4042: }
4043: }
4044: }
4045: }
4046: }
4047: }
4048: }
4049: }
4050:
1.193 albertel 4051:
4052:
1.416 jms 4053: sub header {
4054: return &Apache::loncommon::start_page('Parameter Manager');
4055: }
1.193 albertel 4056:
4057:
4058:
4059: sub print_main_menu {
4060: my ($r,$parm_permission)=@_;
4061: #
1.414 droeschl 4062: $r->print(&header());
4063: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 4064: $r->print(<<ENDMAINFORMHEAD);
4065: <form method="post" enctype="multipart/form-data"
4066: action="/adm/parmset" name="studentform">
4067: ENDMAINFORMHEAD
4068: #
1.195 albertel 4069: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4070: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 4071: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 4072: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 4073:
1.417 droeschl 4074:
1.193 albertel 4075: my @menu =
1.417 droeschl 4076: ( { categorytitle=>'Settings for this Course',
1.414 droeschl 4077: items => [
1.417 droeschl 4078: { linktext => 'Course Environment',
1.414 droeschl 4079: url => '/adm/parmset?action=crsenv',
4080: permission => $parm_permission,
1.417 droeschl 4081: linktitle =>'Edit environment settings for this course.' ,
4082: icon => 'preferences-desktop-remote-desktop.png' ,
4083: #help => 'Course_Environment',
1.414 droeschl 4084: },
1.417 droeschl 4085: { linktext => 'Portfolio Metadata',
1.414 droeschl 4086: url => '/adm/parmset?action=setrestrictmeta',
4087: permission => $parm_permission,
1.417 droeschl 4088: linktitle => 'Restrict metadata for this course.' ,
4089: icon =>'contact-new.png' ,
1.414 droeschl 4090: },
4091: { linktext => 'Manage Course Slots',
4092: url => '/adm/slotrequest?command=showslots',
4093: permission => $vgr,
1.417 droeschl 4094: linktitle =>'Manage slots for this course.' ,
4095: icon => 'format-justify-fill.png' ,
1.414 droeschl 4096: },
4097: { linktext => 'Reset Student Access Times',
4098: url => '/adm/helper/resettimes.helper',
4099: permission => $mgr,
1.417 droeschl 4100: linktitle =>'Reset access times for folders/maps, resources or the course.' ,
4101: icon => 'start-here.png' ,
1.414 droeschl 4102: },
4103:
4104: { linktext => 'Set Parameter Setting Default Actions',
4105: url => '/adm/parmset?action=setdefaults',
4106: permission => $parm_permission,
1.417 droeschl 4107: linktitle =>'Set default actions for parameters.' ,
4108: icon => 'folder-new.png' ,
1.414 droeschl 4109: }]},
1.417 droeschl 4110: { categorytitle => 'New and Existing Parameter Settings for Resources',
1.414 droeschl 4111: items => [
1.417 droeschl 4112: { linktext => 'Edit Resource Parameters - Helper Mode',
1.414 droeschl 4113: url => '/adm/helper/parameter.helper',
4114: permission => $parm_permission,
1.417 droeschl 4115: linktitle =>'Set/Modify resource parameters in helper mode.' ,
4116: icon => 'dialog-information.png' ,
4117: #help => 'Parameter_Helper',
1.414 droeschl 4118: },
1.417 droeschl 4119: { linktext => 'Edit Resource Parameters - Overview Mode',
1.414 droeschl 4120: url => '/adm/parmset?action=newoverview',
4121: permission => $parm_permission,
1.417 droeschl 4122: linktitle =>'Set/Modify resource parameters in overview mode.' ,
4123: icon => 'edit-find.png' ,
4124: #help => 'Parameter_Overview',
1.414 droeschl 4125: },
1.417 droeschl 4126: { linktext => 'Edit Resource Parameters - Table Mode',
1.414 droeschl 4127: url => '/adm/parmset?action=settable',
4128: permission => $parm_permission,
1.417 droeschl 4129: linktitle =>'Set/Modify resource parameters in table mode.' ,
4130: icon => 'edit-copy.png' ,
4131: #help => 'Table_Mode',
1.414 droeschl 4132: }]},
1.417 droeschl 4133: { categorytitle => 'Existing Parameter Settings for Resources',
1.414 droeschl 4134: items => [
4135: { linktext => 'Modify Resource Parameters - Overview Mode',
4136: url => '/adm/parmset?action=setoverview',
4137: permission => $parm_permission,
1.417 droeschl 4138: linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
4139: icon => 'preferences-desktop-wallpaper.png' ,
4140: #help => 'Parameter_Overview',
1.414 droeschl 4141: },
1.417 droeschl 4142: { linktext => 'Change Log',
1.414 droeschl 4143: url => '/adm/parmset?action=parameterchangelog',
4144: permission => $parm_permission,
1.417 droeschl 4145: linktitle =>'View parameter and course blog posting/user notification change log.' ,
4146: icon => 'emblem-system.png' ,
1.414 droeschl 4147: }]}
1.193 albertel 4148: );
1.414 droeschl 4149: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.193 albertel 4150: return;
4151: }
1.414 droeschl 4152:
1.416 jms 4153:
4154:
1.252 banghart 4155: sub output_row {
1.347 banghart 4156: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 4157: my $output;
1.263 banghart 4158: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
4159: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 4160: if (!defined($options)) {
1.254 banghart 4161: $options = 'active,stuadd';
1.261 banghart 4162: $values = '';
1.252 banghart 4163: }
1.337 banghart 4164: if (!($options =~ /deleted/)) {
4165: my @options= ( ['active', 'Show to student'],
1.418 schafran 4166: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 4167: ['choices','Provide choices for students to select from']);
4168: # ['onlyone','Student may select only one choice']);
1.337 banghart 4169: if ($added_flag) {
4170: push @options,['deleted', 'Delete Metadata Field'];
4171: }
1.351 banghart 4172: $output = &Apache::loncommon::start_data_table_row();
4173: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
4174: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 4175: foreach my $opt (@options) {
4176: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 4177: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 4178: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
4179: <input type="checkbox" name="'.
4180: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
4181: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 4182: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 4183: }
1.351 banghart 4184: $output .= &Apache::loncommon::continue_data_table_row();
4185: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
4186: $output .= &Apache::loncommon::end_data_table_row();
4187: my $multiple_checked;
4188: my $single_checked;
4189: if ($options =~ m/onlyone/) {
1.422 bisitz 4190: $multiple_checked = '';
1.423 bisitz 4191: $single_checked = ' checked="checked"';
1.351 banghart 4192: } else {
1.423 bisitz 4193: $multiple_checked = ' checked="checked"';
1.422 bisitz 4194: $single_checked = '';
1.351 banghart 4195: }
4196: $output .= &Apache::loncommon::continue_data_table_row();
4197: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.423 bisitz 4198: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
1.418 schafran 4199: '.&mt('Student may select multiple choices from list').'</span></td>';
1.351 banghart 4200: $output .= &Apache::loncommon::end_data_table_row();
4201: $output .= &Apache::loncommon::continue_data_table_row();
4202: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
1.423 bisitz 4203: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
1.418 schafran 4204: '.&mt('Student may select only one choice from list').'</span></td>';
1.351 banghart 4205: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 4206: }
4207: return ($output);
4208: }
1.416 jms 4209:
4210:
4211:
1.340 banghart 4212: sub order_meta_fields {
4213: my ($r)=@_;
4214: my $idx = 1;
4215: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4216: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 4217: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 4218: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4219: text=>"Add Metadata Field"});
1.345 banghart 4220: &Apache::lonhtmlcommon::add_breadcrumb
4221: ({href=>"/adm/parmset?action=setrestrictmeta",
4222: text=>"Restrict Metadata"},
4223: {text=>"Order Metadata"});
4224: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 4225: if ($env{'form.storeorder'}) {
4226: my $newpos = $env{'form.newpos'} - 1;
4227: my $currentpos = $env{'form.currentpos'} - 1;
4228: my @neworder = ();
4229: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
4230: my $i;
1.341 banghart 4231: if ($newpos > $currentpos) {
1.340 banghart 4232: # moving stuff up
4233: for ($i=0;$i<$currentpos;$i++) {
4234: $neworder[$i]=$oldorder[$i];
4235: }
4236: for ($i=$currentpos;$i<$newpos;$i++) {
4237: $neworder[$i]=$oldorder[$i+1];
4238: }
4239: $neworder[$newpos]=$oldorder[$currentpos];
4240: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
4241: $neworder[$i]=$oldorder[$i];
4242: }
4243: } else {
4244: # moving stuff down
4245: for ($i=0;$i<$newpos;$i++) {
4246: $neworder[$i]=$oldorder[$i];
4247: }
4248: $neworder[$newpos]=$oldorder[$currentpos];
4249: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
4250: $neworder[$i]=$oldorder[$i-1];
4251: }
4252: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
4253: $neworder[$i]=$oldorder[$i];
4254: }
4255: }
4256: my $ordered_fields = join ",", @neworder;
1.343 banghart 4257: my $put_result = &Apache::lonnet::put('environment',
4258: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 4259: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 4260: }
1.357 raeburn 4261: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 4262: my $ordered_fields;
1.340 banghart 4263: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
4264: if (!@fields_in_order) {
4265: # no order found, pick sorted order then create metadata.addedorder key.
4266: foreach my $key (sort keys %$fields) {
4267: push @fields_in_order, $key;
1.341 banghart 4268: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 4269: }
1.341 banghart 4270: my $put_result = &Apache::lonnet::put('environment',
4271: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
4272: }
1.340 banghart 4273: $r->print('<table>');
4274: my $num_fields = scalar(@fields_in_order);
4275: foreach my $key (@fields_in_order) {
4276: $r->print('<tr><td>');
4277: $r->print('<form method="post" action="">');
4278: $r->print('<select name="newpos" onChange="this.form.submit()">');
4279: for (my $i = 1;$i le $num_fields;$i ++) {
4280: if ($i eq $idx) {
4281: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
4282: } else {
4283: $r->print('<option value="'.$i.'">'.$i.'</option>');
4284: }
4285: }
4286: $r->print('</select></td><td>');
4287: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
4288: $r->print('<input type="hidden" name="storeorder" value="true" />');
4289: $r->print('</form>');
4290: $r->print($$fields{$key}.'</td></tr>');
4291: $idx ++;
4292: }
4293: $r->print('</table>');
4294: return 'ok';
4295: }
1.416 jms 4296:
4297:
1.359 banghart 4298: sub continue {
4299: my $output;
4300: $output .= '<form action="" method="post">';
4301: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
4302: $output .= '<input type="submit" value="Continue" />';
4303: return ($output);
4304: }
1.416 jms 4305:
4306:
1.334 banghart 4307: sub addmetafield {
4308: my ($r)=@_;
1.414 droeschl 4309: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4310: text=>"Add Metadata Field"});
1.334 banghart 4311: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
4312: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 4313: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4314: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 4315: if (exists($env{'form.undelete'})) {
1.358 banghart 4316: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 4317: foreach my $meta_field(@meta_fields) {
4318: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
4319: $options =~ s/deleted//;
4320: $options =~ s/,,/,/;
4321: my $put_result = &Apache::lonnet::put('environment',
4322: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
4323:
4324: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
4325: }
1.359 banghart 4326: $r->print(&continue());
1.339 banghart 4327: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 4328: my $meta_field = $env{'form.fieldname'};
4329: my $display_field = $env{'form.fieldname'};
4330: $meta_field =~ s/\W/_/g;
1.338 banghart 4331: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 4332: my $put_result = &Apache::lonnet::put('environment',
4333: {'metadata.'.$meta_field.'.values'=>"",
4334: 'metadata.'.$meta_field.'.added'=>"$display_field",
4335: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 4336: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
4337: $r->print(&continue());
1.335 banghart 4338: } else {
1.357 raeburn 4339: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 4340: if ($fields) {
4341: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
4342: $r->print('<form method="post" action="">');
4343: foreach my $key(keys(%$fields)) {
1.358 banghart 4344: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 4345: }
4346: $r->print('<input type="submit" name="undelete" value="Undelete" />');
4347: $r->print('</form>');
4348: }
4349: $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 4350: $r->print('<input type="text" name="fieldname" /><br />');
4351: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4352: }
1.361 albertel 4353: $r->print('</form>');
1.334 banghart 4354: }
1.416 jms 4355:
4356:
4357:
1.259 banghart 4358: sub setrestrictmeta {
1.240 banghart 4359: my ($r)=@_;
1.242 banghart 4360: my $next_meta;
1.244 banghart 4361: my $output;
1.245 banghart 4362: my $item_num;
1.246 banghart 4363: my $put_result;
1.414 droeschl 4364: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4365: text=>"Restrict Metadata"});
1.280 albertel 4366: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4367: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4368: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4369: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4370: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4371: my $save_field = '';
1.259 banghart 4372: if ($env{'form.restrictmeta'}) {
1.254 banghart 4373: foreach my $field (sort(keys(%env))) {
1.252 banghart 4374: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4375: my $options;
1.252 banghart 4376: my $meta_field = $1;
4377: my $meta_key = $2;
1.253 banghart 4378: if ($save_field ne $meta_field) {
1.252 banghart 4379: $save_field = $meta_field;
1.253 banghart 4380: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 4381: $options.='stuadd,';
4382: }
1.351 banghart 4383: if ($env{'form.'.$meta_field.'_choices'}) {
4384: $options.='choices,';
4385: }
4386: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 4387: $options.='onlyone,';
4388: }
4389: if ($env{'form.'.$meta_field.'_active'}) {
4390: $options.='active,';
1.253 banghart 4391: }
1.337 banghart 4392: if ($env{'form.'.$meta_field.'_deleted'}) {
4393: $options.='deleted,';
4394: }
1.259 banghart 4395: my $name = $save_field;
1.253 banghart 4396: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4397: {'metadata.'.$meta_field.'.options'=>$options,
4398: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4399: },$dom,$crs);
1.252 banghart 4400: }
4401: }
4402: }
4403: }
1.296 albertel 4404: &Apache::lonnet::coursedescription($env{'request.course.id'},
4405: {'freshen_cache' => 1});
1.335 banghart 4406: # Get the default metadata fields
1.258 albertel 4407: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4408: # Now get possible added metadata fields
1.357 raeburn 4409: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4410: my $row_alt = 1;
1.347 banghart 4411: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4412: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4413: if ($field ne 'courserestricted') {
1.346 banghart 4414: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 4415: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 4416: }
1.255 banghart 4417: }
1.351 banghart 4418: my $buttons = (<<ENDButtons);
4419: <input type="submit" name="restrictmeta" value="Save" />
4420: </form><br />
4421: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4422: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4423: </form>
4424: <br />
4425: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4426: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4427: ENDButtons
1.337 banghart 4428: my $added_flag = 1;
1.335 banghart 4429: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4430: $row_alt = $row_alt ? 0 : 1;
4431: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4432: }
1.347 banghart 4433: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 4434: $r->print(<<ENDenv);
1.259 banghart 4435: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4436: $output
1.351 banghart 4437: $buttons
1.340 banghart 4438: </form>
1.244 banghart 4439: ENDenv
1.280 albertel 4440: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4441: return 'ok';
4442: }
1.416 jms 4443:
4444:
4445:
1.335 banghart 4446: sub get_added_meta_fieldnames {
1.357 raeburn 4447: my ($cid) = @_;
1.335 banghart 4448: my %fields;
4449: foreach my $key(%env) {
1.357 raeburn 4450: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4451: my $field_name = $1;
4452: my ($display_field_name) = $env{$key};
4453: $fields{$field_name} = $display_field_name;
4454: }
4455: }
4456: return \%fields;
4457: }
1.416 jms 4458:
4459:
4460:
1.339 banghart 4461: sub get_deleted_meta_fieldnames {
1.357 raeburn 4462: my ($cid) = @_;
1.339 banghart 4463: my %fields;
4464: foreach my $key(%env) {
1.357 raeburn 4465: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4466: my $field_name = $1;
4467: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4468: my ($display_field_name) = $env{$key};
4469: $fields{$field_name} = $display_field_name;
4470: }
4471: }
4472: }
4473: return \%fields;
4474: }
1.220 www 4475: sub defaultsetter {
1.280 albertel 4476: my ($r) = @_;
4477:
1.414 droeschl 4478: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4479: text=>"Set Defaults"});
1.280 albertel 4480: my $start_page =
4481: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4482: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4483: $r->print(<<ENDDEFHEAD);
1.280 albertel 4484: $start_page
1.220 www 4485: $breadcrumbs
4486: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4487: ENDDEFHEAD
1.280 albertel 4488:
4489: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4490: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4491: my @ids=();
4492: my %typep=();
4493: my %keyp=();
4494: my %allparms=();
4495: my %allparts=();
4496: my %allmaps=();
4497: my %mapp=();
4498: my %symbp=();
4499: my %maptitles=();
4500: my %uris=();
4501: my %keyorder=&standardkeyorder();
4502: my %defkeytype=();
4503:
4504: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4505: \%mapp, \%symbp,\%maptitles,\%uris,
4506: \%keyorder,\%defkeytype);
1.224 www 4507: if ($env{'form.storerules'}) {
4508: my %newrules=();
4509: my @delrules=();
1.226 www 4510: my %triggers=();
1.225 albertel 4511: foreach my $key (keys(%env)) {
4512: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4513: my $tempkey=$1;
1.226 www 4514: my $action=$env{$key};
4515: if ($action) {
4516: $newrules{$tempkey.'_action'}=$action;
4517: if ($action ne 'default') {
4518: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4519: $triggers{$whichparm}.=$tempkey.':';
4520: }
4521: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4522: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4523: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4524: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4525: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4526: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4527: } else {
4528: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4529: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4530: }
4531: } else {
1.225 albertel 4532: push(@delrules,$tempkey.'_action');
1.226 www 4533: push(@delrules,$tempkey.'_type');
1.225 albertel 4534: push(@delrules,$tempkey.'_hours');
4535: push(@delrules,$tempkey.'_min');
4536: push(@delrules,$tempkey.'_sec');
4537: push(@delrules,$tempkey.'_value');
1.224 www 4538: }
4539: }
4540: }
1.226 www 4541: foreach my $key (keys %allparms) {
4542: $newrules{$key.'_triggers'}=$triggers{$key};
4543: }
1.224 www 4544: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4545: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4546: &resetrulescache();
4547: }
1.227 www 4548: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4549: 'hours' => 'Hours',
1.221 www 4550: 'min' => 'Minutes',
4551: 'sec' => 'Seconds',
4552: 'yes' => 'Yes',
4553: 'no' => 'No');
1.222 www 4554: my @standardoptions=('','default');
4555: my @standarddisplay=('',&mt('Default value when manually setting'));
4556: my @dateoptions=('','default');
4557: my @datedisplay=('',&mt('Default value when manually setting'));
4558: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4559: unless ($tempkey) { next; }
4560: push @standardoptions,'when_setting_'.$tempkey;
4561: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4562: if (&isdateparm($defkeytype{$tempkey})) {
4563: push @dateoptions,'later_than_'.$tempkey;
4564: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4565: push @dateoptions,'earlier_than_'.$tempkey;
4566: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4567: }
4568: }
1.231 www 4569: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4570: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4571: $r->print("\n".&Apache::loncommon::start_data_table().
4572: &Apache::loncommon::start_data_table_header_row().
4573: "<th>".&mt('Rule for parameter').'</th><th>'.
4574: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4575: &Apache::loncommon::end_data_table_header_row());
1.221 www 4576: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4577: unless ($tempkey) { next; }
1.318 albertel 4578: $r->print("\n".&Apache::loncommon::start_data_table_row().
4579: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4580: my $action=&rulescache($tempkey.'_action');
4581: $r->print('<select name="'.$tempkey.'_action">');
4582: if (&isdateparm($defkeytype{$tempkey})) {
4583: for (my $i=0;$i<=$#dateoptions;$i++) {
4584: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4585: $r->print("\n<option value='$dateoptions[$i]'".
4586: ($dateoptions[$i] eq $action?' selected="selected"':'').
4587: ">$datedisplay[$i]</option>");
4588: }
4589: } else {
4590: for (my $i=0;$i<=$#standardoptions;$i++) {
4591: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4592: $r->print("\n<option value='$standardoptions[$i]'".
4593: ($standardoptions[$i] eq $action?' selected="selected"':'').
4594: ">$standarddisplay[$i]</option>");
4595: }
4596: }
4597: $r->print('</select>');
1.227 www 4598: unless (&isdateparm($defkeytype{$tempkey})) {
4599: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4600: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4601: }
1.222 www 4602: $r->print("\n</td><td>\n");
4603:
1.221 www 4604: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4605: my $days=&rulescache($tempkey.'_days');
1.222 www 4606: my $hours=&rulescache($tempkey.'_hours');
4607: my $min=&rulescache($tempkey.'_min');
4608: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4609: $r->print(<<ENDINPUTDATE);
1.227 www 4610: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4611: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4612: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4613: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4614: ENDINPUTDATE
4615: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4616: my $yeschecked='';
4617: my $nochecked='';
4618: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4619: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4620:
1.221 www 4621: $r->print(<<ENDYESNO);
1.224 www 4622: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4623: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4624: ENDYESNO
4625: } else {
1.224 www 4626: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4627: }
1.318 albertel 4628: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4629: }
1.318 albertel 4630: $r->print(&Apache::loncommon::end_data_table().
1.419 bisitz 4631: "\n".'<input type="submit" name="storerules" value="'.
1.430 schafran 4632: &mt('Save').'" /></form>'."\n".
1.280 albertel 4633: &Apache::loncommon::end_page());
1.220 www 4634: return;
4635: }
1.193 albertel 4636:
1.290 www 4637: sub components {
1.330 albertel 4638: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4639:
4640: if ($typeflag) {
1.290 www 4641: $key=~s/\.type$//;
4642: }
1.330 albertel 4643:
4644: my ($middle,$part,$name)=
4645: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4646: my $issection;
1.330 albertel 4647:
1.290 www 4648: my $section=&mt('All Students');
4649: if ($middle=~/^\[(.*)\]/) {
1.291 www 4650: $issection=$1;
4651: $section=&mt('Group/Section').': '.$issection;
1.290 www 4652: $middle=~s/^\[(.*)\]//;
4653: }
4654: $middle=~s/\.+$//;
4655: $middle=~s/^\.+//;
1.291 www 4656: if ($uname) {
4657: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4658: $issection='';
4659: }
1.316 albertel 4660: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4661: my $realmdescription=&mt('all resources');
1.290 www 4662: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4663: $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 4664: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4665: } elsif ($middle) {
1.290 www 4666: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4667: $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 4668: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4669: }
1.291 www 4670: my $what=$part.'.'.$name;
1.330 albertel 4671: return ($realm,$section,$name,$part,
1.304 www 4672: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4673: }
1.293 www 4674:
1.328 albertel 4675: my %standard_parms;
1.416 jms 4676:
4677:
1.328 albertel 4678: sub load_parameter_names {
4679: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4680: while (my $configline=<$config>) {
4681: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4682: chomp($configline);
4683: my ($short,$plain)=split(/:/,$configline);
4684: my (undef,$name,$type)=split(/\&/,$short,3);
4685: if ($type eq 'display') {
4686: $standard_parms{$name} = $plain;
4687: }
4688: }
4689: close($config);
4690: $standard_parms{'int_pos'} = 'Positive Integer';
4691: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4692: %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
4693: }
4694:
1.292 www 4695: sub standard_parameter_names {
4696: my ($name)=@_;
1.328 albertel 4697: if (!%standard_parms) {
4698: &load_parameter_names();
4699: }
1.292 www 4700: if ($standard_parms{$name}) {
4701: return $standard_parms{$name};
4702: } else {
4703: return $name;
4704: }
4705: }
1.290 www 4706:
1.309 www 4707:
4708:
1.285 albertel 4709: sub parm_change_log {
1.284 www 4710: my ($r)=@_;
1.414 droeschl 4711: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
4712: text=>"Parameter Change Log"});
1.327 albertel 4713: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4714: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4715:
1.286 www 4716: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4717: $env{'course.'.$env{'request.course.id'}.'.domain'},
4718: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4719:
1.301 www 4720: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4721:
1.327 albertel 4722: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4723: method="post" name="parameterlog">');
1.311 albertel 4724:
4725: my %saveable_parameters = ('show' => 'scalar',);
4726: &Apache::loncommon::store_course_settings('parameter_log',
4727: \%saveable_parameters);
4728: &Apache::loncommon::restore_course_settings('parameter_log',
4729: \%saveable_parameters);
1.348 www 4730: $r->print(&Apache::loncommon::display_filter().
1.326 www 4731: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4732: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4733: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4734:
1.291 www 4735: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4736: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4737: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4738: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4739: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4740: &Apache::loncommon::end_data_table_header_row());
1.309 www 4741: my $shown=0;
1.349 www 4742: my $folder='';
4743: if ($env{'form.displayfilter'} eq 'currentfolder') {
4744: my $last='';
4745: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4746: &GDBM_READER(),0640)) {
4747: $last=$hash{'last_known'};
4748: untie(%hash);
4749: }
4750: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4751: }
1.356 albertel 4752: foreach my $id (sort
4753: {
4754: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4755: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4756: }
4757: my $aid = (split('00000',$a))[-1];
4758: my $bid = (split('00000',$b))[-1];
4759: return $bid<=>$aid;
4760: } (keys(%parmlog))) {
1.294 www 4761: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4762: my $count = 0;
1.288 albertel 4763: my $time =
1.294 www 4764: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4765: my $plainname =
1.294 www 4766: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4767: $parmlog{$id}{'exe_udom'});
1.288 albertel 4768: my $about_me_link =
1.289 www 4769: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4770: $parmlog{$id}{'exe_uname'},
4771: $parmlog{$id}{'exe_udom'});
1.293 www 4772: my $send_msg_link='';
1.294 www 4773: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4774: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4775: $send_msg_link ='<br />'.
1.288 albertel 4776: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4777: $parmlog{$id}{'exe_uname'},
4778: $parmlog{$id}{'exe_udom'});
1.288 albertel 4779: }
1.301 www 4780: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4781: my $makenewrow=0;
4782: my %istype=();
1.332 albertel 4783: my $output;
1.293 www 4784: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4785: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4786: my $typeflag = ($changed =~/\.type$/ &&
4787: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4788: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4789: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4790: if ($env{'form.displayfilter'} eq 'currentfolder') {
4791: if ($folder) {
4792: if ($middle!~/^\Q$folder\E/) { next; }
4793: }
4794: }
1.326 www 4795: if ($typeflag) {
1.329 albertel 4796: $istype{$parmname}=$value;
1.326 www 4797: if (!$env{'form.includetypes'}) { next; }
4798: }
1.332 albertel 4799: $count++;
4800: if ($makenewrow) {
4801: $output .= $row_start;
4802: } else {
4803: $makenewrow=1;
4804: }
4805: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 4806: &standard_parameter_names($parmname).'</td><td>'.
1.332 albertel 4807: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4808: my $stillactive=0;
1.332 albertel 4809: if ($parmlog{$id}{'delflag'}) {
4810: $output .= &mt('Deleted');
1.288 albertel 4811: } else {
1.290 www 4812: if ($typeflag) {
1.332 albertel 4813: $output .= &mt('Type: [_1]',&standard_parameter_names($value));
1.290 www 4814: } else {
1.291 www 4815: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4816: $uname,$udom,$issection,$issection,$courseopt);
4817: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4818: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4819: } else {
1.332 albertel 4820: $output .= $value;
1.291 www 4821: }
4822: if ($value ne $all[$level]) {
1.332 albertel 4823: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4824: } else {
4825: $stillactive=1;
4826: }
1.290 www 4827: }
1.288 albertel 4828: }
1.332 albertel 4829: $output .= '</td><td>';
1.291 www 4830: if ($stillactive) {
1.304 www 4831: my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
4832: my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
4833: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4834: if (($uname) && ($udom)) {
1.332 albertel 4835: $output .=
4836: &Apache::loncommon::messagewrapper('Notify User',
4837: $uname,$udom,$title,
4838: $description);
1.292 www 4839: } else {
1.332 albertel 4840: $output .=
4841: &Apache::lonrss::course_blog_link($id,$title,
4842: $description);
1.292 www 4843: }
1.291 www 4844: }
1.332 albertel 4845: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4846: }
1.349 www 4847: if ($env{'form.displayfilter'} eq 'containing') {
4848: my $wholeentry=$about_me_link.':'.
4849: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4850: $output;
4851: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4852: }
4853: if ($count) {
4854: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4855: <td rowspan="'.$count.'">'.$about_me_link.
4856: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4857: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4858: $send_msg_link.'</td>'.$output);
1.349 www 4859: $shown++;
4860: }
1.311 albertel 4861: if (!($env{'form.show'} eq &mt('all')
4862: || $shown<=$env{'form.show'})) { last; }
1.286 www 4863: }
1.301 www 4864: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4865: $r->print(&Apache::loncommon::end_page());
4866: }
4867:
1.437 raeburn 4868: sub update_slots {
4869: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
4870: my %slot=&Apache::lonnet::get_slot($slot_name);
4871: if (!keys(%slot)) {
4872: return 'error: slot does not exist';
4873: }
4874: my $max=$slot{'maxspace'};
4875: if (!defined($max)) { $max=99999; }
4876:
4877: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
4878: "^$slot_name\0");
4879: my ($tmp)=%consumed;
4880: if ($tmp=~/^error: 2 / ) {
4881: return 'error: unable to determine current slot status';
4882: }
4883: my $last=0;
4884: foreach my $key (keys(%consumed)) {
4885: my $num=(split('\0',$key))[1];
4886: if ($num > $last) { $last=$num; }
4887: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4888: return 'ok';
4889: }
4890: }
4891:
4892: if (scalar(keys(%consumed)) >= $max) {
4893: return 'error: no space left in slot';
4894: }
4895: my $wanted=$last+1;
4896:
4897: my %reservation=('name' => $uname.':'.$udom,
4898: 'timestamp' => time,
4899: 'symb' => $symb);
4900:
4901: my $success=&Apache::lonnet::newput('slot_reservations',
4902: {"$slot_name\0$wanted" =>
4903: \%reservation},
4904: $cdom, $cnum);
1.438 raeburn 4905: if ($success eq 'ok') {
4906: my %storehash = (
4907: symb => $symb,
4908: slot => $slot_name,
4909: action => 'reserve',
4910: context => 'parameter',
4911: );
4912: &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
4913: '',$uname,$udom,$cnum,$cdom);
4914:
4915: &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
4916: '',$uname,$udom,$uname,$udom);
4917: }
1.437 raeburn 4918: return $success;
4919: }
4920:
4921: sub delete_slots {
4922: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
4923: my $delresult;
4924: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
4925: $cnum, "^$slot_name\0");
4926: if (&Apache::lonnet::error(%consumed)) {
4927: return 'error: unable to determine current slot status';
4928: }
4929: my ($tmp)=%consumed;
4930: if ($tmp=~/^error: 2 /) {
4931: return 'error: unable to determine current slot status';
4932: }
4933: foreach my $key (keys(%consumed)) {
4934: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4935: my $num=(split('\0',$key))[1];
4936: my $entry = $slot_name.'\0'.$num;
4937: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
4938: $cdom,$cnum);
4939: if ($delresult eq 'ok') {
4940: my %storehash = (
4941: symb => $symb,
4942: slot => $slot_name,
4943: action => 'release',
4944: context => 'parameter',
4945: );
4946: &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
4947: 1,$uname,$udom,$cnum,$cdom);
1.438 raeburn 4948: &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
4949: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 4950: }
4951: }
4952: }
4953: return $delresult;
4954: }
4955:
1.355 albertel 4956: sub check_for_course_info {
4957: my $navmap = Apache::lonnavmaps::navmap->new();
4958: return 1 if ($navmap);
4959: return 0;
4960: }
4961:
1.259 banghart 4962:
1.30 www 4963: sub handler {
1.43 albertel 4964: my $r=shift;
1.30 www 4965:
1.376 albertel 4966: &reset_caches();
4967:
1.414 droeschl 4968: &Apache::loncommon::content_type($r,'text/html');
4969: $r->send_http_header;
4970: return OK if $r->header_only;
4971:
1.193 albertel 4972: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4973: ['action','state',
4974: 'pres_marker',
4975: 'pres_value',
1.206 www 4976: 'pres_type',
1.390 www 4977: 'udom','uname','symb','serial','timebase']);
1.131 www 4978:
1.83 bowersj2 4979:
1.193 albertel 4980: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4981: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4982: text=>"Parameter Manager",
1.204 www 4983: faq=>10,
1.324 www 4984: bug=>'Instructor Interface',
1.442 droeschl 4985: help =>
4986: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 4987:
1.30 www 4988: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4989: my $parm_permission =
4990: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4991: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4992: $env{'request.course.sec'}));
1.355 albertel 4993: my $exists = &check_for_course_info();
4994:
4995: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4996: #
4997: # Main switch on form.action and form.state, as appropriate
4998: #
4999: # Check first if coming from someone else headed directly for
5000: # the table mode
5001: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
5002: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
5003: &assessparms($r);
5004: } elsif (! exists($env{'form.action'})) {
5005: &print_main_menu($r,$parm_permission);
1.414 droeschl 5006: } elsif ($env{'form.action'} eq 'crsenv') {
1.193 albertel 5007: &crsenv($r);
1.414 droeschl 5008: } elsif ($env{'form.action'} eq 'setoverview') {
1.121 www 5009: &overview($r);
1.414 droeschl 5010: } elsif ($env{'form.action'} eq 'addmetadata') {
1.334 banghart 5011: &addmetafield($r);
1.414 droeschl 5012: } elsif ($env{'form.action'} eq 'ordermetadata') {
1.340 banghart 5013: &order_meta_fields($r);
1.414 droeschl 5014: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.259 banghart 5015: &setrestrictmeta($r);
1.414 droeschl 5016: } elsif ($env{'form.action'} eq 'newoverview') {
1.208 www 5017: &newoverview($r);
1.414 droeschl 5018: } elsif ($env{'form.action'} eq 'setdefaults') {
1.220 www 5019: &defaultsetter($r);
1.414 droeschl 5020: } elsif ($env{'form.action'} eq 'settable') {
1.121 www 5021: &assessparms($r);
1.414 droeschl 5022: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.285 albertel 5023: &parm_change_log($r);
1.414 droeschl 5024: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.333 albertel 5025: &clean_parameters($r);
1.414 droeschl 5026: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 5027: &date_shift_one($r);
1.414 droeschl 5028: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 5029: &date_shift_two($r);
1.414 droeschl 5030: } elsif ($env{'form.action'} eq 'categorizecourse') {
1.403 raeburn 5031: &assign_course_categories($r);
5032: }
1.43 albertel 5033: } else {
1.1 www 5034: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 5035: if ($exists) {
5036: $env{'user.error.msg'}=
5037: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
5038: } else {
5039: $env{'user.error.msg'}=
5040: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
5041: }
1.43 albertel 5042: return HTTP_NOT_ACCEPTABLE;
5043: }
1.376 albertel 5044: &reset_caches();
5045:
1.43 albertel 5046: return OK;
1.1 www 5047: }
5048:
5049: 1;
5050: __END__
5051:
5052:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>