Annotation of loncom/interface/lonparmset.pm, revision 1.522.2.13
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.522.2.13! raeburn 4: # $Id: lonparmset.pm,v 1.522.2.12 2013/12/19 19:31:53 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');
1.522.2.13! raeburn 3647: $r->print('<h2>'.&mt('Shift Dates').'</h2>'.
! 3648: '<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
1.390 www 3649: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
1.522.2.13! raeburn 3650: &Apache::lonlocal::locallocaltime($timeshifted)).'</p>');
1.390 www 3651: my $delta=$timeshifted-$env{'form.timebase'};
3652: &dateshift($delta);
1.522.2.13! raeburn 3653: $r->print(
! 3654: &Apache::lonhtmlcommon::confirm_success(&mt('Done')).
! 3655: '<br /><br />'.
! 3656: &Apache::lonhtmlcommon::actionbox(
! 3657: ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));
1.390 www 3658: $r->print(&Apache::loncommon::end_page());
3659: }
3660:
1.333 albertel 3661: sub parse_key {
3662: my ($key) = @_;
3663: my %data;
3664: my ($middle,$part,$name)=
1.473 amueller 3665: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.333 albertel 3666: $data{'scope_type'} = 'all';
3667: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 3668: $data{'scope'} = $1;
3669: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
3670: $data{'scope_type'} = 'user';
3671: $data{'scope'} = [$1,$2];
3672: } else {
3673: #FIXME check for group scope
3674: $data{'scope_type'} = 'section';
3675: }
3676: $middle=~s/^\[(.*)\]//;
1.333 albertel 3677: }
3678: $middle=~s/\.+$//;
3679: $middle=~s/^\.+//;
3680: $data{'realm_type'}='all';
3681: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 3682: $data{'realm'} = $1;
3683: $data{'realm_type'} = 'folder';
3684: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3685: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
1.333 albertel 3686: } elsif ($middle) {
1.473 amueller 3687: $data{'realm'} = $middle;
3688: $data{'realm_type'} = 'symb';
3689: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3690: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3691: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
1.333 albertel 3692: }
1.446 bisitz 3693:
1.333 albertel 3694: $data{'parameter_part'} = $part;
3695: $data{'parameter_name'} = $name;
3696:
3697: return %data;
3698: }
3699:
1.239 raeburn 3700:
1.416 jms 3701: sub header {
1.522.2.3 raeburn 3702: return &Apache::loncommon::start_page('Content and Problem Settings');
1.416 jms 3703: }
1.193 albertel 3704:
3705:
3706:
3707: sub print_main_menu {
3708: my ($r,$parm_permission)=@_;
3709: #
1.414 droeschl 3710: $r->print(&header());
1.522.2.3 raeburn 3711: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
1.193 albertel 3712: $r->print(<<ENDMAINFORMHEAD);
3713: <form method="post" enctype="multipart/form-data"
3714: action="/adm/parmset" name="studentform">
3715: ENDMAINFORMHEAD
3716: #
1.195 albertel 3717: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3718: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3719: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3720: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.520 raeburn 3721: my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
3722: if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
3723: $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
3724: '/'.$env{'request.course.sec'});
3725: }
1.268 albertel 3726:
1.477 raeburn 3727: my $crstype = &Apache::loncommon::course_type();
3728: my $lc_crstype = lc($crstype);
1.417 droeschl 3729:
1.193 albertel 3730: my @menu =
1.507 www 3731: ( { categorytitle=>"Content Settings for this $crstype",
1.473 amueller 3732: items => [
3733: { linktext => 'Portfolio Metadata',
3734: url => '/adm/parmset?action=setrestrictmeta',
3735: permission => $parm_permission,
1.477 raeburn 3736: linktitle => "Restrict metadata for this $lc_crstype." ,
1.473 amueller 3737: icon =>'contact-new.png' ,
3738: },
3739: { linktext => 'Reset Student Access Times',
3740: url => '/adm/helper/resettimes.helper',
3741: permission => $mgr,
1.477 raeburn 3742: linktitle => "Reset access times for folders/maps, resources or the $lc_crstype." ,
1.473 amueller 3743: icon => 'start-here.png' ,
3744: },
1.520 raeburn 3745: { linktext => 'Blocking Communication/Resource Access',
3746: url => '/adm/setblock',
3747: permission => $dcm,
3748: linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
3749: icon => 'comblock.png',
3750: },
1.473 amueller 3751: { linktext => 'Set Parameter Setting Default Actions',
3752: url => '/adm/parmset?action=setdefaults',
3753: permission => $parm_permission,
3754: linktitle =>'Set default actions for parameters.' ,
3755: icon => 'folder-new.png' ,
3756: }]},
3757: { categorytitle => 'New and Existing Parameter Settings for Resources',
3758: items => [
3759: { linktext => 'Edit Resource Parameters - Helper Mode',
3760: url => '/adm/helper/parameter.helper',
3761: permission => $parm_permission,
3762: linktitle =>'Set/Modify resource parameters in helper mode.' ,
3763: icon => 'dialog-information.png' ,
3764: #help => 'Parameter_Helper',
3765: },
3766: { linktext => 'Edit Resource Parameters - Overview Mode',
3767: url => '/adm/parmset?action=newoverview',
3768: permission => $parm_permission,
3769: linktitle =>'Set/Modify resource parameters in overview mode.' ,
3770: icon => 'edit-find.png' ,
3771: #help => 'Parameter_Overview',
3772: },
3773: { linktext => 'Edit Resource Parameters - Table Mode',
3774: url => '/adm/parmset?action=settable',
3775: permission => $parm_permission,
3776: linktitle =>'Set/Modify resource parameters in table mode.' ,
3777: icon => 'edit-copy.png' ,
3778: #help => 'Table_Mode',
3779: }]},
1.417 droeschl 3780: { categorytitle => 'Existing Parameter Settings for Resources',
1.473 amueller 3781: items => [
3782: { linktext => 'Modify Resource Parameters - Overview Mode',
3783: url => '/adm/parmset?action=setoverview',
3784: permission => $parm_permission,
3785: linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
3786: icon => 'preferences-desktop-wallpaper.png' ,
3787: #help => 'Parameter_Overview',
3788: },
3789: { linktext => 'Change Log',
3790: url => '/adm/parmset?action=parameterchangelog',
3791: permission => $parm_permission,
1.477 raeburn 3792: linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
1.487 wenzelju 3793: icon => 'document-properties.png',
1.473 amueller 3794: }]}
1.193 albertel 3795: );
1.414 droeschl 3796: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.522.2.8 raeburn 3797: $r->print('</form>'.&Apache::loncommon::end_page());
1.193 albertel 3798: return;
3799: }
1.414 droeschl 3800:
1.416 jms 3801:
3802:
1.252 banghart 3803: sub output_row {
1.347 banghart 3804: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3805: my $output;
1.263 banghart 3806: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3807: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3808: if (!defined($options)) {
1.254 banghart 3809: $options = 'active,stuadd';
1.261 banghart 3810: $values = '';
1.252 banghart 3811: }
1.337 banghart 3812: if (!($options =~ /deleted/)) {
3813: my @options= ( ['active', 'Show to student'],
1.418 schafran 3814: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 3815: ['choices','Provide choices for students to select from']);
1.473 amueller 3816: # ['onlyone','Student may select only one choice']);
1.337 banghart 3817: if ($added_flag) {
3818: push @options,['deleted', 'Delete Metadata Field'];
3819: }
1.351 banghart 3820: $output = &Apache::loncommon::start_data_table_row();
1.451 bisitz 3821: $output .= '<td><strong>'.$field_text.':</strong></td>';
1.351 banghart 3822: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3823: foreach my $opt (@options) {
1.473 amueller 3824: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3825: $output .= &Apache::loncommon::continue_data_table_row();
3826: $output .= '<td>'.(' ' x 5).'<label>
3827: <input type="checkbox" name="'.
3828: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3829: &mt($opt->[1]).'</label></td>';
3830: $output .= &Apache::loncommon::end_data_table_row();
3831: }
1.351 banghart 3832: $output .= &Apache::loncommon::continue_data_table_row();
1.451 bisitz 3833: $output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
1.351 banghart 3834: $output .= &Apache::loncommon::end_data_table_row();
3835: my $multiple_checked;
3836: my $single_checked;
3837: if ($options =~ m/onlyone/) {
1.422 bisitz 3838: $multiple_checked = '';
1.423 bisitz 3839: $single_checked = ' checked="checked"';
1.351 banghart 3840: } else {
1.423 bisitz 3841: $multiple_checked = ' checked="checked"';
1.422 bisitz 3842: $single_checked = '';
1.351 banghart 3843: }
1.473 amueller 3844: $output .= &Apache::loncommon::continue_data_table_row();
3845: $output .= '<td>'.(' ' x 10).'
3846: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
3847: '.&mt('Student may select multiple choices from list').'</td>';
3848: $output .= &Apache::loncommon::end_data_table_row();
3849: $output .= &Apache::loncommon::continue_data_table_row();
3850: $output .= '<td>'.(' ' x 10).'
3851: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
3852: '.&mt('Student may select only one choice from list').'</td>';
3853: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3854: }
3855: return ($output);
3856: }
1.416 jms 3857:
3858:
3859:
1.340 banghart 3860: sub order_meta_fields {
3861: my ($r)=@_;
3862: my $idx = 1;
3863: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3864: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3865: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 3866: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 3867: text=>"Add Metadata Field"});
1.345 banghart 3868: &Apache::lonhtmlcommon::add_breadcrumb
3869: ({href=>"/adm/parmset?action=setrestrictmeta",
3870: text=>"Restrict Metadata"},
3871: {text=>"Order Metadata"});
3872: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 3873: if ($env{'form.storeorder'}) {
3874: my $newpos = $env{'form.newpos'} - 1;
3875: my $currentpos = $env{'form.currentpos'} - 1;
3876: my @neworder = ();
3877: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3878: my $i;
1.341 banghart 3879: if ($newpos > $currentpos) {
1.340 banghart 3880: # moving stuff up
3881: for ($i=0;$i<$currentpos;$i++) {
1.473 amueller 3882: $neworder[$i]=$oldorder[$i];
1.340 banghart 3883: }
3884: for ($i=$currentpos;$i<$newpos;$i++) {
1.473 amueller 3885: $neworder[$i]=$oldorder[$i+1];
1.340 banghart 3886: }
3887: $neworder[$newpos]=$oldorder[$currentpos];
3888: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
1.473 amueller 3889: $neworder[$i]=$oldorder[$i];
1.340 banghart 3890: }
3891: } else {
3892: # moving stuff down
1.473 amueller 3893: for ($i=0;$i<$newpos;$i++) {
3894: $neworder[$i]=$oldorder[$i];
3895: }
3896: $neworder[$newpos]=$oldorder[$currentpos];
3897: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3898: $neworder[$i]=$oldorder[$i-1];
3899: }
3900: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3901: $neworder[$i]=$oldorder[$i];
3902: }
1.340 banghart 3903: }
1.473 amueller 3904: my $ordered_fields = join ",", @neworder;
1.343 banghart 3905: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 3906: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.473 amueller 3907: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3908: }
1.357 raeburn 3909: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3910: my $ordered_fields;
1.340 banghart 3911: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3912: if (!@fields_in_order) {
3913: # no order found, pick sorted order then create metadata.addedorder key.
3914: foreach my $key (sort keys %$fields) {
3915: push @fields_in_order, $key;
1.341 banghart 3916: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3917: }
1.341 banghart 3918: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 3919: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3920: }
1.340 banghart 3921: $r->print('<table>');
3922: my $num_fields = scalar(@fields_in_order);
3923: foreach my $key (@fields_in_order) {
3924: $r->print('<tr><td>');
3925: $r->print('<form method="post" action="">');
1.522.2.8 raeburn 3926: $r->print('<select name="newpos" onchange="this.form.submit()">');
1.340 banghart 3927: for (my $i = 1;$i le $num_fields;$i ++) {
3928: if ($i eq $idx) {
3929: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3930: } else {
3931: $r->print('<option value="'.$i.'">'.$i.'</option>');
3932: }
3933: }
3934: $r->print('</select></td><td>');
3935: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3936: $r->print('<input type="hidden" name="storeorder" value="true" />');
3937: $r->print('</form>');
3938: $r->print($$fields{$key}.'</td></tr>');
3939: $idx ++;
3940: }
3941: $r->print('</table>');
3942: return 'ok';
3943: }
1.416 jms 3944:
3945:
1.359 banghart 3946: sub continue {
3947: my $output;
3948: $output .= '<form action="" method="post">';
3949: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3950: $output .= '<input type="submit" value="Continue" />';
3951: return ($output);
3952: }
1.416 jms 3953:
3954:
1.334 banghart 3955: sub addmetafield {
3956: my ($r)=@_;
1.414 droeschl 3957: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 3958: text=>"Add Metadata Field"});
1.334 banghart 3959: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3960: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 3961: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3962: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 3963: if (exists($env{'form.undelete'})) {
1.358 banghart 3964: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 3965: foreach my $meta_field(@meta_fields) {
3966: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
3967: $options =~ s/deleted//;
3968: $options =~ s/,,/,/;
3969: my $put_result = &Apache::lonnet::put('environment',
3970: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
1.446 bisitz 3971:
1.339 banghart 3972: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
3973: }
1.359 banghart 3974: $r->print(&continue());
1.339 banghart 3975: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 3976: my $meta_field = $env{'form.fieldname'};
3977: my $display_field = $env{'form.fieldname'};
3978: $meta_field =~ s/\W/_/g;
1.338 banghart 3979: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 3980: my $put_result = &Apache::lonnet::put('environment',
3981: {'metadata.'.$meta_field.'.values'=>"",
3982: 'metadata.'.$meta_field.'.added'=>"$display_field",
3983: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 3984: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
3985: $r->print(&continue());
1.335 banghart 3986: } else {
1.357 raeburn 3987: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 3988: if ($fields) {
3989: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
3990: $r->print('<form method="post" action="">');
3991: foreach my $key(keys(%$fields)) {
1.358 banghart 3992: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 3993: }
3994: $r->print('<input type="submit" name="undelete" value="Undelete" />');
3995: $r->print('</form>');
3996: }
3997: $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 3998: $r->print('<input type="text" name="fieldname" /><br />');
3999: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4000: }
1.361 albertel 4001: $r->print('</form>');
1.334 banghart 4002: }
1.416 jms 4003:
4004:
4005:
1.259 banghart 4006: sub setrestrictmeta {
1.240 banghart 4007: my ($r)=@_;
1.242 banghart 4008: my $next_meta;
1.244 banghart 4009: my $output;
1.245 banghart 4010: my $item_num;
1.246 banghart 4011: my $put_result;
1.414 droeschl 4012: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
1.473 amueller 4013: text=>"Restrict Metadata"});
1.280 albertel 4014: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4015: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4016: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4017: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4018: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4019: my $save_field = '';
1.259 banghart 4020: if ($env{'form.restrictmeta'}) {
1.254 banghart 4021: foreach my $field (sort(keys(%env))) {
1.252 banghart 4022: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4023: my $options;
1.252 banghart 4024: my $meta_field = $1;
4025: my $meta_key = $2;
1.253 banghart 4026: if ($save_field ne $meta_field) {
1.252 banghart 4027: $save_field = $meta_field;
1.473 amueller 4028: if ($env{'form.'.$meta_field.'_stuadd'}) {
4029: $options.='stuadd,';
4030: }
4031: if ($env{'form.'.$meta_field.'_choices'}) {
4032: $options.='choices,';
4033: }
4034: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
4035: $options.='onlyone,';
4036: }
4037: if ($env{'form.'.$meta_field.'_active'}) {
4038: $options.='active,';
4039: }
4040: if ($env{'form.'.$meta_field.'_deleted'}) {
4041: $options.='deleted,';
4042: }
1.259 banghart 4043: my $name = $save_field;
1.253 banghart 4044: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4045: {'metadata.'.$meta_field.'.options'=>$options,
4046: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4047: },$dom,$crs);
1.252 banghart 4048: }
4049: }
4050: }
4051: }
1.296 albertel 4052: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.473 amueller 4053: {'freshen_cache' => 1});
1.335 banghart 4054: # Get the default metadata fields
1.258 albertel 4055: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4056: # Now get possible added metadata fields
1.357 raeburn 4057: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4058: my $row_alt = 1;
1.347 banghart 4059: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4060: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4061: if ($field ne 'courserestricted') {
1.346 banghart 4062: $row_alt = $row_alt ? 0 : 1;
1.473 amueller 4063: $output.= &output_row($r, $field, $metadata_fields{$field});
4064: }
1.255 banghart 4065: }
1.351 banghart 4066: my $buttons = (<<ENDButtons);
4067: <input type="submit" name="restrictmeta" value="Save" />
4068: </form><br />
4069: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4070: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4071: </form>
4072: <br />
4073: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4074: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4075: ENDButtons
1.337 banghart 4076: my $added_flag = 1;
1.335 banghart 4077: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4078: $row_alt = $row_alt ? 0 : 1;
4079: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4080: }
1.347 banghart 4081: $output .= &Apache::loncommon::end_data_table();
1.446 bisitz 4082: $r->print(<<ENDenv);
1.259 banghart 4083: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4084: $output
1.351 banghart 4085: $buttons
1.340 banghart 4086: </form>
1.244 banghart 4087: ENDenv
1.280 albertel 4088: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4089: return 'ok';
4090: }
1.416 jms 4091:
4092:
4093:
1.335 banghart 4094: sub get_added_meta_fieldnames {
1.357 raeburn 4095: my ($cid) = @_;
1.335 banghart 4096: my %fields;
4097: foreach my $key(%env) {
1.357 raeburn 4098: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4099: my $field_name = $1;
4100: my ($display_field_name) = $env{$key};
4101: $fields{$field_name} = $display_field_name;
4102: }
4103: }
4104: return \%fields;
4105: }
1.416 jms 4106:
4107:
4108:
1.339 banghart 4109: sub get_deleted_meta_fieldnames {
1.357 raeburn 4110: my ($cid) = @_;
1.339 banghart 4111: my %fields;
4112: foreach my $key(%env) {
1.357 raeburn 4113: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4114: my $field_name = $1;
4115: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4116: my ($display_field_name) = $env{$key};
4117: $fields{$field_name} = $display_field_name;
4118: }
4119: }
4120: }
4121: return \%fields;
4122: }
1.220 www 4123: sub defaultsetter {
1.280 albertel 4124: my ($r) = @_;
4125:
1.414 droeschl 4126: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
1.473 amueller 4127: text=>"Set Defaults"});
1.446 bisitz 4128: my $start_page =
1.473 amueller 4129: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4130: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.507 www 4131: $r->print($start_page.$breadcrumbs);
4132: $r->print('<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">');
1.280 albertel 4133:
4134: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4135: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4136: my @ids=();
4137: my %typep=();
4138: my %keyp=();
4139: my %allparms=();
4140: my %allparts=();
4141: my %allmaps=();
4142: my %mapp=();
4143: my %symbp=();
4144: my %maptitles=();
4145: my %uris=();
4146: my %keyorder=&standardkeyorder();
4147: my %defkeytype=();
4148:
1.446 bisitz 4149: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 4150: \%mapp, \%symbp,\%maptitles,\%uris,
4151: \%keyorder,\%defkeytype);
1.224 www 4152: if ($env{'form.storerules'}) {
1.473 amueller 4153: my %newrules=();
4154: my @delrules=();
4155: my %triggers=();
4156: foreach my $key (keys(%env)) {
1.225 albertel 4157: if ($key=~/^form\.(\w+)\_action$/) {
1.473 amueller 4158: my $tempkey=$1;
4159: my $action=$env{$key};
1.226 www 4160: if ($action) {
1.473 amueller 4161: $newrules{$tempkey.'_action'}=$action;
4162: if ($action ne 'default') {
4163: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4164: $triggers{$whichparm}.=$tempkey.':';
4165: }
4166: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
4167: if (&isdateparm($defkeytype{$tempkey})) {
4168: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
4169: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4170: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4171: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4172: } else {
4173: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
4174: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
4175: }
4176: } else {
4177: push(@delrules,$tempkey.'_action');
4178: push(@delrules,$tempkey.'_type');
4179: push(@delrules,$tempkey.'_hours');
4180: push(@delrules,$tempkey.'_min');
4181: push(@delrules,$tempkey.'_sec');
4182: push(@delrules,$tempkey.'_value');
4183: }
4184: }
4185: }
4186: foreach my $key (keys %allparms) {
4187: $newrules{$key.'_triggers'}=$triggers{$key};
4188: }
4189: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4190: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4191: &resetrulescache();
1.224 www 4192: }
1.227 www 4193: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
1.473 amueller 4194: 'hours' => 'Hours',
4195: 'min' => 'Minutes',
4196: 'sec' => 'Seconds',
4197: 'yes' => 'Yes',
4198: 'no' => 'No');
1.222 www 4199: my @standardoptions=('','default');
4200: my @standarddisplay=('',&mt('Default value when manually setting'));
4201: my @dateoptions=('','default');
4202: my @datedisplay=('',&mt('Default value when manually setting'));
4203: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4204: unless ($tempkey) { next; }
4205: push @standardoptions,'when_setting_'.$tempkey;
4206: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4207: if (&isdateparm($defkeytype{$tempkey})) {
4208: push @dateoptions,'later_than_'.$tempkey;
4209: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4210: push @dateoptions,'earlier_than_'.$tempkey;
4211: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4212: }
1.222 www 4213: }
1.231 www 4214: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
1.473 amueller 4215: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4216: $r->print("\n".&Apache::loncommon::start_data_table().
1.473 amueller 4217: &Apache::loncommon::start_data_table_header_row().
4218: "<th>".&mt('Rule for parameter').'</th><th>'.
4219: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4220: &Apache::loncommon::end_data_table_header_row());
1.221 www 4221: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4222: unless ($tempkey) { next; }
4223: $r->print("\n".&Apache::loncommon::start_data_table_row().
4224: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
4225: my $action=&rulescache($tempkey.'_action');
4226: $r->print('<select name="'.$tempkey.'_action">');
4227: if (&isdateparm($defkeytype{$tempkey})) {
4228: for (my $i=0;$i<=$#dateoptions;$i++) {
4229: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4230: $r->print("\n<option value='$dateoptions[$i]'".
4231: ($dateoptions[$i] eq $action?' selected="selected"':'').
4232: ">$datedisplay[$i]</option>");
4233: }
4234: } else {
4235: for (my $i=0;$i<=$#standardoptions;$i++) {
4236: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4237: $r->print("\n<option value='$standardoptions[$i]'".
4238: ($standardoptions[$i] eq $action?' selected="selected"':'').
4239: ">$standarddisplay[$i]</option>");
4240: }
4241: }
4242: $r->print('</select>');
4243: unless (&isdateparm($defkeytype{$tempkey})) {
4244: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4245: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4246: }
4247: $r->print("\n</td><td>\n");
1.222 www 4248:
1.221 www 4249: if (&isdateparm($defkeytype{$tempkey})) {
1.473 amueller 4250: my $days=&rulescache($tempkey.'_days');
4251: my $hours=&rulescache($tempkey.'_hours');
4252: my $min=&rulescache($tempkey.'_min');
4253: my $sec=&rulescache($tempkey.'_sec');
4254: $r->print(<<ENDINPUTDATE);
1.227 www 4255: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4256: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4257: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4258: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4259: ENDINPUTDATE
1.473 amueller 4260: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4261: my $yeschecked='';
4262: my $nochecked='';
1.444 bisitz 4263: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
4264: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
1.222 www 4265:
1.473 amueller 4266: $r->print(<<ENDYESNO);
1.444 bisitz 4267: <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
4268: <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
1.221 www 4269: ENDYESNO
4270: } else {
1.473 amueller 4271: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
4272: }
1.318 albertel 4273: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4274: }
1.318 albertel 4275: $r->print(&Apache::loncommon::end_data_table().
1.473 amueller 4276: "\n".'<input type="submit" name="storerules" value="'.
1.507 www 4277: &mt('Save').'" /></form>'."\n");
4278: $r->print(&Apache::loncommon::end_page());
1.220 www 4279: return;
4280: }
1.193 albertel 4281:
1.290 www 4282: sub components {
1.330 albertel 4283: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4284:
4285: if ($typeflag) {
1.473 amueller 4286: $key=~s/\.type$//;
1.290 www 4287: }
1.330 albertel 4288:
4289: my ($middle,$part,$name)=
1.473 amueller 4290: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4291: my $issection;
1.330 albertel 4292:
1.290 www 4293: my $section=&mt('All Students');
4294: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4295: $issection=$1;
4296: $section=&mt('Group/Section').': '.$issection;
4297: $middle=~s/^\[(.*)\]//;
1.290 www 4298: }
4299: $middle=~s/\.+$//;
4300: $middle=~s/^\.+//;
1.291 www 4301: if ($uname) {
1.473 amueller 4302: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4303: $issection='';
1.291 www 4304: }
1.316 albertel 4305: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.446 bisitz 4306: my $realmdescription=&mt('all resources');
1.290 www 4307: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4308: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
4309: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
1.304 www 4310: } elsif ($middle) {
1.473 amueller 4311: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
4312: $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>';
4313: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4314: }
1.291 www 4315: my $what=$part.'.'.$name;
1.330 albertel 4316: return ($realm,$section,$name,$part,
1.473 amueller 4317: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4318: }
1.293 www 4319:
1.328 albertel 4320: my %standard_parms;
1.469 raeburn 4321: my %standard_parms_types;
1.416 jms 4322:
1.328 albertel 4323: sub load_parameter_names {
4324: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4325: while (my $configline=<$config>) {
1.473 amueller 4326: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4327: chomp($configline);
4328: my ($short,$plain)=split(/:/,$configline);
4329: my (undef,$name,$type)=split(/\&/,$short,3);
4330: if ($type eq 'display') {
4331: $standard_parms{$name} = $plain;
1.469 raeburn 4332: } elsif ($type eq 'type') {
4333: $standard_parms_types{$name} = $plain;
4334: }
1.328 albertel 4335: }
4336: close($config);
4337: $standard_parms{'int_pos'} = 'Positive Integer';
4338: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4339: }
4340:
1.292 www 4341: sub standard_parameter_names {
4342: my ($name)=@_;
1.328 albertel 4343: if (!%standard_parms) {
1.473 amueller 4344: &load_parameter_names();
1.328 albertel 4345: }
1.292 www 4346: if ($standard_parms{$name}) {
1.473 amueller 4347: return $standard_parms{$name};
1.446 bisitz 4348: } else {
1.473 amueller 4349: return $name;
1.292 www 4350: }
4351: }
1.290 www 4352:
1.469 raeburn 4353: sub standard_parameter_types {
4354: my ($name)=@_;
4355: if (!%standard_parms_types) {
4356: &load_parameter_names();
4357: }
4358: if ($standard_parms_types{$name}) {
4359: return $standard_parms_types{$name};
4360: }
4361: return;
4362: }
1.309 www 4363:
1.285 albertel 4364: sub parm_change_log {
1.284 www 4365: my ($r)=@_;
1.414 droeschl 4366: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.473 amueller 4367: text=>"Parameter Change Log"});
1.522 raeburn 4368: my $js = '<script type="text/javascript">'."\n".
4369: '// <![CDATA['."\n".
4370: &Apache::loncommon::display_filter_js('parmslog')."\n".
4371: '// ]]>'."\n".
4372: '</script>'."\n";
4373: $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
1.327 albertel 4374: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
1.286 www 4375: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
1.473 amueller 4376: $env{'course.'.$env{'request.course.id'}.'.domain'},
4377: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4378:
1.301 www 4379: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4380:
1.522 raeburn 4381: $r->print('<div class="LC_left_float">'.
4382: '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
4383: '<form action="/adm/parmset?action=parameterchangelog"
1.327 albertel 4384: method="post" name="parameterlog">');
1.446 bisitz 4385:
1.311 albertel 4386: my %saveable_parameters = ('show' => 'scalar',);
4387: &Apache::loncommon::store_course_settings('parameter_log',
4388: \%saveable_parameters);
4389: &Apache::loncommon::restore_course_settings('parameter_log',
4390: \%saveable_parameters);
1.522 raeburn 4391: $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
4392: '<input type="submit" value="'.&mt('Display').'" />'.
4393: '</form></fieldset></div><br clear="all" />');
1.301 www 4394:
1.291 www 4395: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
1.473 amueller 4396: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4397: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1.473 amueller 4398: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4399: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4400: &Apache::loncommon::end_data_table_header_row());
1.309 www 4401: my $shown=0;
1.349 www 4402: my $folder='';
4403: if ($env{'form.displayfilter'} eq 'currentfolder') {
1.473 amueller 4404: my $last='';
4405: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4406: &GDBM_READER(),0640)) {
4407: $last=$hash{'last_known'};
4408: untie(%hash);
4409: }
4410: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
1.349 www 4411: }
1.446 bisitz 4412: foreach my $id (sort
1.473 amueller 4413: {
4414: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4415: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4416: }
4417: my $aid = (split('00000',$a))[-1];
4418: my $bid = (split('00000',$b))[-1];
4419: return $bid<=>$aid;
4420: } (keys(%parmlog))) {
1.294 www 4421: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.473 amueller 4422: my $count = 0;
4423: my $time =
4424: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
4425: my $plainname =
4426: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4427: $parmlog{$id}{'exe_udom'});
4428: my $about_me_link =
4429: &Apache::loncommon::aboutmewrapper($plainname,
4430: $parmlog{$id}{'exe_uname'},
4431: $parmlog{$id}{'exe_udom'});
4432: my $send_msg_link='';
4433: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4434: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
4435: $send_msg_link ='<br />'.
4436: &Apache::loncommon::messagewrapper(&mt('Send message'),
4437: $parmlog{$id}{'exe_uname'},
4438: $parmlog{$id}{'exe_udom'});
4439: }
4440: my $row_start=&Apache::loncommon::start_data_table_row();
4441: my $makenewrow=0;
4442: my %istype=();
4443: my $output;
4444: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4445: my $value=$parmlog{$id}{'logentry'}{$changed};
1.473 amueller 4446: my $typeflag = ($changed =~/\.type$/ &&
4447: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4448: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.473 amueller 4449: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
4450: if ($env{'form.displayfilter'} eq 'currentfolder') {
4451: if ($folder) {
4452: if ($middle!~/^\Q$folder\E/) { next; }
4453: }
4454: }
4455: if ($typeflag) {
4456: $istype{$parmname}=$value;
4457: if (!$env{'form.includetypes'}) { next; }
4458: }
4459: $count++;
4460: if ($makenewrow) {
4461: $output .= $row_start;
4462: } else {
4463: $makenewrow=1;
4464: }
1.470 raeburn 4465: my $parmitem = &standard_parameter_names($parmname);
1.473 amueller 4466: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
4467: &mt($parmitem).'</td><td>'.
4468: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
4469: my $stillactive=0;
4470: if ($parmlog{$id}{'delflag'}) {
4471: $output .= &mt('Deleted');
4472: } else {
4473: if ($typeflag) {
1.470 raeburn 4474: my $parmitem = &standard_parameter_names($value);
4475: $parmitem = &mt($parmitem);
1.473 amueller 4476: $output .= &mt('Type: [_1]',$parmitem);
4477: } else {
4478: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4479: $uname,$udom,$issection,$issection,$courseopt);
1.469 raeburn 4480: my $showvalue = $value;
4481: if ($istype{$parmname} eq '') {
4482: my $type = &standard_parameter_types($parmname);
4483: if ($type ne '') {
4484: if (&isdateparm($type)) {
4485: $showvalue =
4486: &Apache::lonlocal::locallocaltime($value);
4487: }
4488: }
4489: } else {
1.473 amueller 4490: if (&isdateparm($istype{$parmname})) {
4491: $showvalue =
1.469 raeburn 4492: &Apache::lonlocal::locallocaltime($value);
1.473 amueller 4493: }
1.469 raeburn 4494: }
4495: $output .= $showvalue;
1.473 amueller 4496: if ($value ne $all[$level]) {
4497: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
4498: } else {
4499: $stillactive=1;
4500: }
4501: }
4502: }
4503: $output .= '</td><td>';
1.470 raeburn 4504:
1.473 amueller 4505: if ($stillactive) {
1.470 raeburn 4506: my $parmitem = &standard_parameter_names($parmname);
4507: $parmitem = &mt($parmitem);
1.473 amueller 4508: my $title=&mt('Changed [_1]',$parmitem);
1.471 raeburn 4509: my $description=&mt('Changed [_1] for [_2] to [_3]',
4510: $parmitem,$realmdescription,
1.473 amueller 4511: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
4512: if (($uname) && ($udom)) {
4513: $output .=
4514: &Apache::loncommon::messagewrapper('Notify User',
4515: $uname,$udom,$title,
4516: $description);
4517: } else {
4518: $output .=
4519: &Apache::lonrss::course_blog_link($id,$title,
4520: $description);
4521: }
4522: }
4523: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4524: }
1.349 www 4525: if ($env{'form.displayfilter'} eq 'containing') {
1.473 amueller 4526: my $wholeentry=$about_me_link.':'.
4527: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4528: $output;
4529: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4530: }
1.349 www 4531: if ($count) {
1.473 amueller 4532: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4533: <td rowspan="'.$count.'">'.$about_me_link.
1.473 amueller 4534: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4535: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4536: $send_msg_link.'</td>'.$output);
4537: $shown++;
4538: }
4539: if (!($env{'form.show'} eq &mt('all')
4540: || $shown<=$env{'form.show'})) { last; }
1.286 www 4541: }
1.301 www 4542: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4543: $r->print(&Apache::loncommon::end_page());
4544: }
4545:
1.437 raeburn 4546: sub update_slots {
4547: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
4548: my %slot=&Apache::lonnet::get_slot($slot_name);
4549: if (!keys(%slot)) {
4550: return 'error: slot does not exist';
4551: }
4552: my $max=$slot{'maxspace'};
4553: if (!defined($max)) { $max=99999; }
4554:
4555: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
4556: "^$slot_name\0");
4557: my ($tmp)=%consumed;
4558: if ($tmp=~/^error: 2 / ) {
4559: return 'error: unable to determine current slot status';
4560: }
4561: my $last=0;
4562: foreach my $key (keys(%consumed)) {
4563: my $num=(split('\0',$key))[1];
4564: if ($num > $last) { $last=$num; }
4565: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4566: return 'ok';
4567: }
4568: }
4569:
4570: if (scalar(keys(%consumed)) >= $max) {
4571: return 'error: no space left in slot';
4572: }
4573: my $wanted=$last+1;
4574:
4575: my %reservation=('name' => $uname.':'.$udom,
4576: 'timestamp' => time,
4577: 'symb' => $symb);
4578:
4579: my $success=&Apache::lonnet::newput('slot_reservations',
4580: {"$slot_name\0$wanted" =>
4581: \%reservation},
4582: $cdom, $cnum);
1.438 raeburn 4583: if ($success eq 'ok') {
4584: my %storehash = (
4585: symb => $symb,
4586: slot => $slot_name,
4587: action => 'reserve',
4588: context => 'parameter',
4589: );
1.522.2.3 raeburn 4590: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.438 raeburn 4591: '',$uname,$udom,$cnum,$cdom);
4592:
1.522.2.3 raeburn 4593: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 4594: '',$uname,$udom,$uname,$udom);
4595: }
1.437 raeburn 4596: return $success;
4597: }
4598:
4599: sub delete_slots {
4600: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
4601: my $delresult;
4602: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
4603: $cnum, "^$slot_name\0");
4604: if (&Apache::lonnet::error(%consumed)) {
4605: return 'error: unable to determine current slot status';
4606: }
4607: my ($tmp)=%consumed;
4608: if ($tmp=~/^error: 2 /) {
4609: return 'error: unable to determine current slot status';
4610: }
4611: foreach my $key (keys(%consumed)) {
4612: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4613: my $num=(split('\0',$key))[1];
4614: my $entry = $slot_name.'\0'.$num;
4615: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
4616: $cdom,$cnum);
4617: if ($delresult eq 'ok') {
4618: my %storehash = (
4619: symb => $symb,
4620: slot => $slot_name,
4621: action => 'release',
4622: context => 'parameter',
4623: );
1.522.2.3 raeburn 4624: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.437 raeburn 4625: 1,$uname,$udom,$cnum,$cdom);
1.522.2.3 raeburn 4626: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.438 raeburn 4627: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 4628: }
4629: }
4630: }
4631: return $delresult;
4632: }
4633:
1.355 albertel 4634: sub check_for_course_info {
4635: my $navmap = Apache::lonnavmaps::navmap->new();
4636: return 1 if ($navmap);
4637: return 0;
4638: }
4639:
1.514 raeburn 4640: sub parameter_release_vars {
1.504 raeburn 4641: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4642: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
4643: my $chostname = &Apache::lonnet::hostname($chome);
4644: my ($cmajor,$cminor) =
4645: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
4646: return ($chostname,$cmajor,$cminor);
4647: }
4648:
1.514 raeburn 4649: sub parameter_releasecheck {
4650: my ($name,$value,$needsrelease,$chostname,$cmajor,$cminor) = @_;
1.504 raeburn 4651: my $needsnewer;
4652: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
4653: if (($cmajor < $needsmajor) ||
4654: ($cmajor == $needsmajor && $cminor < $needsminor)) {
4655: $needsnewer = 1;
4656: } else {
1.514 raeburn 4657: &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
1.504 raeburn 4658: }
4659: return $needsnewer;
4660: }
4661:
4662: sub oldversion_warning {
1.514 raeburn 4663: my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
1.504 raeburn 4664: my $desc;
1.514 raeburn 4665: my %stringtypes = (
1.519 raeburn 4666: type => 'string_questiontype',
4667: lenient => 'string_lenient',
4668: retrypartial => 'string_yesno',
1.521 raeburn 4669: discussvote => 'string_discussvote',
1.522.2.7 raeburn 4670: examcode => 'string_examcode',
1.514 raeburn 4671: );
4672: if (exists($stringtypes{$name})) {
1.522.2.7 raeburn 4673: if ($name eq 'examcode') {
4674: $desc = $value;
4675: } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
1.514 raeburn 4676: foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
4677: next unless (ref($possibilities) eq 'ARRAY');
4678: my ($parmval, $description) = @{ $possibilities };
4679: if ($parmval eq $value) {
4680: $desc = $description;
4681: last;
4682: }
1.504 raeburn 4683: }
4684: }
4685: }
1.514 raeburn 4686: my $standard_name = &standard_parameter_names($name);
1.504 raeburn 4687: return '<p class="LC_warning">'.
1.514 raeburn 4688: &mt('[_1] was [_2]not[_3] set to [_4].',
4689: $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
1.504 raeburn 4690: &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
4691: $cmajor.'.'.$cminor,$chostname,
4692: $needsrelease).
4693: '</p>';
4694: }
1.259 banghart 4695:
1.30 www 4696: sub handler {
1.43 albertel 4697: my $r=shift;
1.30 www 4698:
1.376 albertel 4699: &reset_caches();
4700:
1.414 droeschl 4701: &Apache::loncommon::content_type($r,'text/html');
4702: $r->send_http_header;
4703: return OK if $r->header_only;
4704:
1.193 albertel 4705: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.473 amueller 4706: ['action','state',
1.205 www 4707: 'pres_marker',
4708: 'pres_value',
1.206 www 4709: 'pres_type',
1.506 www 4710: 'filter','part',
1.390 www 4711: 'udom','uname','symb','serial','timebase']);
1.131 www 4712:
1.83 bowersj2 4713:
1.193 albertel 4714: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4715: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
1.522.2.3 raeburn 4716: text=>"Content and Problem Settings",
1.473 amueller 4717: faq=>10,
4718: bug=>'Instructor Interface',
1.442 droeschl 4719: help =>
4720: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 4721:
1.30 www 4722: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4723: my $parm_permission =
1.473 amueller 4724: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
4725: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
4726: $env{'request.course.sec'}));
1.355 albertel 4727: my $exists = &check_for_course_info();
4728:
4729: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4730: #
4731: # Main switch on form.action and form.state, as appropriate
4732: #
4733: # Check first if coming from someone else headed directly for
4734: # the table mode
4735: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
1.473 amueller 4736: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
4737: &assessparms($r);
1.193 albertel 4738: } elsif (! exists($env{'form.action'})) {
4739: &print_main_menu($r,$parm_permission);
1.414 droeschl 4740: } elsif ($env{'form.action'} eq 'setoverview') {
1.473 amueller 4741: &overview($r);
4742: } elsif ($env{'form.action'} eq 'addmetadata') {
4743: &addmetafield($r);
4744: } elsif ($env{'form.action'} eq 'ordermetadata') {
4745: &order_meta_fields($r);
1.414 droeschl 4746: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.473 amueller 4747: &setrestrictmeta($r);
1.414 droeschl 4748: } elsif ($env{'form.action'} eq 'newoverview') {
1.473 amueller 4749: &newoverview($r);
1.414 droeschl 4750: } elsif ($env{'form.action'} eq 'setdefaults') {
1.473 amueller 4751: &defaultsetter($r);
4752: } elsif ($env{'form.action'} eq 'settable') {
4753: &assessparms($r);
1.414 droeschl 4754: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.473 amueller 4755: &parm_change_log($r);
1.414 droeschl 4756: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.473 amueller 4757: &clean_parameters($r);
1.414 droeschl 4758: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 4759: &date_shift_one($r);
1.414 droeschl 4760: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 4761: &date_shift_two($r);
1.446 bisitz 4762: }
1.43 albertel 4763: } else {
1.1 www 4764: # ----------------------------- Not in a course, or not allowed to modify parms
1.473 amueller 4765: if ($exists) {
4766: $env{'user.error.msg'}=
4767: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4768: } else {
4769: $env{'user.error.msg'}=
4770: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4771: }
4772: return HTTP_NOT_ACCEPTABLE;
1.43 albertel 4773: }
1.376 albertel 4774: &reset_caches();
4775:
1.43 albertel 4776: return OK;
1.1 www 4777: }
4778:
4779: 1;
4780: __END__
4781:
4782:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>