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