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