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