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