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