Annotation of loncom/interface/lonparmset.pm, revision 1.544
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.544 ! raeburn 4: # $Id: lonparmset.pm,v 1.543 2014/01/15 18:48:35 bisitz 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.512 foxr 1413: 'printopendate' => 'time_settings',
1414: 'printclosedate' => '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,
1996: 'parameter_0_printopendate' => 22,
1997: 'parameter_0_printclosedate' => 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.512 foxr 2170:
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.533 raeburn 2204: } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode)\&\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.533 raeburn 2211: }
1.504 raeburn 2212: $needsrelease =
1.533 raeburn 2213: $Apache::lonnet::needsrelease{"parameter:$name:$val"};
1.504 raeburn 2214: if ($needsrelease) {
1.505 raeburn 2215: unless ($got_chostname) {
1.514 raeburn 2216: ($chostname,$cmajor,$cminor) = ¶meter_release_vars();
1.504 raeburn 2217: $got_chostname = 1;
2218: }
1.534 raeburn 2219: $needsnewer = ¶meter_releasecheck($name,$val,
1.514 raeburn 2220: $needsrelease,
2221: $cmajor,$cminor);
1.500 raeburn 2222: }
1.437 raeburn 2223: }
1.504 raeburn 2224: if ($needsnewer) {
1.514 raeburn 2225: $message .= &oldversion_warning($name,$values[$i],$chostname,$cmajor,
1.504 raeburn 2226: $cminor,$needsrelease);
2227: } else {
2228: $message.=&storeparm(split(/\&/,$markers[$i]),
2229: $values[$i],
2230: $types[$i],
2231: $uname,$udom,$csec,$cgroup);
2232: $totalstored ++;
2233: }
1.473 amueller 2234: }
1.68 www 2235: # ---------------------------------------------------------------- Done storing
1.504 raeburn 2236: if ($totalstored) {
2237: $message.='<p class="LC_warning">'
2238: .&mt('Changes can take up to 10 minutes before being active for all students.')
2239: .&Apache::loncommon::help_open_topic('Caching')
2240: .'</p>';
2241: }
1.68 www 2242: }
1.57 albertel 2243: #----------------------------------------------- if all selected, fill in array
1.209 www 2244: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1.501 bisitz 2245: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries','type','problemstatus') };
1.57 albertel 2246: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 2247: # ------------------------------------------------------------------ Start page
1.63 bowersj2 2248:
1.531 raeburn 2249: my $crstype = &Apache::loncommon::course_type();
2250: &startpage($r,$pssymb,$crstype);
1.57 albertel 2251:
1.44 albertel 2252: foreach ('tolerance','date_default','date_start','date_end',
1.473 amueller 2253: 'date_interval','int','float','string') {
2254: $r->print('<input type="hidden" value="'.
2255: &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
2256: '" name="recent_'.$_.'" />');
1.44 albertel 2257: }
1.446 bisitz 2258:
1.459 bisitz 2259: # ----- Start Parameter Selection
2260:
2261: # Hide parm selection?
2262: $r->print(<<ENDPARMSELSCRIPT);
2263: <script type="text/javascript">
2264: // <![CDATA[
2265: function parmsel_show() {
2266: document.getElementById('parmsel').style.display = "";
2267: document.getElementById('parmsellink').style.display = "none";
2268: }
2269: // ]]>
2270: </script>
2271: ENDPARMSELSCRIPT
1.474 amueller 2272:
1.445 neumanie 2273: if (!$pssymb) {
1.486 www 2274: my $parmselhiddenstyle=' style="display:none"';
2275: if($env{'form.hideparmsel'} eq 'hidden') {
2276: $r->print('<div id="parmsel"'.$parmselhiddenstyle.'>');
2277: } else {
2278: $r->print('<div id="parmsel">');
2279: }
2280:
1.491 bisitz 2281: # Step 1
1.523 raeburn 2282: $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'),'parmstep1'));
2283: $r->print('
1.474 amueller 2284: <script type="text/javascript">
1.523 raeburn 2285: // <![CDATA['.
2286: &showhide_js().'
1.474 amueller 2287: // ]]>
2288: </script>
1.523 raeburn 2289: ');
2290: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.209 www 2291: &levelmenu($r,\%alllevs,$parmlev);
1.491 bisitz 2292: $r->print(&Apache::lonhtmlcommon::row_closure());
1.474 amueller 2293: &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp);
1.491 bisitz 2294: $r->print(&Apache::lonhtmlcommon::row_closure());
2295: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
2296: &partmenu($r,\%allparts,\@psprt);
1.474 amueller 2297: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2298: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2299:
2300: # Step 2
1.523 raeburn 2301: $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
1.536 raeburn 2302: &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll');
1.491 bisitz 2303:
2304: # Step 3
1.523 raeburn 2305: $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
1.486 www 2306: $r->print(&Apache::lonhtmlcommon::start_pick_box());
2307: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
2308: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2309: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.491 bisitz 2310:
2311: # Update Display Button
1.486 www 2312: $r->print('<p>'
2313: .'<input type="submit" name="dis"'
1.511 www 2314: .' value="'.&mt('Update Display').'" />'
1.486 www 2315: .'<input type="hidden" name="hideparmsel" value="hidden" />'
2316: .'</p>');
2317: $r->print('</div>');
1.491 bisitz 2318:
1.486 www 2319: # Offer link to display parameter selection again
2320: $r->print('<p id="parmsellink"');
2321: if ($env{'form.hideparmsel'} ne 'hidden') {
2322: $r->print($parmselhiddenstyle);
2323: }
2324: $r->print('>'
2325: .'<a href="javascript:parmsel_show()">'
2326: .&mt('Change Parameter Selection')
2327: .'</a>'
2328: .'</p>');
1.44 albertel 2329: } else {
1.478 amueller 2330: # parameter screen for a single resource.
1.486 www 2331: my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.473 amueller 2332: my $title = &Apache::lonnet::gettitle($pssymb);
1.501 bisitz 2333: $r->print(&mt('Specific Resource: [_1] ([_2])',
2334: $title,'<span class="LC_filename">'.$resource.'</span>').
1.472 amueller 2335: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.486 www 2336: '<br />');
2337: $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));
2338: $r->print(&Apache::lonhtmlcommon::start_pick_box());
2339: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
2340: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2341: $r->print(&Apache::lonhtmlcommon::end_pick_box());
2342: $r->print('<p>'
1.459 bisitz 2343: .'<input type="submit" name="dis"'
1.511 www 2344: .' value="'.&mt('Update Display').'" />'
1.459 bisitz 2345: .'<input type="hidden" name="hideparmsel" value="hidden" />'
1.486 www 2346: .'</p>');
1.459 bisitz 2347: }
1.478 amueller 2348:
1.486 www 2349: # ----- End Parameter Selection
1.57 albertel 2350:
1.459 bisitz 2351: # Display Messages
2352: $r->print('<div>'.$message.'</div>');
1.210 www 2353:
1.57 albertel 2354:
2355: my @temp_pscat;
2356: map {
2357: my $cat = $_;
2358: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
2359: } @pscat;
2360:
2361: @pscat = @temp_pscat;
2362:
1.209 www 2363: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 2364: # ----------------------------------------------------------------- Start Table
1.57 albertel 2365: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 2366: my $csuname=$env{'user.name'};
2367: my $csudom=$env{'user.domain'};
1.57 albertel 2368:
1.203 www 2369: if ($parmlev eq 'full') {
1.506 www 2370: #
2371: # This produces the cascading table output of parameters
2372: #
1.473 amueller 2373: my $coursespan=$csec?8:5;
2374: my $userspan=3;
2375: if ($cgroup ne '') {
2376: $coursespan += 3;
2377: }
2378:
1.517 www 2379: $r->print(&Apache::loncommon::start_data_table());
1.506 www 2380: #
2381: # This produces the headers
2382: #
1.473 amueller 2383: $r->print('<tr><td colspan="5"></td>');
2384: $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
2385: if ($uname) {
2386: if (@usersgroups > 1) {
2387: $userspan ++;
2388: }
2389: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.540 bisitz 2390: $r->print(&mt('User [_1] at Domain [_2]',"'".$uname."'","'".$udom."'").'</th>');
1.473 amueller 2391: }
2392: my %lt=&Apache::lonlocal::texthash(
2393: 'pie' => "Parameter in Effect",
2394: 'csv' => "Current Session Value",
1.472 amueller 2395: 'rl' => "Resource Level",
1.473 amueller 2396: 'ic' => 'in Course',
2397: 'aut' => "Assessment URL and Title",
2398: 'type' => 'Type',
2399: 'emof' => "Enclosing Map or Folder",
2400: 'part' => 'Part',
1.472 amueller 2401: 'pn' => 'Parameter Name',
1.473 amueller 2402: 'def' => 'default',
2403: 'femof' => 'from Enclosing Map or Folder',
2404: 'gen' => 'general',
2405: 'foremf' => 'for Enclosing Map or Folder',
2406: 'fr' => 'for Resource'
2407: );
2408: $r->print(<<ENDTABLETWO);
1.419 bisitz 2409: <th rowspan="3">$lt{'pie'}</th>
1.501 bisitz 2410: <th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>
1.419 bisitz 2411: </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
2412: <th colspan="1">$lt{'ic'}</th>
1.182 albertel 2413:
1.10 www 2414: ENDTABLETWO
1.473 amueller 2415: if ($csec) {
2416: $r->print('<th colspan="3">'.
2417: &mt("in Section")." $csec</th>");
2418: }
2419: if ($cgroup) {
1.419 bisitz 2420: $r->print('<th colspan="3">'.
1.472 amueller 2421: &mt("in Group")." $cgroup</th>");
1.473 amueller 2422: }
2423: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 2424: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
2425: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 2426: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
2427: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 2428: ENDTABLEHEADFOUR
1.57 albertel 2429:
1.473 amueller 2430: if ($csec) {
2431: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2432: }
2433:
2434: if ($cgroup) {
2435: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2436: }
2437:
2438: if ($uname) {
2439: if (@usersgroups > 1) {
2440: $r->print('<th>'.&mt('Control by other group?').'</th>');
2441: }
2442: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
2443: }
2444:
2445: $r->print('</tr>');
1.506 www 2446: #
2447: # Done with the headers
2448: #
1.473 amueller 2449: my $defbgone='';
2450: my $defbgtwo='';
2451: my $defbgthree = '';
1.57 albertel 2452:
1.531 raeburn 2453: foreach my $rid (@ids) {
1.57 albertel 2454:
2455: my ($inmapid)=($rid=~/\.(\d+)$/);
2456:
1.446 bisitz 2457: if ((!$pssymb &&
1.473 amueller 2458: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
2459: ||
2460: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 2461: # ------------------------------------------------------ Entry for one resource
1.473 amueller 2462: if ($defbgone eq '#E0E099') {
2463: $defbgone='#E0E0DD';
1.57 albertel 2464: } else {
1.419 bisitz 2465: $defbgone='#E0E099';
1.57 albertel 2466: }
1.419 bisitz 2467: if ($defbgtwo eq '#FFFF99') {
1.473 amueller 2468: $defbgtwo='#FFFFDD';
1.57 albertel 2469: } else {
1.473 amueller 2470: $defbgtwo='#FFFF99';
1.57 albertel 2471: }
1.419 bisitz 2472: if ($defbgthree eq '#FFBB99') {
2473: $defbgthree='#FFBBDD';
1.269 raeburn 2474: } else {
1.419 bisitz 2475: $defbgthree='#FFBB99';
1.269 raeburn 2476: }
2477:
1.57 albertel 2478: my $thistitle='';
2479: my %name= ();
2480: undef %name;
2481: my %part= ();
2482: my %display=();
2483: my %type= ();
2484: my %default=();
1.196 www 2485: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2486:
1.506 www 2487: my $filter=$env{'form.filter'};
1.210 www 2488: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 2489: my $tempkeyp = $_;
2490: if (grep $_ eq $tempkeyp, @catmarker) {
1.506 www 2491: my $parmname=&Apache::lonnet::metadata($uri,$_.'.name');
2492: # We may only want certain parameters listed
2493: if ($filter) {
2494: unless ($filter=~/\Q$parmname\E/) { next; }
2495: }
2496: $name{$_}=$parmname;
1.57 albertel 2497: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1.506 www 2498:
1.433 raeburn 2499: my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
2500: if ($allparms{$name{$_}} ne '') {
2501: my $identifier;
2502: if ($parmdis =~ /(\s*\[Part.*)$/) {
2503: $identifier = $1;
2504: }
2505: $display{$_} = $allparms{$name{$_}}.$identifier;
2506: } else {
2507: $display{$_} = $parmdis;
2508: }
1.57 albertel 2509: unless ($display{$_}) { $display{$_}=''; }
2510: $display{$_}.=' ('.$name{$_}.')';
2511: $default{$_}=&Apache::lonnet::metadata($uri,$_);
2512: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
2513: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
2514: }
2515: }
2516: my $totalparms=scalar keys %name;
2517: if ($totalparms>0) {
1.473 amueller 2518: my $firstrow=1;
2519: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.419 bisitz 2520: $r->print('<tr><td style="background-color:'.$defbgone.';"'.
1.57 albertel 2521: ' rowspan='.$totalparms.
1.419 bisitz 2522: '><tt><font size="-1">'.
1.57 albertel 2523: join(' / ',split(/\//,$uri)).
2524: '</font></tt><p><b>'.
1.154 albertel 2525: "<a href=\"javascript:openWindow('".
1.473 amueller 2526: &Apache::lonnet::clutter($uri).'?symb='.
2527: &escape($symbp{$rid}).
1.336 albertel 2528: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
2529: " target=\"_self\">$title");
1.57 albertel 2530:
2531: if ($thistitle) {
1.473 amueller 2532: $r->print(' ('.$thistitle.')');
1.57 albertel 2533: }
2534: $r->print('</a></b></td>');
1.419 bisitz 2535: $r->print('<td style="background-color:'.$defbgtwo.';"'.
1.57 albertel 2536: ' rowspan='.$totalparms.'>'.$typep{$rid}.
2537: '</td>');
2538:
1.419 bisitz 2539: $r->print('<td style="background-color:'.$defbgone.';"'.
1.57 albertel 2540: ' rowspan='.$totalparms.
1.238 www 2541: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.512 foxr 2542: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 2543:
2544: unless ($firstrow) {
2545: $r->print('<tr>');
2546: } else {
2547: undef $firstrow;
2548: }
1.201 www 2549: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 2550: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 2551: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 2552: $cgroup,\@usersgroups);
1.57 albertel 2553: }
2554: }
2555: }
2556: } # end foreach ids
1.43 albertel 2557: # -------------------------------------------------- End entry for one resource
1.517 www 2558: $r->print(&Apache::loncommon::end_data_table);
1.203 www 2559: } # end of full
1.57 albertel 2560: #--------------------------------------------------- Entry for parm level map
2561: if ($parmlev eq 'map') {
1.419 bisitz 2562: my $defbgone = '#E0E099';
2563: my $defbgtwo = '#FFFF99';
2564: my $defbgthree = '#FFBB99';
1.57 albertel 2565:
2566: my %maplist;
2567:
2568: if ($pschp eq 'all') {
1.446 bisitz 2569: %maplist = %allmaps;
1.57 albertel 2570: } else {
2571: %maplist = ($pschp => $mapp{$pschp});
2572: }
2573:
2574: #-------------------------------------------- for each map, gather information
2575: my $mapid;
1.473 amueller 2576: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1.60 albertel 2577: my $maptitle = $maplist{$mapid};
1.57 albertel 2578:
2579: #----------------------- loop through ids and get all parameter types for map
2580: #----------------------------------------- and associated information
2581: my %name = ();
2582: my %part = ();
2583: my %display = ();
2584: my %type = ();
2585: my %default = ();
2586: my $map = 0;
2587:
1.473 amueller 2588: # $r->print("Catmarker: @catmarker<br />\n");
1.446 bisitz 2589:
1.57 albertel 2590: foreach (@ids) {
1.473 amueller 2591: ($map)=(/([\d]*?)\./);
2592: my $rid = $_;
1.446 bisitz 2593:
1.57 albertel 2594: # $r->print("$mapid:$map: $rid <br /> \n");
2595:
1.473 amueller 2596: if ($map eq $mapid) {
2597: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2598: # $r->print("Keys: $keyp{$rid} <br />\n");
2599:
2600: #--------------------------------------------------------------------
2601: # @catmarker contains list of all possible parameters including part #s
2602: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2603: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2604: # When storing information, store as part 0
2605: # When requesting information, request from full part
2606: #-------------------------------------------------------------------
1.473 amueller 2607: foreach (&keysplit($keyp{$rid})) {
2608: my $tempkeyp = $_;
2609: my $fullkeyp = $tempkeyp;
2610: $tempkeyp =~ s/_\w+_/_0_/;
2611:
2612: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2613: $part{$tempkeyp}="0";
2614: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
2615: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2616: if ($allparms{$name{$tempkeyp}} ne '') {
2617: my $identifier;
2618: if ($parmdis =~ /(\s*\[Part.*)$/) {
2619: $identifier = $1;
2620: }
2621: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2622: } else {
2623: $display{$tempkeyp} = $parmdis;
2624: }
2625: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2626: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
2627: $display{$tempkeyp} =~ s/_\w+_/_0_/;
2628: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2629: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2630: }
2631: } # end loop through keys
2632: }
1.57 albertel 2633: } # end loop through ids
1.446 bisitz 2634:
1.57 albertel 2635: #---------------------------------------------------- print header information
1.133 www 2636: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 2637: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 2638: my $tmp="";
1.57 albertel 2639: if ($uname) {
1.473 amueller 2640: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 2641: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
2642: &mt('in')." \n";
1.57 albertel 2643: } else {
1.401 bisitz 2644: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 2645: }
1.269 raeburn 2646: if ($cgroup) {
1.401 bisitz 2647: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
2648: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2649: $csec = '';
2650: } elsif ($csec) {
1.401 bisitz 2651: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
2652: "</i></font> ".&mt('of')." \n";
1.269 raeburn 2653: }
1.401 bisitz 2654: $r->print('<div align="center"><h4>'
2655: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 2656: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 2657: ,$tmp
2658: ,'<font color="red"><i>'.$coursename.'</i></font>'
2659: )
2660: ."<br /></h4>\n"
1.422 bisitz 2661: );
1.57 albertel 2662: #---------------------------------------------------------------- print table
1.419 bisitz 2663: $r->print('<p>'.&Apache::loncommon::start_data_table()
2664: .&Apache::loncommon::start_data_table_header_row()
2665: .'<th>'.&mt('Parameter Name').'</th>'
2666: .'<th>'.&mt('Default Value').'</th>'
2667: .'<th>'.&mt('Parameter in Effect').'</th>'
2668: .&Apache::loncommon::end_data_table_header_row()
2669: );
1.57 albertel 2670:
1.473 amueller 2671: foreach (&keysinorder(\%name,\%keyorder)) {
2672: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2673: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2674: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2675: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2676: }
1.422 bisitz 2677: $r->print(&Apache::loncommon::end_data_table().'</p>'
2678: .'</div>'
2679: );
1.57 albertel 2680: } # end each map
2681: } # end of $parmlev eq map
2682: #--------------------------------- Entry for parm level general (Course level)
2683: if ($parmlev eq 'general') {
1.473 amueller 2684: my $defbgone = '#E0E099';
1.419 bisitz 2685: my $defbgtwo = '#FFFF99';
2686: my $defbgthree = '#FFBB99';
1.57 albertel 2687:
2688: #-------------------------------------------- for each map, gather information
2689: my $mapid="0.0";
2690: #----------------------- loop through ids and get all parameter types for map
2691: #----------------------------------------- and associated information
2692: my %name = ();
2693: my %part = ();
2694: my %display = ();
2695: my %type = ();
2696: my %default = ();
1.446 bisitz 2697:
1.57 albertel 2698: foreach (@ids) {
2699: my $rid = $_;
1.446 bisitz 2700:
1.196 www 2701: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 2702:
2703: #--------------------------------------------------------------------
2704: # @catmarker contains list of all possible parameters including part #s
2705: # $fullkeyp contains the full part/id # for the extraction of proper parameters
2706: # $tempkeyp contains part 0 only (no ids - ie, subparts)
2707: # When storing information, store as part 0
2708: # When requesting information, request from full part
2709: #-------------------------------------------------------------------
1.473 amueller 2710: foreach (&keysplit($keyp{$rid})) {
2711: my $tempkeyp = $_;
2712: my $fullkeyp = $tempkeyp;
2713: $tempkeyp =~ s/_\w+_/_0_/;
2714: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
2715: $part{$tempkeyp}="0";
2716: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
2717: my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
2718: if ($allparms{$name{$tempkeyp}} ne '') {
2719: my $identifier;
2720: if ($parmdis =~ /(\s*\[Part.*)$/) {
2721: $identifier = $1;
2722: }
2723: $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
2724: } else {
2725: $display{$tempkeyp} = $parmdis;
2726: }
2727: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
2728: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
2729: $display{$tempkeyp} =~ s/_\w+_/_0_/;
2730: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
2731: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
2732: }
1.57 albertel 2733: } # end loop through keys
2734: } # end loop through ids
1.446 bisitz 2735:
1.57 albertel 2736: #---------------------------------------------------- print header information
1.473 amueller 2737: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 2738: $r->print(<<ENDMAPONE);
1.419 bisitz 2739: <center>
2740: <h4>$setdef
1.135 albertel 2741: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 2742: ENDMAPONE
2743: if ($uname) {
1.473 amueller 2744: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2745: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2746: } else {
1.135 albertel 2747: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2748: }
1.446 bisitz 2749:
1.135 albertel 2750: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2751: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2752: $r->print("</h4>\n");
1.57 albertel 2753: #---------------------------------------------------------------- print table
1.419 bisitz 2754: $r->print('<p>'.&Apache::loncommon::start_data_table()
2755: .&Apache::loncommon::start_data_table_header_row()
2756: .'<th>'.&mt('Parameter Name').'</th>'
2757: .'<th>'.&mt('Default Value').'</th>'
2758: .'<th>'.&mt('Parameter in Effect').'</th>'
2759: .&Apache::loncommon::end_data_table_header_row()
2760: );
1.57 albertel 2761:
1.473 amueller 2762: foreach (&keysinorder(\%name,\%keyorder)) {
1.419 bisitz 2763: $r->print(&Apache::loncommon::start_data_table_row());
1.201 www 2764: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2765: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2766: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2767: }
1.419 bisitz 2768: $r->print(&Apache::loncommon::end_data_table()
2769: .'</p>'
2770: .'</center>'
2771: );
1.57 albertel 2772: } # end of $parmlev eq general
1.43 albertel 2773: }
1.507 www 2774: $r->print('</form>');
2775: &endSettingsScreen($r);
2776: $r->print(&Apache::loncommon::end_page());
1.57 albertel 2777: } # end sub assessparms
1.30 www 2778:
1.120 www 2779: ##################################################
1.207 www 2780: # Overview mode
2781: ##################################################
1.124 www 2782: my $tableopen;
2783:
2784: sub tablestart {
2785: if ($tableopen) {
1.473 amueller 2786: return '';
1.124 www 2787: } else {
1.473 amueller 2788: $tableopen=1;
2789: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
2790: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2791: }
2792: }
2793:
2794: sub tableend {
2795: if ($tableopen) {
1.473 amueller 2796: $tableopen=0;
2797: return &Apache::loncommon::end_data_table();
1.124 www 2798: } else {
1.473 amueller 2799: return'';
1.124 www 2800: }
2801: }
2802:
1.207 www 2803: sub readdata {
2804: my ($crs,$dom)=@_;
2805: # Read coursedata
2806: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2807: # Read userdata
2808:
2809: my $classlist=&Apache::loncoursedata::get_classlist();
2810: foreach (keys %$classlist) {
1.350 albertel 2811: if ($_=~/^($match_username)\:($match_domain)$/) {
1.473 amueller 2812: my ($tuname,$tudom)=($1,$2);
2813: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
1.207 www 2814: foreach my $userkey (keys %{$useropt}) {
1.473 amueller 2815: if ($userkey=~/^$env{'request.course.id'}/) {
1.207 www 2816: my $newkey=$userkey;
1.473 amueller 2817: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2818: $$resourcedata{$newkey}=$$useropt{$userkey};
2819: }
2820: }
2821: }
1.207 www 2822: }
2823: return $resourcedata;
2824: }
2825:
2826:
1.124 www 2827: # Setting
1.208 www 2828:
2829: sub storedata {
2830: my ($r,$crs,$dom)=@_;
1.207 www 2831: # Set userlevel immediately
2832: # Do an intermediate store of course level
2833: my $olddata=&readdata($crs,$dom);
1.124 www 2834: my %newdata=();
2835: undef %newdata;
2836: my @deldata=();
2837: undef @deldata;
1.504 raeburn 2838: my ($got_chostname,$chostname,$cmajor,$cminor);
2839: foreach my $key (keys(%env)) {
2840: if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
1.473 amueller 2841: my $cmd=$1;
2842: my $thiskey=$2;
2843: my ($tuname,$tudom)=&extractuser($thiskey);
2844: my $tkey=$thiskey;
2845: if ($tuname) {
2846: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2847: }
2848: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.514 raeburn 2849: my ($data, $typeof, $text, $name);
1.473 amueller 2850: if ($cmd eq 'set') {
1.504 raeburn 2851: $data=$env{$key};
1.473 amueller 2852: $typeof=$env{'form.typeof_'.$thiskey};
2853: $text = &mt('Saved modified parameter for');
1.504 raeburn 2854: if ($typeof eq 'string_questiontype') {
1.514 raeburn 2855: $name = 'type';
2856: } elsif ($typeof eq 'string_lenient') {
2857: $name = 'lenient';
1.521 raeburn 2858: } elsif ($typeof eq 'string_discussvote') {
2859: $name = 'discussvote';
1.533 raeburn 2860: } elsif ($typeof eq 'string_examcode') {
2861: $name = 'examcode';
1.519 raeburn 2862: } elsif ($typeof eq 'string_yesno') {
2863: if ($thiskey =~ /\.retrypartial$/) {
2864: $name = 'retrypartial';
2865: }
1.514 raeburn 2866: }
2867: if ($name ne '') {
1.504 raeburn 2868: my ($needsrelease,$needsnewer);
1.514 raeburn 2869: $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$data"};
1.504 raeburn 2870: if ($needsrelease) {
2871: unless ($got_chostname) {
1.514 raeburn 2872: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
1.504 raeburn 2873: $got_chostname = 1;
2874: }
1.514 raeburn 2875: $needsnewer = ¶meter_releasecheck($name,$data,
2876: $needsrelease,
1.544 ! raeburn 2877: $cmajor,$cminor);
1.504 raeburn 2878: }
2879: if ($needsnewer) {
1.514 raeburn 2880: $r->print('<br />'.&oldversion_warning($name,$data,
2881: $chostname,$cmajor,
1.504 raeburn 2882: $cminor,$needsrelease));
2883: next;
2884: }
2885: }
1.473 amueller 2886: } elsif ($cmd eq 'datepointer') {
1.504 raeburn 2887: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
1.473 amueller 2888: $typeof=$env{'form.typeof_'.$thiskey};
2889: $text = &mt('Saved modified date for');
2890: } elsif ($cmd eq 'dateinterval') {
2891: $data=&get_date_interval_from_form($thiskey);
2892: $typeof=$env{'form.typeof_'.$thiskey};
2893: $text = &mt('Saved modified date for');
2894: }
2895: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 2896: if ($tuname) {
1.473 amueller 2897: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2898: $tkey.'.type' => $typeof},
2899: $tudom,$tuname) eq 'ok') {
2900: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
2901: $r->print('<br />'.$text.' '.
2902: &Apache::loncommon::plainname($tuname,$tudom));
2903: } else {
2904: $r->print('<div class="LC_error">'.
2905: &mt('Error saving parameters').'</div>');
2906: }
2907: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2908: } else {
2909: $newdata{$thiskey}=$data;
2910: $newdata{$thiskey.'.type'}=$typeof;
1.446 bisitz 2911: }
1.473 amueller 2912: }
2913: } elsif ($cmd eq 'del') {
2914: if ($tuname) {
2915: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
2916: &log_parmset({$tkey=>''},1,$tuname,$tudom);
2917: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2918: } else {
2919: $r->print('<div class="LC_error">'.
2920: &mt('Error deleting parameters').'</div>');
2921: }
2922: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2923: } else {
2924: push (@deldata,$thiskey,$thiskey.'.type');
2925: }
2926: }
2927: }
1.124 www 2928: }
1.207 www 2929: # Store all course level
1.144 www 2930: my $delentries=$#deldata+1;
2931: my @newdatakeys=keys %newdata;
2932: my $putentries=$#newdatakeys+1;
2933: if ($delentries) {
1.473 amueller 2934: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
2935: my %loghash=map { $_ => '' } @deldata;
2936: &log_parmset(\%loghash,1);
1.529 raeburn 2937: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)',$delentries).'</h2>');
1.473 amueller 2938: } else {
2939: $r->print('<div class="LC_error">'.
2940: &mt('Error deleting parameters').'</div>');
2941: }
2942: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2943: }
2944: if ($putentries) {
1.473 amueller 2945: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
2946: &log_parmset(\%newdata,0);
2947: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
2948: } else {
2949: $r->print('<div class="LC_error">'.
2950: &mt('Error saving parameters').'</div>');
2951: }
2952: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2953: }
1.208 www 2954: }
1.207 www 2955:
1.208 www 2956: sub extractuser {
2957: my $key=shift;
1.350 albertel 2958: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 2959: }
1.206 www 2960:
1.381 albertel 2961: sub parse_listdata_key {
2962: my ($key,$listdata) = @_;
2963: # split into student/section affected, and
2964: # the realm (folder/resource part and parameter
1.446 bisitz 2965: my ($student,$realm) =
1.473 amueller 2966: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
1.381 albertel 2967: # if course wide student would be undefined
2968: if (!defined($student)) {
1.473 amueller 2969: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.381 albertel 2970: }
2971: # strip off the .type if it's not the Question type parameter
2972: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
1.473 amueller 2973: $realm=~s/\.type//;
1.381 albertel 2974: }
2975: # split into resource+part and parameter name
1.388 albertel 2976: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
2977: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 2978: return ($student,$res,$part,$parm);
2979: }
2980:
1.208 www 2981: sub listdata {
1.214 www 2982: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2983: # Start list output
1.206 www 2984:
1.122 www 2985: my $oldsection='';
2986: my $oldrealm='';
2987: my $oldpart='';
1.123 www 2988: my $pointer=0;
1.124 www 2989: $tableopen=0;
1.145 www 2990: my $foundkeys=0;
1.248 albertel 2991: my %keyorder=&standardkeyorder();
1.381 albertel 2992:
1.214 www 2993: foreach my $thiskey (sort {
1.473 amueller 2994: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
2995: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
1.381 albertel 2996:
1.473 amueller 2997: # get the numerical order for the param
2998: $aparm=$keyorder{'parameter_0_'.$aparm};
2999: $bparm=$keyorder{'parameter_0_'.$bparm};
1.381 albertel 3000:
1.473 amueller 3001: my $result=0;
1.381 albertel 3002:
1.473 amueller 3003: if ($sortorder eq 'realmstudent') {
1.381 albertel 3004: if ($ares ne $bres ) {
1.473 amueller 3005: $result = ($ares cmp $bres);
1.446 bisitz 3006: } elsif ($astudent ne $bstudent) {
1.473 amueller 3007: $result = ($astudent cmp $bstudent);
3008: } elsif ($apart ne $bpart ) {
3009: $result = ($apart cmp $bpart);
3010: }
3011: } else {
3012: if ($astudent ne $bstudent) {
3013: $result = ($astudent cmp $bstudent);
3014: } elsif ($ares ne $bres ) {
3015: $result = ($ares cmp $bres);
3016: } elsif ($apart ne $bpart ) {
3017: $result = ($apart cmp $bpart);
3018: }
3019: }
1.446 bisitz 3020:
1.473 amueller 3021: if (!$result) {
1.381 albertel 3022: if (defined($aparm) && defined($bparm)) {
1.473 amueller 3023: $result = ($aparm <=> $bparm);
1.381 albertel 3024: } elsif (defined($aparm)) {
1.473 amueller 3025: $result = -1;
1.381 albertel 3026: } elsif (defined($bparm)) {
1.473 amueller 3027: $result = 1;
3028: }
3029: }
1.381 albertel 3030:
1.473 amueller 3031: $result;
1.214 www 3032: } keys %{$listdata}) {
1.381 albertel 3033:
1.473 amueller 3034: if ($$listdata{$thiskey.'.type'}) {
1.211 www 3035: my $thistype=$$listdata{$thiskey.'.type'};
3036: if ($$resourcedata{$thiskey.'.type'}) {
1.473 amueller 3037: $thistype=$$resourcedata{$thiskey.'.type'};
3038: }
3039: my ($middle,$part,$name)=
3040: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3041: my $section=&mt('All Students');
3042: if ($middle=~/^\[(.*)\]/) {
3043: my $issection=$1;
3044: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
3045: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
3046: } else {
3047: $section=&mt('Group/Section').': '.$issection;
3048: }
3049: $middle=~s/^\[(.*)\]//;
3050: }
3051: $middle=~s/\.+$//;
3052: $middle=~s/^\.+//;
3053: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
3054: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3055: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
3056: } elsif ($middle) {
3057: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
3058: $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>';
3059: }
3060: if ($sortorder eq 'realmstudent') {
3061: if ($realm ne $oldrealm) {
3062: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
3063: $oldrealm=$realm;
3064: $oldsection='';
3065: }
3066: if ($section ne $oldsection) {
3067: $r->print(&tableend()."\n<h2>$section</h2>");
3068: $oldsection=$section;
3069: $oldpart='';
3070: }
3071: } else {
3072: if ($section ne $oldsection) {
3073: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
3074: $oldsection=$section;
3075: $oldrealm='';
3076: }
3077: if ($realm ne $oldrealm) {
3078: $r->print(&tableend()."\n<h2>$realm</h2>");
3079: $oldrealm=$realm;
3080: $oldpart='';
3081: }
3082: }
3083: if ($part ne $oldpart) {
3084: $r->print(&tableend().
3085: "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
3086: $oldpart=$part;
3087: }
1.123 www 3088: #
3089: # Ready to print
3090: #
1.470 raeburn 3091: my $parmitem = &standard_parameter_names($name);
1.473 amueller 3092: $r->print(&tablestart().
3093: &Apache::loncommon::start_data_table_row().
3094: '<td><b>'.&mt($parmitem).
3095: '</b></td><td><input type="checkbox" name="del_'.
3096: $thiskey.'" /></td><td>');
3097: $foundkeys++;
3098: if (&isdateparm($thistype)) {
3099: my $jskey='key_'.$pointer;
3100: $pointer++;
3101: $r->print(
3102: &Apache::lonhtmlcommon::date_setter('parmform',
3103: $jskey,
3104: $$resourcedata{$thiskey},
3105: '',1,'','').
1.277 www 3106: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.413 bisitz 3107: (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
3108: &mt('Shift all dates based on this date').'</a></span>':'').
1.277 www 3109: &date_sanity_info($$resourcedata{$thiskey})
1.473 amueller 3110: );
3111: } elsif ($thistype eq 'date_interval') {
3112: $r->print(&date_interval_selector($thiskey,
3113: $$resourcedata{$thiskey}));
3114: } elsif ($thistype =~ m/^string/) {
3115: $r->print(&string_selector($thistype,$thiskey,
1.514 raeburn 3116: $$resourcedata{$thiskey},$name));
1.473 amueller 3117: } else {
3118: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
3119: }
3120: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
3121: $thistype.'" />');
3122: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
3123: }
1.121 www 3124: }
1.208 www 3125: return $foundkeys;
3126: }
3127:
1.385 albertel 3128:
3129: sub date_interval_selector {
3130: my ($thiskey, $showval) = @_;
3131: my $result;
3132: foreach my $which (['days', 86400, 31],
1.473 amueller 3133: ['hours', 3600, 23],
3134: ['minutes', 60, 59],
3135: ['seconds', 1, 59]) {
3136: my ($name, $factor, $max) = @{ $which };
3137: my $amount = int($showval/$factor);
3138: $showval %= $factor;
3139: my %select = ((map {$_ => $_} (0..$max)),
3140: 'select_form_order' => [0..$max]);
3141: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
1.496 raeburn 3142: \%select);
1.473 amueller 3143: $result .= ' '.&mt($name);
1.385 albertel 3144: }
3145: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
3146: return $result;
3147:
3148: }
3149:
3150: sub get_date_interval_from_form {
3151: my ($key) = @_;
3152: my $seconds = 0;
3153: foreach my $which (['days', 86400],
1.473 amueller 3154: ['hours', 3600],
3155: ['minutes', 60],
3156: ['seconds', 1]) {
3157: my ($name, $factor) = @{ $which };
3158: if (defined($env{'form.'.$name.'_'.$key})) {
3159: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3160: }
1.385 albertel 3161: }
3162: return $seconds;
3163: }
3164:
3165:
1.383 albertel 3166: sub default_selector {
3167: my ($thiskey, $showval) = @_;
1.385 albertel 3168: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3169: }
3170:
1.446 bisitz 3171: my %strings =
1.383 albertel 3172: (
3173: 'string_yesno'
3174: => [[ 'yes', 'Yes' ],
1.473 amueller 3175: [ 'no', 'No' ]],
1.383 albertel 3176: 'string_problemstatus'
3177: => [[ 'yes', 'Yes' ],
1.473 amueller 3178: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
3179: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3180: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
1.504 raeburn 3181: 'string_questiontype'
3182: => [[ 'problem', 'Standard Problem'],
3183: [ 'survey', 'Survey'],
3184: [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'],
1.530 bisitz 3185: [ 'exam', 'Bubblesheet Exam'],
1.504 raeburn 3186: [ 'anonsurvey', 'Anonymous Survey'],
3187: [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'],
3188: [ 'practice', 'Practice'],
3189: [ 'surveycred', 'Survey (credit for submission)']],
1.514 raeburn 3190: 'string_lenient'
3191: => [['yes', 'Yes' ],
3192: [ 'no', 'No' ],
1.521 raeburn 3193: [ 'default', 'Default - only bubblesheet grading is lenient' ]],
3194: 'string_discussvote'
3195: => [['yes','Yes'],
3196: ['notended','Yes, unless discussion ended'],
3197: ['no','No']],
1.383 albertel 3198: );
3199:
1.505 raeburn 3200: sub standard_string_options {
3201: my ($string_type) = @_;
3202: if (ref($strings{$string_type}) eq 'ARRAY') {
3203: return $strings{$string_type};
3204: }
3205: return;
3206: }
1.383 albertel 3207:
3208: sub string_selector {
1.514 raeburn 3209: my ($thistype, $thiskey, $showval, $name) = @_;
1.446 bisitz 3210:
1.383 albertel 3211: if (!exists($strings{$thistype})) {
1.473 amueller 3212: return &default_selector($thiskey,$showval);
1.383 albertel 3213: }
3214:
1.504 raeburn 3215: my %skiptype;
1.514 raeburn 3216: if (($thistype eq 'string_questiontype') ||
1.519 raeburn 3217: ($thistype eq 'string_lenient') ||
1.521 raeburn 3218: ($thistype eq 'string_discussvote') ||
1.519 raeburn 3219: ($name eq 'retrypartial')) {
1.504 raeburn 3220: my ($got_chostname,$chostname,$cmajor,$cminor);
3221: foreach my $possibilities (@{ $strings{$thistype} }) {
3222: next unless (ref($possibilities) eq 'ARRAY');
1.514 raeburn 3223: my ($parmval, $description) = @{ $possibilities };
3224: my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"};
1.504 raeburn 3225: if ($needsrelease) {
3226: unless ($got_chostname) {
1.514 raeburn 3227: ($chostname,$cmajor,$cminor)=¶meter_release_vars();
1.504 raeburn 3228: $got_chostname = 1;
3229: }
1.514 raeburn 3230: my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease,
1.544 ! raeburn 3231: $cmajor,$cminor);
1.504 raeburn 3232: if ($needsnewer) {
1.514 raeburn 3233: $skiptype{$parmval} = 1;
1.504 raeburn 3234: }
3235: }
3236: }
3237: }
1.514 raeburn 3238:
1.504 raeburn 3239:
1.383 albertel 3240: my $result;
1.504 raeburn 3241: my $numinrow = 3;
3242: if ($thistype eq 'string_problemstatus') {
3243: $numinrow = 2;
3244: } elsif ($thistype eq 'string_questiontype') {
3245: if (keys(%skiptype) > 0) {
3246: $numinrow = 4;
3247: }
3248: }
3249: my $rem;
3250: if (ref($strings{$thistype}) eq 'ARRAY') {
3251: my $i=0;
3252: foreach my $possibilities (@{ $strings{$thistype} }) {
3253: next unless (ref($possibilities) eq 'ARRAY');
3254: my ($name, $description) = @{ $possibilities };
3255: next if ($skiptype{$name});
3256: $rem = $i%($numinrow);
3257: if ($rem == 0) {
3258: if ($i > 0) {
3259: $result .= '</tr>';
3260: }
3261: $result .= '<tr>';
3262: }
3263: $result .= '<td class="LC_left_item">'.
3264: '<span class="LC_nobreak"><label>'.
3265: '<input type="radio" name="set_'.$thiskey.
3266: '" value="'.$name.'"';
3267: if ($showval eq $name) {
3268: $result .= ' checked="checked"';
3269: }
3270: $result .= ' />'.&mt($description).'</label></span></td>';
3271: $i++;
3272: }
3273: $rem = @{ $strings{$thistype} }%($numinrow);
3274: my $colsleft = $numinrow - $rem;
3275: if ($colsleft > 1 ) {
3276: $result .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3277: ' </td>';
3278: } elsif ($colsleft == 1) {
3279: $result .= '<td class="LC_left_item"> </td>';
3280: }
3281: $result .= '</tr>';
1.473 amueller 3282: }
1.504 raeburn 3283: if ($result) {
3284: $result = '<table border="0">'.$result.'</table>';
1.383 albertel 3285: }
3286: return $result;
3287: }
3288:
1.389 www 3289: #
3290: # Shift all start and end dates by $shift
3291: #
3292:
3293: sub dateshift {
3294: my ($shift)=@_;
3295: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3296: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3297: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3298: # ugly retro fix for broken version of types
3299: foreach my $key (keys %data) {
3300: if ($key=~/\wtype$/) {
3301: my $newkey=$key;
3302: $newkey=~s/type$/\.type/;
3303: $data{$newkey}=$data{$key};
3304: delete $data{$key};
3305: }
3306: }
1.391 www 3307: my %storecontent=();
1.389 www 3308: # go through all parameters and look for dates
3309: foreach my $key (keys %data) {
3310: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3311: my $newdate=$data{$key}+$shift;
1.391 www 3312: $storecontent{$key}=$newdate;
1.389 www 3313: }
3314: }
1.391 www 3315: my $reply=&Apache::lonnet::cput
3316: ('resourcedata',\%storecontent,$dom,$crs);
3317: if ($reply eq 'ok') {
3318: &log_parmset(\%storecontent);
3319: }
3320: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3321: return $reply;
1.389 www 3322: }
3323:
1.208 www 3324: sub newoverview {
1.280 albertel 3325: my ($r) = @_;
3326:
1.208 www 3327: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3328: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 3329: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1.414 droeschl 3330: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 3331: text=>"Overview Mode"});
1.523 raeburn 3332:
3333: my %loaditems = (
3334: 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1');",
3335: );
3336: my $js = '
3337: <script type="text/javascript">
3338: // <![CDATA[
3339: '.
3340: &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n".
3341: &showhide_js()."\n".
3342: '// ]]>
3343: </script>
3344: ';
3345: my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
3346: {'add_entries' => \%loaditems,});
1.298 albertel 3347: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 3348: $r->print($start_page.$breadcrumbs);
1.531 raeburn 3349: &startSettingsScreen($r,'parmset',$crstype);
1.208 www 3350: $r->print(<<ENDOVER);
1.232 albertel 3351: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3352: ENDOVER
1.211 www 3353: my @ids=();
3354: my %typep=();
3355: my %keyp=();
3356: my %allparms=();
3357: my %allparts=();
3358: my %allmaps=();
3359: my %mapp=();
3360: my %symbp=();
3361: my %maptitles=();
3362: my %uris=();
3363: my %keyorder=&standardkeyorder();
3364: my %defkeytype=();
3365:
3366: my %alllevs=();
3367: $alllevs{'Resource Level'}='full';
1.215 www 3368: $alllevs{'Map/Folder Level'}='map';
1.211 www 3369: $alllevs{'Course Level'}='general';
3370:
3371: my $csec=$env{'form.csec'};
1.269 raeburn 3372: my $cgroup=$env{'form.cgroup'};
1.211 www 3373:
3374: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3375: my $pschp=$env{'form.pschp'};
1.506 www 3376:
1.211 www 3377: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.516 www 3378: if (!@psprt) { $psprt[0]='all'; }
1.211 www 3379:
1.446 bisitz 3380: my @selected_sections =
1.473 amueller 3381: &Apache::loncommon::get_env_multiple('form.Section');
1.211 www 3382: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3383: foreach my $sec (@selected_sections) {
3384: if ($sec eq 'all') {
1.211 www 3385: @selected_sections = ('all');
3386: }
3387: }
1.269 raeburn 3388: my @selected_groups =
3389: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3390:
3391: my $pssymb='';
3392: my $parmlev='';
1.446 bisitz 3393:
1.211 www 3394: unless ($env{'form.parmlev'}) {
3395: $parmlev = 'map';
3396: } else {
3397: $parmlev = $env{'form.parmlev'};
3398: }
3399:
1.446 bisitz 3400: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 3401: \%mapp, \%symbp,\%maptitles,\%uris,
3402: \%keyorder,\%defkeytype);
1.211 www 3403:
1.374 albertel 3404: if (grep {$_ eq 'all'} (@psprt)) {
1.481 amueller 3405: @psprt = keys(%allparts);
1.374 albertel 3406: }
1.211 www 3407: # Menu to select levels, etc
3408:
1.456 bisitz 3409: $r->print('<div class="LC_Box">');
1.445 neumanie 3410: #$r->print('<h2 class="LC_hcell">Step 1</h2>');
1.452 bisitz 3411: $r->print('<div>');
1.523 raeburn 3412: $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
1.211 www 3413: &levelmenu($r,\%alllevs,$parmlev);
3414: if ($parmlev ne 'general') {
1.447 bisitz 3415: $r->print(&Apache::lonhtmlcommon::row_closure());
1.483 amueller 3416: &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp);
1.211 www 3417: }
1.447 bisitz 3418: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 3419: $r->print(&Apache::lonhtmlcommon::end_pick_box());
3420: $r->print('</div></div>');
1.446 bisitz 3421:
1.456 bisitz 3422: $r->print('<div class="LC_Box">');
1.452 bisitz 3423: $r->print('<div>');
1.510 www 3424: &displaymenu($r,\%allparms,\@pscat,\%keyorder);
1.453 schualex 3425: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.446 bisitz 3426: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
1.481 amueller 3427: $r->print('<table>'.
1.317 albertel 3428: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3429: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3430: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3431: $r->print('</td><td>');
1.211 www 3432: §ionmenu($r,\@selected_sections);
1.317 albertel 3433: $r->print('</td><td>');
1.269 raeburn 3434: &groupmenu($r,\@selected_groups);
3435: $r->print('</td></tr></table>');
1.445 neumanie 3436: #$r->print('</td></tr></table>');
1.447 bisitz 3437: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1.445 neumanie 3438: $r->print(&Apache::lonhtmlcommon::end_pick_box());
3439: $r->print('</div></div>');
3440:
1.456 bisitz 3441: $r->print('<div class="LC_Box">');
1.452 bisitz 3442: $r->print('<div>');
1.214 www 3443: my $sortorder=$env{'form.sortorder'};
3444: unless ($sortorder) { $sortorder='realmstudent'; }
3445: &sortmenu($r,$sortorder);
1.445 neumanie 3446: $r->print('</div></div>');
1.446 bisitz 3447:
1.214 www 3448: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.446 bisitz 3449:
1.211 www 3450: # Build the list data hash from the specified parms
3451:
3452: my $listdata;
3453: %{$listdata}=();
3454:
3455: foreach my $cat (@pscat) {
1.269 raeburn 3456: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3457: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3458: }
3459:
1.212 www 3460: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3461:
1.481 amueller 3462: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3463:
3464: # Read modified data
3465:
1.481 amueller 3466: my $resourcedata=&readdata($crs,$dom);
1.211 www 3467:
3468: # List data
3469:
1.481 amueller 3470: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3471: }
3472: $r->print(&tableend().
1.473 amueller 3473: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.507 www 3474: '</form>');
3475: &endSettingsScreen($r);
3476: $r->print(&Apache::loncommon::end_page());
1.208 www 3477: }
3478:
1.269 raeburn 3479: sub secgroup_lister {
3480: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3481: foreach my $item (@{$selections}) {
3482: foreach my $part (@{$psprt}) {
3483: my $rootparmkey=$env{'request.course.id'};
3484: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3485: $rootparmkey.='.['.$item.']';
3486: }
3487: if ($parmlev eq 'general') {
3488: # course-level parameter
3489: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3490: $$listdata{$newparmkey}=1;
3491: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3492: } elsif ($parmlev eq 'map') {
3493: # map-level parameter
3494: foreach my $mapid (keys %{$allmaps}) {
3495: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3496: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3497: $$listdata{$newparmkey}=1;
3498: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3499: }
3500: } else {
3501: # resource-level parameter
3502: foreach my $rid (@{$ids}) {
3503: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3504: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3505: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3506: $$listdata{$newparmkey}=1;
3507: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3508: }
3509: }
3510: }
3511: }
3512: }
3513:
1.208 www 3514: sub overview {
1.280 albertel 3515: my ($r) = @_;
1.208 www 3516: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3517: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 3518: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1.280 albertel 3519:
1.414 droeschl 3520: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
1.473 amueller 3521: text=>"Overview Mode"});
1.280 albertel 3522: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3523: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.507 www 3524: $r->print($start_page.$breadcrumbs);
1.531 raeburn 3525: &startSettingsScreen($r,'parmset',$crstype);
1.507 www 3526: $r->print('<form method="post" action="/adm/parmset?action=setoverview" name="parmform">');
3527:
1.208 www 3528: # Store modified
3529:
3530: &storedata($r,$crs,$dom);
3531:
3532: # Read modified data
3533:
3534: my $resourcedata=&readdata($crs,$dom);
3535:
1.214 www 3536:
3537: my $sortorder=$env{'form.sortorder'};
3538: unless ($sortorder) { $sortorder='realmstudent'; }
3539: &sortmenu($r,$sortorder);
3540:
1.208 www 3541: # List data
3542:
1.214 www 3543: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3544:
1.145 www 3545: $r->print(&tableend().'<p>'.
1.527 bisitz 3546: ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':'<span class="LC_info">'.&mt('There are no parameters.').'</span>').'</p></form>'.
1.473 amueller 3547: &Apache::loncommon::end_page());
1.120 www 3548: }
1.121 www 3549:
1.333 albertel 3550: sub clean_parameters {
3551: my ($r) = @_;
3552: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3553: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3554:
1.414 droeschl 3555: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
1.473 amueller 3556: text=>"Clean Parameters"});
1.333 albertel 3557: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3558: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3559: $r->print(<<ENDOVER);
3560: $start_page
3561: $breadcrumbs
3562: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3563: ENDOVER
3564: # Store modified
3565:
3566: &storedata($r,$crs,$dom);
3567:
3568: # Read modified data
3569:
3570: my $resourcedata=&readdata($crs,$dom);
3571:
3572: # List data
3573:
3574: $r->print('<h3>'.
1.473 amueller 3575: &mt('These parameters refer to resources that do not exist.').
3576: '</h3>'.
3577: '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
3578: '<br />');
1.333 albertel 3579: $r->print(&Apache::loncommon::start_data_table().
1.473 amueller 3580: '<tr>'.
3581: '<th>'.&mt('Delete').'</th>'.
3582: '<th>'.&mt('Parameter').'</th>'.
3583: '</tr>');
1.333 albertel 3584: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
1.473 amueller 3585: next if (!exists($resourcedata->{$thiskey.'.type'})
3586: && $thiskey=~/\.type$/);
3587: my %data = &parse_key($thiskey);
3588: if (1) { #exists($data{'realm_exists'})
3589: #&& !$data{'realm_exists'}) {
3590: $r->print(&Apache::loncommon::start_data_table_row().
3591: '<tr>'.
3592: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3593:
3594: $r->print('<td>');
3595: my $display_value = $resourcedata->{$thiskey};
3596: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3597: $display_value =
3598: &Apache::lonlocal::locallocaltime($display_value);
3599: }
1.470 raeburn 3600: my $parmitem = &standard_parameter_names($data{'parameter_name'});
3601: $parmitem = &mt($parmitem);
1.473 amueller 3602: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3603: $parmitem,$resourcedata->{$thiskey}));
3604: $r->print('<br />');
3605: if ($data{'scope_type'} eq 'all') {
3606: $r->print(&mt('All users'));
3607: } elsif ($data{'scope_type'} eq 'user') {
3608: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3609: } elsif ($data{'scope_type'} eq 'section') {
3610: $r->print(&mt('Section: [_1]',$data{'scope'}));
3611: } elsif ($data{'scope_type'} eq 'group') {
3612: $r->print(&mt('Group: [_1]',$data{'scope'}));
3613: }
3614: $r->print('<br />');
3615: if ($data{'realm_type'} eq 'all') {
3616: $r->print(&mt('All Resources'));
3617: } elsif ($data{'realm_type'} eq 'folder') {
3618: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3619: } elsif ($data{'realm_type'} eq 'symb') {
3620: my ($map,$resid,$url) =
3621: &Apache::lonnet::decode_symb($data{'realm'});
1.529 raeburn 3622: $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
3623: $url.' <br /> ',
3624: $resid.' <br /> ',$map));
1.473 amueller 3625: }
3626: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
3627: $r->print('</td></tr>');
1.446 bisitz 3628:
1.473 amueller 3629: }
1.333 albertel 3630: }
3631: $r->print(&Apache::loncommon::end_data_table().'<p>'.
1.473 amueller 3632: '<input type="submit" value="'.&mt('Delete Selected').'" />'.
1.507 www 3633: '</p></form>');
3634: &endSettingsScreen($r);
3635: $r->print(&Apache::loncommon::end_page());
1.333 albertel 3636: }
3637:
1.390 www 3638: sub date_shift_one {
3639: my ($r) = @_;
3640: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3641: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 3642: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1.390 www 3643:
1.414 droeschl 3644: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 3645: text=>"Shifting Dates"});
1.390 www 3646: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3647: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 3648: $r->print($start_page.$breadcrumbs);
1.531 raeburn 3649: &startSettingsScreen($r,'parmset',$crstype);
1.538 bisitz 3650: $r->print('<form name="shiftform" method="post" action="">'.
1.390 www 3651: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3652: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3653: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
1.541 bisitz 3654: &Apache::lonhtmlcommon::date_setter('shiftform',
1.390 www 3655: 'timeshifted',
3656: $env{'form.timebase'},,
3657: '').
3658: '</td></tr></table>'.
3659: '<input type="hidden" name="action" value="dateshift2" />'.
3660: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3661: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
1.507 www 3662: &endSettingsScreen($r);
1.390 www 3663: $r->print(&Apache::loncommon::end_page());
3664: }
3665:
3666: sub date_shift_two {
3667: my ($r) = @_;
3668: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3669: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 3670: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1.414 droeschl 3671: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.473 amueller 3672: text=>"Shifting Dates"});
1.390 www 3673: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3674: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
1.507 www 3675: $r->print($start_page.$breadcrumbs);
1.531 raeburn 3676: &startSettingsScreen($r,'parmset',$crstype);
1.390 www 3677: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
1.543 bisitz 3678: $r->print('<h2>'.&mt('Shift Dates').'</h2>'.
3679: '<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
1.390 www 3680: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
1.543 bisitz 3681: &Apache::lonlocal::locallocaltime($timeshifted)).'</p>');
1.390 www 3682: my $delta=$timeshifted-$env{'form.timebase'};
3683: &dateshift($delta);
1.543 bisitz 3684: $r->print(
3685: &Apache::lonhtmlcommon::confirm_success(&mt('Done')).
3686: '<br /><br />'.
3687: &Apache::lonhtmlcommon::actionbox(
3688: ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));
1.507 www 3689: &endSettingsScreen($r);
1.390 www 3690: $r->print(&Apache::loncommon::end_page());
3691: }
3692:
1.333 albertel 3693: sub parse_key {
3694: my ($key) = @_;
3695: my %data;
3696: my ($middle,$part,$name)=
1.473 amueller 3697: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.333 albertel 3698: $data{'scope_type'} = 'all';
3699: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 3700: $data{'scope'} = $1;
3701: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
3702: $data{'scope_type'} = 'user';
3703: $data{'scope'} = [$1,$2];
3704: } else {
3705: #FIXME check for group scope
3706: $data{'scope_type'} = 'section';
3707: }
3708: $middle=~s/^\[(.*)\]//;
1.333 albertel 3709: }
3710: $middle=~s/\.+$//;
3711: $middle=~s/^\.+//;
3712: $data{'realm_type'}='all';
3713: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 3714: $data{'realm'} = $1;
3715: $data{'realm_type'} = 'folder';
3716: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3717: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
1.333 albertel 3718: } elsif ($middle) {
1.473 amueller 3719: $data{'realm'} = $middle;
3720: $data{'realm_type'} = 'symb';
3721: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3722: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3723: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
1.333 albertel 3724: }
1.446 bisitz 3725:
1.333 albertel 3726: $data{'parameter_part'} = $part;
3727: $data{'parameter_name'} = $name;
3728:
3729: return %data;
3730: }
3731:
1.239 raeburn 3732:
1.416 jms 3733: sub header {
1.507 www 3734: return &Apache::loncommon::start_page('Settings');
1.416 jms 3735: }
1.193 albertel 3736:
3737:
3738:
3739: sub print_main_menu {
3740: my ($r,$parm_permission)=@_;
3741: #
1.414 droeschl 3742: $r->print(&header());
1.507 www 3743: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
1.531 raeburn 3744: my $crstype = &Apache::loncommon::course_type();
3745: my $lc_crstype = lc($crstype);
3746:
3747: &startSettingsScreen($r,'parmset',$crstype);
1.193 albertel 3748: $r->print(<<ENDMAINFORMHEAD);
3749: <form method="post" enctype="multipart/form-data"
3750: action="/adm/parmset" name="studentform">
3751: ENDMAINFORMHEAD
3752: #
1.195 albertel 3753: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3754: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3755: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3756: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.520 raeburn 3757: my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
3758: if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
3759: $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
3760: '/'.$env{'request.course.sec'});
3761: }
1.268 albertel 3762:
1.193 albertel 3763: my @menu =
1.507 www 3764: ( { categorytitle=>"Content Settings for this $crstype",
1.473 amueller 3765: items => [
3766: { linktext => 'Portfolio Metadata',
3767: url => '/adm/parmset?action=setrestrictmeta',
3768: permission => $parm_permission,
1.477 raeburn 3769: linktitle => "Restrict metadata for this $lc_crstype." ,
1.473 amueller 3770: icon =>'contact-new.png' ,
3771: },
3772: { linktext => 'Reset Student Access Times',
3773: url => '/adm/helper/resettimes.helper',
3774: permission => $mgr,
1.477 raeburn 3775: linktitle => "Reset access times for folders/maps, resources or the $lc_crstype." ,
1.473 amueller 3776: icon => 'start-here.png' ,
3777: },
1.520 raeburn 3778: { linktext => 'Blocking Communication/Resource Access',
3779: url => '/adm/setblock',
3780: permission => $dcm,
3781: linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
3782: icon => 'comblock.png',
3783: },
1.473 amueller 3784: { linktext => 'Set Parameter Setting Default Actions',
3785: url => '/adm/parmset?action=setdefaults',
3786: permission => $parm_permission,
3787: linktitle =>'Set default actions for parameters.' ,
3788: icon => 'folder-new.png' ,
3789: }]},
3790: { categorytitle => 'New and Existing Parameter Settings for Resources',
3791: items => [
3792: { linktext => 'Edit Resource Parameters - Helper Mode',
3793: url => '/adm/helper/parameter.helper',
3794: permission => $parm_permission,
3795: linktitle =>'Set/Modify resource parameters in helper mode.' ,
3796: icon => 'dialog-information.png' ,
3797: #help => 'Parameter_Helper',
3798: },
3799: { linktext => 'Edit Resource Parameters - Overview Mode',
3800: url => '/adm/parmset?action=newoverview',
3801: permission => $parm_permission,
3802: linktitle =>'Set/Modify resource parameters in overview mode.' ,
3803: icon => 'edit-find.png' ,
3804: #help => 'Parameter_Overview',
3805: },
3806: { linktext => 'Edit Resource Parameters - Table Mode',
3807: url => '/adm/parmset?action=settable',
3808: permission => $parm_permission,
3809: linktitle =>'Set/Modify resource parameters in table mode.' ,
3810: icon => 'edit-copy.png' ,
3811: #help => 'Table_Mode',
3812: }]},
1.417 droeschl 3813: { categorytitle => 'Existing Parameter Settings for Resources',
1.473 amueller 3814: items => [
3815: { linktext => 'Modify Resource Parameters - Overview Mode',
3816: url => '/adm/parmset?action=setoverview',
3817: permission => $parm_permission,
3818: linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
3819: icon => 'preferences-desktop-wallpaper.png' ,
3820: #help => 'Parameter_Overview',
3821: },
3822: { linktext => 'Change Log',
3823: url => '/adm/parmset?action=parameterchangelog',
3824: permission => $parm_permission,
1.477 raeburn 3825: linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
1.487 wenzelju 3826: icon => 'document-properties.png',
1.473 amueller 3827: }]}
1.193 albertel 3828: );
1.414 droeschl 3829: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.539 raeburn 3830: $r->print('</form>');
1.507 www 3831: &endSettingsScreen($r);
1.539 raeburn 3832: $r->print(&Apache::loncommon::end_page());
1.193 albertel 3833: return;
3834: }
1.414 droeschl 3835:
1.416 jms 3836:
3837:
1.252 banghart 3838: sub output_row {
1.347 banghart 3839: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3840: my $output;
1.263 banghart 3841: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3842: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3843: if (!defined($options)) {
1.254 banghart 3844: $options = 'active,stuadd';
1.261 banghart 3845: $values = '';
1.252 banghart 3846: }
1.337 banghart 3847: if (!($options =~ /deleted/)) {
3848: my @options= ( ['active', 'Show to student'],
1.418 schafran 3849: ['stuadd', 'Provide text area for students to type metadata'],
1.351 banghart 3850: ['choices','Provide choices for students to select from']);
1.473 amueller 3851: # ['onlyone','Student may select only one choice']);
1.337 banghart 3852: if ($added_flag) {
3853: push @options,['deleted', 'Delete Metadata Field'];
3854: }
1.351 banghart 3855: $output = &Apache::loncommon::start_data_table_row();
1.451 bisitz 3856: $output .= '<td><strong>'.$field_text.':</strong></td>';
1.351 banghart 3857: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3858: foreach my $opt (@options) {
1.473 amueller 3859: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3860: $output .= &Apache::loncommon::continue_data_table_row();
3861: $output .= '<td>'.(' ' x 5).'<label>
3862: <input type="checkbox" name="'.
3863: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3864: &mt($opt->[1]).'</label></td>';
3865: $output .= &Apache::loncommon::end_data_table_row();
3866: }
1.351 banghart 3867: $output .= &Apache::loncommon::continue_data_table_row();
1.451 bisitz 3868: $output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
1.351 banghart 3869: $output .= &Apache::loncommon::end_data_table_row();
3870: my $multiple_checked;
3871: my $single_checked;
3872: if ($options =~ m/onlyone/) {
1.422 bisitz 3873: $multiple_checked = '';
1.423 bisitz 3874: $single_checked = ' checked="checked"';
1.351 banghart 3875: } else {
1.423 bisitz 3876: $multiple_checked = ' checked="checked"';
1.422 bisitz 3877: $single_checked = '';
1.351 banghart 3878: }
1.473 amueller 3879: $output .= &Apache::loncommon::continue_data_table_row();
3880: $output .= '<td>'.(' ' x 10).'
3881: <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
3882: '.&mt('Student may select multiple choices from list').'</td>';
3883: $output .= &Apache::loncommon::end_data_table_row();
3884: $output .= &Apache::loncommon::continue_data_table_row();
3885: $output .= '<td>'.(' ' x 10).'
3886: <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
3887: '.&mt('Student may select only one choice from list').'</td>';
3888: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3889: }
3890: return ($output);
3891: }
1.416 jms 3892:
3893:
3894:
1.340 banghart 3895: sub order_meta_fields {
3896: my ($r)=@_;
3897: my $idx = 1;
3898: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3899: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 3900: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};;
1.341 banghart 3901: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.414 droeschl 3902: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 3903: text=>"Add Metadata Field"});
1.345 banghart 3904: &Apache::lonhtmlcommon::add_breadcrumb
3905: ({href=>"/adm/parmset?action=setrestrictmeta",
3906: text=>"Restrict Metadata"},
3907: {text=>"Order Metadata"});
3908: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.531 raeburn 3909: &startSettingsScreen($r,'parmset',$crstype);
1.340 banghart 3910: if ($env{'form.storeorder'}) {
3911: my $newpos = $env{'form.newpos'} - 1;
3912: my $currentpos = $env{'form.currentpos'} - 1;
3913: my @neworder = ();
3914: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3915: my $i;
1.341 banghart 3916: if ($newpos > $currentpos) {
1.340 banghart 3917: # moving stuff up
3918: for ($i=0;$i<$currentpos;$i++) {
1.473 amueller 3919: $neworder[$i]=$oldorder[$i];
1.340 banghart 3920: }
3921: for ($i=$currentpos;$i<$newpos;$i++) {
1.473 amueller 3922: $neworder[$i]=$oldorder[$i+1];
1.340 banghart 3923: }
3924: $neworder[$newpos]=$oldorder[$currentpos];
3925: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
1.473 amueller 3926: $neworder[$i]=$oldorder[$i];
1.340 banghart 3927: }
3928: } else {
3929: # moving stuff down
1.473 amueller 3930: for ($i=0;$i<$newpos;$i++) {
3931: $neworder[$i]=$oldorder[$i];
3932: }
3933: $neworder[$newpos]=$oldorder[$currentpos];
3934: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3935: $neworder[$i]=$oldorder[$i-1];
3936: }
3937: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3938: $neworder[$i]=$oldorder[$i];
3939: }
1.340 banghart 3940: }
1.473 amueller 3941: my $ordered_fields = join ",", @neworder;
1.343 banghart 3942: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 3943: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.473 amueller 3944: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3945: }
1.357 raeburn 3946: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3947: my $ordered_fields;
1.340 banghart 3948: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3949: if (!@fields_in_order) {
3950: # no order found, pick sorted order then create metadata.addedorder key.
3951: foreach my $key (sort keys %$fields) {
3952: push @fields_in_order, $key;
1.341 banghart 3953: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3954: }
1.341 banghart 3955: my $put_result = &Apache::lonnet::put('environment',
1.446 bisitz 3956: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3957: }
1.340 banghart 3958: $r->print('<table>');
3959: my $num_fields = scalar(@fields_in_order);
3960: foreach my $key (@fields_in_order) {
3961: $r->print('<tr><td>');
3962: $r->print('<form method="post" action="">');
1.537 bisitz 3963: $r->print('<select name="newpos" onchange="this.form.submit()">');
1.340 banghart 3964: for (my $i = 1;$i le $num_fields;$i ++) {
3965: if ($i eq $idx) {
3966: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3967: } else {
3968: $r->print('<option value="'.$i.'">'.$i.'</option>');
3969: }
3970: }
3971: $r->print('</select></td><td>');
3972: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3973: $r->print('<input type="hidden" name="storeorder" value="true" />');
3974: $r->print('</form>');
3975: $r->print($$fields{$key}.'</td></tr>');
3976: $idx ++;
3977: }
3978: $r->print('</table>');
1.507 www 3979: &endSettingsScreen($r);
1.340 banghart 3980: return 'ok';
3981: }
1.416 jms 3982:
3983:
1.359 banghart 3984: sub continue {
3985: my $output;
3986: $output .= '<form action="" method="post">';
3987: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3988: $output .= '<input type="submit" value="Continue" />';
3989: return ($output);
3990: }
1.416 jms 3991:
3992:
1.334 banghart 3993: sub addmetafield {
3994: my ($r)=@_;
1.414 droeschl 3995: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
1.473 amueller 3996: text=>"Add Metadata Field"});
1.334 banghart 3997: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3998: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 3999: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4000: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 4001: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
4002: &startSettingsScreen($r,'parmset',$crstype);
1.339 banghart 4003: if (exists($env{'form.undelete'})) {
1.358 banghart 4004: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 4005: foreach my $meta_field(@meta_fields) {
4006: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
4007: $options =~ s/deleted//;
4008: $options =~ s/,,/,/;
4009: my $put_result = &Apache::lonnet::put('environment',
4010: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
1.446 bisitz 4011:
1.339 banghart 4012: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
4013: }
1.359 banghart 4014: $r->print(&continue());
1.339 banghart 4015: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 4016: my $meta_field = $env{'form.fieldname'};
4017: my $display_field = $env{'form.fieldname'};
4018: $meta_field =~ s/\W/_/g;
1.338 banghart 4019: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 4020: my $put_result = &Apache::lonnet::put('environment',
4021: {'metadata.'.$meta_field.'.values'=>"",
4022: 'metadata.'.$meta_field.'.added'=>"$display_field",
4023: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 4024: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
4025: $r->print(&continue());
1.335 banghart 4026: } else {
1.357 raeburn 4027: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 4028: if ($fields) {
4029: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
4030: $r->print('<form method="post" action="">');
4031: foreach my $key(keys(%$fields)) {
1.358 banghart 4032: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 4033: }
4034: $r->print('<input type="submit" name="undelete" value="Undelete" />');
4035: $r->print('</form>');
4036: }
4037: $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 4038: $r->print('<input type="text" name="fieldname" /><br />');
4039: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 4040: }
1.361 albertel 4041: $r->print('</form>');
1.507 www 4042: &endSettingsScreen($r);
1.334 banghart 4043: }
1.416 jms 4044:
4045:
4046:
1.259 banghart 4047: sub setrestrictmeta {
1.240 banghart 4048: my ($r)=@_;
1.242 banghart 4049: my $next_meta;
1.244 banghart 4050: my $output;
1.245 banghart 4051: my $item_num;
1.246 banghart 4052: my $put_result;
1.414 droeschl 4053: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
1.473 amueller 4054: text=>"Restrict Metadata"});
1.280 albertel 4055: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 4056: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 4057: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4058: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.531 raeburn 4059: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
4060: &startSettingsScreen($r,'parmset',$crstype);
1.259 banghart 4061: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 4062: my $save_field = '';
1.259 banghart 4063: if ($env{'form.restrictmeta'}) {
1.254 banghart 4064: foreach my $field (sort(keys(%env))) {
1.252 banghart 4065: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 4066: my $options;
1.252 banghart 4067: my $meta_field = $1;
4068: my $meta_key = $2;
1.253 banghart 4069: if ($save_field ne $meta_field) {
1.252 banghart 4070: $save_field = $meta_field;
1.473 amueller 4071: if ($env{'form.'.$meta_field.'_stuadd'}) {
4072: $options.='stuadd,';
4073: }
4074: if ($env{'form.'.$meta_field.'_choices'}) {
4075: $options.='choices,';
4076: }
4077: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
4078: $options.='onlyone,';
4079: }
4080: if ($env{'form.'.$meta_field.'_active'}) {
4081: $options.='active,';
4082: }
4083: if ($env{'form.'.$meta_field.'_deleted'}) {
4084: $options.='deleted,';
4085: }
1.259 banghart 4086: my $name = $save_field;
1.253 banghart 4087: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 4088: {'metadata.'.$meta_field.'.options'=>$options,
4089: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 4090: },$dom,$crs);
1.252 banghart 4091: }
4092: }
4093: }
4094: }
1.296 albertel 4095: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.473 amueller 4096: {'freshen_cache' => 1});
1.335 banghart 4097: # Get the default metadata fields
1.258 albertel 4098: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 4099: # Now get possible added metadata fields
1.357 raeburn 4100: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 4101: my $row_alt = 1;
1.347 banghart 4102: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 4103: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 4104: if ($field ne 'courserestricted') {
1.346 banghart 4105: $row_alt = $row_alt ? 0 : 1;
1.473 amueller 4106: $output.= &output_row($r, $field, $metadata_fields{$field});
4107: }
1.255 banghart 4108: }
1.351 banghart 4109: my $buttons = (<<ENDButtons);
4110: <input type="submit" name="restrictmeta" value="Save" />
4111: </form><br />
4112: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
4113: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
4114: </form>
4115: <br />
4116: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
4117: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
4118: ENDButtons
1.337 banghart 4119: my $added_flag = 1;
1.335 banghart 4120: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 4121: $row_alt = $row_alt ? 0 : 1;
4122: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 4123: }
1.347 banghart 4124: $output .= &Apache::loncommon::end_data_table();
1.446 bisitz 4125: $r->print(<<ENDenv);
1.259 banghart 4126: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 4127: $output
1.351 banghart 4128: $buttons
1.340 banghart 4129: </form>
1.244 banghart 4130: ENDenv
1.507 www 4131: &endSettingsScreen($r);
1.280 albertel 4132: $r->print(&Apache::loncommon::end_page());
1.240 banghart 4133: return 'ok';
4134: }
1.416 jms 4135:
4136:
4137:
1.335 banghart 4138: sub get_added_meta_fieldnames {
1.357 raeburn 4139: my ($cid) = @_;
1.335 banghart 4140: my %fields;
4141: foreach my $key(%env) {
1.357 raeburn 4142: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 4143: my $field_name = $1;
4144: my ($display_field_name) = $env{$key};
4145: $fields{$field_name} = $display_field_name;
4146: }
4147: }
4148: return \%fields;
4149: }
1.416 jms 4150:
4151:
4152:
1.339 banghart 4153: sub get_deleted_meta_fieldnames {
1.357 raeburn 4154: my ($cid) = @_;
1.339 banghart 4155: my %fields;
4156: foreach my $key(%env) {
1.357 raeburn 4157: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 4158: my $field_name = $1;
4159: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4160: my ($display_field_name) = $env{$key};
4161: $fields{$field_name} = $display_field_name;
4162: }
4163: }
4164: }
4165: return \%fields;
4166: }
1.220 www 4167: sub defaultsetter {
1.280 albertel 4168: my ($r) = @_;
4169:
1.414 droeschl 4170: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
1.473 amueller 4171: text=>"Set Defaults"});
1.531 raeburn 4172: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4173: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4174: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1.446 bisitz 4175: my $start_page =
1.531 raeburn 4176: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4177: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.507 www 4178: $r->print($start_page.$breadcrumbs);
1.531 raeburn 4179: &startSettingsScreen($r,'parmset',$crstype);
1.507 www 4180: $r->print('<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">');
1.280 albertel 4181:
1.221 www 4182: my @ids=();
4183: my %typep=();
4184: my %keyp=();
4185: my %allparms=();
4186: my %allparts=();
4187: my %allmaps=();
4188: my %mapp=();
4189: my %symbp=();
4190: my %maptitles=();
4191: my %uris=();
4192: my %keyorder=&standardkeyorder();
4193: my %defkeytype=();
4194:
1.446 bisitz 4195: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1.473 amueller 4196: \%mapp, \%symbp,\%maptitles,\%uris,
4197: \%keyorder,\%defkeytype);
1.224 www 4198: if ($env{'form.storerules'}) {
1.473 amueller 4199: my %newrules=();
4200: my @delrules=();
4201: my %triggers=();
4202: foreach my $key (keys(%env)) {
1.225 albertel 4203: if ($key=~/^form\.(\w+)\_action$/) {
1.473 amueller 4204: my $tempkey=$1;
4205: my $action=$env{$key};
1.226 www 4206: if ($action) {
1.473 amueller 4207: $newrules{$tempkey.'_action'}=$action;
4208: if ($action ne 'default') {
4209: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4210: $triggers{$whichparm}.=$tempkey.':';
4211: }
4212: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
4213: if (&isdateparm($defkeytype{$tempkey})) {
4214: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
4215: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4216: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4217: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4218: } else {
4219: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
4220: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
4221: }
4222: } else {
4223: push(@delrules,$tempkey.'_action');
4224: push(@delrules,$tempkey.'_type');
4225: push(@delrules,$tempkey.'_hours');
4226: push(@delrules,$tempkey.'_min');
4227: push(@delrules,$tempkey.'_sec');
4228: push(@delrules,$tempkey.'_value');
4229: }
4230: }
4231: }
4232: foreach my $key (keys %allparms) {
4233: $newrules{$key.'_triggers'}=$triggers{$key};
4234: }
1.531 raeburn 4235: &Apache::lonnet::put('parmdefactions',\%newrules,$cdom,$cnum);
4236: &Apache::lonnet::del('parmdefactions',\@delrules,$cdom,$cnum);
1.473 amueller 4237: &resetrulescache();
1.224 www 4238: }
1.227 www 4239: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
1.473 amueller 4240: 'hours' => 'Hours',
4241: 'min' => 'Minutes',
4242: 'sec' => 'Seconds',
4243: 'yes' => 'Yes',
4244: 'no' => 'No');
1.222 www 4245: my @standardoptions=('','default');
4246: my @standarddisplay=('',&mt('Default value when manually setting'));
4247: my @dateoptions=('','default');
4248: my @datedisplay=('',&mt('Default value when manually setting'));
4249: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4250: unless ($tempkey) { next; }
4251: push @standardoptions,'when_setting_'.$tempkey;
4252: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4253: if (&isdateparm($defkeytype{$tempkey})) {
4254: push @dateoptions,'later_than_'.$tempkey;
4255: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4256: push @dateoptions,'earlier_than_'.$tempkey;
4257: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4258: }
1.222 www 4259: }
1.231 www 4260: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
1.473 amueller 4261: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4262: $r->print("\n".&Apache::loncommon::start_data_table().
1.473 amueller 4263: &Apache::loncommon::start_data_table_header_row().
4264: "<th>".&mt('Rule for parameter').'</th><th>'.
4265: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4266: &Apache::loncommon::end_data_table_header_row());
1.221 www 4267: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.473 amueller 4268: unless ($tempkey) { next; }
4269: $r->print("\n".&Apache::loncommon::start_data_table_row().
4270: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
4271: my $action=&rulescache($tempkey.'_action');
4272: $r->print('<select name="'.$tempkey.'_action">');
4273: if (&isdateparm($defkeytype{$tempkey})) {
4274: for (my $i=0;$i<=$#dateoptions;$i++) {
4275: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4276: $r->print("\n<option value='$dateoptions[$i]'".
4277: ($dateoptions[$i] eq $action?' selected="selected"':'').
4278: ">$datedisplay[$i]</option>");
4279: }
4280: } else {
4281: for (my $i=0;$i<=$#standardoptions;$i++) {
4282: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4283: $r->print("\n<option value='$standardoptions[$i]'".
4284: ($standardoptions[$i] eq $action?' selected="selected"':'').
4285: ">$standarddisplay[$i]</option>");
4286: }
4287: }
4288: $r->print('</select>');
4289: unless (&isdateparm($defkeytype{$tempkey})) {
4290: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4291: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4292: }
4293: $r->print("\n</td><td>\n");
1.222 www 4294:
1.221 www 4295: if (&isdateparm($defkeytype{$tempkey})) {
1.473 amueller 4296: my $days=&rulescache($tempkey.'_days');
4297: my $hours=&rulescache($tempkey.'_hours');
4298: my $min=&rulescache($tempkey.'_min');
4299: my $sec=&rulescache($tempkey.'_sec');
4300: $r->print(<<ENDINPUTDATE);
1.227 www 4301: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4302: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4303: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4304: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4305: ENDINPUTDATE
1.473 amueller 4306: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4307: my $yeschecked='';
4308: my $nochecked='';
1.444 bisitz 4309: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
4310: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
1.222 www 4311:
1.473 amueller 4312: $r->print(<<ENDYESNO);
1.444 bisitz 4313: <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
4314: <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
1.221 www 4315: ENDYESNO
4316: } else {
1.473 amueller 4317: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
4318: }
1.318 albertel 4319: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4320: }
1.318 albertel 4321: $r->print(&Apache::loncommon::end_data_table().
1.473 amueller 4322: "\n".'<input type="submit" name="storerules" value="'.
1.507 www 4323: &mt('Save').'" /></form>'."\n");
4324: &endSettingsScreen($r);
4325: $r->print(&Apache::loncommon::end_page());
1.220 www 4326: return;
4327: }
1.193 albertel 4328:
1.290 www 4329: sub components {
1.330 albertel 4330: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4331:
4332: if ($typeflag) {
1.473 amueller 4333: $key=~s/\.type$//;
1.290 www 4334: }
1.330 albertel 4335:
4336: my ($middle,$part,$name)=
1.473 amueller 4337: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4338: my $issection;
1.330 albertel 4339:
1.290 www 4340: my $section=&mt('All Students');
4341: if ($middle=~/^\[(.*)\]/) {
1.473 amueller 4342: $issection=$1;
4343: $section=&mt('Group/Section').': '.$issection;
4344: $middle=~s/^\[(.*)\]//;
1.290 www 4345: }
4346: $middle=~s/\.+$//;
4347: $middle=~s/^\.+//;
1.291 www 4348: if ($uname) {
1.473 amueller 4349: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4350: $issection='';
1.291 www 4351: }
1.316 albertel 4352: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.446 bisitz 4353: my $realmdescription=&mt('all resources');
1.290 www 4354: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.473 amueller 4355: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
4356: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
1.304 www 4357: } elsif ($middle) {
1.473 amueller 4358: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
4359: $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>';
4360: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4361: }
1.291 www 4362: my $what=$part.'.'.$name;
1.330 albertel 4363: return ($realm,$section,$name,$part,
1.473 amueller 4364: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4365: }
1.293 www 4366:
1.328 albertel 4367: my %standard_parms;
1.469 raeburn 4368: my %standard_parms_types;
1.416 jms 4369:
1.328 albertel 4370: sub load_parameter_names {
4371: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4372: while (my $configline=<$config>) {
1.473 amueller 4373: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4374: chomp($configline);
4375: my ($short,$plain)=split(/:/,$configline);
4376: my (undef,$name,$type)=split(/\&/,$short,3);
4377: if ($type eq 'display') {
4378: $standard_parms{$name} = $plain;
1.469 raeburn 4379: } elsif ($type eq 'type') {
4380: $standard_parms_types{$name} = $plain;
4381: }
1.328 albertel 4382: }
4383: close($config);
4384: $standard_parms{'int_pos'} = 'Positive Integer';
4385: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4386: }
4387:
1.292 www 4388: sub standard_parameter_names {
4389: my ($name)=@_;
1.328 albertel 4390: if (!%standard_parms) {
1.473 amueller 4391: &load_parameter_names();
1.328 albertel 4392: }
1.292 www 4393: if ($standard_parms{$name}) {
1.473 amueller 4394: return $standard_parms{$name};
1.446 bisitz 4395: } else {
1.473 amueller 4396: return $name;
1.292 www 4397: }
4398: }
1.290 www 4399:
1.469 raeburn 4400: sub standard_parameter_types {
4401: my ($name)=@_;
4402: if (!%standard_parms_types) {
4403: &load_parameter_names();
4404: }
4405: if ($standard_parms_types{$name}) {
4406: return $standard_parms_types{$name};
4407: }
4408: return;
4409: }
1.309 www 4410:
1.285 albertel 4411: sub parm_change_log {
1.284 www 4412: my ($r)=@_;
1.531 raeburn 4413: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4414: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4415: my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}
1.414 droeschl 4416: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.473 amueller 4417: text=>"Parameter Change Log"});
1.522 raeburn 4418: my $js = '<script type="text/javascript">'."\n".
4419: '// <![CDATA['."\n".
4420: &Apache::loncommon::display_filter_js('parmslog')."\n".
4421: '// ]]>'."\n".
4422: '</script>'."\n";
4423: $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
1.327 albertel 4424: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
1.531 raeburn 4425: &startSettingsScreen($r,'parmset',$crstype);
4426: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',$cdom,$cnum);
1.311 albertel 4427:
1.301 www 4428: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4429:
1.522 raeburn 4430: $r->print('<div class="LC_left_float">'.
4431: '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
4432: '<form action="/adm/parmset?action=parameterchangelog"
1.327 albertel 4433: method="post" name="parameterlog">');
1.446 bisitz 4434:
1.311 albertel 4435: my %saveable_parameters = ('show' => 'scalar',);
4436: &Apache::loncommon::store_course_settings('parameter_log',
4437: \%saveable_parameters);
4438: &Apache::loncommon::restore_course_settings('parameter_log',
4439: \%saveable_parameters);
1.522 raeburn 4440: $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
4441: '<input type="submit" value="'.&mt('Display').'" />'.
4442: '</form></fieldset></div><br clear="all" />');
1.301 www 4443:
1.531 raeburn 4444: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.301 www 4445: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1.473 amueller 4446: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4447: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4448: &Apache::loncommon::end_data_table_header_row());
1.309 www 4449: my $shown=0;
1.349 www 4450: my $folder='';
4451: if ($env{'form.displayfilter'} eq 'currentfolder') {
1.473 amueller 4452: my $last='';
4453: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4454: &GDBM_READER(),0640)) {
4455: $last=$hash{'last_known'};
4456: untie(%hash);
4457: }
4458: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
1.349 www 4459: }
1.446 bisitz 4460: foreach my $id (sort
1.473 amueller 4461: {
4462: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4463: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4464: }
4465: my $aid = (split('00000',$a))[-1];
4466: my $bid = (split('00000',$b))[-1];
4467: return $bid<=>$aid;
4468: } (keys(%parmlog))) {
1.294 www 4469: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.473 amueller 4470: my $count = 0;
4471: my $time =
4472: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
4473: my $plainname =
4474: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4475: $parmlog{$id}{'exe_udom'});
4476: my $about_me_link =
4477: &Apache::loncommon::aboutmewrapper($plainname,
4478: $parmlog{$id}{'exe_uname'},
4479: $parmlog{$id}{'exe_udom'});
4480: my $send_msg_link='';
4481: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4482: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
4483: $send_msg_link ='<br />'.
4484: &Apache::loncommon::messagewrapper(&mt('Send message'),
4485: $parmlog{$id}{'exe_uname'},
4486: $parmlog{$id}{'exe_udom'});
4487: }
4488: my $row_start=&Apache::loncommon::start_data_table_row();
4489: my $makenewrow=0;
4490: my %istype=();
4491: my $output;
4492: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4493: my $value=$parmlog{$id}{'logentry'}{$changed};
1.473 amueller 4494: my $typeflag = ($changed =~/\.type$/ &&
4495: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4496: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.473 amueller 4497: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
4498: if ($env{'form.displayfilter'} eq 'currentfolder') {
4499: if ($folder) {
4500: if ($middle!~/^\Q$folder\E/) { next; }
4501: }
4502: }
4503: if ($typeflag) {
4504: $istype{$parmname}=$value;
4505: if (!$env{'form.includetypes'}) { next; }
4506: }
4507: $count++;
4508: if ($makenewrow) {
4509: $output .= $row_start;
4510: } else {
4511: $makenewrow=1;
4512: }
1.470 raeburn 4513: my $parmitem = &standard_parameter_names($parmname);
1.473 amueller 4514: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
4515: &mt($parmitem).'</td><td>'.
4516: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
4517: my $stillactive=0;
4518: if ($parmlog{$id}{'delflag'}) {
4519: $output .= &mt('Deleted');
4520: } else {
4521: if ($typeflag) {
1.470 raeburn 4522: my $parmitem = &standard_parameter_names($value);
4523: $parmitem = &mt($parmitem);
1.473 amueller 4524: $output .= &mt('Type: [_1]',$parmitem);
4525: } else {
4526: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4527: $uname,$udom,$issection,$issection,$courseopt);
1.469 raeburn 4528: my $showvalue = $value;
4529: if ($istype{$parmname} eq '') {
4530: my $type = &standard_parameter_types($parmname);
4531: if ($type ne '') {
4532: if (&isdateparm($type)) {
4533: $showvalue =
4534: &Apache::lonlocal::locallocaltime($value);
4535: }
4536: }
4537: } else {
1.473 amueller 4538: if (&isdateparm($istype{$parmname})) {
4539: $showvalue =
1.469 raeburn 4540: &Apache::lonlocal::locallocaltime($value);
1.473 amueller 4541: }
1.469 raeburn 4542: }
4543: $output .= $showvalue;
1.473 amueller 4544: if ($value ne $all[$level]) {
4545: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
4546: } else {
4547: $stillactive=1;
4548: }
4549: }
4550: }
4551: $output .= '</td><td>';
1.470 raeburn 4552:
1.473 amueller 4553: if ($stillactive) {
1.470 raeburn 4554: my $parmitem = &standard_parameter_names($parmname);
4555: $parmitem = &mt($parmitem);
1.473 amueller 4556: my $title=&mt('Changed [_1]',$parmitem);
1.471 raeburn 4557: my $description=&mt('Changed [_1] for [_2] to [_3]',
4558: $parmitem,$realmdescription,
1.473 amueller 4559: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
4560: if (($uname) && ($udom)) {
4561: $output .=
4562: &Apache::loncommon::messagewrapper('Notify User',
4563: $uname,$udom,$title,
4564: $description);
4565: } else {
4566: $output .=
4567: &Apache::lonrss::course_blog_link($id,$title,
4568: $description);
4569: }
4570: }
4571: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4572: }
1.349 www 4573: if ($env{'form.displayfilter'} eq 'containing') {
1.473 amueller 4574: my $wholeentry=$about_me_link.':'.
4575: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4576: $output;
4577: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4578: }
1.349 www 4579: if ($count) {
1.473 amueller 4580: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4581: <td rowspan="'.$count.'">'.$about_me_link.
1.473 amueller 4582: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4583: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4584: $send_msg_link.'</td>'.$output);
4585: $shown++;
4586: }
4587: if (!($env{'form.show'} eq &mt('all')
4588: || $shown<=$env{'form.show'})) { last; }
1.286 www 4589: }
1.301 www 4590: $r->print(&Apache::loncommon::end_data_table());
1.507 www 4591: &endSettingsScreen($r);
1.284 www 4592: $r->print(&Apache::loncommon::end_page());
4593: }
4594:
1.437 raeburn 4595: sub update_slots {
4596: my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
4597: my %slot=&Apache::lonnet::get_slot($slot_name);
4598: if (!keys(%slot)) {
4599: return 'error: slot does not exist';
4600: }
4601: my $max=$slot{'maxspace'};
4602: if (!defined($max)) { $max=99999; }
4603:
4604: my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
4605: "^$slot_name\0");
4606: my ($tmp)=%consumed;
4607: if ($tmp=~/^error: 2 / ) {
4608: return 'error: unable to determine current slot status';
4609: }
4610: my $last=0;
4611: foreach my $key (keys(%consumed)) {
4612: my $num=(split('\0',$key))[1];
4613: if ($num > $last) { $last=$num; }
4614: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4615: return 'ok';
4616: }
4617: }
4618:
4619: if (scalar(keys(%consumed)) >= $max) {
4620: return 'error: no space left in slot';
4621: }
4622: my $wanted=$last+1;
4623:
4624: my %reservation=('name' => $uname.':'.$udom,
4625: 'timestamp' => time,
4626: 'symb' => $symb);
4627:
4628: my $success=&Apache::lonnet::newput('slot_reservations',
4629: {"$slot_name\0$wanted" =>
4630: \%reservation},
4631: $cdom, $cnum);
1.438 raeburn 4632: if ($success eq 'ok') {
4633: my %storehash = (
4634: symb => $symb,
4635: slot => $slot_name,
4636: action => 'reserve',
4637: context => 'parameter',
4638: );
1.526 raeburn 4639: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.524 raeburn 4640: '',$uname,$udom,$cnum,$cdom);
1.438 raeburn 4641:
1.526 raeburn 4642: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.524 raeburn 4643: '',$uname,$udom,$uname,$udom);
1.438 raeburn 4644: }
1.437 raeburn 4645: return $success;
4646: }
4647:
4648: sub delete_slots {
4649: my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
4650: my $delresult;
4651: my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
4652: $cnum, "^$slot_name\0");
4653: if (&Apache::lonnet::error(%consumed)) {
4654: return 'error: unable to determine current slot status';
4655: }
4656: my ($tmp)=%consumed;
4657: if ($tmp=~/^error: 2 /) {
4658: return 'error: unable to determine current slot status';
4659: }
4660: foreach my $key (keys(%consumed)) {
4661: if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
4662: my $num=(split('\0',$key))[1];
4663: my $entry = $slot_name.'\0'.$num;
4664: $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
4665: $cdom,$cnum);
4666: if ($delresult eq 'ok') {
4667: my %storehash = (
4668: symb => $symb,
4669: slot => $slot_name,
4670: action => 'release',
4671: context => 'parameter',
4672: );
1.526 raeburn 4673: &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1.524 raeburn 4674: 1,$uname,$udom,$cnum,$cdom);
1.526 raeburn 4675: &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1.524 raeburn 4676: 1,$uname,$udom,$uname,$udom);
1.437 raeburn 4677: }
4678: }
4679: }
4680: return $delresult;
4681: }
4682:
1.355 albertel 4683: sub check_for_course_info {
4684: my $navmap = Apache::lonnavmaps::navmap->new();
4685: return 1 if ($navmap);
4686: return 0;
4687: }
4688:
1.514 raeburn 4689: sub parameter_release_vars {
1.504 raeburn 4690: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4691: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
4692: my $chostname = &Apache::lonnet::hostname($chome);
4693: my ($cmajor,$cminor) =
4694: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
4695: return ($chostname,$cmajor,$cminor);
4696: }
4697:
1.514 raeburn 4698: sub parameter_releasecheck {
1.544 ! raeburn 4699: my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
1.504 raeburn 4700: my $needsnewer;
4701: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
4702: if (($cmajor < $needsmajor) ||
4703: ($cmajor == $needsmajor && $cminor < $needsminor)) {
4704: $needsnewer = 1;
4705: } else {
1.514 raeburn 4706: &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
1.504 raeburn 4707: }
4708: return $needsnewer;
4709: }
4710:
4711: sub oldversion_warning {
1.514 raeburn 4712: my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
1.504 raeburn 4713: my $desc;
1.514 raeburn 4714: my %stringtypes = (
1.519 raeburn 4715: type => 'string_questiontype',
4716: lenient => 'string_lenient',
4717: retrypartial => 'string_yesno',
1.521 raeburn 4718: discussvote => 'string_discussvote',
1.533 raeburn 4719: examcode => 'string_examcode',
1.514 raeburn 4720: );
4721: if (exists($stringtypes{$name})) {
1.533 raeburn 4722: if ($name eq 'examcode') {
1.535 raeburn 4723: $desc = $value;
1.533 raeburn 4724: } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
1.514 raeburn 4725: foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
4726: next unless (ref($possibilities) eq 'ARRAY');
4727: my ($parmval, $description) = @{ $possibilities };
4728: if ($parmval eq $value) {
4729: $desc = $description;
4730: last;
4731: }
1.504 raeburn 4732: }
4733: }
4734: }
1.514 raeburn 4735: my $standard_name = &standard_parameter_names($name);
1.504 raeburn 4736: return '<p class="LC_warning">'.
1.514 raeburn 4737: &mt('[_1] was [_2]not[_3] set to [_4].',
4738: $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
1.504 raeburn 4739: &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
4740: $cmajor.'.'.$cminor,$chostname,
4741: $needsrelease).
4742: '</p>';
4743: }
1.259 banghart 4744:
1.30 www 4745: sub handler {
1.43 albertel 4746: my $r=shift;
1.30 www 4747:
1.376 albertel 4748: &reset_caches();
4749:
1.414 droeschl 4750: &Apache::loncommon::content_type($r,'text/html');
4751: $r->send_http_header;
4752: return OK if $r->header_only;
4753:
1.193 albertel 4754: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.473 amueller 4755: ['action','state',
1.205 www 4756: 'pres_marker',
4757: 'pres_value',
1.206 www 4758: 'pres_type',
1.506 www 4759: 'filter','part',
1.390 www 4760: 'udom','uname','symb','serial','timebase']);
1.131 www 4761:
1.83 bowersj2 4762:
1.193 albertel 4763: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4764: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
1.507 www 4765: text=>"Content and Problem Settings",
1.473 amueller 4766: faq=>10,
4767: bug=>'Instructor Interface',
1.442 droeschl 4768: help =>
4769: 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
1.203 www 4770:
1.30 www 4771: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4772: my $parm_permission =
1.473 amueller 4773: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
4774: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
4775: $env{'request.course.sec'}));
1.355 albertel 4776: my $exists = &check_for_course_info();
4777:
4778: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4779: #
4780: # Main switch on form.action and form.state, as appropriate
4781: #
4782: # Check first if coming from someone else headed directly for
4783: # the table mode
4784: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
1.473 amueller 4785: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
4786: &assessparms($r);
1.193 albertel 4787: } elsif (! exists($env{'form.action'})) {
4788: &print_main_menu($r,$parm_permission);
1.414 droeschl 4789: } elsif ($env{'form.action'} eq 'setoverview') {
1.473 amueller 4790: &overview($r);
4791: } elsif ($env{'form.action'} eq 'addmetadata') {
4792: &addmetafield($r);
4793: } elsif ($env{'form.action'} eq 'ordermetadata') {
4794: &order_meta_fields($r);
1.414 droeschl 4795: } elsif ($env{'form.action'} eq 'setrestrictmeta') {
1.473 amueller 4796: &setrestrictmeta($r);
1.414 droeschl 4797: } elsif ($env{'form.action'} eq 'newoverview') {
1.473 amueller 4798: &newoverview($r);
1.414 droeschl 4799: } elsif ($env{'form.action'} eq 'setdefaults') {
1.473 amueller 4800: &defaultsetter($r);
4801: } elsif ($env{'form.action'} eq 'settable') {
4802: &assessparms($r);
1.414 droeschl 4803: } elsif ($env{'form.action'} eq 'parameterchangelog') {
1.473 amueller 4804: &parm_change_log($r);
1.414 droeschl 4805: } elsif ($env{'form.action'} eq 'cleanparameters') {
1.473 amueller 4806: &clean_parameters($r);
1.414 droeschl 4807: } elsif ($env{'form.action'} eq 'dateshift1') {
1.390 www 4808: &date_shift_one($r);
1.414 droeschl 4809: } elsif ($env{'form.action'} eq 'dateshift2') {
1.390 www 4810: &date_shift_two($r);
1.446 bisitz 4811: }
1.43 albertel 4812: } else {
1.1 www 4813: # ----------------------------- Not in a course, or not allowed to modify parms
1.473 amueller 4814: if ($exists) {
4815: $env{'user.error.msg'}=
4816: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4817: } else {
4818: $env{'user.error.msg'}=
4819: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4820: }
4821: return HTTP_NOT_ACCEPTABLE;
1.43 albertel 4822: }
1.376 albertel 4823: &reset_caches();
4824:
1.43 albertel 4825: return OK;
1.1 www 4826: }
4827:
4828: 1;
4829: __END__
4830:
4831:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>