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