Annotation of loncom/interface/lonparmset.pm, revision 1.275
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.275 ! raeburn 4: # $Id: lonparmset.pm,v 1.274 2005/12/29 17:58:13 albertel 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:
47: =over 4
48:
49: =cut
50:
51: ###################################################################
52: ###################################################################
1.1 www 53:
54: package Apache::lonparmset;
55:
56: use strict;
57: use Apache::lonnet;
58: use Apache::Constants qw(:common :http REDIRECT);
1.88 matthew 59: use Apache::lonhtmlcommon();
1.36 albertel 60: use Apache::loncommon;
1.1 www 61: use GDBM_File;
1.57 albertel 62: use Apache::lonhomework;
63: use Apache::lonxml;
1.130 www 64: use Apache::lonlocal;
1.197 www 65: use Apache::lonnavmaps;
1.1 www 66:
1.198 www 67: # --- Caches local to lonparmset
1.2 www 68:
1.199 www 69: my $parmhashid;
70: my %parmhash;
1.201 www 71: my $symbsid;
72: my %symbs;
1.221 www 73: my $rulesid;
74: my %rules;
1.198 www 75:
76: # --- end local caches
77:
1.59 matthew 78: ##################################################
79: ##################################################
80:
81: =pod
82:
83: =item parmval
84:
85: Figure out a cascading parameter.
86:
1.71 albertel 87: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 88: $id - a bighash Id number
1.71 albertel 89: $def - the resource's default value 'stupid emacs
90:
1.269 raeburn 91: 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 92:
1.269 raeburn 93: 14 - General Course
94: 13 - Map or Folder level in course
95: 12- resource default
96: 11- map default
97: 10 - resource level in course
98: 9 - General for section
99: 8 - Map or Folder level for section
100: 7 - resource level in section
101: 6 - General for group
102: 5 - Map or Folder level for group
103: 4 - resource level in group
1.71 albertel 104: 3 - General for specific student
1.82 www 105: 2 - Map or Folder level for specific student
1.71 albertel 106: 1 - resource level for specific student
1.2 www 107:
1.59 matthew 108: =cut
109:
110: ##################################################
1.2 www 111: sub parmval {
1.275 ! raeburn 112: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
! 113: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
! 114: $cgroup,$courseopt);
1.201 www 115: }
116:
117: sub parmval_by_symb {
1.275 ! raeburn 118: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.198 www 119: # load caches
1.200 www 120:
1.198 www 121: &cacheparmhash();
1.200 www 122:
123: my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
124:
1.8 www 125: my $result='';
1.44 albertel 126: my @outpar=();
1.2 www 127: # ----------------------------------------------------- Cascading lookup scheme
1.201 www 128: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.10 www 129:
1.201 www 130: my $symbparm=$symb.'.'.$what;
131: my $mapparm=$map.'___(all).'.$what;
1.10 www 132:
1.269 raeburn 133: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
134: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
135: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
136:
1.190 albertel 137: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
138: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
139: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
140:
141: my $courselevel=$env{'request.course.id'}.'.'.$what;
142: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
143: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 144:
1.11 www 145:
1.182 albertel 146: # --------------------------------------------------------- first, check course
1.11 www 147:
1.200 www 148: if (defined($$courseopt{$courselevel})) {
1.269 raeburn 149: $outpar[14]=$$courseopt{$courselevel};
150: $result=14;
1.43 albertel 151: }
1.11 www 152:
1.200 www 153: if (defined($$courseopt{$courselevelm})) {
1.269 raeburn 154: $outpar[13]=$$courseopt{$courselevelm};
155: $result=13;
1.43 albertel 156: }
1.11 www 157:
1.182 albertel 158: # ------------------------------------------------------- second, check default
159:
1.269 raeburn 160: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 161:
162: # ------------------------------------------------------ third, check map parms
163:
164: my $thisparm=$parmhash{$symbparm};
1.269 raeburn 165: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 166:
1.200 www 167: if (defined($$courseopt{$courselevelr})) {
1.269 raeburn 168: $outpar[10]=$$courseopt{$courselevelr};
169: $result=10;
1.43 albertel 170: }
1.11 www 171:
1.182 albertel 172: # ------------------------------------------------------ fourth, back to course
1.71 albertel 173: if (defined($csec)) {
1.200 www 174: if (defined($$courseopt{$seclevel})) {
1.269 raeburn 175: $outpar[9]=$$courseopt{$seclevel};
176: $result=9;
1.43 albertel 177: }
1.200 www 178: if (defined($$courseopt{$seclevelm})) {
1.269 raeburn 179: $outpar[8]=$$courseopt{$seclevelm};
180: $result=8;
1.43 albertel 181: }
182:
1.200 www 183: if (defined($$courseopt{$seclevelr})) {
1.269 raeburn 184: $outpar[7]=$$courseopt{$seclevelr};
185: $result=7;
1.43 albertel 186: }
187: }
1.275 ! raeburn 188: # ------------------------------------------------------ fifth, check course group
1.269 raeburn 189: if (defined($cgroup)) {
190: if (defined($$courseopt{$grplevel})) {
191: $outpar[6]=$$courseopt{$grplevel};
192: $result=6;
193: }
194: if (defined($$courseopt{$grplevelm})) {
195: $outpar[5]=$$courseopt{$grplevelm};
196: $result=5;
197: }
198: if (defined($$courseopt{$grplevelr})) {
199: $outpar[4]=$$courseopt{$grplevelr};
200: $result=4;
201: }
202: }
1.11 www 203:
1.182 albertel 204: # ---------------------------------------------------------- fifth, check user
1.11 www 205:
1.71 albertel 206: if (defined($uname)) {
1.200 www 207: if (defined($$useropt{$courselevel})) {
208: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 209: $result=3;
210: }
1.10 www 211:
1.200 www 212: if (defined($$useropt{$courselevelm})) {
213: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 214: $result=2;
215: }
1.2 www 216:
1.200 www 217: if (defined($$useropt{$courselevelr})) {
218: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 219: $result=1;
220: }
221: }
1.44 albertel 222: return ($result,@outpar);
1.2 www 223: }
224:
1.198 www 225: sub resetparmhash {
226: $parmhashid='';
227: }
228:
229: sub cacheparmhash {
230: if ($parmhashid eq $env{'request.course.fn'}) { return; }
231: my %parmhashfile;
232: if (tie(%parmhashfile,'GDBM_File',
233: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
234: %parmhash=%parmhashfile;
235: untie %parmhashfile;
236: $parmhashid=$env{'request.course.fn'};
237: }
238: }
239:
1.203 www 240: sub resetsymbcache {
241: $symbsid='';
242: }
243:
1.201 www 244: sub symbcache {
245: my $id=shift;
246: if ($symbsid ne $env{'request.course.id'}) {
247: %symbs=();
248: }
249: unless ($symbs{$id}) {
250: my $navmap = Apache::lonnavmaps::navmap->new();
251: if ($id=~/\./) {
252: my $resource=$navmap->getById($id);
253: $symbs{$id}=$resource->symb();
254: } else {
255: my $resource=$navmap->getByMapPc($id);
256: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
257: }
258: $symbsid=$env{'request.course.id'};
259: }
260: return $symbs{$id};
261: }
262:
1.221 www 263: sub resetrulescache {
264: $rulesid='';
265: }
266:
267: sub rulescache {
268: my $id=shift;
269: if ($rulesid ne $env{'request.course.id'}) {
270: %rules=();
271: }
1.224 www 272: unless (defined($rules{$id})) {
1.221 www 273: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
274: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.224 www 275: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
1.221 www 276: $rulesid=$env{'request.course.id'};
277: }
278: return $rules{$id};
279: }
280:
1.229 www 281: sub preset_defaults {
282: my $type=shift;
283: if (&rulescache($type.'_action') eq 'default') {
284: # yes, there is something
285: return (&rulescache($type.'_hours'),
286: &rulescache($type.'_min'),
287: &rulescache($type.'_sec'),
288: &rulescache($type.'_value'));
289: } else {
290: # nothing there or something else
291: return ('','','','','');
292: }
293: }
294:
1.186 www 295: ##################################################
296: ##################################################
297: #
1.197 www 298: # Store a parameter by ID
1.186 www 299: #
300: # Takes
301: # - resource id
302: # - name of parameter
303: # - level
304: # - new value
305: # - new type
1.187 www 306: # - username
307: # - userdomain
308:
1.186 www 309: sub storeparm {
1.269 raeburn 310: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 ! raeburn 311: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 312: }
313:
314: #
315: # Store a parameter by symb
316: #
317: # Takes
318: # - symb
319: # - name of parameter
320: # - level
321: # - new value
322: # - new type
323: # - username
324: # - userdomain
325:
1.226 www 326: my %recstack;
1.197 www 327: sub storeparm_by_symb {
1.275 ! raeburn 328: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 329: unless ($recflag) {
330: # first time call
331: %recstack=();
332: $recflag=1;
333: }
334: # store parameter
335: &storeparm_by_symb_inner
1.269 raeburn 336: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 337: # don't do anything if parameter was reset
338: unless ($nval) { return; }
1.226 www 339: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
340: # remember that this was set
341: $recstack{$parm}=1;
342: # what does this trigger?
343: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
344: # don't backfire
345: unless ((!$triggered) || ($recstack{$triggered})) {
346: my $action=&rulescache($triggered.'_action');
347: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
348: # set triggered parameter on same level
349: my $newspnam=$prefix.$triggered;
1.227 www 350: my $newvalue='';
1.228 www 351: my $active=1;
352: if ($action=~/^when\_setting/) {
353: # are there restrictions?
354: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
355: $active=0;
356: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
357: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
358: }
359: }
360: $newvalue=&rulescache($triggered.'_value');
1.227 www 361: } else {
362: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
1.228 www 363: if ($action=~/^later\_than/) {
364: $newvalue=$nval+$totalsecs;
365: } else {
366: $newvalue=$nval-$totalsecs;
367: }
368: }
369: if ($active) {
370: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
1.275 ! raeburn 371: $uname,$udom,$csec,$recflag,$cgroup);
1.227 www 372: }
1.226 www 373: }
374: }
375: return '';
376: }
377:
378: sub storeparm_by_symb_inner {
1.197 www 379: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 380: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 381: # ---------------------------------------------------------- Construct prefixes
1.186 www 382: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 383: my $map=(&Apache::lonnet::decode_symb($symb))[0];
384: my $symbparm=$symb.'.'.$spnam;
385: my $mapparm=$map.'___(all).'.$spnam;
386:
1.269 raeburn 387: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
388: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
389: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
390:
1.190 albertel 391: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
392: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
393: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 394:
1.190 albertel 395: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
396: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
397: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 398:
399: my $storeunder='';
1.269 raeburn 400: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
401: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
402: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
403: if ($snum==9) { $storeunder=$seclevel; }
404: if ($snum==8) { $storeunder=$seclevelm; }
405: if ($snum==7) { $storeunder=$seclevelr; }
406: if ($snum==6) { $storeunder=$grplevel; }
407: if ($snum==5) { $storeunder=$grplevelm; }
408: if ($snum==4) { $storeunder=$grplevelr; }
409:
1.186 www 410:
411: my $delete;
412: if ($nval eq '') { $delete=1;}
413: my %storecontent = ($storeunder => $nval,
414: $storeunder.'.type' => $ntype);
415: my $reply='';
416: if ($snum>3) {
417: # ---------------------------------------------------------------- Store Course
418: #
1.200 www 419: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
420: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 421: # Expire sheets
422: &Apache::lonnet::expirespread('','','studentcalc');
1.269 raeburn 423: if (($snum==10) || ($snum==7) || ($snum==4)) {
1.197 www 424: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.269 raeburn 425: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
1.197 www 426: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 427: } else {
428: &Apache::lonnet::expirespread('','','assesscalc');
429: }
430: # Store parameter
431: if ($delete) {
432: $reply=&Apache::lonnet::del
1.200 www 433: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.186 www 434: } else {
435: $reply=&Apache::lonnet::cput
1.200 www 436: ('resourcedata',\%storecontent,$cdom,$cnum);
1.186 www 437: }
1.200 www 438: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 439: } else {
440: # ------------------------------------------------------------------ Store User
441: #
442: # Expire sheets
443: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
444: if ($snum==1) {
445: &Apache::lonnet::expirespread
1.197 www 446: ($uname,$udom,'assesscalc',$symb);
1.186 www 447: } elsif ($snum==2) {
448: &Apache::lonnet::expirespread
1.197 www 449: ($uname,$udom,'assesscalc',$map);
1.186 www 450: } else {
451: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
452: }
453: # Store parameter
454: if ($delete) {
455: $reply=&Apache::lonnet::del
456: ('resourcedata',[keys(%storecontent)],$udom,$uname);
457: } else {
458: $reply=&Apache::lonnet::cput
459: ('resourcedata',\%storecontent,$udom,$uname);
460: }
1.191 albertel 461: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 462: }
463:
464: if ($reply=~/^error\:(.*)/) {
465: return "<font color=red>Write Error: $1</font>";
466: }
467: return '';
468: }
469:
1.59 matthew 470: ##################################################
471: ##################################################
472:
473: =pod
474:
475: =item valout
476:
477: Format a value for output.
478:
479: Inputs: $value, $type
480:
481: Returns: $value, formatted for output. If $type indicates it is a date,
482: localtime($value) is returned.
1.9 www 483:
1.59 matthew 484: =cut
485:
486: ##################################################
487: ##################################################
1.9 www 488: sub valout {
489: my ($value,$type)=@_;
1.59 matthew 490: my $result = '';
491: # Values of zero are valid.
492: if (! $value && $value ne '0') {
1.71 albertel 493: $result = ' ';
1.59 matthew 494: } else {
1.66 www 495: if ($type eq 'date_interval') {
496: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
497: $year=$year-70;
498: $mday--;
499: if ($year) {
500: $result.=$year.' yrs ';
501: }
502: if ($mon) {
503: $result.=$mon.' mths ';
504: }
505: if ($mday) {
506: $result.=$mday.' days ';
507: }
508: if ($hour) {
509: $result.=$hour.' hrs ';
510: }
511: if ($min) {
512: $result.=$min.' mins ';
513: }
514: if ($sec) {
515: $result.=$sec.' secs ';
516: }
517: $result=~s/\s+$//;
1.213 www 518: } elsif (&isdateparm($type)) {
1.59 matthew 519: $result = localtime($value);
520: } else {
521: $result = $value;
522: }
523: }
524: return $result;
1.9 www 525: }
526:
1.59 matthew 527: ##################################################
528: ##################################################
529:
530: =pod
1.5 www 531:
1.59 matthew 532: =item plink
533:
534: Produces a link anchor.
535:
536: Inputs: $type,$dis,$value,$marker,$return,$call
537:
538: Returns: scalar with html code for a link which will envoke the
539: javascript function 'pjump'.
540:
541: =cut
542:
543: ##################################################
544: ##################################################
1.5 www 545: sub plink {
546: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 547: my $winvalue=$value;
548: unless ($winvalue) {
1.213 www 549: if (&isdateparm($type)) {
1.190 albertel 550: $winvalue=$env{'form.recent_'.$type};
1.23 www 551: } else {
1.190 albertel 552: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 553: }
554: }
1.229 www 555: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
556: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
557: unless (defined($winvalue)) { $winvalue=$val; }
1.270 www 558: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.
1.43 albertel 559: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.229 www 560: .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
1.270 www 561: &valout($value,$type).'</a></td></tr></table>';
1.5 www 562: }
563:
1.44 albertel 564: sub startpage {
1.209 www 565: my $r=shift;
1.269 raeburn 566: my $loaditems = qq|onUnload="pclose()" onLoad="group_or_section('cgroup')"|;
1.120 www 567: my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
1.269 raeburn 568: $loaditems);
1.204 www 569: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting');
1.81 www 570: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 571: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.183 albertel 572: my $html=&Apache::lonxml::xmlbegin();
1.44 albertel 573: $r->print(<<ENDHEAD);
1.183 albertel 574: $html
1.44 albertel 575: <head>
576: <title>LON-CAPA Course Parameters</title>
577: <script>
578:
579: function pclose() {
580: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
581: "height=350,width=350,scrollbars=no,menubar=no");
582: parmwin.close();
583: }
584:
1.88 matthew 585: $pjump_def
1.44 albertel 586:
587: function psub() {
588: pclose();
589: if (document.parmform.pres_marker.value!='') {
590: document.parmform.action+='#'+document.parmform.pres_marker.value;
591: var typedef=new Array();
592: typedef=document.parmform.pres_type.value.split('_');
593: if (document.parmform.pres_type.value!='') {
594: if (typedef[0]=='date') {
595: eval('document.parmform.recent_'+
596: document.parmform.pres_type.value+
597: '.value=document.parmform.pres_value.value;');
598: } else {
599: eval('document.parmform.recent_'+typedef[0]+
600: '.value=document.parmform.pres_value.value;');
601: }
602: }
603: document.parmform.submit();
604: } else {
605: document.parmform.pres_value.value='';
606: document.parmform.pres_marker.value='';
607: }
608: }
609:
1.57 albertel 610: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
611: var options = "width=" + w + ",height=" + h + ",";
612: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
613: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
614: var newWin = window.open(url, wdwName, options);
615: newWin.focus();
616: }
1.44 albertel 617: </script>
1.81 www 618: $selscript
1.44 albertel 619: </head>
1.64 www 620: $bodytag
1.193 albertel 621: $breadcrumbs
622: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.44 albertel 623: <input type="hidden" value='' name="pres_value">
624: <input type="hidden" value='' name="pres_type">
625: <input type="hidden" value='' name="pres_marker">
1.209 www 626: <input type="hidden" value='1' name="prevvisit">
1.44 albertel 627: ENDHEAD
628: }
629:
1.209 www 630:
1.44 albertel 631: sub print_row {
1.201 www 632: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.275 ! raeburn 633: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
! 634: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
! 635: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
! 636: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 637: # get the values for the parameter in cascading order
638: # empty levels will remain empty
1.44 albertel 639: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.275 ! raeburn 640: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 641: # get the type for the parameters
642: # problem: these may not be set for all levels
643: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 ! raeburn 644: $$name{$which}.'.type',$rid,
! 645: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 646: # cascade down manually
1.182 albertel 647: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 648: for (my $i=14;$i>0;$i--) {
1.66 www 649: if ($typeoutpar[$i]) {
650: $cascadetype=$typeoutpar[$i];
651: } else {
652: $typeoutpar[$i]=$cascadetype;
653: }
654: }
1.57 albertel 655: my $parm=$$display{$which};
656:
1.203 www 657: if ($parmlev eq 'full') {
1.57 albertel 658: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
659: .$$part{$which}.'</td>');
660: } else {
661: $parm=~s|\[.*\]\s||g;
662: }
1.231 www 663: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
664: if ($automatic) {
665: $parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>';
666: }
1.159 albertel 667: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 668:
1.44 albertel 669: my $thismarker=$which;
670: $thismarker=~s/^parameter\_//;
671: my $mprefix=$rid.'&'.$thismarker.'&';
1.275 ! raeburn 672: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
! 673: my ($othergrp,$grp_parm,$controlgrp);
1.44 albertel 674:
1.57 albertel 675: if ($parmlev eq 'general') {
676:
677: if ($uname) {
1.66 www 678: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 679: } elsif ($cgroup) {
680: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 681: } elsif ($csec) {
1.269 raeburn 682: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 683: } else {
1.269 raeburn 684: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 685: }
686: } elsif ($parmlev eq 'map') {
687:
688: if ($uname) {
1.66 www 689: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 690: } elsif ($cgroup) {
691: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 692: } elsif ($csec) {
1.269 raeburn 693: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 694: } else {
1.269 raeburn 695: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 696: }
697: } else {
1.275 ! raeburn 698: if ($uname) {
! 699: if (@{$usersgroups} > 1) {
! 700: my ($coursereply,$grp_parm,$controlgrp);
! 701: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
! 702: &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
! 703: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
! 704: if ($coursereply && $result > 3) {
! 705: if (defined($controlgrp)) {
! 706: if ($cgroup ne $controlgrp) {
! 707: $effective_parm = $grp_parm;
! 708: $result = 0;
! 709: }
! 710: }
! 711: }
! 712: }
! 713: }
1.57 albertel 714:
1.269 raeburn 715: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 716:
1.269 raeburn 717: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
718: &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
719: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 720: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
721:
722: if ($csec) {
1.269 raeburn 723: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
724: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
725: &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 726: }
1.269 raeburn 727:
728: if ($cgroup) {
729: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
730: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
731: &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
732: }
1.275 ! raeburn 733:
1.203 www 734: if ($uname) {
1.275 ! raeburn 735: if ($othergrp) {
! 736: $r->print($othergrp);
! 737: }
1.203 www 738: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
739: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
740: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
741: }
1.57 albertel 742:
743: } # end of $parmlev if/else
1.275 ! raeburn 744: $r->print('<td bgcolor="#CCCCFF" align="center">'.$effective_parm.'</td>');
1.136 albertel 745:
1.203 www 746: if ($parmlev eq 'full') {
1.136 albertel 747: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 748: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 749: my $sessionvaltype=$typeoutpar[$result];
750: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.275 ! raeburn 751: $r->print('<td bgcolor="#999999" align="center"><font color="#FFFFFF">'.
1.66 www 752: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 753: '</font></td>');
1.136 albertel 754: }
1.44 albertel 755: $r->print('</tr>');
1.57 albertel 756: $r->print("\n");
1.44 albertel 757: }
1.59 matthew 758:
1.44 albertel 759: sub print_td {
1.66 www 760: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 761: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 762: ' align="center">');
1.269 raeburn 763: if ($which<11 || $which > 12) {
1.114 www 764: $r->print(&plink($$typeoutpar[$which],
765: $$display{$value},$$outpar[$which],
766: $mprefix."$which",'parmform.pres','psub'));
767: } else {
768: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
769: }
770: $r->print('</td>'."\n");
1.57 albertel 771: }
772:
1.275 ! raeburn 773: sub print_usergroups {
! 774: my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
! 775: my $courseid = $env{'request.course.id'};
! 776: my $output;
! 777: my $symb = &symbcache($rid);
! 778: my $symbparm=$symb.'.'.$what;
! 779: my $map=(&Apache::lonnet::decode_symb($symb))[0];
! 780: my $mapparm=$map.'___(all).'.$what;
! 781: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
! 782: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
! 783: $courseopt);
! 784: my $bgcolor = $defbg;
! 785: my $grp_parm;
! 786: if (($coursereply) && ($cgroup ne $resultgroup)) {
! 787: if ($result > 3) {
! 788: $bgcolor = '"#AAFFAA"';
! 789: $grp_parm = &valout($coursereply,$resulttype);
! 790: }
! 791: $grp_parm = &valout($coursereply,$resulttype);
! 792: $output = '<td bgcolor='.$bgcolor.' align="center">';
! 793: if ($resultgroup && $resultlevel) {
! 794: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
! 795: } else {
! 796: $output .= ' ';
! 797: }
! 798: $output .= '</td>';
! 799: } else {
! 800: $output .= '<td bgcolor='.$bgcolor.'> </td>';
! 801: }
! 802: return ($coursereply,$output,$grp_parm,$resultgroup);
! 803: }
! 804:
! 805: sub parm_control_group {
! 806: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
! 807: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
! 808: my $grpfound = 0;
! 809: my @levels = ($symbparm,$mapparm,$what);
! 810: my @levelnames = ('resource','map/folder','general');
! 811: foreach my $group (@{$usersgroups}) {
! 812: if ($grpfound) { last; }
! 813: for (my $i=0; $i<@levels; $i++) {
! 814: my $item = $courseid.'.['.$group.'].'.$levels[$i];
! 815: if (defined($$courseopt{$item})) {
! 816: $coursereply = $$courseopt{$item};
! 817: $resultitem = $item;
! 818: $resultgroup = $group;
! 819: $resultlevel = $levelnames[$i];
! 820: $resulttype = $$courseopt{$item.'.type'};
! 821: $grpfound = 1;
! 822: last;
! 823: }
! 824: }
! 825: }
! 826: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
! 827: }
1.201 www 828:
1.63 bowersj2 829: =pod
830:
831: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
832:
833: Input: See list below:
834:
835: =over 4
836:
837: =item B<ids>: An array that will contain all of the ids in the course.
838:
839: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
840:
1.171 www 841: =item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
1.63 bowersj2 842:
843: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
844:
845: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
846:
847: =item B<allkeys>: hash, full key to part->display value (what's display value?)
848:
849: =item B<allmaps>: hash, ???
850:
851: =item B<fcat>: ???
852:
853: =item B<defp>: hash, ???
854:
855: =item B<mapp>: ??
856:
857: =item B<symbp>: hash, id->full sym?
858:
859: =back
860:
861: =cut
862:
863: sub extractResourceInformation {
864: my $ids = shift;
865: my $typep = shift;
866: my $keyp = shift;
867: my $allparms = shift;
868: my $allparts = shift;
869: my $allmaps = shift;
870: my $mapp = shift;
871: my $symbp = shift;
1.82 www 872: my $maptitles=shift;
1.196 www 873: my $uris=shift;
1.210 www 874: my $keyorder=shift;
1.211 www 875: my $defkeytype=shift;
1.196 www 876:
1.210 www 877: my $keyordercnt=100;
1.63 bowersj2 878:
1.196 www 879: my $navmap = Apache::lonnavmaps::navmap->new();
880: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
881: foreach my $resource (@allres) {
882: my $id=$resource->id();
883: my ($mapid,$resid)=split(/\./,$id);
884: if ($mapid eq '0') { next; }
885: $$ids[$#$ids+1]=$id;
886: my $srcf=$resource->src();
887: $srcf=~/\.(\w+)$/;
888: $$typep{$id}=$1;
889: $$keyp{$id}='';
890: $$uris{$id}=$srcf;
891: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
892: if ($_=~/^parameter\_(.*)/) {
893: my $key=$_;
1.209 www 894: # Hidden parameters
895: if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
896: next;
1.63 bowersj2 897: }
1.196 www 898: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
899: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
900: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.209 www 901: #
902: # allparms is a hash of parameter names
903: #
1.196 www 904: my $parmdis = $display;
1.209 www 905: $parmdis =~ s/\[Part.*$//g;
906: $$allparms{$name}=$parmdis;
1.211 www 907: $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
1.209 www 908: #
909: # allparts is a hash of all parts
910: #
911: $$allparts{$part} = "Part: $part";
912: #
913: # Remember all keys going with this resource
914: #
1.196 www 915: if ($$keyp{$id}) {
916: $$keyp{$id}.=','.$key;
1.175 albertel 917: } else {
1.196 www 918: $$keyp{$id}=$key;
1.175 albertel 919: }
1.210 www 920: #
921: # Put in order
922: #
923: unless ($$keyorder{$key}) {
924: $$keyorder{$key}=$keyordercnt;
925: $keyordercnt++;
926: }
927:
1.63 bowersj2 928: }
929: }
1.196 www 930: $$mapp{$id}=
931: &Apache::lonnet::declutter($resource->enclosing_map_src());
932: $$mapp{$mapid}=$$mapp{$id};
933: $$allmaps{$mapid}=$$mapp{$id};
934: if ($mapid eq '1') {
935: $$maptitles{$mapid}='Main Course Documents';
936: } else {
937: $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
938: }
939: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
940: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
941: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.63 bowersj2 942: }
943: }
944:
1.208 www 945:
946: ##################################################
947: ##################################################
948:
1.213 www 949: sub isdateparm {
950: my $type=shift;
951: return (($type=~/^date/) && (!($type eq 'date_interval')));
952: }
953:
1.208 www 954: sub parmmenu {
1.211 www 955: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 956: my $tempkey;
957: $r->print(<<ENDSCRIPT);
958: <script type="text/javascript">
959: function checkall(value, checkName) {
960: for (i=0; i<document.forms.parmform.elements.length; i++) {
961: ele = document.forms.parmform.elements[i];
962: if (ele.name == checkName) {
963: document.forms.parmform.elements[i].checked=value;
964: }
965: }
966: }
1.210 www 967:
968: function checkthis(thisvalue, checkName) {
969: for (i=0; i<document.forms.parmform.elements.length; i++) {
970: ele = document.forms.parmform.elements[i];
971: if (ele.name == checkName) {
972: if (ele.value == thisvalue) {
973: document.forms.parmform.elements[i].checked=true;
974: }
975: }
976: }
977: }
978:
979: function checkdates() {
980: checkthis('duedate','pscat');
981: checkthis('opendate','pscat');
982: checkthis('answerdate','pscat');
1.218 www 983: }
984:
985: function checkdisset() {
986: checkthis('discussend','pscat');
987: checkthis('discusshide','pscat');
988: }
989:
990: function checkcontdates() {
991: checkthis('contentopen','pscat');
992: checkthis('contentclose','pscat');
993: }
994:
1.210 www 995:
996: function checkvisi() {
997: checkthis('hiddenresource','pscat');
998: checkthis('encrypturl','pscat');
999: checkthis('problemstatus','pscat');
1000: checkthis('contentopen','pscat');
1001: checkthis('opendate','pscat');
1002: }
1003:
1004: function checkparts() {
1005: checkthis('hiddenparts','pscat');
1006: checkthis('display','pscat');
1007: checkthis('ordered','pscat');
1008: }
1009:
1010: function checkstandard() {
1011: checkall(false,'pscat');
1012: checkdates();
1013: checkthis('weight','pscat');
1014: checkthis('maxtries','pscat');
1015: }
1016:
1.208 www 1017: </script>
1018: ENDSCRIPT
1.209 www 1019: $r->print();
1.208 www 1020: $r->print("\n<table><tr>");
1021: my $cnt=0;
1.211 www 1022: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.235 albertel 1023: $r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' ");
1.208 www 1024: $r->print('value="'.$tempkey.'"');
1025: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1026: $r->print(' checked');
1027: }
1.235 albertel 1028: $r->print('>'.$$allparms{$tempkey}.'</label></font></td>');
1.209 www 1029: $cnt++;
1030: if ($cnt==3) {
1031: $r->print("</tr>\n<tr>");
1032: $cnt=0;
1033: }
1.208 www 1034: }
1035: $r->print('
1036: </tr><tr><td>
1.233 albertel 1037: <a href="javascript:checkall(true, \'pscat\')">Select All</a><br />
1038: <a href="javascript:checkstandard()">Select Common Only</a>
1.210 www 1039: </td><td>
1.233 albertel 1040: <a href="javascript:checkdates()">Add Problem Dates</a>
1041: <a href="javascript:checkcontdates()">Add Content Dates</a><br />
1042: <a href="javascript:checkdisset()">Add Discussion Settings</a>
1043: <a href="javascript:checkvisi()">Add Visibilities</a><br />
1044: <a href="javascript:checkparts()">Add Part Parameters</a>
1.210 www 1045: </td><td>
1.233 albertel 1046: <a href="javascript:checkall(false, \'pscat\')">Unselect All</a>
1.208 www 1047: </td>
1048: ');
1049: $r->print('</tr></table>');
1050: }
1051:
1.209 www 1052: sub partmenu {
1053: my ($r,$allparts,$psprt)=@_;
1.211 www 1054: $r->print('<select multiple name="psprt" size="8">');
1.208 www 1055: $r->print('<option value="all"');
1056: $r->print(' selected') unless (@{$psprt});
1057: $r->print('>'.&mt('All Parts').'</option>');
1058: my %temphash=();
1059: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1060: foreach my $tempkey (sort {
1061: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1062: } keys(%{$allparts})) {
1.208 www 1063: unless ($tempkey =~ /\./) {
1064: $r->print('<option value="'.$tempkey.'"');
1065: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1066: $r->print(' selected');
1067: }
1068: $r->print('>'.$$allparts{$tempkey}.'</option>');
1069: }
1070: }
1.209 www 1071: $r->print('</select>');
1072: }
1073:
1074: sub usermenu {
1.275 ! raeburn 1075: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1076: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1077: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1078: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1079: my %lt=&Apache::lonlocal::texthash(
1.269 raeburn 1080: 'se' => "Section",
1081: 'gr' => "Group",
1.209 www 1082: 'fu' => "For User",
1083: 'oi' => "or ID",
1084: 'ad' => "at Domain"
1085: );
1086: my %sectionhash=();
1087: my $sections='';
1.269 raeburn 1088: my $numsec = &Apache::loncommon::get_sections(
1.209 www 1089: $env{'course.'.$env{'request.course.id'}.'.domain'},
1090: $env{'course.'.$env{'request.course.id'}.'.num'},
1.269 raeburn 1091: \%sectionhash);
1092: my $groups;
1093: my %grouphash;
1094: my $numgrp = &Apache::loncommon::coursegroups(
1095: \%grouphash,
1096: $env{'course.'.$env{'request.course.id'}.'.domain'},
1097: $env{'course.'.$env{'request.course.id'}.'.num'});
1098: if ($numsec > 0) {
1099: $sections=$lt{'se'}.': <select name="csec"';
1100: if ($numsec && $numgrp && $parmlev ne 'full') {
1101: $sections .= qq| onchange="group_or_section('csec')" |;
1102: }
1103: $sections .= '>';
1.275 ! raeburn 1104: foreach my $section ('',sort keys %sectionhash) {
! 1105: $sections.='<option value="'.$section.'" '.
! 1106: ($section eq $csec?'selected="selected"':'').'>'.$section.
! 1107: '</option>';
1.209 www 1108: }
1109: $sections.='</select>';
1.269 raeburn 1110: }
1111: if ($numsec && $numgrp && $parmlev ne 'full') {
1112: $sections .= ' or ';
1113: $sections .= qq|
1114: <script type="text/javascript">
1115: function group_or_section(caller) {
1116: if (caller == "cgroup") {
1117: if (document.parmform.cgroup.selectedIndex != 0) {
1118: document.parmform.csec.selectedIndex = 0;
1119: }
1120: } else {
1121: if (document.parmform.csec.selectedIndex != 0) {
1122: document.parmform.cgroup.selectedIndex = 0;
1123: }
1124: }
1125: }
1126: </script>
1127: |;
1128: } else {
1129: $sections .= qq|
1130: <script type="text/javascript">
1131: function group_or_section(caller) {
1132: return;
1133: }
1134: </script>
1135: |;
1136: }
1137: if ($numgrp > 0) {
1138: $groups=$lt{'gr'}.': <select name="cgroup"';
1139: if ($numsec && $numgrp && $env{'form.action'} eq 'settable') {
1140: $groups .= qq| onchange="group_or_section('cgroup')" |;
1141: }
1142: $groups .= '>';
1.275 ! raeburn 1143: foreach my $grp ('',sort keys %grouphash) {
! 1144: $groups.='<option value="'.$grp.'" ';
! 1145: if ($grp eq $cgroup) {
! 1146: unless ((defined($uname)) && ($grp eq '')) {
! 1147: $groups .= 'selected="selected" ';
! 1148: }
! 1149: } elsif (!defined($cgroup)) {
! 1150: if (@{$usersgroups} == 1) {
! 1151: if ($grp eq $$usersgroups[0]) {
! 1152: $groups .= 'selected="selected" ';
! 1153: }
! 1154: }
! 1155: }
! 1156: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1157: }
1158: $groups.='</select>';
1159: }
1160: $r->print(<<ENDMENU);
1.209 www 1161: <b>
1162: $sections
1.269 raeburn 1163: $groups
1.209 www 1164: <br />
1165: $lt{'fu'}
1166: <input type="text" value="$uname" size="12" name="uname" />
1167: $lt{'oi'}
1168: <input type="text" value="$id" size="12" name="id" />
1169: $lt{'ad'}
1170: $chooseopt
1171: </b>
1172: ENDMENU
1173: }
1174:
1175: sub displaymenu {
1.211 www 1176: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1177: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1178: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1179: &parmmenu($r,$allparms,$pscat,$keyorder);
1.209 www 1180: $r->print('</td><td>');
1181: &partmenu($r,$allparts,$psprt);
1182: $r->print('</td></tr></table>');
1183: }
1184:
1185: sub mapmenu {
1186: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1187: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1188: $r->print('<select name="pschp">');
1189: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1190: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1191: $r->print('<option value="'.$_.'"');
1.209 www 1192: if (($pschp eq $_)) { $r->print(' selected'); }
1193: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1194: }
1195: $r->print("</select>");
1196: }
1197:
1198: sub levelmenu {
1199: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1200: $r->print('<b>'.&mt('Select Parameter Level').
1201: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1202: $r->print('<select name="parmlev">');
1203: foreach (reverse sort keys %{$alllevs}) {
1204: $r->print('<option value="'.$$alllevs{$_}.'"');
1205: if ($parmlev eq $$alllevs{$_}) {
1206: $r->print(' selected');
1207: }
1208: $r->print('>'.$_.'</option>');
1.208 www 1209: }
1.209 www 1210: $r->print("</select>");
1.208 www 1211: }
1212:
1.211 www 1213:
1214: sub sectionmenu {
1215: my ($r,$selectedsections)=@_;
1.212 www 1216: my %sectionhash=();
1.269 raeburn 1217: my $sections='';
1218: my $numsec = &Apache::loncommon::get_sections(
1.212 www 1219: $env{'course.'.$env{'request.course.id'}.'.domain'},
1220: $env{'course.'.$env{'request.course.id'}.'.num'},
1.269 raeburn 1221: \%sectionhash);
1222: if ($numsec) {
1.212 www 1223: $r->print('<select name="Section" multiple="true" size="8" >');
1224: foreach my $s ('all',sort keys %sectionhash) {
1225: $r->print(' <option value="'.$s.'"');
1226: foreach (@{$selectedsections}) {
1227: if ($s eq $_) {
1228: $r->print(' selected');
1229: last;
1230: }
1231: }
1232: $r->print('>'.$s."</option>\n");
1233: }
1.269 raeburn 1234: $r->print("</select>\n");
1235: }
1236: }
1237:
1238: sub groupmenu {
1239: my ($r,$selectedgroups)=@_;
1240: my %grouphash;
1241: my $numgrp = &Apache::loncommon::coursegroups(
1242: \%grouphash,
1243: $env{'course.'.$env{'request.course.id'}.'.domain'},
1244: $env{'course.'.$env{'request.course.id'}.'.num'});
1245: if ($numgrp) {
1246: $r->print('<select name="Group" multiple="true" size="8" >');
1247: foreach my $group (sort(keys(%grouphash))) {
1248: $r->print(' <option value="'.$group.'"');
1249: foreach (@{$selectedgroups}) {
1250: if ($group eq $_) {
1251: $r->print(' selected');
1252: last;
1253: }
1254: }
1255: $r->print('>'.$group."</option>\n");
1256: }
1257: $r->print("</select>\n");
1.211 www 1258: }
1259: }
1260:
1.269 raeburn 1261:
1.210 www 1262: sub keysplit {
1263: my $keyp=shift;
1264: return (split(/\,/,$keyp));
1265: }
1266:
1267: sub keysinorder {
1268: my ($name,$keyorder)=@_;
1269: return sort {
1270: $$keyorder{$a} <=> $$keyorder{$b};
1271: } (keys %{$name});
1272: }
1273:
1.236 albertel 1274: sub keysinorder_bytype {
1275: my ($name,$keyorder)=@_;
1276: return sort {
1277: my $ta=(split('_',$a))[-1];
1278: my $tb=(split('_',$b))[-1];
1279: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1280: return ($a cmp $b);
1281: }
1282: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1283: } (keys %{$name});
1284: }
1285:
1.211 www 1286: sub keysindisplayorder {
1287: my ($name,$keyorder)=@_;
1288: return sort {
1289: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1290: } (keys %{$name});
1291: }
1292:
1.214 www 1293: sub sortmenu {
1294: my ($r,$sortorder)=@_;
1.236 albertel 1295: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1296: if ($sortorder eq 'realmstudent') {
1297: $r->print(' checked="on"');
1298: }
1299: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1300: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1301: if ($sortorder eq 'studentrealm') {
1302: $r->print(' checked="on"');
1303: }
1.236 albertel 1304: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1305: '</label>');
1.214 www 1306: }
1307:
1.211 www 1308: sub standardkeyorder {
1309: return ('parameter_0_opendate' => 1,
1310: 'parameter_0_duedate' => 2,
1311: 'parameter_0_answerdate' => 3,
1312: 'parameter_0_interval' => 4,
1313: 'parameter_0_weight' => 5,
1314: 'parameter_0_maxtries' => 6,
1315: 'parameter_0_hinttries' => 7,
1316: 'parameter_0_contentopen' => 8,
1317: 'parameter_0_contentclose' => 9,
1318: 'parameter_0_type' => 10,
1319: 'parameter_0_problemstatus' => 11,
1320: 'parameter_0_hiddenresource' => 12,
1321: 'parameter_0_hiddenparts' => 13,
1322: 'parameter_0_display' => 14,
1323: 'parameter_0_ordered' => 15,
1324: 'parameter_0_tol' => 16,
1325: 'parameter_0_sig' => 17,
1.218 www 1326: 'parameter_0_turnoffunit' => 18,
1327: 'parameter_0_discussend' => 19,
1328: 'parameter_0_discusshide' => 20);
1.211 www 1329: }
1330:
1.59 matthew 1331: ##################################################
1332: ##################################################
1333:
1334: =pod
1335:
1336: =item assessparms
1337:
1338: Show assessment data and parameters. This is a large routine that should
1339: be simplified and shortened... someday.
1340:
1341: Inputs: $r
1342:
1343: Returns: nothing
1344:
1.63 bowersj2 1345: Variables used (guessed by Jeremy):
1346:
1347: =over 4
1348:
1349: =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.
1350:
1351: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
1352:
1353: =item B<allmaps>:
1354:
1355: =back
1356:
1.59 matthew 1357: =cut
1358:
1359: ##################################################
1360: ##################################################
1.30 www 1361: sub assessparms {
1.1 www 1362:
1.43 albertel 1363: my $r=shift;
1.201 www 1364:
1365: my @ids=();
1366: my %symbp=();
1367: my %mapp=();
1368: my %typep=();
1369: my %keyp=();
1370: my %uris=();
1371: my %maptitles=();
1372:
1.2 www 1373: # -------------------------------------------------------- Variable declaration
1.209 www 1374:
1.129 www 1375: my %allmaps=();
1376: my %alllevs=();
1.57 albertel 1377:
1.187 www 1378: my $uname;
1379: my $udom;
1380: my $uhome;
1381: my $csec;
1.269 raeburn 1382: my $cgroup;
1.275 ! raeburn 1383: my $grouplist;
! 1384: my @usersgroups = ();
1.187 www 1385:
1.190 albertel 1386: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1387:
1.57 albertel 1388: $alllevs{'Resource Level'}='full';
1.215 www 1389: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1390: $alllevs{'Course Level'}='general';
1391:
1392: my %allparms;
1393: my %allparts;
1.210 www 1394: #
1395: # Order in which these parameters will be displayed
1396: #
1.211 www 1397: my %keyorder=&standardkeyorder();
1398:
1.43 albertel 1399: @ids=();
1400: %symbp=();
1401: %typep=();
1402:
1403: my $message='';
1404:
1.190 albertel 1405: $csec=$env{'form.csec'};
1.269 raeburn 1406: $cgroup=$env{'form.cgroup'};
1.188 www 1407:
1.190 albertel 1408: if ($udom=$env{'form.udom'}) {
1409: } elsif ($udom=$env{'request.role.domain'}) {
1410: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1411: } else {
1412: $udom=$r->dir_config('lonDefDomain');
1413: }
1.43 albertel 1414:
1.134 albertel 1415: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1416: my $pschp=$env{'form.pschp'};
1.134 albertel 1417: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1418: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1419:
1.43 albertel 1420: my $pssymb='';
1.57 albertel 1421: my $parmlev='';
1422:
1.190 albertel 1423: unless ($env{'form.parmlev'}) {
1.57 albertel 1424: $parmlev = 'map';
1425: } else {
1.190 albertel 1426: $parmlev = $env{'form.parmlev'};
1.57 albertel 1427: }
1.26 www 1428:
1.29 www 1429: # ----------------------------------------------- Was this started from grades?
1430:
1.190 albertel 1431: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1432: && (!$env{'form.dis'})) {
1433: my $url=$env{'form.url'};
1.194 albertel 1434: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1435: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1436: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1437: $pschp='';
1.57 albertel 1438: $parmlev = 'full';
1.190 albertel 1439: } elsif ($env{'form.symb'}) {
1440: $pssymb=$env{'form.symb'};
1.92 albertel 1441: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1442: $pschp='';
1.57 albertel 1443: $parmlev = 'full';
1.43 albertel 1444: } else {
1.190 albertel 1445: $env{'form.url'}='';
1.43 albertel 1446: }
1447:
1.190 albertel 1448: my $id=$env{'form.id'};
1.43 albertel 1449: if (($id) && ($udom)) {
1450: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1451: if ($uname) {
1452: $id='';
1453: } else {
1454: $message=
1.133 www 1455: "<font color=red>".&mt("Unknown ID")." '$id' ".
1456: &mt('at domain')." '$udom'</font>";
1.43 albertel 1457: }
1458: } else {
1.190 albertel 1459: $uname=$env{'form.uname'};
1.43 albertel 1460: }
1461: unless ($udom) { $uname=''; }
1462: $uhome='';
1463: if ($uname) {
1464: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1465: if ($uhome eq 'no_host') {
1466: $message=
1.133 www 1467: "<font color=red>".&mt("Unknown user")." '$uname' ".
1468: &mt("at domain")." '$udom'</font>";
1.43 albertel 1469: $uname='';
1.12 www 1470: } else {
1.103 albertel 1471: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1472: $env{'request.course.id'});
1.269 raeburn 1473:
1.43 albertel 1474: if ($csec eq '-1') {
1475: $message="<font color=red>".
1.133 www 1476: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1477: &mt("not in this course")."</font>";
1.43 albertel 1478: $uname='';
1.190 albertel 1479: $csec=$env{'form.csec'};
1.269 raeburn 1480: $cgroup=$env{'form.cgroup'};
1.43 albertel 1481: } else {
1482: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1483: ('firstname','middlename','lastname','generation','id'));
1.133 www 1484: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1485: $name{'firstname'}.' '.$name{'middlename'}.' '
1486: .$name{'lastname'}.' '.$name{'generation'}.
1.133 www 1487: "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1488: }
1.275 ! raeburn 1489: $grouplist = &Apache::lonnet::get_users_groups(
! 1490: $udom,$uname,$env{'request.course.id'});
1.269 raeburn 1491: if ($grouplist) {
1.275 ! raeburn 1492: @usersgroups = &Apache::lonnet::sort_course_groups($grouplist,
! 1493: $env{'request.course.id'});
! 1494: unless (grep/^\Q$cgroup\E$/,@usersgroups) {
! 1495: $cgroup = $usersgroups[0];
! 1496: }
! 1497: } else {
! 1498: $cgroup = '';
1.269 raeburn 1499: }
1.12 www 1500: }
1.43 albertel 1501: }
1.2 www 1502:
1.43 albertel 1503: unless ($csec) { $csec=''; }
1.269 raeburn 1504: unless ($cgroup) { $cgroup=''; }
1.12 www 1505:
1.14 www 1506: # --------------------------------------------------------- Get all assessments
1.210 www 1507: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1508: \%mapp, \%symbp,\%maptitles,\%uris,
1509: \%keyorder);
1.63 bowersj2 1510:
1.57 albertel 1511: $mapp{'0.0'} = '';
1512: $symbp{'0.0'} = '';
1.99 albertel 1513:
1.14 www 1514: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1515: if ($env{'form.pres_marker'}) {
1.205 www 1516: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1517: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1518: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1519: for (my $i=0;$i<=$#markers;$i++) {
1520: $message.=&storeparm(split(/\&/,$markers[$i]),
1521: $values[$i],
1522: $types[$i],
1.269 raeburn 1523: $uname,$udom,$csec,$cgroup);
1.205 www 1524: }
1.68 www 1525: # ---------------------------------------------------------------- Done storing
1.130 www 1526: $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
1.68 www 1527: }
1.57 albertel 1528: #----------------------------------------------- if all selected, fill in array
1.209 www 1529: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1530: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1531: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1532: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1533:
1.209 www 1534: &startpage($r);
1.57 albertel 1535:
1.44 albertel 1536: foreach ('tolerance','date_default','date_start','date_end',
1537: 'date_interval','int','float','string') {
1538: $r->print('<input type="hidden" value="'.
1.190 albertel 1539: $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
1.44 albertel 1540: }
1.57 albertel 1541:
1.44 albertel 1542: if (!$pssymb) {
1.209 www 1543: $r->print('<table border="1"><tr><td>');
1544: &levelmenu($r,\%alllevs,$parmlev);
1.128 albertel 1545: if ($parmlev ne 'general') {
1.209 www 1546: $r->print('<td>');
1547: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1548: $r->print('</td>');
1.128 albertel 1549: }
1.209 www 1550: $r->print('</td></tr></table>');
1.211 www 1551: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1552: } else {
1.125 www 1553: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.209 www 1554: $r->print(&mt('Specific Resource').": ".$resource.
1.238 www 1555: '<input type="hidden" value="'.$pssymb.'" name="symb">'.
1556: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1557: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1558: }
1.275 ! raeburn 1559: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.57 albertel 1560:
1.210 www 1561: $r->print('<p>'.$message.'</p>');
1562:
1.209 www 1563: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1564:
1565: my @temp_pscat;
1566: map {
1567: my $cat = $_;
1568: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1569: } @pscat;
1570:
1571: @pscat = @temp_pscat;
1572:
1.209 www 1573: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1574: # ----------------------------------------------------------------- Start Table
1.57 albertel 1575: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1576: my $csuname=$env{'user.name'};
1577: my $csudom=$env{'user.domain'};
1.57 albertel 1578:
1.203 www 1579: if ($parmlev eq 'full') {
1.57 albertel 1580: my $coursespan=$csec?8:5;
1.275 ! raeburn 1581: my $userspan=3;
1.269 raeburn 1582: if ($cgroup ne '') {
1583: $coursespan += 3;
1584: }
1585:
1.57 albertel 1586: $r->print('<p><table border=2>');
1587: $r->print('<tr><td colspan=5></td>');
1.130 www 1588: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1589: if ($uname) {
1.275 ! raeburn 1590: if (@usersgroups > 1) {
! 1591: $userspan ++;
! 1592: }
! 1593: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1594: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1595: }
1.133 www 1596: my %lt=&Apache::lonlocal::texthash(
1597: 'pie' => "Parameter in Effect",
1598: 'csv' => "Current Session Value",
1599: 'at' => 'at',
1600: 'rl' => "Resource Level",
1601: 'ic' => 'in Course',
1602: 'aut' => "Assessment URL and Title",
1.143 albertel 1603: 'type' => 'Type',
1.133 www 1604: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1605: 'part' => 'Part',
1.133 www 1606: 'pn' => 'Parameter Name',
1607: 'def' => 'default',
1608: 'femof' => 'from Enclosing Map or Folder',
1609: 'gen' => 'general',
1610: 'foremf' => 'for Enclosing Map or Folder',
1611: 'fr' => 'for Resource'
1612: );
1.57 albertel 1613: $r->print(<<ENDTABLETWO);
1.133 www 1614: <th rowspan=3>$lt{'pie'}</th>
1615: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1616: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1617: <th colspan=1>$lt{'ic'}</th>
1618:
1.10 www 1619: ENDTABLETWO
1.57 albertel 1620: if ($csec) {
1.133 www 1621: $r->print("<th colspan=3>".
1.269 raeburn 1622: &mt("in Section")." $csec</th>");
1623: }
1624: if ($cgroup) {
1625: $r->print("<th colspan=3>".
1626: &mt("in Group")." $cgroup</th>");
1.57 albertel 1627: }
1628: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1629: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1630: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1631: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1632: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1633: ENDTABLEHEADFOUR
1.57 albertel 1634:
1635: if ($csec) {
1.130 www 1636: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1637: }
1638:
1.269 raeburn 1639: if ($cgroup) {
1640: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1641: }
1642:
1.57 albertel 1643: if ($uname) {
1.275 ! raeburn 1644: if (@usersgroups > 1) {
! 1645: $r->print('<th>'.&mt('Control by other group?').'</th>');
! 1646: }
1.130 www 1647: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1648: }
1649:
1650: $r->print('</tr>');
1651:
1652: my $defbgone='';
1653: my $defbgtwo='';
1.269 raeburn 1654: my $defbgthree = '';
1.57 albertel 1655:
1656: foreach (@ids) {
1657:
1658: my $rid=$_;
1659: my ($inmapid)=($rid=~/\.(\d+)$/);
1660:
1.152 albertel 1661: if ((!$pssymb &&
1662: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1663: ||
1664: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1665: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1666: if ($defbgone eq '"#E0E099"') {
1667: $defbgone='"#E0E0DD"';
1.57 albertel 1668: } else {
1.184 albertel 1669: $defbgone='"#E0E099"';
1.57 albertel 1670: }
1.184 albertel 1671: if ($defbgtwo eq '"#FFFF99"') {
1672: $defbgtwo='"#FFFFDD"';
1.57 albertel 1673: } else {
1.184 albertel 1674: $defbgtwo='"#FFFF99"';
1.57 albertel 1675: }
1.269 raeburn 1676: if ($defbgthree eq '"#FFBB99"') {
1677: $defbgthree='"#FFBBDD"';
1678: } else {
1679: $defbgthree='"#FFBB99"';
1680: }
1681:
1.57 albertel 1682: my $thistitle='';
1683: my %name= ();
1684: undef %name;
1685: my %part= ();
1686: my %display=();
1687: my %type= ();
1688: my %default=();
1.196 www 1689: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1690:
1.210 www 1691: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1692: my $tempkeyp = $_;
1693: if (grep $_ eq $tempkeyp, @catmarker) {
1694: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1695: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1696: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1697: unless ($display{$_}) { $display{$_}=''; }
1698: $display{$_}.=' ('.$name{$_}.')';
1699: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1700: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1701: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1702: }
1703: }
1704: my $totalparms=scalar keys %name;
1705: if ($totalparms>0) {
1706: my $firstrow=1;
1.274 albertel 1707: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.57 albertel 1708: $r->print('<tr><td bgcolor='.$defbgone.
1709: ' rowspan='.$totalparms.
1710: '><tt><font size=-1>'.
1711: join(' / ',split(/\//,$uri)).
1712: '</font></tt><p><b>'.
1.154 albertel 1713: "<a href=\"javascript:openWindow('".
1.274 albertel 1714: &Apache::lonnet::clutter($uri).'?symb='.
1715: &Apache::lonnet::escape($symbp{$rid}).
1.57 albertel 1716: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1.127 albertel 1717: " TARGET=_self>$title");
1.57 albertel 1718:
1719: if ($thistitle) {
1720: $r->print(' ('.$thistitle.')');
1721: }
1722: $r->print('</a></b></td>');
1723: $r->print('<td bgcolor='.$defbgtwo.
1724: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1725: '</td>');
1726:
1727: $r->print('<td bgcolor='.$defbgone.
1728: ' rowspan='.$totalparms.
1.238 www 1729: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 1730:
1.236 albertel 1731: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 1732: unless ($firstrow) {
1733: $r->print('<tr>');
1734: } else {
1735: undef $firstrow;
1736: }
1.201 www 1737: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 1738: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 1739: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 ! raeburn 1740: $cgroup,\@usersgroups);
1.57 albertel 1741: }
1742: }
1743: }
1744: } # end foreach ids
1.43 albertel 1745: # -------------------------------------------------- End entry for one resource
1.57 albertel 1746: $r->print('</table>');
1.203 www 1747: } # end of full
1.57 albertel 1748: #--------------------------------------------------- Entry for parm level map
1749: if ($parmlev eq 'map') {
1750: my $defbgone = '"E0E099"';
1751: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1752: my $defbgthree = '"FFBB99"';
1.57 albertel 1753:
1754: my %maplist;
1755:
1756: if ($pschp eq 'all') {
1757: %maplist = %allmaps;
1758: } else {
1759: %maplist = ($pschp => $mapp{$pschp});
1760: }
1761:
1762: #-------------------------------------------- for each map, gather information
1763: my $mapid;
1.60 albertel 1764: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1765: my $maptitle = $maplist{$mapid};
1.57 albertel 1766:
1767: #----------------------- loop through ids and get all parameter types for map
1768: #----------------------------------------- and associated information
1769: my %name = ();
1770: my %part = ();
1771: my %display = ();
1772: my %type = ();
1773: my %default = ();
1774: my $map = 0;
1775:
1776: # $r->print("Catmarker: @catmarker<br />\n");
1777:
1778: foreach (@ids) {
1779: ($map)=(/([\d]*?)\./);
1780: my $rid = $_;
1781:
1782: # $r->print("$mapid:$map: $rid <br /> \n");
1783:
1784: if ($map eq $mapid) {
1.196 www 1785: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1786: # $r->print("Keys: $keyp{$rid} <br />\n");
1787:
1788: #--------------------------------------------------------------------
1789: # @catmarker contains list of all possible parameters including part #s
1790: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1791: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1792: # When storing information, store as part 0
1793: # When requesting information, request from full part
1794: #-------------------------------------------------------------------
1.210 www 1795: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1796: my $tempkeyp = $_;
1797: my $fullkeyp = $tempkeyp;
1.73 albertel 1798: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1799:
1800: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1801: $part{$tempkeyp}="0";
1802: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1803: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1804: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1805: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1806: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1807: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1808: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1809: }
1810: } # end loop through keys
1811: }
1812: } # end loop through ids
1813:
1814: #---------------------------------------------------- print header information
1.133 www 1815: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1816: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1817: $r->print(<<ENDMAPONE);
1818: <center><h4>
1.135 albertel 1819: Set Defaults for All Resources in $foldermap<br />
1820: <font color="red"><i>$showtitle</i></font><br />
1.57 albertel 1821: Specifically for
1822: ENDMAPONE
1823: if ($uname) {
1.267 albertel 1824: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 1825: $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1.130 www 1826: &mt('in')." \n");
1.57 albertel 1827: } else {
1.135 albertel 1828: $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
1.57 albertel 1829: }
1.269 raeburn 1830: if ($cgroup) {
1831: $r->print(&mt("Group")." <font color=\"red\"><i>$cgroup".
1832: "</i></font> ".&mt('of')." \n");
1833: $csec = '';
1834: } elsif ($csec) {
1835: $r->print(&mt("Section")." <font color=\"red\"><i>$csec".
1836: "</i></font> ".&mt('of')." \n");
1837: }
1.135 albertel 1838: $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
1839: $r->print("</h4>\n");
1.57 albertel 1840: #---------------------------------------------------------------- print table
1841: $r->print('<p><table border="2">');
1.130 www 1842: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1843: $r->print('<th>'.&mt('Default Value').'</th>');
1844: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1845:
1.210 www 1846: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 1847: $r->print('<tr>');
1.201 www 1848: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 1849: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1850: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 1851: }
1852: $r->print("</table></center>");
1853: } # end each map
1854: } # end of $parmlev eq map
1855: #--------------------------------- Entry for parm level general (Course level)
1856: if ($parmlev eq 'general') {
1857: my $defbgone = '"E0E099"';
1858: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1859: my $defbgthree = '"FFBB99"';
1.57 albertel 1860:
1861: #-------------------------------------------- for each map, gather information
1862: my $mapid="0.0";
1863: #----------------------- loop through ids and get all parameter types for map
1864: #----------------------------------------- and associated information
1865: my %name = ();
1866: my %part = ();
1867: my %display = ();
1868: my %type = ();
1869: my %default = ();
1870:
1871: foreach (@ids) {
1872: my $rid = $_;
1873:
1.196 www 1874: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1875:
1876: #--------------------------------------------------------------------
1877: # @catmarker contains list of all possible parameters including part #s
1878: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1879: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1880: # When storing information, store as part 0
1881: # When requesting information, request from full part
1882: #-------------------------------------------------------------------
1.210 www 1883: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1884: my $tempkeyp = $_;
1885: my $fullkeyp = $tempkeyp;
1.73 albertel 1886: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1887: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1888: $part{$tempkeyp}="0";
1889: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1890: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1891: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1892: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1893: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1894: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1895: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1896: }
1897: } # end loop through keys
1898: } # end loop through ids
1899:
1900: #---------------------------------------------------- print header information
1.133 www 1901: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1902: $r->print(<<ENDMAPONE);
1.133 www 1903: <center><h4>$setdef
1.135 albertel 1904: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 1905: ENDMAPONE
1906: if ($uname) {
1.267 albertel 1907: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 1908: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 1909: } else {
1.135 albertel 1910: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 1911: }
1912:
1.135 albertel 1913: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.269 raeburn 1914: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.135 albertel 1915: $r->print("</h4>\n");
1.57 albertel 1916: #---------------------------------------------------------------- print table
1917: $r->print('<p><table border="2">');
1.130 www 1918: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1919: $r->print('<th>'.&mt('Default Value').'</th>');
1920: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1921:
1.210 www 1922: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 1923: $r->print('<tr>');
1.201 www 1924: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 1925: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1926: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 1927: }
1928: $r->print("</table></center>");
1929: } # end of $parmlev eq general
1.43 albertel 1930: }
1.44 albertel 1931: $r->print('</form></body></html>');
1.57 albertel 1932: } # end sub assessparms
1.30 www 1933:
1.59 matthew 1934:
1935: ##################################################
1936: ##################################################
1937:
1938: =pod
1939:
1940: =item crsenv
1941:
1.105 matthew 1942: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1943: be simplified and shortened... someday.
1944:
1945: Inputs: $r
1946:
1947: Returns: nothing
1948:
1949: =cut
1950:
1951: ##################################################
1952: ##################################################
1.30 www 1953: sub crsenv {
1954: my $r=shift;
1955: my $setoutput='';
1.64 www 1956: my $bodytag=&Apache::loncommon::bodytag(
1957: 'Set Course Environment Parameters');
1.194 albertel 1958: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,
1959: 'Edit Course Environment');
1.190 albertel 1960: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1961: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 1962:
1963: #
1964: # Go through list of changes
1.190 albertel 1965: foreach (keys %env) {
1.105 matthew 1966: next if ($_!~/^form\.(.+)\_setparmval$/);
1967: my $name = $1;
1.190 albertel 1968: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 1969: if ($name eq 'newp') {
1.190 albertel 1970: $name = $env{'form.newp_name'};
1.105 matthew 1971: }
1972: if ($name eq 'url') {
1973: $value=~s/^\/res\///;
1974: my $bkuptime=time;
1975: my @tmp = &Apache::lonnet::get
1976: ('environment',['url'],$dom,$crs);
1.130 www 1977: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 1978: &Apache::lonnet::put
1979: ('environment',
1980: {'top level map backup '.$bkuptime => $tmp[1] },
1981: $dom,$crs).
1982: '<br>';
1983: }
1984: #
1985: # Deal with modified default spreadsheets
1986: if ($name =~ /^spreadsheet_default_(classcalc|
1987: studentcalc|
1988: assesscalc)$/x) {
1989: my $sheettype = $1;
1990: if ($sheettype eq 'classcalc') {
1991: # no need to do anything since viewing the sheet will
1992: # cause it to be updated.
1993: } elsif ($sheettype eq 'studentcalc') {
1994: # expire all the student spreadsheets
1995: &Apache::lonnet::expirespread('','','studentcalc');
1996: } else {
1997: # expire all the assessment spreadsheets
1998: # this includes non-default spreadsheets, but better to
1999: # be safe than sorry.
2000: &Apache::lonnet::expirespread('','','assesscalc');
2001: # expire all the student spreadsheets
2002: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2003: }
1.105 matthew 2004: }
2005: #
1.107 matthew 2006: # Deal with the enrollment dates
2007: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2008: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2009: }
1.178 raeburn 2010: # Get existing cloners
2011: my @oldcloner = ();
2012: if ($name eq 'cloners') {
2013: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2014: if ($clonenames{'cloners'} =~ /,/) {
2015: @oldcloner = split/,/,$clonenames{'cloners'};
2016: } else {
2017: $oldcloner[0] = $clonenames{'cloners'};
2018: }
2019: }
1.107 matthew 2020: #
1.105 matthew 2021: # Let the user know we made the changes
1.153 albertel 2022: if ($name && defined($value)) {
1.239 raeburn 2023: my $failed_cloners;
1.178 raeburn 2024: if ($name eq 'cloners') {
1.239 raeburn 2025: $value =~ s/\s//g;
1.178 raeburn 2026: $value =~ s/^,//;
2027: $value =~ s/,$//;
1.239 raeburn 2028: # check requested clones are valid users.
2029: $failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2030: }
1.105 matthew 2031: my $put_result = &Apache::lonnet::put('environment',
2032: {$name=>$value},$dom,$crs);
2033: if ($put_result eq 'ok') {
1.130 www 2034: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
1.178 raeburn 2035: if ($name eq 'cloners') {
2036: &change_clone($value,\@oldcloner);
2037: }
1.179 raeburn 2038: # Flush the course logs so course description is immediately updated
2039: if ($name eq 'description' && defined($value)) {
2040: &Apache::lonnet::flushcourselogs();
2041: }
1.105 matthew 2042: } else {
1.130 www 2043: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2044: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2045: }
1.239 raeburn 2046: if (($name eq 'cloners') && ($failed_cloners)) {
2047: $setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '.
2048: &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
2049: '.<br />'.&mt('Please ').
2050: ' <a href="/adm/createuser">'.
2051: &mt('add the user(s)').'</a>, '.
2052: &mt('and then return to the ').
2053: '<a href="/admparmset?action=crsenv">'.
2054: &mt('Course Parameters page').'</a> '.
2055: &mt('to add the new user(s) to the list of possible cloners').
2056: '.<br />';
2057: }
1.30 www 2058: }
1.38 harris41 2059: }
1.108 www 2060: # ------------------------- Re-init course environment entries for this session
2061:
1.190 albertel 2062: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.105 matthew 2063:
1.30 www 2064: # -------------------------------------------------------- Get parameters again
1.45 matthew 2065:
2066: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2067: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2068: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2069: my $output='';
1.45 matthew 2070: if (! exists($values{'con_lost'})) {
1.30 www 2071: my %descriptions=
1.140 sakharuk 2072: ('url' => '<b>'.&mt('Top Level Map').'</b> '.
1.46 matthew 2073: '<a href="javascript:openbrowser'.
1.47 matthew 2074: "('envform','url','sequence')\">".
1.140 sakharuk 2075: &mt('Select Map').'</a><br /><font color=red> '.
2076: &mt('Modification may make assessment data inaccessible').
2077: '</font>',
2078: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2079: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2080: '</b><br />'.
2081: '('.&mt('internal').', '.&mt('optional').')',
1.177 raeburn 2082: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
1.150 www 2083: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
2084: '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
1.140 sakharuk 2085: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
1.52 www 2086: '<a href="javascript:openbrowser'.
2087: "('envform','default_xml_style'".
1.140 sakharuk 2088: ",'sty')\">$SelectStyleFile</a><br>",
1.141 sakharuk 2089: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
2090: '</b><br />(<tt>user:domain,'.
1.74 www 2091: 'user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2092: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
1.74 www 2093: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2094: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
1.75 albertel 2095: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 2096: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
1.158 sakharuk 2097: '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
1.141 sakharuk 2098: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
1.158 sakharuk 2099: '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
1.141 sakharuk 2100: &mt('changes will not show until next login').')',
1.169 matthew 2101: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b>'.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
1.118 matthew 2102:
1.141 sakharuk 2103: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
2104: '</b><br />"<tt>st</tt>": '.
1.158 sakharuk 2105: &mt('student').', "<tt>ta</tt>": '.
1.118 matthew 2106: 'TA, "<tt>in</tt>": '.
1.158 sakharuk 2107: &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
1.118 matthew 2108: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
2109: 'plc.users.denied' =>
1.141 sakharuk 2110: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.118 matthew 2111: '(<tt>user:domain,user:domain,...</tt>)',
2112:
1.141 sakharuk 2113: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
2114: '</b><br />"<tt>st</tt>": '.
1.61 albertel 2115: 'student, "<tt>ta</tt>": '.
2116: 'TA, "<tt>in</tt>": '.
1.75 albertel 2117: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 2118: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2119: 'pch.users.denied' =>
1.141 sakharuk 2120: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.53 www 2121: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 2122: 'spreadsheet_default_classcalc'
1.141 sakharuk 2123: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2124: '<a href="javascript:openbrowser'.
2125: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2126: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2127: 'spreadsheet_default_studentcalc'
1.141 sakharuk 2128: => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
1.50 matthew 2129: '<a href="javascript:openbrowser'.
2130: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2131: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2132: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2133: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2134: '<a href="javascript:openbrowser'.
2135: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2136: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2137: 'allow_limited_html_in_feedback'
1.141 sakharuk 2138: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.158 sakharuk 2139: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.170 raeburn 2140: 'allow_discussion_post_editing'
2141: => '<b>'.&mt('Allow users to edit/delete their own discussion posts').'</b><br />'.
2142: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.89 albertel 2143: 'rndseed'
1.140 sakharuk 2144: => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
2145: '<font color="red">'.&mt('Modifying this will make problems').' '.
2146: &mt('have different numbers and answers').'</font>',
1.151 albertel 2147: 'receiptalg'
2148: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2149: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2150: 'suppress_tries'
1.272 albertel 2151: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.273 www 2152: ' ('.&mt('"[_1]" to suppress, anything else to not suppress','<tt>yes</tt>').')',
1.113 sakharuk 2153: 'problem_stream_switch'
1.141 sakharuk 2154: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.158 sakharuk 2155: ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
1.161 sakharuk 2156: 'default_paper_size'
2157: => '<b>'.&mt('Default paper type').'</b><br />'.
2158: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2159: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2160: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.111 sakharuk 2161: 'anonymous_quiz'
1.150 www 2162: => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
1.141 sakharuk 2163: ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
1.217 albertel 2164: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2165: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.150 www 2166: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
2167: '<br />(<tt>user:domain,user:domain,...</tt>)',
1.140 sakharuk 2168: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2169: 'disable_receipt_display'
1.141 sakharuk 2170: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2171: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.163 albertel 2172: 'disablesigfigs'
2173: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2174: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2175: 'disableexampointprint'
2176: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2177: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.149 albertel 2178: 'tthoptions'
2179: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
1.107 matthew 2180: );
1.177 raeburn 2181: my @Display_Order = ('url','description','courseid','cloners','grading',
1.107 matthew 2182: 'default_xml_style','pageseparators',
2183: 'question.email','comment.email','policy.email',
1.169 matthew 2184: 'student_classlist_view',
1.118 matthew 2185: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2186: 'pch.roles.denied','pch.users.denied',
2187: 'allow_limited_html_in_feedback',
1.170 raeburn 2188: 'allow_discussion_post_editing',
1.108 www 2189: 'languages',
1.150 www 2190: 'nothideprivileged',
1.107 matthew 2191: 'rndseed',
1.151 albertel 2192: 'receiptalg',
1.107 matthew 2193: 'problem_stream_switch',
1.164 sakharuk 2194: 'suppress_tries',
1.161 sakharuk 2195: 'default_paper_size',
1.115 www 2196: 'disable_receipt_display',
1.107 matthew 2197: 'spreadsheet_default_classcalc',
2198: 'spreadsheet_default_studentcalc',
2199: 'spreadsheet_default_assesscalc',
2200: 'hideemptyrows',
2201: 'default_enrollment_start_date',
2202: 'default_enrollment_end_date',
1.163 albertel 2203: 'tthoptions',
1.251 albertel 2204: 'disablesigfigs',
2205: 'disableexampointprint'
1.107 matthew 2206: );
2207: foreach my $parameter (sort(keys(%values))) {
1.244 banghart 2208: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
1.142 raeburn 2209: if (! $descriptions{$parameter}) {
2210: $descriptions{$parameter}=$parameter;
2211: push(@Display_Order,$parameter);
2212: }
2213: }
1.43 albertel 2214: }
1.107 matthew 2215: foreach my $parameter (@Display_Order) {
2216: my $description = $descriptions{$parameter};
1.51 matthew 2217: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2218: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2219: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2220: '.checked=true;"';
1.107 matthew 2221: $output .= '<tr><td>'.$description.'</td>';
2222: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2223: $output .= '<td>'.
2224: &Apache::lonhtmlcommon::date_setter('envform',
2225: $parameter.'_value',
2226: $values{$parameter},
2227: $onchange).
2228: '</td>';
2229: } else {
2230: $output .= '<td>'.
2231: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2232: $values{$parameter},
2233: 40,$onchange).'</td>';
2234: }
2235: $output .= '<td>'.
2236: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2237: '</td>';
2238: $output .= "</tr>\n";
1.51 matthew 2239: }
1.69 www 2240: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2241: '[\'envform\'].elements[\'newp_setparmval\']'.
2242: '.checked=true;"';
1.130 www 2243: $output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2244: '<input type="text" size=40 name="newp_name" '.
2245: $onchange.' /></td><td>'.
2246: '<input type="text" size=40 name="newp_value" '.
2247: $onchange.' /></td><td>'.
2248: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 2249: }
1.157 sakharuk 2250: my %lt=&Apache::lonlocal::texthash(
2251: 'par' => 'Parameter',
2252: 'val' => 'Value',
2253: 'set' => 'Set',
2254: 'sce' => 'Set Course Environment'
2255: );
2256:
1.140 sakharuk 2257: my $Parameter=&mt('Parameter');
2258: my $Value=&mt('Value');
1.141 sakharuk 2259: my $Set=&mt('Set');
1.167 albertel 2260: my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset');
1.183 albertel 2261: my $html=&Apache::lonxml::xmlbegin();
1.190 albertel 2262: $r->print(<<ENDenv);
1.183 albertel 2263: $html
2264: <head>
1.46 matthew 2265: <script type="text/javascript" language="Javascript" >
1.155 albertel 2266: $browse_js
1.46 matthew 2267: </script>
1.30 www 2268: <title>LON-CAPA Course Environment</title>
2269: </head>
1.64 www 2270: $bodytag
1.193 albertel 2271: $breadcrumbs
2272: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2273: $setoutput
2274: <p>
2275: <table border=2>
1.157 sakharuk 2276: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
1.30 www 2277: $output
2278: </table>
1.157 sakharuk 2279: <input type="submit" name="crsenv" value="$lt{'sce'}">
1.30 www 2280: </form>
2281: </body>
2282: </html>
1.190 albertel 2283: ENDenv
1.30 www 2284: }
1.120 www 2285: ##################################################
1.207 www 2286: # Overview mode
2287: ##################################################
1.124 www 2288: my $tableopen;
2289:
2290: sub tablestart {
2291: if ($tableopen) {
2292: return '';
2293: } else {
2294: $tableopen=1;
1.130 www 2295: return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
2296: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2297: }
2298: }
2299:
2300: sub tableend {
2301: if ($tableopen) {
2302: $tableopen=0;
2303: return '</table>';
2304: } else {
2305: return'';
2306: }
2307: }
2308:
1.207 www 2309: sub readdata {
2310: my ($crs,$dom)=@_;
2311: # Read coursedata
2312: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2313: # Read userdata
2314:
2315: my $classlist=&Apache::loncoursedata::get_classlist();
2316: foreach (keys %$classlist) {
2317: # the following undefs are for 'domain', and 'username' respectively.
2318: if ($_=~/^(\w+)\:(\w+)$/) {
2319: my ($tuname,$tudom)=($1,$2);
2320: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2321: foreach my $userkey (keys %{$useropt}) {
2322: if ($userkey=~/^$env{'request.course.id'}/) {
2323: my $newkey=$userkey;
2324: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2325: $$resourcedata{$newkey}=$$useropt{$userkey};
2326: }
2327: }
2328: }
2329: }
2330: return $resourcedata;
2331: }
2332:
2333:
1.124 www 2334: # Setting
1.208 www 2335:
2336: sub storedata {
2337: my ($r,$crs,$dom)=@_;
1.207 www 2338: # Set userlevel immediately
2339: # Do an intermediate store of course level
2340: my $olddata=&readdata($crs,$dom);
1.124 www 2341: my %newdata=();
2342: undef %newdata;
2343: my @deldata=();
2344: undef @deldata;
1.190 albertel 2345: foreach (keys %env) {
1.124 www 2346: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2347: my $cmd=$1;
2348: my $thiskey=$2;
1.207 www 2349: my ($tuname,$tudom)=&extractuser($thiskey);
2350: my $tkey=$thiskey;
2351: if ($tuname) {
2352: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2353: }
1.124 www 2354: if ($cmd eq 'set') {
1.190 albertel 2355: my $data=$env{$_};
1.212 www 2356: my $typeof=$env{'form.typeof_'.$thiskey};
2357: if ($$olddata{$thiskey} ne $data) {
1.207 www 2358: if ($tuname) {
1.212 www 2359: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2360: $tkey.'.type' => $typeof},
2361: $tudom,$tuname) eq 'ok') {
1.207 www 2362: $r->print('<br />'.&mt('Stored modified parameter for').' '.
2363: &Apache::loncommon::plainname($tuname,$tudom));
2364: } else {
2365: $r->print('<h2><font color="red">'.
2366: &mt('Error storing parameters').'</font></h2>');
2367: }
2368: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2369: } else {
2370: $newdata{$thiskey}=$data;
1.212 www 2371: $newdata{$thiskey.'.type'}=$typeof;
2372: }
1.207 www 2373: }
1.124 www 2374: } elsif ($cmd eq 'del') {
1.207 www 2375: if ($tuname) {
2376: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
2377: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2378: } else {
2379: $r->print('<h2><font color="red">'.
2380: &mt('Error deleting parameters').'</font></h2>');
2381: }
2382: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2383: } else {
2384: push (@deldata,$thiskey);
2385: }
1.124 www 2386: } elsif ($cmd eq 'datepointer') {
1.190 albertel 2387: my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
1.212 www 2388: my $typeof=$env{'form.typeof_'.$thiskey};
1.207 www 2389: if (defined($data) and $$olddata{$thiskey} ne $data) {
2390: if ($tuname) {
1.212 www 2391: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2392: $tkey.'.type' => $typeof},
2393: $tudom,$tuname) eq 'ok') {
1.207 www 2394: $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2395: } else {
2396: $r->print('<h2><font color="red">'.
2397: &mt('Error storing parameters').'</font></h2>');
2398: }
2399: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2400: } else {
1.212 www 2401: $newdata{$thiskey}=$data;
2402: $newdata{$thiskey.'.type'}=$typeof;
1.207 www 2403: }
2404: }
1.124 www 2405: }
2406: }
2407: }
1.207 www 2408: # Store all course level
1.144 www 2409: my $delentries=$#deldata+1;
2410: my @newdatakeys=keys %newdata;
2411: my $putentries=$#newdatakeys+1;
2412: if ($delentries) {
2413: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
2414: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2415: } else {
2416: $r->print('<h2><font color="red">'.
2417: &mt('Error deleting parameters').'</font></h2>');
2418: }
1.205 www 2419: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2420: }
2421: if ($putentries) {
2422: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.212 www 2423: $r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2424: } else {
2425: $r->print('<h2><font color="red">'.
2426: &mt('Error storing parameters').'</font></h2>');
2427: }
1.205 www 2428: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2429: }
1.208 www 2430: }
1.207 www 2431:
1.208 www 2432: sub extractuser {
2433: my $key=shift;
2434: return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
2435: }
1.206 www 2436:
1.208 www 2437: sub listdata {
1.214 www 2438: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2439: # Start list output
1.206 www 2440:
1.122 www 2441: my $oldsection='';
2442: my $oldrealm='';
2443: my $oldpart='';
1.123 www 2444: my $pointer=0;
1.124 www 2445: $tableopen=0;
1.145 www 2446: my $foundkeys=0;
1.248 albertel 2447: my %keyorder=&standardkeyorder();
1.214 www 2448: foreach my $thiskey (sort {
2449: if ($sortorder eq 'realmstudent') {
1.247 albertel 2450: my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2451: my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2452: if (!defined($astudent)) {
2453: ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.237 albertel 2454: }
1.247 albertel 2455: if (!defined($bstudent)) {
2456: ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2457: }
1.248 albertel 2458: $arealm=~s/\.type//;
2459: my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
2460: $aparm=$keyorder{'parameter_0_'.$aparm};
2461: $brealm=~s/\.type//;
2462: my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
2463: $bparm=$keyorder{'parameter_0_'.$bparm};
2464: if ($ares eq $bres) {
2465: if (defined($aparm) && defined($bparm)) {
2466: ($aparm <=> $bparm);
2467: } elsif (defined($aparm)) {
2468: -1;
2469: } elsif (defined($bparm)) {
2470: 1;
2471: } else {
2472: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2473: }
2474: } else {
2475: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2476: }
1.214 www 2477: } else {
2478: $a cmp $b;
2479: }
2480: } keys %{$listdata}) {
1.247 albertel 2481:
1.211 www 2482: if ($$listdata{$thiskey.'.type'}) {
2483: my $thistype=$$listdata{$thiskey.'.type'};
2484: if ($$resourcedata{$thiskey.'.type'}) {
2485: $thistype=$$resourcedata{$thiskey.'.type'};
2486: }
1.207 www 2487: my ($middle,$part,$name)=
2488: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2489: my $section=&mt('All Students');
1.207 www 2490: if ($middle=~/^\[(.*)\]/) {
1.206 www 2491: my $issection=$1;
2492: if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
2493: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
2494: } else {
2495: $section=&mt('Group/Section').': '.$issection;
2496: }
1.207 www 2497: $middle=~s/^\[(.*)\]//;
1.122 www 2498: }
1.207 www 2499: $middle=~s/\.+$//;
2500: $middle=~s/^\.+//;
1.130 www 2501: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.122 www 2502: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.174 albertel 2503: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.122 www 2504: } elsif ($middle) {
1.174 albertel 2505: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
2506: $realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
1.122 www 2507: }
1.214 www 2508: if ($sortorder eq 'realmstudent') {
2509: if ($realm ne $oldrealm) {
2510: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
2511: $oldrealm=$realm;
2512: $oldsection='';
2513: }
2514: if ($section ne $oldsection) {
2515: $r->print(&tableend()."\n<h2>$section</h2>");
2516: $oldsection=$section;
2517: $oldpart='';
2518: }
2519: } else {
2520: if ($section ne $oldsection) {
2521: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
2522: $oldsection=$section;
2523: $oldrealm='';
2524: }
2525: if ($realm ne $oldrealm) {
2526: $r->print(&tableend()."\n<h2>$realm</h2>");
2527: $oldrealm=$realm;
2528: $oldpart='';
2529: }
1.122 www 2530: }
2531: if ($part ne $oldpart) {
1.124 www 2532: $r->print(&tableend().
1.214 www 2533: "\n<font color='blue'>".&mt('Part').": $part</font>");
1.122 www 2534: $oldpart=$part;
2535: }
1.123 www 2536: #
1.230 www 2537: # Preset defaults?
2538: #
2539: my ($hour,$min,$sec,$val)=('','','','');
2540: unless ($$resourcedata{$thiskey}) {
2541: my ($parmname)=($thiskey=~/\.(\w+)$/);
2542: ($hour,$min,$sec,$val)=&preset_defaults($parmname);
2543: }
2544:
2545: #
1.123 www 2546: # Ready to print
2547: #
1.124 www 2548: $r->print(&tablestart().'<tr><td><b>'.$name.
2549: ':</b></td><td><input type="checkbox" name="del_'.
2550: $thiskey.'" /></td><td>');
1.145 www 2551: $foundkeys++;
1.213 www 2552: if (&isdateparm($thistype)) {
1.123 www 2553: my $jskey='key_'.$pointer;
2554: $pointer++;
2555: $r->print(
1.232 albertel 2556: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 2557: $jskey,
1.219 www 2558: $$resourcedata{$thiskey},
1.230 www 2559: '',1,'','',$hour,$min,$sec).
1.123 www 2560: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
2561: );
1.219 www 2562: } elsif ($thistype eq 'string_yesno') {
1.230 www 2563: my $showval;
2564: if (defined($$resourcedata{$thiskey})) {
2565: $showval=$$resourcedata{$thiskey};
2566: } else {
2567: $showval=$val;
2568: }
1.219 www 2569: $r->print('<label><input type="radio" name="set_'.$thiskey.
2570: '" value="yes"');
1.230 www 2571: if ($showval eq 'yes') {
1.219 www 2572: $r->print(' checked="checked"');
2573: }
2574: $r->print(' />'.&mt('Yes').'</label> ');
2575: $r->print('<label><input type="radio" name="set_'.$thiskey.
2576: '" value="no"');
1.230 www 2577: if ($showval eq 'no') {
1.219 www 2578: $r->print(' checked="checked"');
2579: }
2580: $r->print(' />'.&mt('No').'</label>');
1.123 www 2581: } else {
1.230 www 2582: my $showval;
2583: if (defined($$resourcedata{$thiskey})) {
2584: $showval=$$resourcedata{$thiskey};
2585: } else {
2586: $showval=$val;
2587: }
1.211 www 2588: $r->print('<input type="text" name="set_'.$thiskey.'" value="'.
1.230 www 2589: $showval.'">');
1.123 www 2590: }
1.211 www 2591: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
2592: $thistype.'">');
1.124 www 2593: $r->print('</td></tr>');
1.122 www 2594: }
1.121 www 2595: }
1.208 www 2596: return $foundkeys;
2597: }
2598:
2599: sub newoverview {
2600: my $r=shift;
1.216 www 2601: my $bodytag=&Apache::loncommon::bodytag('Set Parameters');
1.208 www 2602: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2603: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
2604: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
2605: my $html=&Apache::lonxml::xmlbegin();
2606: $r->print(<<ENDOVER);
2607: $html
2608: <head>
2609: <title>LON-CAPA Parameters</title>
2610: </head>
2611: $bodytag
2612: $breadcrumbs
1.232 albertel 2613: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 2614: ENDOVER
1.211 www 2615: my @ids=();
2616: my %typep=();
2617: my %keyp=();
2618: my %allparms=();
2619: my %allparts=();
2620: my %allmaps=();
2621: my %mapp=();
2622: my %symbp=();
2623: my %maptitles=();
2624: my %uris=();
2625: my %keyorder=&standardkeyorder();
2626: my %defkeytype=();
2627:
2628: my %alllevs=();
2629: $alllevs{'Resource Level'}='full';
1.215 www 2630: $alllevs{'Map/Folder Level'}='map';
1.211 www 2631: $alllevs{'Course Level'}='general';
2632:
2633: my $csec=$env{'form.csec'};
1.269 raeburn 2634: my $cgroup=$env{'form.cgroup'};
1.211 www 2635:
2636: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
2637: my $pschp=$env{'form.pschp'};
2638: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
2639: if (!@psprt) { $psprt[0]='0'; }
2640:
2641: my @selected_sections =
2642: &Apache::loncommon::get_env_multiple('form.Section');
2643: @selected_sections = ('all') if (! @selected_sections);
2644: foreach (@selected_sections) {
2645: if ($_ eq 'all') {
2646: @selected_sections = ('all');
2647: }
2648: }
1.269 raeburn 2649: my @selected_groups =
2650: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 2651:
2652: my $pssymb='';
2653: my $parmlev='';
2654:
2655: unless ($env{'form.parmlev'}) {
2656: $parmlev = 'map';
2657: } else {
2658: $parmlev = $env{'form.parmlev'};
2659: }
2660:
2661: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
2662: \%mapp, \%symbp,\%maptitles,\%uris,
2663: \%keyorder,\%defkeytype);
2664:
2665: # Menu to select levels, etc
2666:
2667: $r->print('<table border="1"><tr><td>');
2668: &levelmenu($r,\%alllevs,$parmlev);
2669: if ($parmlev ne 'general') {
2670: $r->print('<td>');
2671: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
2672: $r->print('</td>');
2673: }
2674: $r->print('</td></tr></table>');
2675:
2676: $r->print('<table border="1"><tr><td>');
2677: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.269 raeburn 2678: $r->print('</td><td><table border="0" cellspacing="0" cellpadding="0">'.
2679: '<tr><td>'.&mt('Parts').'</td><td></td><td>'.&mt('Section(s)').
2680: '</td><td></td><td>'.&mt('Group(s)').'</td></tr><tr><td>');
1.211 www 2681: &partmenu($r,\%allparts,\@psprt);
1.269 raeburn 2682: $r->print('</td><td> </td><td>');
1.211 www 2683: §ionmenu($r,\@selected_sections);
1.269 raeburn 2684: $r->print('</td><td> </td><td>');
2685: &groupmenu($r,\@selected_groups);
2686: $r->print('</td></tr></table>');
1.214 www 2687: $r->print('</td></tr></table>');
2688:
2689: my $sortorder=$env{'form.sortorder'};
2690: unless ($sortorder) { $sortorder='realmstudent'; }
2691: &sortmenu($r,$sortorder);
2692:
2693: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 2694:
2695: # Build the list data hash from the specified parms
2696:
2697: my $listdata;
2698: %{$listdata}=();
2699:
2700: foreach my $cat (@pscat) {
1.269 raeburn 2701: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
2702: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 2703: }
2704:
1.212 www 2705: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 2706:
1.212 www 2707: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 2708:
2709: # Read modified data
2710:
2711: my $resourcedata=&readdata($crs,$dom);
2712:
2713: # List data
2714:
1.214 www 2715: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 2716: }
2717: $r->print(&tableend().
1.212 www 2718: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':'').
2719: '</form></body></html>');
1.208 www 2720: }
2721:
1.269 raeburn 2722: sub secgroup_lister {
2723: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
2724: foreach my $item (@{$selections}) {
2725: foreach my $part (@{$psprt}) {
2726: my $rootparmkey=$env{'request.course.id'};
2727: if (($item ne 'all') && ($item ne 'none') && ($item)) {
2728: $rootparmkey.='.['.$item.']';
2729: }
2730: if ($parmlev eq 'general') {
2731: # course-level parameter
2732: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
2733: $$listdata{$newparmkey}=1;
2734: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2735: } elsif ($parmlev eq 'map') {
2736: # map-level parameter
2737: foreach my $mapid (keys %{$allmaps}) {
2738: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
2739: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
2740: $$listdata{$newparmkey}=1;
2741: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2742: }
2743: } else {
2744: # resource-level parameter
2745: foreach my $rid (@{$ids}) {
2746: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
2747: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
2748: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
2749: $$listdata{$newparmkey}=1;
2750: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2751: }
2752: }
2753: }
2754: }
2755: }
2756:
1.208 www 2757: sub overview {
2758: my $r=shift;
1.216 www 2759: my $bodytag=&Apache::loncommon::bodytag('Modify Parameters');
1.208 www 2760: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2761: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
2762: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
2763: my $html=&Apache::lonxml::xmlbegin();
2764: $r->print(<<ENDOVER);
2765: $html
2766: <head>
2767: <title>LON-CAPA Parameters</title>
2768: </head>
2769: $bodytag
2770: $breadcrumbs
1.232 albertel 2771: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 2772: ENDOVER
2773: # Store modified
2774:
2775: &storedata($r,$crs,$dom);
2776:
2777: # Read modified data
2778:
2779: my $resourcedata=&readdata($crs,$dom);
2780:
1.214 www 2781:
2782: my $sortorder=$env{'form.sortorder'};
2783: unless ($sortorder) { $sortorder='realmstudent'; }
2784: &sortmenu($r,$sortorder);
2785:
1.208 www 2786: # List data
2787:
1.214 www 2788: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 2789:
1.145 www 2790: $r->print(&tableend().'<p>'.
1.208 www 2791: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form></body></html>');
1.120 www 2792: }
1.121 www 2793:
1.59 matthew 2794: ##################################################
2795: ##################################################
1.178 raeburn 2796:
2797: =pod
1.239 raeburn 2798:
2799: =item check_cloners
2800:
2801: Checks if new users included in list of allowed cloners
2802: are valid users. Replaces supplied list with
2803: cleaned list containing only users with valid usernames
2804: and domains.
2805:
2806: Inputs: $clonelist, $oldcloner
2807: where $clonelist is ref to array of requested cloners,
2808: and $oldcloner is ref to array of currently allowed
2809: cloners.
2810:
2811: Returns: string - comma separated list of requested
2812: cloners (username:domain) who do not exist in system.
2813:
2814: =item change_clone
2815:
1.178 raeburn 2816: Modifies the list of courses a user can clone (stored
1.239 raeburn 2817: in the user's environment.db file), called when a
1.178 raeburn 2818: change is made to the list of users allowed to clone
2819: a course.
1.239 raeburn 2820:
1.178 raeburn 2821: Inputs: $action,$cloner
2822: where $action is add or drop, and $cloner is identity of
2823: user for whom cloning ability is to be changed in course.
2824:
2825: =cut
2826:
2827: ##################################################
2828: ##################################################
2829:
1.239 raeburn 2830: sub extract_cloners {
2831: my ($clonelist,$allowclone) = @_;
2832: if ($clonelist =~ /,/) {
2833: @{$allowclone} = split/,/,$clonelist;
2834: } else {
2835: $$allowclone[0] = $clonelist;
2836: }
2837: }
2838:
2839:
2840: sub check_cloners {
2841: my ($clonelist,$oldcloner) = @_;
2842: my ($clean_clonelist,$disallowed);
2843: my @allowclone = ();
2844: &extract_cloners($$clonelist,\@allowclone);
2845: foreach my $currclone (@allowclone) {
2846: if (!grep/^$currclone$/,@$oldcloner) {
2847: my ($uname,$udom) = split/:/,$currclone;
2848: if ($uname && $udom) {
2849: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2850: $disallowed .= $currclone.',';
2851: } else {
2852: $clean_clonelist .= $currclone.',';
2853: }
2854: }
2855: } else {
2856: $clean_clonelist .= $currclone.',';
2857: }
2858: }
2859: if ($disallowed) {
2860: $disallowed =~ s/,$//;
2861: }
2862: if ($clean_clonelist) {
2863: $clean_clonelist =~ s/,$//;
2864: }
2865: $$clonelist = $clean_clonelist;
2866: return $disallowed;
2867: }
1.178 raeburn 2868:
2869: sub change_clone {
2870: my ($clonelist,$oldcloner) = @_;
2871: my ($uname,$udom);
1.190 albertel 2872: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2873: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 2874: my $clone_crs = $cnum.':'.$cdom;
2875:
2876: if ($cnum && $cdom) {
1.239 raeburn 2877: my @allowclone;
2878: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 2879: foreach my $currclone (@allowclone) {
2880: if (!grep/^$currclone$/,@$oldcloner) {
2881: ($uname,$udom) = split/:/,$currclone;
2882: if ($uname && $udom) {
2883: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2884: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2885: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
2886: if ($currclonecrs{'cloneable'} eq '') {
2887: $currclonecrs{'cloneable'} = $clone_crs;
2888: } else {
2889: $currclonecrs{'cloneable'} .= ','.$clone_crs;
2890: }
2891: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
2892: }
2893: }
2894: }
2895: }
2896: }
2897: foreach my $oldclone (@$oldcloner) {
2898: if (!grep/^$oldclone$/,@allowclone) {
2899: ($uname,$udom) = split/:/,$oldclone;
2900: if ($uname && $udom) {
2901: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2902: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2903: my %newclonecrs = ();
2904: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
2905: if ($currclonecrs{'cloneable'} =~ /,/) {
2906: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
2907: foreach (@currclonecrs) {
2908: unless ($_ eq $clone_crs) {
2909: $newclonecrs{'cloneable'} .= $_.',';
2910: }
2911: }
2912: $newclonecrs{'cloneable'} =~ s/,$//;
2913: } else {
2914: $newclonecrs{'cloneable'} = '';
2915: }
2916: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
2917: }
2918: }
2919: }
2920: }
2921: }
2922: }
2923: }
2924:
1.193 albertel 2925:
2926: ##################################################
2927: ##################################################
2928:
2929: =pod
2930:
2931: =item * header
2932:
2933: Output html header for page
2934:
2935: =cut
2936:
2937: ##################################################
2938: ##################################################
2939: sub header {
2940: my $html=&Apache::lonxml::xmlbegin();
2941: my $bodytag=&Apache::loncommon::bodytag('Parameter Manager');
2942: my $title = &mt('LON-CAPA Parameter Manager');
2943: return(<<ENDHEAD);
2944: $html
2945: <head>
2946: <title>$title</title>
2947: </head>
2948: $bodytag
2949: ENDHEAD
2950: }
2951: ##################################################
2952: ##################################################
2953: sub print_main_menu {
2954: my ($r,$parm_permission)=@_;
2955: #
2956: $r->print(<<ENDMAINFORMHEAD);
2957: <form method="post" enctype="multipart/form-data"
2958: action="/adm/parmset" name="studentform">
2959: ENDMAINFORMHEAD
2960: #
1.195 albertel 2961: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2962: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 2963: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
2964:
1.193 albertel 2965: my @menu =
2966: (
2967: { text => 'Set Course Environment Parameters',
1.204 www 2968: action => 'crsenv',
1.193 albertel 2969: permission => $parm_permission,
2970: },
1.255 banghart 2971: { text => 'Set Portfolio Metadata',
1.259 banghart 2972: action => 'setrestrictmeta',
1.240 banghart 2973: permission => $parm_permission,
2974: },
1.271 www 2975: { text => 'Manage Course Slots',
1.268 albertel 2976: url => '/adm/slotrequest?command=showslots',
2977: permission => $vgr,
2978: },
2979: { divider => 1,
2980: },
1.216 www 2981: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 2982: url => '/adm/helper/parameter.helper',
2983: permission => $parm_permission,
2984: },
1.216 www 2985: { text => 'Modify Resource Parameters - Overview Mode',
1.193 albertel 2986: action => 'setoverview',
2987: permission => $parm_permission,
1.208 www 2988: },
1.216 www 2989: { text => 'Set Resource Parameters - Overview Mode',
1.208 www 2990: action => 'newoverview',
2991: permission => $parm_permission,
1.193 albertel 2992: },
1.216 www 2993: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 2994: action => 'settable',
2995: permission => $parm_permission,
1.204 www 2996: help => 'Cascading_Parameters',
1.193 albertel 2997: },
1.220 www 2998: { text => 'Set Parameter Setting Default Actions',
2999: action => 'setdefaults',
3000: permission => $parm_permission,
3001: },
1.193 albertel 3002: );
3003: my $menu_html = '';
3004: foreach my $menu_item (@menu) {
1.268 albertel 3005: if ($menu_item->{'divider'}) {
3006: $menu_html .= '<hr />';
3007: next;
3008: }
1.193 albertel 3009: next if (! $menu_item->{'permission'});
3010: $menu_html.='<p>';
3011: $menu_html.='<font size="+1">';
3012: if (exists($menu_item->{'url'})) {
3013: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3014: } else {
3015: $menu_html.=
3016: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3017: }
3018: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
3019: if (exists($menu_item->{'help'})) {
3020: $menu_html.=
3021: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3022: }
3023: $menu_html.='</p>'.$/;
3024: }
3025: $r->print($menu_html);
3026: return;
3027: }
1.255 banghart 3028: ### Set portfolio metadata
1.252 banghart 3029: sub output_row {
1.255 banghart 3030: my ($r, $field_name, $field_text) = @_;
1.252 banghart 3031: my $output;
1.263 banghart 3032: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3033: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.254 banghart 3034: unless (defined($options)) {
3035: $options = 'active,stuadd';
1.261 banghart 3036: $values = '';
1.252 banghart 3037: }
1.260 banghart 3038: $output.='<strong>'.$field_text.':</strong>';
1.264 albertel 3039: $output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />';
3040:
3041: my @options= ( ['active', 'Show to student'],
3042: ['onlyone','Student may select only one choice'],
3043: ['stuadd', 'Student may type choices']);
3044: foreach my $opt (@options) {
3045: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3046: $output.=(' 'x5).'<label><input type="checkbox" name="'.
3047: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3048: &mt($opt->[1]).'</label> <br />';
1.252 banghart 3049: }
3050: return ($output);
3051: }
1.259 banghart 3052:
3053: sub setrestrictmeta {
1.240 banghart 3054: my ($r)=@_;
1.242 banghart 3055: my $next_meta;
1.244 banghart 3056: my $output;
1.245 banghart 3057: my $item_num;
1.246 banghart 3058: my $put_result;
1.240 banghart 3059: $r->print(&Apache::lonxml::xmlbegin());
3060: $r->print('<head>
1.260 banghart 3061: <title>LON-CAPA Restrict Metadata</title>
1.240 banghart 3062: </head>');
1.260 banghart 3063: $r->print(&Apache::loncommon::bodytag('Restrict Metadata'));
1.240 banghart 3064: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
1.260 banghart 3065: 'Restrict Metadata'));
1.240 banghart 3066: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3067: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3068: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3069: my $save_field = '';
1.259 banghart 3070: if ($env{'form.restrictmeta'}) {
1.254 banghart 3071: foreach my $field (sort(keys(%env))) {
1.252 banghart 3072: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3073: my $options;
1.252 banghart 3074: my $meta_field = $1;
3075: my $meta_key = $2;
1.253 banghart 3076: if ($save_field ne $meta_field) {
1.252 banghart 3077: $save_field = $meta_field;
1.253 banghart 3078: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3079: $options.='stuadd,';
3080: }
1.253 banghart 3081: if ($env{'form.'.$meta_field.'_onlyone'}) {
1.254 banghart 3082: $options.='onlyone,';
3083: }
3084: if ($env{'form.'.$meta_field.'_active'}) {
3085: $options.='active,';
1.253 banghart 3086: }
1.259 banghart 3087: my $name = $save_field;
1.253 banghart 3088: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3089: {'metadata.'.$meta_field.'.options'=>$options,
3090: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 3091: },$dom,$crs);
1.252 banghart 3092: }
3093: }
3094: }
3095: }
3096: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.258 albertel 3097: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
3098: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 3099: &Apache::lonnet::logthis ($field);
3100: if ($field ne 'courserestricted') {
3101: $output.= &output_row($r, $field, $metadata_fields{$field});
3102: }
1.255 banghart 3103: }
1.244 banghart 3104: $r->print(<<ENDenv);
1.259 banghart 3105: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 3106: <p>
3107: $output
1.259 banghart 3108: <input type="submit" name="restrictmeta" value="Update Metadata Restrictions">
1.244 banghart 3109: </form>
3110: ENDenv
1.241 banghart 3111: $r->print('</body>
3112: </html>');
1.240 banghart 3113: return 'ok';
3114: }
1.220 www 3115: ##################################################
1.193 albertel 3116:
1.220 www 3117: sub defaultsetter {
3118: my $r=shift;
3119: my $bodytag=&Apache::loncommon::bodytag('Parameter Setting Default Actions');
3120: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3121: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3122: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults');
3123: my $html=&Apache::lonxml::xmlbegin();
3124: $r->print(<<ENDDEFHEAD);
3125: $html
3126: <head>
3127: <title>LON-CAPA Parameters</title>
3128: </head>
3129: $bodytag
3130: $breadcrumbs
3131: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
3132: ENDDEFHEAD
1.221 www 3133: my @ids=();
3134: my %typep=();
3135: my %keyp=();
3136: my %allparms=();
3137: my %allparts=();
3138: my %allmaps=();
3139: my %mapp=();
3140: my %symbp=();
3141: my %maptitles=();
3142: my %uris=();
3143: my %keyorder=&standardkeyorder();
3144: my %defkeytype=();
3145:
3146: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3147: \%mapp, \%symbp,\%maptitles,\%uris,
3148: \%keyorder,\%defkeytype);
1.224 www 3149: if ($env{'form.storerules'}) {
3150: my %newrules=();
3151: my @delrules=();
1.226 www 3152: my %triggers=();
1.225 albertel 3153: foreach my $key (keys(%env)) {
3154: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 3155: my $tempkey=$1;
1.226 www 3156: my $action=$env{$key};
3157: if ($action) {
3158: $newrules{$tempkey.'_action'}=$action;
3159: if ($action ne 'default') {
3160: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
3161: $triggers{$whichparm}.=$tempkey.':';
3162: }
3163: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 3164: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3165: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 3166: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
3167: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
3168: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
3169: } else {
3170: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 3171: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 3172: }
3173: } else {
1.225 albertel 3174: push(@delrules,$tempkey.'_action');
1.226 www 3175: push(@delrules,$tempkey.'_type');
1.225 albertel 3176: push(@delrules,$tempkey.'_hours');
3177: push(@delrules,$tempkey.'_min');
3178: push(@delrules,$tempkey.'_sec');
3179: push(@delrules,$tempkey.'_value');
1.224 www 3180: }
3181: }
3182: }
1.226 www 3183: foreach my $key (keys %allparms) {
3184: $newrules{$key.'_triggers'}=$triggers{$key};
3185: }
1.224 www 3186: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
3187: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
3188: &resetrulescache();
3189: }
1.227 www 3190: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
3191: 'hours' => 'Hours',
1.221 www 3192: 'min' => 'Minutes',
3193: 'sec' => 'Seconds',
3194: 'yes' => 'Yes',
3195: 'no' => 'No');
1.222 www 3196: my @standardoptions=('','default');
3197: my @standarddisplay=('',&mt('Default value when manually setting'));
3198: my @dateoptions=('','default');
3199: my @datedisplay=('',&mt('Default value when manually setting'));
3200: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
3201: unless ($tempkey) { next; }
3202: push @standardoptions,'when_setting_'.$tempkey;
3203: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
3204: if (&isdateparm($defkeytype{$tempkey})) {
3205: push @dateoptions,'later_than_'.$tempkey;
3206: push @datedisplay,&mt('Automatically set later than ').$tempkey;
3207: push @dateoptions,'earlier_than_'.$tempkey;
3208: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
3209: }
3210: }
1.231 www 3211: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
3212: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.221 www 3213: $r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'.
1.222 www 3214: &mt('Action').'</th><th>'.&mt('Value').'</th></tr>');
1.221 www 3215: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 3216: unless ($tempkey) { next; }
1.221 www 3217: $r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 3218: my $action=&rulescache($tempkey.'_action');
3219: $r->print('<select name="'.$tempkey.'_action">');
3220: if (&isdateparm($defkeytype{$tempkey})) {
3221: for (my $i=0;$i<=$#dateoptions;$i++) {
3222: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
3223: $r->print("\n<option value='$dateoptions[$i]'".
3224: ($dateoptions[$i] eq $action?' selected="selected"':'').
3225: ">$datedisplay[$i]</option>");
3226: }
3227: } else {
3228: for (my $i=0;$i<=$#standardoptions;$i++) {
3229: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
3230: $r->print("\n<option value='$standardoptions[$i]'".
3231: ($standardoptions[$i] eq $action?' selected="selected"':'').
3232: ">$standarddisplay[$i]</option>");
3233: }
3234: }
3235: $r->print('</select>');
1.227 www 3236: unless (&isdateparm($defkeytype{$tempkey})) {
3237: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
3238: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
3239: }
1.222 www 3240: $r->print("\n</td><td>\n");
3241:
1.221 www 3242: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3243: my $days=&rulescache($tempkey.'_days');
1.222 www 3244: my $hours=&rulescache($tempkey.'_hours');
3245: my $min=&rulescache($tempkey.'_min');
3246: my $sec=&rulescache($tempkey.'_sec');
1.221 www 3247: $r->print(<<ENDINPUTDATE);
1.227 www 3248: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 3249: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
3250: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
3251: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 3252: ENDINPUTDATE
3253: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 3254: my $yeschecked='';
3255: my $nochecked='';
3256: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
3257: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
3258:
1.221 www 3259: $r->print(<<ENDYESNO);
1.224 www 3260: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
3261: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 3262: ENDYESNO
3263: } else {
1.224 www 3264: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 3265: }
3266: $r->print('</td></tr>');
3267: }
1.224 www 3268: $r->print("</table>\n<input type='submit' name='storerules' value='".
3269: &mt('Store Rules')."' /></form>\n</body>\n</html>");
1.220 www 3270: return;
3271: }
1.193 albertel 3272:
1.178 raeburn 3273: ##################################################
3274: ##################################################
1.30 www 3275:
1.59 matthew 3276: =pod
3277:
1.83 bowersj2 3278: =item * handler
1.59 matthew 3279:
3280: Main handler. Calls &assessparms and &crsenv subroutines.
3281:
3282: =cut
3283: ##################################################
3284: ##################################################
1.220 www 3285: # use Data::Dumper;
3286:
1.259 banghart 3287:
1.30 www 3288: sub handler {
1.43 albertel 3289: my $r=shift;
1.30 www 3290:
1.43 albertel 3291: if ($r->header_only) {
1.126 www 3292: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 3293: $r->send_http_header;
3294: return OK;
3295: }
1.193 albertel 3296: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 3297: ['action','state',
3298: 'pres_marker',
3299: 'pres_value',
1.206 www 3300: 'pres_type',
1.243 banghart 3301: 'udom','uname','symb','serial']);
1.131 www 3302:
1.83 bowersj2 3303:
1.193 albertel 3304: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 3305: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
3306: text=>"Parameter Manager",
1.204 www 3307: faq=>10,
1.194 albertel 3308: bug=>'Instructor Interface'});
1.203 www 3309:
1.30 www 3310: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 3311: my $parm_permission =
3312: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 3313: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 3314: $env{'request.course.sec'}));
1.194 albertel 3315: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 3316:
3317: # Start Page
1.126 www 3318: &Apache::loncommon::content_type($r,'text/html');
1.106 www 3319: $r->send_http_header;
1.30 www 3320:
1.203 www 3321:
3322: # id numbers can change on re-ordering of folders
3323:
3324: &resetsymbcache();
3325:
1.193 albertel 3326: #
3327: # Main switch on form.action and form.state, as appropriate
3328: #
3329: # Check first if coming from someone else headed directly for
3330: # the table mode
3331: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
3332: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
3333: &assessparms($r);
3334:
3335: } elsif (! exists($env{'form.action'})) {
3336: $r->print(&header());
1.194 albertel 3337: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
3338: 'Parameter Manager'));
1.193 albertel 3339: &print_main_menu($r,$parm_permission);
3340: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 3341: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
3342: text=>"Course Environment"});
1.193 albertel 3343: &crsenv($r);
3344: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 3345: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3346: text=>"Overview Mode"});
1.121 www 3347: &overview($r);
1.259 banghart 3348: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
3349: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
3350: text=>"Restrict Metadata"});
3351: &setrestrictmeta($r);
1.208 www 3352: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
3353: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3354: text=>"Overview Mode"});
3355: &newoverview($r);
1.220 www 3356: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
3357: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
3358: text=>"Set Defaults"});
3359: &defaultsetter($r);
3360: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 3361: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 3362: text=>"Table Mode",
3363: help => 'Course_Setting_Parameters'});
1.121 www 3364: &assessparms($r);
1.193 albertel 3365: }
3366:
1.43 albertel 3367: } else {
1.1 www 3368: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 3369: $env{'user.error.msg'}=
1.43 albertel 3370: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
3371: return HTTP_NOT_ACCEPTABLE;
3372: }
3373: return OK;
1.1 www 3374: }
3375:
3376: 1;
3377: __END__
3378:
1.59 matthew 3379: =pod
1.38 harris41 3380:
3381: =back
3382:
3383: =cut
1.1 www 3384:
3385:
3386:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>