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