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