Annotation of loncom/interface/lonparmset.pm, revision 1.528
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.528 ! bisitz 4: # $Id: lonparmset.pm,v 1.527 2012/10/04 13:41:10 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);
2917: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
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'});
3601: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3602: $url,$resid,$map));
3603: }
3604: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
3605: $r->print('</td></tr>');
1.446 bisitz 3606:
1.473 amueller 3607: }
1.333 albertel 3608: }
3609: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.473 amueller 3610: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.507 www 3611: '</p></form>');
3612: &endSettingsScreen($r);
3613: $r->print(&Apache::loncommon::end_page());
1.333 albertel 3614: }
3615:
1.390 www 3616: sub date_shift_one {
3617: my ($r) = @_;
3618: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3619: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3620:
1.414 droeschl 3621: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 3622: text=>"Shifting Dates"});
1.390 www 3623: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3624: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 3625: $r->print($start_page.$breadcrumbs);
3626: &startSettingsScreen($r,'parmset');
1.390 www 3627: $r->print('<form name="shiftform" method="post">'.
3628: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3629: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3630: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
1.512 foxr 3631: &Apache::lonhtmlcommon::dshowerfuck.net
3632: ate_setter('shiftform',
1.390 www 3633: 'timeshifted',
3634: $env{'form.timebase'},,
3635: '').
3636: '</td></tr></table>'.
3637: '<input type="hidden" name="action" value="dateshift2" />'.
3638: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3639: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
1.507 www 3640: &endSettingsScreen($r);
1.390 www 3641: $r->print(&Apache::loncommon::end_page());
3642: }
3643:
3644: sub date_shift_two {
3645: my ($r) = @_;
3646: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3647: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.414 droeschl 3648: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 3649: text=>"Shifting Dates"});
1.390 www 3650: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3651: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 3652: $r->print($start_page.$breadcrumbs);
3653: &startSettingsScreen($r,'parmset');
1.390 www 3654: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3655: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3656: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3657: &Apache::lonlocal::locallocaltime($timeshifted)));
3658: my $delta=$timeshifted-$env{'form.timebase'};
3659: &dateshift($delta);
1.507 www 3660: &endSettingsScreen($r);
1.390 www 3661: $r->print(&Apache::loncommon::end_page());
3662: }
3663:
1.333 albertel 3664: sub parse_key {
3665: my ($key) = @_;
3666: my %data;
3667: my ($middle,$part,$name)=
1.473 amueller 3668: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.333 albertel 3669: $data{'scope_type'} = 'all';
3670: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 3671: $data{'scope'} = $1;
3672: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
3673: $data{'scope_type'} = 'user';
3674: $data{'scope'} = [$1,$2];
3675: } else {
3676: #FIXME check for group scope
3677: $data{'scope_type'} = 'section';
3678: }
3679: $middle=~s/^\[(.*)\]//;
1.333 albertel 3680: }
3681: $middle=~s/\.+$//;
3682: $middle=~s/^\.+//;
3683: $data{'realm_type'}='all';
3684: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 3685: $data{'realm'} = $1;
3686: $data{'realm_type'} = 'folder';
3687: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3688: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
1.333 albertel 3689: } elsif ($middle) {
1.473 amueller 3690: $data{'realm'} = $middle;
3691: $data{'realm_type'} = 'symb';
3692: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3693: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3694: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
1.333 albertel 3695: }
1.446 bisitz 3696:
1.333 albertel 3697: $data{'parameter_part'} = $part;
3698: $data{'parameter_name'} = $name;
3699:
3700: return %data;
3701: }
3702:
1.239 raeburn 3703:
1.416 jms 3704: sub header {
1.507 www 3705: return &Apache::loncommon::start_page('Settings');
1.416 jms 3706: }
1.193 albertel 3707:
3708:
3709:
3710: sub print_main_menu {
3711: my ($r,$parm_permission)=@_;
3712: #
1.414 droeschl 3713: $r->print(&header());
1.507 www 3714: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
3715: &startSettingsScreen($r,'parmset');
1.193 albertel 3716: $r->print(<<ENDMAINFORMHEAD);
3717: <form method="post" enctype="multipart/form-data"
3718: action="/adm/parmset" name="studentform">
3719: ENDMAINFORMHEAD
3720: #
1.195 albertel 3721: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3722: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3723: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3724: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.520 raeburn 3725: my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
3726: if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
3727: $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
3728: '/'.$env{'request.course.sec'});
3729: }
1.268 albertel 3730:
1.477 raeburn 3731: my $crstype = &Apache::loncommon::course_type();
3732: my $lc_crstype = lc($crstype);
1.417 droeschl 3733:
1.193 albertel 3734: my @menu =
1.507 www 3735: ( { categorytitle=>"Content Settings for this $crstype",
1.473 amueller 3736: items => [
3737: { linktext => 'Portfolio Metadata',
3738: url => '/adm/parmset?action=setrestrictmeta',
3739: permission => $parm_permission,
1.477 raeburn 3740: linktitle => "Restrict metadata for this $lc_crstype." ,
1.473 amueller 3741: icon =>'contact-new.png' ,
3742: },
3743: { linktext => 'Reset Student Access Times',
3744: url => '/adm/helper/resettimes.helper',
3745: permission => $mgr,
1.477 raeburn 3746: linktitle => "Reset access times for folders/maps, resources or the $lc_crstype." ,
1.473 amueller 3747: icon => 'start-here.png' ,
3748: },
1.520 raeburn 3749: { linktext => 'Blocking Communication/Resource Access',
3750: url => '/adm/setblock',
3751: permission => $dcm,
3752: linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
3753: icon => 'comblock.png',
3754: },
1.473 amueller 3755: { linktext => 'Set Parameter Setting Default Actions',
3756: url => '/adm/parmset?action=setdefaults',
3757: permission => $parm_permission,
3758: linktitle =>'Set default actions for parameters.' ,
3759: icon => 'folder-new.png' ,
3760: }]},
3761: { categorytitle => 'New and Existing Parameter Settings for Resources',
3762: items => [
3763: { linktext => 'Edit Resource Parameters - Helper Mode',
3764: url => '/adm/helper/parameter.helper',
3765: permission => $parm_permission,
3766: linktitle =>'Set/Modify resource parameters in helper mode.' ,
3767: icon => 'dialog-information.png' ,
3768: #help => 'Parameter_Helper',
3769: },
3770: { linktext => 'Edit Resource Parameters - Overview Mode',
3771: url => '/adm/parmset?action=newoverview',
3772: permission => $parm_permission,
3773: linktitle =>'Set/Modify resource parameters in overview mode.' ,
3774: icon => 'edit-find.png' ,
3775: #help => 'Parameter_Overview',
3776: },
3777: { linktext => 'Edit Resource Parameters - Table Mode',
3778: url => '/adm/parmset?action=settable',
3779: permission => $parm_permission,
3780: linktitle =>'Set/Modify resource parameters in table mode.' ,
3781: icon => 'edit-copy.png' ,
3782: #help => 'Table_Mode',
3783: }]},
1.417 droeschl 3784: { categorytitle => 'Existing Parameter Settings for Resources',
1.473 amueller 3785: items => [
3786: { linktext => 'Modify Resource Parameters - Overview Mode',
3787: url => '/adm/parmset?action=setoverview',
3788: permission => $parm_permission,
3789: linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
3790: icon => 'preferences-desktop-wallpaper.png' ,
3791: #help => 'Parameter_Overview',
3792: },
3793: { linktext => 'Change Log',
3794: url => '/adm/parmset?action=parameterchangelog',
3795: permission => $parm_permission,
1.477 raeburn 3796: linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
1.487 wenzelju 3797: icon => 'document-properties.png',
1.473 amueller 3798: }]}
1.193 albertel 3799: );
1.414 droeschl 3800: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.507 www 3801: &endSettingsScreen($r);
1.193 albertel 3802: return;
3803: }
1.414 droeschl 3804:
1.416 jms 3805:
3806:
1.252 banghart 3807: sub output_row {
1.347 banghart 3808: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3809: my $output;
1.263 banghart 3810: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3811: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3812: if (!defined($options)) {
1.254 banghart 3813: $options = 'active,stuadd';
1.261 banghart 3814: $values = '';
1.252 banghart 3815: }
1.337 banghart 3816: if (!($options =~ /deleted/)) {
3817: my @options= ( ['active', 'Show to student'],
1.418 schafran 3818: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 3819: ['choices','Provide choices for students to select from']);
1.473 amueller 3820: # ['onlyone','Student may select only one choice']);
1.337 banghart 3821: if ($added_flag) {
3822: push @options,['deleted', 'Delete Metadata Field'];
3823: }
1.351 banghart 3824: $output = &Apache::loncommon::start_data_table_row();
1.451 bisitz 3825: $output .= '<td><strong>'.$field_text.':</strong></td>';
1.351 banghart 3826: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3827: foreach my $opt (@options) {
1.473 amueller 3828: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3829: $output .= &Apache::loncommon::continue_data_table_row();
3830: $output .= '<td>'.(' ' x 5).'<label>
3831: <input type="checkbox" name="'.
3832: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3833: &mt($opt->[1]).'</label></td>';
3834: $output .= &Apache::loncommon::end_data_table_row();
3835: }
1.351 banghart 3836: $output .= &Apache::loncommon::continue_data_table_row();
1.451 bisitz 3837: $output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
1.351 banghart 3838: $output .= &Apache::loncommon::end_data_table_row();
3839: my $multiple_checked;
3840: my $single_checked;
3841: if ($options =~ m/onlyone/) {
1.422 bisitz 3842: $multiple_checked = '';
1.423 bisitz 3843: $single_checked = ' checked="checked"';
1.351 banghart 3844: } else {
1.423 bisitz 3845: $multiple_checked = ' checked="checked"';
1.422 bisitz 3846: $single_checked = '';
1.351 banghart 3847: }
1.473 amueller 3848: $output .= &Apache::loncommon::continue_data_table_row();
3849: $output .= '<td>'.(' ' x 10).'
3850: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
3851: '.&mt('Student may select multiple choices from list').'</td>';
3852: $output .= &Apache::loncommon::end_data_table_row();
3853: $output .= &Apache::loncommon::continue_data_table_row();
3854: $output .= '<td>'.(' ' x 10).'
3855: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
3856: '.&mt('Student may select only one choice from list').'</td>';
3857: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3858: }
3859: return ($output);
3860: }
1.416 jms 3861:
3862:
3863:
1.340 banghart 3864: sub order_meta_fields {
3865: my ($r)=@_;
3866: my $idx = 1;
3867: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3868: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3869: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 3870: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 3871: text=>"Add Metadata Field"});
1.345 banghart 3872: &Apache::lonhtmlcommon::add_breadcrumb
3873: ({href=>"/adm/parmset?action=setrestrictmeta",
3874: text=>"Restrict Metadata"},
3875: {text=>"Order Metadata"});
3876: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.507 www 3877: &startSettingsScreen($r,'parmset');
1.340 banghart 3878: if ($env{'form.storeorder'}) {
3879: my $newpos = $env{'form.newpos'} - 1;
3880: my $currentpos = $env{'form.currentpos'} - 1;
3881: my @neworder = ();
3882: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3883: my $i;
1.341 banghart 3884: if ($newpos > $currentpos) {
1.340 banghart 3885: # moving stuff up
3886: for ($i=0;$i<$currentpos;$i++) {
1.473 amueller 3887: $neworder[$i]=$oldorder[$i];
1.340 banghart 3888: }
3889: for ($i=$currentpos;$i<$newpos;$i++) {
1.473 amueller 3890: $neworder[$i]=$oldorder[$i+1];
1.340 banghart 3891: }
3892: $neworder[$newpos]=$oldorder[$currentpos];
3893: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
1.473 amueller 3894: $neworder[$i]=$oldorder[$i];
1.340 banghart 3895: }
3896: } else {
3897: # moving stuff down
1.473 amueller 3898: for ($i=0;$i<$newpos;$i++) {
3899: $neworder[$i]=$oldorder[$i];
3900: }
3901: $neworder[$newpos]=$oldorder[$currentpos];
3902: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3903: $neworder[$i]=$oldorder[$i-1];
3904: }
3905: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3906: $neworder[$i]=$oldorder[$i];
3907: }
1.340 banghart 3908: }
1.473 amueller 3909: my $ordered_fields = join ",", @neworder;
1.343 banghart 3910: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 3911: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.473 amueller 3912: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3913: }
1.357 raeburn 3914: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3915: my $ordered_fields;
1.340 banghart 3916: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3917: if (!@fields_in_order) {
3918: # no order found, pick sorted order then create metadata.addedorder key.
3919: foreach my $key (sort keys %$fields) {
3920: push @fields_in_order, $key;
1.341 banghart 3921: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3922: }
1.341 banghart 3923: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 3924: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3925: }
1.340 banghart 3926: $r->print('<table>');
3927: my $num_fields = scalar(@fields_in_order);
3928: foreach my $key (@fields_in_order) {
3929: $r->print('<tr><td>');
3930: $r->print('<form method="post" action="">');
3931: $r->print('<select name="newpos" onChange="this.form.submit()">');
3932: for (my $i = 1;$i le $num_fields;$i ++) {
3933: if ($i eq $idx) {
3934: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3935: } else {
3936: $r->print('<option value="'.$i.'">'.$i.'</option>');
3937: }
3938: }
3939: $r->print('</select></td><td>');
3940: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3941: $r->print('<input type="hidden" name="storeorder" value="true" />');
3942: $r->print('</form>');
3943: $r->print($$fields{$key}.'</td></tr>');
3944: $idx ++;
3945: }
3946: $r->print('</table>');
1.507 www 3947: &endSettingsScreen($r);
1.340 banghart 3948: return 'ok';
3949: }
1.416 jms 3950:
3951:
1.359 banghart 3952: sub continue {
3953: my $output;
3954: $output .= '<form action="" method="post">';
3955: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3956: $output .= '<input type="submit" value="Continue" />';
3957: return ($output);
3958: }
1.416 jms 3959:
3960:
1.334 banghart 3961: sub addmetafield {
3962: my ($r)=@_;
1.414 droeschl 3963: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 3964: text=>"Add Metadata Field"});
1.334 banghart 3965: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3966: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.507 www 3967: &startSettingsScreen($r,'parmset');
1.335 banghart 3968: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3969: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 3970: if (exists($env{'form.undelete'})) {
1.358 banghart 3971: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 3972: foreach my $meta_field(@meta_fields) {
3973: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
3974: $options =~ s/deleted//;
3975: $options =~ s/,,/,/;
3976: my $put_result = &Apache::lonnet::put('environment',
3977: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
1.446 bisitz 3978:
1.339 banghart 3979: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
3980: }
1.359 banghart 3981: $r->print(&continue());
1.339 banghart 3982: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 3983: my $meta_field = $env{'form.fieldname'};
3984: my $display_field = $env{'form.fieldname'};
3985: $meta_field =~ s/\W/_/g;
1.338 banghart 3986: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 3987: my $put_result = &Apache::lonnet::put('environment',
3988: {'metadata.'.$meta_field.'.values'=>"",
3989: 'metadata.'.$meta_field.'.added'=>"$display_field",
3990: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 3991: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
3992: $r->print(&continue());
1.335 banghart 3993: } else {
1.357 raeburn 3994: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 3995: if ($fields) {
3996: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
3997: $r->print('<form method="post" action="">');
3998: foreach my $key(keys(%$fields)) {
1.358 banghart 3999: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 4000: }
4001: $r->print('<input type="submit" name="undelete" value="Undelete" />');
4002: $r->print('</form>');
4003: }
4004: $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 4005: $r->print('<input type="text" name="fieldname" /><br />');
4006: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4007: }
1.361 albertel 4008: $r->print('</form>');
1.507 www 4009: &endSettingsScreen($r);
1.334 banghart 4010: }
1.416 jms 4011:
4012:
4013:
1.259 banghart 4014: sub setrestrictmeta {
1.240 banghart 4015: my ($r)=@_;
1.242 banghart 4016: my $next_meta;
1.244 banghart 4017: my $output;
1.245 banghart 4018: my $item_num;
1.246 banghart 4019: my $put_result;
1.414 droeschl 4020: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
1.473 amueller 4021: text=>"Restrict Metadata"});
1.280 albertel 4022: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4023: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.507 www 4024: &startSettingsScreen($r,'parmset');
1.240 banghart 4025: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4026: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 4027: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4028: my $save_field = '';
1.259 banghart 4029: if ($env{'form.restrictmeta'}) {
1.254 banghart 4030: foreach my $field (sort(keys(%env))) {
1.252 banghart 4031: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4032: my $options;
1.252 banghart 4033: my $meta_field = $1;
4034: my $meta_key = $2;
1.253 banghart 4035: if ($save_field ne $meta_field) {
1.252 banghart 4036: $save_field = $meta_field;
1.473 amueller 4037: if ($env{'form.'.$meta_field.'_stuadd'}) {
4038: $options.='stuadd,';
4039: }
4040: if ($env{'form.'.$meta_field.'_choices'}) {
4041: $options.='choices,';
4042: }
4043: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
4044: $options.='onlyone,';
4045: }
4046: if ($env{'form.'.$meta_field.'_active'}) {
4047: $options.='active,';
4048: }
4049: if ($env{'form.'.$meta_field.'_deleted'}) {
4050: $options.='deleted,';
4051: }
1.259 banghart 4052: my $name = $save_field;
1.253 banghart 4053: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4054: {'metadata.'.$meta_field.'.options'=>$options,
4055: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4056: },$dom,$crs);
1.252 banghart 4057: }
4058: }
4059: }
4060: }
1.296 albertel 4061: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.473 amueller 4062: {'freshen_cache' => 1});
1.335 banghart 4063: # Get the default metadata fields
1.258 albertel 4064: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4065: # Now get possible added metadata fields
1.357 raeburn 4066: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4067: my $row_alt = 1;
1.347 banghart 4068: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4069: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4070: if ($field ne 'courserestricted') {
1.346 banghart 4071: $row_alt = $row_alt ? 0 : 1;
1.473 amueller 4072: $output.= &output_row($r, $field, $metadata_fields{$field});
4073: }
1.255 banghart 4074: }
1.351 banghart 4075: my $buttons = (<<ENDButtons);
4076: <input type="submit" name="restrictmeta" value="Save" />
4077: </form><br />
4078: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4079: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4080: </form>
4081: <br />
4082: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4083: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4084: ENDButtons
1.337 banghart 4085: my $added_flag = 1;
1.335 banghart 4086: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4087: $row_alt = $row_alt ? 0 : 1;
4088: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4089: }
1.347 banghart 4090: $output .= &Apache::loncommon::end_data_table();
1.446 bisitz 4091: $r->print(<<ENDenv);
1.259 banghart 4092: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4093: $output
1.351 banghart 4094: $buttons
1.340 banghart 4095: </form>
1.244 banghart 4096: ENDenv
1.507 www 4097: &endSettingsScreen($r);
1.280 albertel 4098: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4099: return 'ok';
4100: }
1.416 jms 4101:
4102:
4103:
1.335 banghart 4104: sub get_added_meta_fieldnames {
1.357 raeburn 4105: my ($cid) = @_;
1.335 banghart 4106: my %fields;
4107: foreach my $key(%env) {
1.357 raeburn 4108: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4109: my $field_name = $1;
4110: my ($display_field_name) = $env{$key};
4111: $fields{$field_name} = $display_field_name;
4112: }
4113: }
4114: return \%fields;
4115: }
1.416 jms 4116:
4117:
4118:
1.339 banghart 4119: sub get_deleted_meta_fieldnames {
1.357 raeburn 4120: my ($cid) = @_;
1.339 banghart 4121: my %fields;
4122: foreach my $key(%env) {
1.357 raeburn 4123: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4124: my $field_name = $1;
4125: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4126: my ($display_field_name) = $env{$key};
4127: $fields{$field_name} = $display_field_name;
4128: }
4129: }
4130: }
4131: return \%fields;
4132: }
1.220 www 4133: sub defaultsetter {
1.280 albertel 4134: my ($r) = @_;
4135:
1.414 droeschl 4136: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
1.473 amueller 4137: text=>"Set Defaults"});
1.446 bisitz 4138: my $start_page =
1.473 amueller 4139: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4140: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.507 www 4141: $r->print($start_page.$breadcrumbs);
4142: &startSettingsScreen($r,'parmset');
4143: $r->print('<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">');
1.280 albertel 4144:
4145: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4146: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4147: my @ids=();
4148: my %typep=();
4149: my %keyp=();
4150: my %allparms=();
4151: my %allparts=();
4152: my %allmaps=();
4153: my %mapp=();
4154: my %symbp=();
4155: my %maptitles=();
4156: my %uris=();
4157: my %keyorder=&standardkeyorder();
4158: my %defkeytype=();
4159:
1.446 bisitz 4160: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 4161: \%mapp, \%symbp,\%maptitles,\%uris,
4162: \%keyorder,\%defkeytype);
1.224 www 4163: if ($env{'form.storerules'}) {
1.473 amueller 4164: my %newrules=();
4165: my @delrules=();
4166: my %triggers=();
4167: foreach my $key (keys(%env)) {
1.225 albertel 4168: if ($key=~/^form\.(\w+)\_action$/) {
1.473 amueller 4169: my $tempkey=$1;
4170: my $action=$env{$key};
1.226 www 4171: if ($action) {
1.473 amueller 4172: $newrules{$tempkey.'_action'}=$action;
4173: if ($action ne 'default') {
4174: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4175: $triggers{$whichparm}.=$tempkey.':';
4176: }
4177: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
4178: if (&isdateparm($defkeytype{$tempkey})) {
4179: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
4180: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4181: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4182: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4183: } else {
4184: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
4185: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
4186: }
4187: } else {
4188: push(@delrules,$tempkey.'_action');
4189: push(@delrules,$tempkey.'_type');
4190: push(@delrules,$tempkey.'_hours');
4191: push(@delrules,$tempkey.'_min');
4192: push(@delrules,$tempkey.'_sec');
4193: push(@delrules,$tempkey.'_value');
4194: }
4195: }
4196: }
4197: foreach my $key (keys %allparms) {
4198: $newrules{$key.'_triggers'}=$triggers{$key};
4199: }
4200: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4201: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4202: &resetrulescache();
1.224 www 4203: }
1.227 www 4204: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
1.473 amueller 4205: 'hours' => 'Hours',
4206: 'min' => 'Minutes',
4207: 'sec' => 'Seconds',
4208: 'yes' => 'Yes',
4209: 'no' => 'No');
1.222 www 4210: my @standardoptions=('','default');
4211: my @standarddisplay=('',&mt('Default value when manually setting'));
4212: my @dateoptions=('','default');
4213: my @datedisplay=('',&mt('Default value when manually setting'));
4214: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4215: unless ($tempkey) { next; }
4216: push @standardoptions,'when_setting_'.$tempkey;
4217: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4218: if (&isdateparm($defkeytype{$tempkey})) {
4219: push @dateoptions,'later_than_'.$tempkey;
4220: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4221: push @dateoptions,'earlier_than_'.$tempkey;
4222: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4223: }
1.222 www 4224: }
1.231 www 4225: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
1.473 amueller 4226: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4227: $r->print("\n".&Apache::loncommon::start_data_table().
1.473 amueller 4228: &Apache::loncommon::start_data_table_header_row().
4229: "<th>".&mt('Rule for parameter').'</th><th>'.
4230: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4231: &Apache::loncommon::end_data_table_header_row());
1.221 www 4232: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4233: unless ($tempkey) { next; }
4234: $r->print("\n".&Apache::loncommon::start_data_table_row().
4235: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
4236: my $action=&rulescache($tempkey.'_action');
4237: $r->print('<select name="'.$tempkey.'_action">');
4238: if (&isdateparm($defkeytype{$tempkey})) {
4239: for (my $i=0;$i<=$#dateoptions;$i++) {
4240: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4241: $r->print("\n<option value='$dateoptions[$i]'".
4242: ($dateoptions[$i] eq $action?' selected="selected"':'').
4243: ">$datedisplay[$i]</option>");
4244: }
4245: } else {
4246: for (my $i=0;$i<=$#standardoptions;$i++) {
4247: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4248: $r->print("\n<option value='$standardoptions[$i]'".
4249: ($standardoptions[$i] eq $action?' selected="selected"':'').
4250: ">$standarddisplay[$i]</option>");
4251: }
4252: }
4253: $r->print('</select>');
4254: unless (&isdateparm($defkeytype{$tempkey})) {
4255: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4256: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4257: }
4258: $r->print("\n</td><td>\n");
1.222 www 4259:
1.221 www 4260: if (&isdateparm($defkeytype{$tempkey})) {
1.473 amueller 4261: my $days=&rulescache($tempkey.'_days');
4262: my $hours=&rulescache($tempkey.'_hours');
4263: my $min=&rulescache($tempkey.'_min');
4264: my $sec=&rulescache($tempkey.'_sec');
4265: $r->print(<<ENDINPUTDATE);
1.227 www 4266: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4267: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4268: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4269: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4270: ENDINPUTDATE
1.473 amueller 4271: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4272: my $yeschecked='';
4273: my $nochecked='';
1.444 bisitz 4274: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
4275: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
1.222 www 4276:
1.473 amueller 4277: $r->print(<<ENDYESNO);
1.444 bisitz 4278: <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
4279: <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
1.221 www 4280: ENDYESNO
4281: } else {
1.473 amueller 4282: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
4283: }
1.318 albertel 4284: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4285: }
1.318 albertel 4286: $r->print(&Apache::loncommon::end_data_table().
1.473 amueller 4287: "\n".'<input type="submit" name="storerules" value="'.
1.507 www 4288: &mt('Save').'" /></form>'."\n");
4289: &endSettingsScreen($r);
4290: $r->print(&Apache::loncommon::end_page());
1.220 www 4291: return;
4292: }
1.193 albertel 4293:
1.290 www 4294: sub components {
1.330 albertel 4295: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4296:
4297: if ($typeflag) {
1.473 amueller 4298: $key=~s/\.type$//;
1.290 www 4299: }
1.330 albertel 4300:
4301: my ($middle,$part,$name)=
1.473 amueller 4302: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4303: my $issection;
1.330 albertel 4304:
1.290 www 4305: my $section=&mt('All Students');
4306: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4307: $issection=$1;
4308: $section=&mt('Group/Section').': '.$issection;
4309: $middle=~s/^\[(.*)\]//;
1.290 www 4310: }
4311: $middle=~s/\.+$//;
4312: $middle=~s/^\.+//;
1.291 www 4313: if ($uname) {
1.473 amueller 4314: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4315: $issection='';
1.291 www 4316: }
1.316 albertel 4317: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.446 bisitz 4318: my $realmdescription=&mt('all resources');
1.290 www 4319: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4320: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
4321: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
1.304 www 4322: } elsif ($middle) {
1.473 amueller 4323: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
4324: $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>';
4325: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4326: }
1.291 www 4327: my $what=$part.'.'.$name;
1.330 albertel 4328: return ($realm,$section,$name,$part,
1.473 amueller 4329: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4330: }
1.293 www 4331:
1.328 albertel 4332: my %standard_parms;
1.469 raeburn 4333: my %standard_parms_types;
1.416 jms 4334:
1.328 albertel 4335: sub load_parameter_names {
4336: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4337: while (my $configline=<$config>) {
1.473 amueller 4338: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4339: chomp($configline);
4340: my ($short,$plain)=split(/:/,$configline);
4341: my (undef,$name,$type)=split(/\&/,$short,3);
4342: if ($type eq 'display') {
4343: $standard_parms{$name} = $plain;
1.469 raeburn 4344: } elsif ($type eq 'type') {
4345: $standard_parms_types{$name} = $plain;
4346: }
1.328 albertel 4347: }
4348: close($config);
4349: $standard_parms{'int_pos'} = 'Positive Integer';
4350: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4351: }
4352:
1.292 www 4353: sub standard_parameter_names {
4354: my ($name)=@_;
1.328 albertel 4355: if (!%standard_parms) {
1.473 amueller 4356: &load_parameter_names();
1.328 albertel 4357: }
1.292 www 4358: if ($standard_parms{$name}) {
1.473 amueller 4359: return $standard_parms{$name};
1.446 bisitz 4360: } else {
1.473 amueller 4361: return $name;
1.292 www 4362: }
4363: }
1.290 www 4364:
1.469 raeburn 4365: sub standard_parameter_types {
4366: my ($name)=@_;
4367: if (!%standard_parms_types) {
4368: &load_parameter_names();
4369: }
4370: if ($standard_parms_types{$name}) {
4371: return $standard_parms_types{$name};
4372: }
4373: return;
4374: }
1.309 www 4375:
1.285 albertel 4376: sub parm_change_log {
1.284 www 4377: my ($r)=@_;
1.414 droeschl 4378: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.473 amueller 4379: text=>"Parameter Change Log"});
1.522 raeburn 4380: my $js = '<script type="text/javascript">'."\n".
4381: '// <![CDATA['."\n".
4382: &Apache::loncommon::display_filter_js('parmslog')."\n".
4383: '// ]]>'."\n".
4384: '</script>'."\n";
4385: $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
1.327 albertel 4386: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
1.507 www 4387: &startSettingsScreen($r,'parmset');
1.286 www 4388: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
1.473 amueller 4389: $env{'course.'.$env{'request.course.id'}.'.domain'},
4390: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4391:
1.301 www 4392: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4393:
1.522 raeburn 4394: $r->print('<div class="LC_left_float">'.
4395: '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
4396: '<form action="/adm/parmset?action=parameterchangelog"
1.327 albertel 4397: method="post" name="parameterlog">');
1.446 bisitz 4398:
1.311 albertel 4399: my %saveable_parameters = ('show' => 'scalar',);
4400: &Apache::loncommon::store_course_settings('parameter_log',
4401: \%saveable_parameters);
4402: &Apache::loncommon::restore_course_settings('parameter_log',
4403: \%saveable_parameters);
1.522 raeburn 4404: $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
4405: '<input type="submit" value="'.&mt('Display').'" />'.
4406: '</form></fieldset></div><br clear="all" />');
1.301 www 4407:
1.291 www 4408: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
1.473 amueller 4409: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4410: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1.473 amueller 4411: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4412: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4413: &Apache::loncommon::end_data_table_header_row());
1.309 www 4414: my $shown=0;
1.349 www 4415: my $folder='';
4416: if ($env{'form.displayfilter'} eq 'currentfolder') {
1.473 amueller 4417: my $last='';
4418: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4419: &GDBM_READER(),0640)) {
4420: $last=$hash{'last_known'};
4421: untie(%hash);
4422: }
4423: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
1.349 www 4424: }
1.446 bisitz 4425: foreach my $id (sort
1.473 amueller 4426: {
4427: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4428: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4429: }
4430: my $aid = (split('00000',$a))[-1];
4431: my $bid = (split('00000',$b))[-1];
4432: return $bid<=>$aid;
4433: } (keys(%parmlog))) {
1.294 www 4434: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.473 amueller 4435: my $count = 0;
4436: my $time =
4437: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
4438: my $plainname =
4439: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4440: $parmlog{$id}{'exe_udom'});
4441: my $about_me_link =
4442: &Apache::loncommon::aboutmewrapper($plainname,
4443: $parmlog{$id}{'exe_uname'},
4444: $parmlog{$id}{'exe_udom'});
4445: my $send_msg_link='';
4446: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4447: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
4448: $send_msg_link ='<br />'.
4449: &Apache::loncommon::messagewrapper(&mt('Send message'),
4450: $parmlog{$id}{'exe_uname'},
4451: $parmlog{$id}{'exe_udom'});
4452: }
4453: my $row_start=&Apache::loncommon::start_data_table_row();
4454: my $makenewrow=0;
4455: my %istype=();
4456: my $output;
4457: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4458: my $value=$parmlog{$id}{'logentry'}{$changed};
1.473 amueller 4459: my $typeflag = ($changed =~/\.type$/ &&
4460: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4461: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.473 amueller 4462: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
4463: if ($env{'form.displayfilter'} eq 'currentfolder') {
4464: if ($folder) {
4465: if ($middle!~/^\Q$folder\E/) { next; }
4466: }
4467: }
4468: if ($typeflag) {
4469: $istype{$parmname}=$value;
4470: if (!$env{'form.includetypes'}) { next; }
4471: }
4472: $count++;
4473: if ($makenewrow) {
4474: $output .= $row_start;
4475: } else {
4476: $makenewrow=1;
4477: }
1.470 raeburn 4478: my $parmitem = &standard_parameter_names($parmname);
1.473 amueller 4479: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
4480: &mt($parmitem).'</td><td>'.
4481: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
4482: my $stillactive=0;
4483: if ($parmlog{$id}{'delflag'}) {
4484: $output .= &mt('Deleted');
4485: } else {
4486: if ($typeflag) {
1.470 raeburn 4487: my $parmitem = &standard_parameter_names($value);
4488: $parmitem = &mt($parmitem);
1.473 amueller 4489: $output .= &mt('Type: [_1]',$parmitem);
4490: } else {
4491: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4492: $uname,$udom,$issection,$issection,$courseopt);
1.469 raeburn 4493: my $showvalue = $value;
4494: if ($istype{$parmname} eq '') {
4495: my $type = &standard_parameter_types($parmname);
4496: if ($type ne '') {
4497: if (&isdateparm($type)) {
4498: $showvalue =
4499: &Apache::lonlocal::locallocaltime($value);
4500: }
4501: }
4502: } else {
1.473 amueller 4503: if (&isdateparm($istype{$parmname})) {
4504: $showvalue =
1.469 raeburn 4505: &Apache::lonlocal::locallocaltime($value);
1.473 amueller 4506: }
1.469 raeburn 4507: }
4508: $output .= $showvalue;
1.473 amueller 4509: if ($value ne $all[$level]) {
4510: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
4511: } else {
4512: $stillactive=1;
4513: }
4514: }
4515: }
4516: $output .= '</td><td>';
1.470 raeburn 4517:
1.473 amueller 4518: if ($stillactive) {
1.470 raeburn 4519: my $parmitem = &standard_parameter_names($parmname);
4520: $parmitem = &mt($parmitem);
1.473 amueller 4521: my $title=&mt('Changed [_1]',$parmitem);
1.471 raeburn 4522: my $description=&mt('Changed [_1] for [_2] to [_3]',
4523: $parmitem,$realmdescription,
1.473 amueller 4524: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
4525: if (($uname) && ($udom)) {
4526: $output .=
4527: &Apache::loncommon::messagewrapper('Notify User',
4528: $uname,$udom,$title,
4529: $description);
4530: } else {
4531: $output .=
4532: &Apache::lonrss::course_blog_link($id,$title,
4533: $description);
4534: }
4535: }
4536: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4537: }
1.349 www 4538: if ($env{'form.displayfilter'} eq 'containing') {
1.473 amueller 4539: my $wholeentry=$about_me_link.':'.
4540: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4541: $output;
4542: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4543: }
1.349 www 4544: if ($count) {
1.473 amueller 4545: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4546: <td rowspan="'.$count.'">'.$about_me_link.
1.473 amueller 4547: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4548: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4549: $send_msg_link.'</td>'.$output);
4550: $shown++;
4551: }
4552: if (!($env{'form.show'} eq &mt('all')
4553: || $shown<=$env{'form.show'})) { last; }
1.286 www 4554: }
1.301 www 4555: $r->print(&Apache::loncommon::end_data_table());
1.507 www 4556: &endSettingsScreen($r);
1.284 www 4557: $r->print(&Apache::loncommon::end_page());
4558: }
4559:
1.437 raeburn 4560: sub update_slots {
4561: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
4562: my %slot=&Apache::lonnet::get_slot($slot_name);
4563: if (!keys(%slot)) {
4564: return 'error: slot does not exist';
4565: }
4566: my $max=$slot{'maxspace'};
4567: if (!defined($max)) { $max=99999; }
4568:
4569: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
4570: "^$slot_name\0");
4571: my ($tmp)=%consumed;
4572: if ($tmp=~/^error: 2 / ) {
4573: return 'error: unable to determine current slot status';
4574: }
4575: my $last=0;
4576: foreach my $key (keys(%consumed)) {
4577: my $num=(split('\0',$key))[1];
4578: if ($num > $last) { $last=$num; }
4579: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4580: return 'ok';
4581: }
4582: }
4583:
4584: if (scalar(keys(%consumed)) >= $max) {
4585: return 'error: no space left in slot';
4586: }
4587: my $wanted=$last+1;
4588:
4589: my %reservation=('name' => $uname.':'.$udom,
4590: 'timestamp' => time,
4591: 'symb' => $symb);
4592:
4593: my $success=&Apache::lonnet::newput('slot_reservations',
4594: {"$slot_name\0$wanted" =>
4595: \%reservation},
4596: $cdom, $cnum);
1.438 raeburn 4597: if ($success eq 'ok') {
4598: my %storehash = (
4599: symb => $symb,
4600: slot => $slot_name,
4601: action => 'reserve',
4602: context => 'parameter',
4603: );
1.526 raeburn 4604: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.524 raeburn 4605: '',$uname,$udom,$cnum,$cdom);
1.438 raeburn 4606:
1.526 raeburn 4607: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.524 raeburn 4608: '',$uname,$udom,$uname,$udom);
1.438 raeburn 4609: }
1.437 raeburn 4610: return $success;
4611: }
4612:
4613: sub delete_slots {
4614: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
4615: my $delresult;
4616: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
4617: $cnum, "^$slot_name\0");
4618: if (&Apache::lonnet::error(%consumed)) {
4619: return 'error: unable to determine current slot status';
4620: }
4621: my ($tmp)=%consumed;
4622: if ($tmp=~/^error: 2 /) {
4623: return 'error: unable to determine current slot status';
4624: }
4625: foreach my $key (keys(%consumed)) {
4626: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4627: my $num=(split('\0',$key))[1];
4628: my $entry = $slot_name.'\0'.$num;
4629: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
4630: $cdom,$cnum);
4631: if ($delresult eq 'ok') {
4632: my %storehash = (
4633: symb => $symb,
4634: slot => $slot_name,
4635: action => 'release',
4636: context => 'parameter',
4637: );
1.526 raeburn 4638: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.524 raeburn 4639: 1,$uname,$udom,$cnum,$cdom);
1.526 raeburn 4640: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.524 raeburn 4641: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 4642: }
4643: }
4644: }
4645: return $delresult;
4646: }
4647:
1.355 albertel 4648: sub check_for_course_info {
4649: my $navmap = Apache::lonnavmaps::navmap->new();
4650: return 1 if ($navmap);
4651: return 0;
4652: }
4653:
1.514 raeburn 4654: sub parameter_release_vars {
1.504 raeburn 4655: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4656: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
4657: my $chostname = &Apache::lonnet::hostname($chome);
4658: my ($cmajor,$cminor) =
4659: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
4660: return ($chostname,$cmajor,$cminor);
4661: }
4662:
1.514 raeburn 4663: sub parameter_releasecheck {
4664: my ($name,$value,$needsrelease,$chostname,$cmajor,$cminor) = @_;
1.504 raeburn 4665: my $needsnewer;
4666: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
4667: if (($cmajor < $needsmajor) ||
4668: ($cmajor == $needsmajor && $cminor < $needsminor)) {
4669: $needsnewer = 1;
4670: } else {
1.514 raeburn 4671: &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
1.504 raeburn 4672: }
4673: return $needsnewer;
4674: }
4675:
4676: sub oldversion_warning {
1.514 raeburn 4677: my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
1.504 raeburn 4678: my $desc;
1.514 raeburn 4679: my %stringtypes = (
1.519 raeburn 4680: type => 'string_questiontype',
4681: lenient => 'string_lenient',
4682: retrypartial => 'string_yesno',
1.521 raeburn 4683: discussvote => 'string_discussvote',
1.514 raeburn 4684: );
4685: if (exists($stringtypes{$name})) {
4686: if (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
4687: foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
4688: next unless (ref($possibilities) eq 'ARRAY');
4689: my ($parmval, $description) = @{ $possibilities };
4690: if ($parmval eq $value) {
4691: $desc = $description;
4692: last;
4693: }
1.504 raeburn 4694: }
4695: }
4696: }
1.514 raeburn 4697: my $standard_name = &standard_parameter_names($name);
1.504 raeburn 4698: return '<p class="LC_warning">'.
1.514 raeburn 4699: &mt('[_1] was [_2]not[_3] set to [_4].',
4700: $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
1.504 raeburn 4701: &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
4702: $cmajor.'.'.$cminor,$chostname,
4703: $needsrelease).
4704: '</p>';
4705: }
1.259 banghart 4706:
1.30 www 4707: sub handler {
1.43 albertel 4708: my $r=shift;
1.30 www 4709:
1.376 albertel 4710: &reset_caches();
4711:
1.414 droeschl 4712: &Apache::loncommon::content_type($r,'text/html');
4713: $r->send_http_header;
4714: return OK if $r->header_only;
4715:
1.193 albertel 4716: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.473 amueller 4717: ['action','state',
1.205 www 4718: 'pres_marker',
4719: 'pres_value',
1.206 www 4720: 'pres_type',
1.506 www 4721: 'filter','part',
1.390 www 4722: 'udom','uname','symb','serial','timebase']);
1.131 www 4723:
1.83 bowersj2 4724:
1.193 albertel 4725: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4726: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
1.507 www 4727: text=>"Content and Problem Settings",
1.473 amueller 4728: faq=>10,
4729: bug=>'Instructor Interface',
1.442 droeschl 4730: help =>
4731: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 4732:
1.30 www 4733: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4734: my $parm_permission =
1.473 amueller 4735: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
4736: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
4737: $env{'request.course.sec'}));
1.355 albertel 4738: my $exists = &check_for_course_info();
4739:
4740: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4741: #
4742: # Main switch on form.action and form.state, as appropriate
4743: #
4744: # Check first if coming from someone else headed directly for
4745: # the table mode
4746: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
1.473 amueller 4747: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
4748: &assessparms($r);
1.193 albertel 4749: } elsif (! exists($env{'form.action'})) {
4750: &print_main_menu($r,$parm_permission);
1.414 droeschl 4751: } elsif ($env{'form.action'} eq 'setoverview') {
1.473 amueller 4752: &overview($r);
4753: } elsif ($env{'form.action'} eq 'addmetadata') {
4754: &addmetafield($r);
4755: } elsif ($env{'form.action'} eq 'ordermetadata') {
4756: &order_meta_fields($r);
1.414 droeschl 4757: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.473 amueller 4758: &setrestrictmeta($r);
1.414 droeschl 4759: } elsif ($env{'form.action'} eq 'newoverview') {
1.473 amueller 4760: &newoverview($r);
1.414 droeschl 4761: } elsif ($env{'form.action'} eq 'setdefaults') {
1.473 amueller 4762: &defaultsetter($r);
4763: } elsif ($env{'form.action'} eq 'settable') {
4764: &assessparms($r);
1.414 droeschl 4765: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.473 amueller 4766: &parm_change_log($r);
1.414 droeschl 4767: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.473 amueller 4768: &clean_parameters($r);
1.414 droeschl 4769: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 4770: &date_shift_one($r);
1.414 droeschl 4771: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 4772: &date_shift_two($r);
1.446 bisitz 4773: }
1.43 albertel 4774: } else {
1.1 www 4775: # ----------------------------- Not in a course, or not allowed to modify parms
1.473 amueller 4776: if ($exists) {
4777: $env{'user.error.msg'}=
4778: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4779: } else {
4780: $env{'user.error.msg'}=
4781: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4782: }
4783: return HTTP_NOT_ACCEPTABLE;
1.43 albertel 4784: }
1.376 albertel 4785: &reset_caches();
4786:
1.43 albertel 4787: return OK;
1.1 www 4788: }
4789:
4790: 1;
4791: __END__
4792:
4793:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>