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