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