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