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