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