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