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