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