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