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