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