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