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