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