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