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