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