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