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