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