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