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