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