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