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