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