Annotation of loncom/interface/lonparmset.pm, revision 1.306
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.306 ! albertel 4: # $Id: lonparmset.pm,v 1.305 2006/05/15 23:40:54 albertel Exp $
1.40 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.59 matthew 28: ###################################################################
29: ###################################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: lonparmset - Handler to set parameters for assessments and course
36:
37: =head1 SYNOPSIS
38:
39: lonparmset provides an interface to setting course parameters.
40:
41: =head1 DESCRIPTION
42:
43: This module sets coursewide and assessment parameters.
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over 4
48:
49: =cut
50:
51: ###################################################################
52: ###################################################################
1.1 www 53:
54: package Apache::lonparmset;
55:
56: use strict;
57: use Apache::lonnet;
58: use Apache::Constants qw(:common :http REDIRECT);
1.88 matthew 59: use Apache::lonhtmlcommon();
1.36 albertel 60: use Apache::loncommon;
1.1 www 61: use GDBM_File;
1.57 albertel 62: use Apache::lonhomework;
63: use Apache::lonxml;
1.130 www 64: use Apache::lonlocal;
1.197 www 65: use Apache::lonnavmaps;
1.303 www 66: use Apache::lonrss;
1.1 www 67:
1.198 www 68: # --- Caches local to lonparmset
1.2 www 69:
1.199 www 70: my $parmhashid;
71: my %parmhash;
1.201 www 72: my $symbsid;
73: my %symbs;
1.221 www 74: my $rulesid;
75: my %rules;
1.198 www 76:
77: # --- end local caches
78:
1.59 matthew 79: ##################################################
80: ##################################################
81:
82: =pod
83:
84: =item parmval
85:
86: Figure out a cascading parameter.
87:
1.71 albertel 88: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 89: $id - a bighash Id number
1.71 albertel 90: $def - the resource's default value 'stupid emacs
91:
1.269 raeburn 92: 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 93:
1.306 ! albertel 94: 14- General Course
! 95: 13- Map or Folder level in course
1.269 raeburn 96: 12- resource default
97: 11- map default
1.306 ! albertel 98: 10- resource level in course
1.269 raeburn 99: 9 - General for section
100: 8 - Map or Folder level for section
101: 7 - resource level in section
102: 6 - General for group
103: 5 - Map or Folder level for group
104: 4 - resource level in group
1.71 albertel 105: 3 - General for specific student
1.82 www 106: 2 - Map or Folder level for specific student
1.71 albertel 107: 1 - resource level for specific student
1.2 www 108:
1.59 matthew 109: =cut
110:
111: ##################################################
1.2 www 112: sub parmval {
1.275 raeburn 113: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
114: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
115: $cgroup,$courseopt);
1.201 www 116: }
117:
118: sub parmval_by_symb {
1.275 raeburn 119: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.198 www 120: # load caches
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.305 albertel 129: $map = &Apache::lonnet::deversion($map);
1.10 www 130:
1.201 www 131: my $symbparm=$symb.'.'.$what;
132: my $mapparm=$map.'___(all).'.$what;
1.10 www 133:
1.269 raeburn 134: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
135: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
136: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
137:
1.190 albertel 138: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
139: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
140: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
141:
142: my $courselevel=$env{'request.course.id'}.'.'.$what;
143: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
144: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 145:
1.11 www 146:
1.182 albertel 147: # --------------------------------------------------------- first, check course
1.11 www 148:
1.200 www 149: if (defined($$courseopt{$courselevel})) {
1.269 raeburn 150: $outpar[14]=$$courseopt{$courselevel};
151: $result=14;
1.43 albertel 152: }
1.11 www 153:
1.200 www 154: if (defined($$courseopt{$courselevelm})) {
1.269 raeburn 155: $outpar[13]=$$courseopt{$courselevelm};
156: $result=13;
1.43 albertel 157: }
1.11 www 158:
1.182 albertel 159: # ------------------------------------------------------- second, check default
160:
1.269 raeburn 161: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 162:
163: # ------------------------------------------------------ third, check map parms
164:
165: my $thisparm=$parmhash{$symbparm};
1.269 raeburn 166: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 167:
1.200 www 168: if (defined($$courseopt{$courselevelr})) {
1.269 raeburn 169: $outpar[10]=$$courseopt{$courselevelr};
170: $result=10;
1.43 albertel 171: }
1.11 www 172:
1.182 albertel 173: # ------------------------------------------------------ fourth, back to course
1.71 albertel 174: if (defined($csec)) {
1.200 www 175: if (defined($$courseopt{$seclevel})) {
1.269 raeburn 176: $outpar[9]=$$courseopt{$seclevel};
177: $result=9;
1.43 albertel 178: }
1.200 www 179: if (defined($$courseopt{$seclevelm})) {
1.269 raeburn 180: $outpar[8]=$$courseopt{$seclevelm};
181: $result=8;
1.43 albertel 182: }
183:
1.200 www 184: if (defined($$courseopt{$seclevelr})) {
1.269 raeburn 185: $outpar[7]=$$courseopt{$seclevelr};
186: $result=7;
1.43 albertel 187: }
188: }
1.275 raeburn 189: # ------------------------------------------------------ fifth, check course group
1.269 raeburn 190: if (defined($cgroup)) {
191: if (defined($$courseopt{$grplevel})) {
192: $outpar[6]=$$courseopt{$grplevel};
193: $result=6;
194: }
195: if (defined($$courseopt{$grplevelm})) {
196: $outpar[5]=$$courseopt{$grplevelm};
197: $result=5;
198: }
199: if (defined($$courseopt{$grplevelr})) {
200: $outpar[4]=$$courseopt{$grplevelr};
201: $result=4;
202: }
203: }
1.11 www 204:
1.182 albertel 205: # ---------------------------------------------------------- fifth, check user
1.11 www 206:
1.71 albertel 207: if (defined($uname)) {
1.200 www 208: if (defined($$useropt{$courselevel})) {
209: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 210: $result=3;
211: }
1.10 www 212:
1.200 www 213: if (defined($$useropt{$courselevelm})) {
214: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 215: $result=2;
216: }
1.2 www 217:
1.200 www 218: if (defined($$useropt{$courselevelr})) {
219: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 220: $result=1;
221: }
222: }
1.44 albertel 223: return ($result,@outpar);
1.2 www 224: }
225:
1.198 www 226: sub resetparmhash {
227: $parmhashid='';
228: }
229:
230: sub cacheparmhash {
231: if ($parmhashid eq $env{'request.course.fn'}) { return; }
232: my %parmhashfile;
233: if (tie(%parmhashfile,'GDBM_File',
234: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
235: %parmhash=%parmhashfile;
236: untie %parmhashfile;
237: $parmhashid=$env{'request.course.fn'};
238: }
239: }
240:
1.203 www 241: sub resetsymbcache {
242: $symbsid='';
243: }
244:
1.201 www 245: sub symbcache {
246: my $id=shift;
247: if ($symbsid ne $env{'request.course.id'}) {
248: %symbs=();
249: }
250: unless ($symbs{$id}) {
251: my $navmap = Apache::lonnavmaps::navmap->new();
252: if ($id=~/\./) {
253: my $resource=$navmap->getById($id);
254: $symbs{$id}=$resource->symb();
255: } else {
256: my $resource=$navmap->getByMapPc($id);
257: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
258: }
259: $symbsid=$env{'request.course.id'};
260: }
261: return $symbs{$id};
262: }
263:
1.221 www 264: sub resetrulescache {
265: $rulesid='';
266: }
267:
268: sub rulescache {
269: my $id=shift;
270: if ($rulesid ne $env{'request.course.id'}) {
271: %rules=();
272: }
1.224 www 273: unless (defined($rules{$id})) {
1.221 www 274: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
275: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.224 www 276: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
1.221 www 277: $rulesid=$env{'request.course.id'};
278: }
279: return $rules{$id};
280: }
281:
1.229 www 282: sub preset_defaults {
283: my $type=shift;
284: if (&rulescache($type.'_action') eq 'default') {
285: # yes, there is something
286: return (&rulescache($type.'_hours'),
287: &rulescache($type.'_min'),
288: &rulescache($type.'_sec'),
289: &rulescache($type.'_value'));
290: } else {
291: # nothing there or something else
292: return ('','','','','');
293: }
294: }
295:
1.186 www 296: ##################################################
1.277 www 297:
298: sub date_sanity_info {
299: my $checkdate=shift;
300: unless ($checkdate) { return ''; }
301: my $result='';
302: my $crsprefix='course.'.$env{'request.course.id'}.'.';
303: if ($env{$crsprefix.'default_enrollment_end_date'}) {
304: if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
305: $result.='<br />'.&mt('After course enrollment end!');
306: }
307: }
308: if ($env{$crsprefix.'default_enrollment_start_date'}) {
309: if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
310: $result.='<br />'.&mt('Before course enrollment start!');
311: }
312: }
313: return $result;
314: }
315: ##################################################
1.186 www 316: ##################################################
317: #
1.197 www 318: # Store a parameter by ID
1.186 www 319: #
320: # Takes
321: # - resource id
322: # - name of parameter
323: # - level
324: # - new value
325: # - new type
1.187 www 326: # - username
327: # - userdomain
328:
1.186 www 329: sub storeparm {
1.269 raeburn 330: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 raeburn 331: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 332: }
333:
334: #
335: # Store a parameter by symb
336: #
337: # Takes
338: # - symb
339: # - name of parameter
340: # - level
341: # - new value
342: # - new type
343: # - username
344: # - userdomain
345:
1.226 www 346: my %recstack;
1.197 www 347: sub storeparm_by_symb {
1.275 raeburn 348: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 349: unless ($recflag) {
350: # first time call
351: %recstack=();
352: $recflag=1;
353: }
354: # store parameter
355: &storeparm_by_symb_inner
1.269 raeburn 356: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 357: # don't do anything if parameter was reset
358: unless ($nval) { return; }
1.226 www 359: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
360: # remember that this was set
361: $recstack{$parm}=1;
362: # what does this trigger?
363: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
364: # don't backfire
365: unless ((!$triggered) || ($recstack{$triggered})) {
366: my $action=&rulescache($triggered.'_action');
367: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
368: # set triggered parameter on same level
369: my $newspnam=$prefix.$triggered;
1.227 www 370: my $newvalue='';
1.228 www 371: my $active=1;
372: if ($action=~/^when\_setting/) {
373: # are there restrictions?
374: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
375: $active=0;
376: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
377: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
378: }
379: }
380: $newvalue=&rulescache($triggered.'_value');
1.227 www 381: } else {
382: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
1.228 www 383: if ($action=~/^later\_than/) {
384: $newvalue=$nval+$totalsecs;
385: } else {
386: $newvalue=$nval-$totalsecs;
387: }
388: }
389: if ($active) {
390: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
1.275 raeburn 391: $uname,$udom,$csec,$recflag,$cgroup);
1.227 www 392: }
1.226 www 393: }
394: }
395: return '';
396: }
397:
1.293 www 398: sub log_parmset {
399: return &Apache::lonnet::instructor_log('parameterlog',@_);
1.284 www 400: }
401:
1.226 www 402: sub storeparm_by_symb_inner {
1.197 www 403: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 404: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 405: # ---------------------------------------------------------- Construct prefixes
1.186 www 406: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 407: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 408: $map = &Apache::lonnet::deversion($map);
409:
1.197 www 410: my $symbparm=$symb.'.'.$spnam;
411: my $mapparm=$map.'___(all).'.$spnam;
412:
1.269 raeburn 413: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
414: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
415: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
416:
1.190 albertel 417: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
418: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
419: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 420:
1.190 albertel 421: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
422: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
423: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 424:
425: my $storeunder='';
1.269 raeburn 426: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
427: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
428: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
429: if ($snum==9) { $storeunder=$seclevel; }
430: if ($snum==8) { $storeunder=$seclevelm; }
431: if ($snum==7) { $storeunder=$seclevelr; }
432: if ($snum==6) { $storeunder=$grplevel; }
433: if ($snum==5) { $storeunder=$grplevelm; }
434: if ($snum==4) { $storeunder=$grplevelr; }
435:
1.186 www 436:
437: my $delete;
438: if ($nval eq '') { $delete=1;}
439: my %storecontent = ($storeunder => $nval,
440: $storeunder.'.type' => $ntype);
441: my $reply='';
442: if ($snum>3) {
443: # ---------------------------------------------------------------- Store Course
444: #
1.200 www 445: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
446: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 447: # Expire sheets
448: &Apache::lonnet::expirespread('','','studentcalc');
1.269 raeburn 449: if (($snum==10) || ($snum==7) || ($snum==4)) {
1.197 www 450: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.269 raeburn 451: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
1.197 www 452: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 453: } else {
454: &Apache::lonnet::expirespread('','','assesscalc');
455: }
456: # Store parameter
457: if ($delete) {
458: $reply=&Apache::lonnet::del
1.200 www 459: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.290 www 460: &log_parmset(\%storecontent,1);
1.186 www 461: } else {
462: $reply=&Apache::lonnet::cput
1.200 www 463: ('resourcedata',\%storecontent,$cdom,$cnum);
1.290 www 464: &log_parmset(\%storecontent);
1.186 www 465: }
1.200 www 466: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 467: } else {
468: # ------------------------------------------------------------------ Store User
469: #
470: # Expire sheets
471: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
472: if ($snum==1) {
473: &Apache::lonnet::expirespread
1.197 www 474: ($uname,$udom,'assesscalc',$symb);
1.186 www 475: } elsif ($snum==2) {
476: &Apache::lonnet::expirespread
1.197 www 477: ($uname,$udom,'assesscalc',$map);
1.186 www 478: } else {
479: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
480: }
481: # Store parameter
482: if ($delete) {
483: $reply=&Apache::lonnet::del
484: ('resourcedata',[keys(%storecontent)],$udom,$uname);
1.290 www 485: &log_parmset(\%storecontent,1,$uname,$udom);
1.186 www 486: } else {
487: $reply=&Apache::lonnet::cput
488: ('resourcedata',\%storecontent,$udom,$uname);
1.290 www 489: &log_parmset(\%storecontent,0,$uname,$udom);
1.186 www 490: }
1.191 albertel 491: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 492: }
493:
494: if ($reply=~/^error\:(.*)/) {
495: return "<font color=red>Write Error: $1</font>";
496: }
497: return '';
498: }
499:
1.59 matthew 500: ##################################################
501: ##################################################
502:
503: =pod
504:
505: =item valout
506:
507: Format a value for output.
508:
509: Inputs: $value, $type
510:
511: Returns: $value, formatted for output. If $type indicates it is a date,
512: localtime($value) is returned.
1.9 www 513:
1.59 matthew 514: =cut
515:
516: ##################################################
517: ##################################################
1.9 www 518: sub valout {
519: my ($value,$type)=@_;
1.59 matthew 520: my $result = '';
521: # Values of zero are valid.
522: if (! $value && $value ne '0') {
1.71 albertel 523: $result = ' ';
1.59 matthew 524: } else {
1.66 www 525: if ($type eq 'date_interval') {
526: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
527: $year=$year-70;
528: $mday--;
529: if ($year) {
530: $result.=$year.' yrs ';
531: }
532: if ($mon) {
533: $result.=$mon.' mths ';
534: }
535: if ($mday) {
536: $result.=$mday.' days ';
537: }
538: if ($hour) {
539: $result.=$hour.' hrs ';
540: }
541: if ($min) {
542: $result.=$min.' mins ';
543: }
544: if ($sec) {
545: $result.=$sec.' secs ';
546: }
547: $result=~s/\s+$//;
1.213 www 548: } elsif (&isdateparm($type)) {
1.277 www 549: $result = localtime($value).&date_sanity_info($value);
1.59 matthew 550: } else {
551: $result = $value;
552: }
553: }
554: return $result;
1.9 www 555: }
556:
1.59 matthew 557: ##################################################
558: ##################################################
559:
560: =pod
1.5 www 561:
1.59 matthew 562: =item plink
563:
564: Produces a link anchor.
565:
566: Inputs: $type,$dis,$value,$marker,$return,$call
567:
568: Returns: scalar with html code for a link which will envoke the
569: javascript function 'pjump'.
570:
571: =cut
572:
573: ##################################################
574: ##################################################
1.5 www 575: sub plink {
576: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 577: my $winvalue=$value;
578: unless ($winvalue) {
1.213 www 579: if (&isdateparm($type)) {
1.190 albertel 580: $winvalue=$env{'form.recent_'.$type};
1.23 www 581: } else {
1.190 albertel 582: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 583: }
584: }
1.229 www 585: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
586: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
587: unless (defined($winvalue)) { $winvalue=$val; }
1.270 www 588: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.
1.43 albertel 589: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.229 www 590: .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
1.270 www 591: &valout($value,$type).'</a></td></tr></table>';
1.5 www 592: }
593:
1.280 albertel 594: sub page_js {
595:
1.81 www 596: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 597: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.280 albertel 598:
599: return(<<ENDJS);
600: <script type="text/javascript">
1.44 albertel 601:
602: function pclose() {
603: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
604: "height=350,width=350,scrollbars=no,menubar=no");
605: parmwin.close();
606: }
607:
1.88 matthew 608: $pjump_def
1.44 albertel 609:
610: function psub() {
611: pclose();
612: if (document.parmform.pres_marker.value!='') {
613: document.parmform.action+='#'+document.parmform.pres_marker.value;
614: var typedef=new Array();
615: typedef=document.parmform.pres_type.value.split('_');
616: if (document.parmform.pres_type.value!='') {
617: if (typedef[0]=='date') {
618: eval('document.parmform.recent_'+
619: document.parmform.pres_type.value+
620: '.value=document.parmform.pres_value.value;');
621: } else {
622: eval('document.parmform.recent_'+typedef[0]+
623: '.value=document.parmform.pres_value.value;');
624: }
625: }
626: document.parmform.submit();
627: } else {
628: document.parmform.pres_value.value='';
629: document.parmform.pres_marker.value='';
630: }
631: }
632:
1.57 albertel 633: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
634: var options = "width=" + w + ",height=" + h + ",";
635: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
636: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
637: var newWin = window.open(url, wdwName, options);
638: newWin.focus();
639: }
1.44 albertel 640: </script>
1.81 www 641: $selscript
1.280 albertel 642: ENDJS
643:
644: }
645: sub startpage {
646: my ($r) = @_;
1.281 albertel 647:
1.282 albertel 648: my %loaditems = ('onunload' => "pclose()",
1.283 albertel 649: 'onload' => "group_or_section('cgroup')",);
1.280 albertel 650:
1.281 albertel 651: my $start_page =
652: &Apache::loncommon::start_page('Set/Modify Course Parameters',
653: &page_js(),
1.282 albertel 654: {'add_entries' => \%loaditems,});
1.280 albertel 655: my $breadcrumbs =
1.298 albertel 656: &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting');
1.280 albertel 657: $r->print(<<ENDHEAD);
1.281 albertel 658: $start_page
1.193 albertel 659: $breadcrumbs
660: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.280 albertel 661: <input type="hidden" value='' name="pres_value" />
662: <input type="hidden" value='' name="pres_type" />
663: <input type="hidden" value='' name="pres_marker" />
664: <input type="hidden" value='1' name="prevvisit" />
1.44 albertel 665: ENDHEAD
666: }
667:
1.209 www 668:
1.44 albertel 669: sub print_row {
1.201 www 670: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.275 raeburn 671: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
672: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
673: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
674: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 675: # get the values for the parameter in cascading order
676: # empty levels will remain empty
1.44 albertel 677: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.275 raeburn 678: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 679: # get the type for the parameters
680: # problem: these may not be set for all levels
681: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 raeburn 682: $$name{$which}.'.type',$rid,
683: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 684: # cascade down manually
1.182 albertel 685: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 686: for (my $i=14;$i>0;$i--) {
1.66 www 687: if ($typeoutpar[$i]) {
688: $cascadetype=$typeoutpar[$i];
689: } else {
690: $typeoutpar[$i]=$cascadetype;
691: }
692: }
1.57 albertel 693: my $parm=$$display{$which};
694:
1.203 www 695: if ($parmlev eq 'full') {
1.57 albertel 696: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
697: .$$part{$which}.'</td>');
698: } else {
699: $parm=~s|\[.*\]\s||g;
700: }
1.231 www 701: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
702: if ($automatic) {
703: $parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>';
704: }
1.159 albertel 705: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 706:
1.44 albertel 707: my $thismarker=$which;
708: $thismarker=~s/^parameter\_//;
709: my $mprefix=$rid.'&'.$thismarker.'&';
1.275 raeburn 710: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
711: my ($othergrp,$grp_parm,$controlgrp);
1.44 albertel 712:
1.57 albertel 713: if ($parmlev eq 'general') {
714:
715: if ($uname) {
1.66 www 716: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 717: } elsif ($cgroup) {
718: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 719: } elsif ($csec) {
1.269 raeburn 720: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 721: } else {
1.269 raeburn 722: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 723: }
724: } elsif ($parmlev eq 'map') {
725:
726: if ($uname) {
1.66 www 727: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 728: } elsif ($cgroup) {
729: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 730: } elsif ($csec) {
1.269 raeburn 731: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 732: } else {
1.269 raeburn 733: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 734: }
735: } else {
1.275 raeburn 736: if ($uname) {
737: if (@{$usersgroups} > 1) {
738: my ($coursereply,$grp_parm,$controlgrp);
739: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
740: &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
741: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
742: if ($coursereply && $result > 3) {
743: if (defined($controlgrp)) {
744: if ($cgroup ne $controlgrp) {
745: $effective_parm = $grp_parm;
746: $result = 0;
747: }
748: }
749: }
750: }
751: }
1.57 albertel 752:
1.269 raeburn 753: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 754:
1.269 raeburn 755: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
756: &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
757: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 758: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
759:
760: if ($csec) {
1.269 raeburn 761: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
762: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
763: &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 764: }
1.269 raeburn 765:
766: if ($cgroup) {
767: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
768: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
769: &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
770: }
1.275 raeburn 771:
1.203 www 772: if ($uname) {
1.275 raeburn 773: if ($othergrp) {
774: $r->print($othergrp);
775: }
1.203 www 776: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
777: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
778: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
779: }
1.57 albertel 780:
781: } # end of $parmlev if/else
1.275 raeburn 782: $r->print('<td bgcolor="#CCCCFF" align="center">'.$effective_parm.'</td>');
1.136 albertel 783:
1.203 www 784: if ($parmlev eq 'full') {
1.136 albertel 785: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 786: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 787: my $sessionvaltype=$typeoutpar[$result];
788: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.275 raeburn 789: $r->print('<td bgcolor="#999999" align="center"><font color="#FFFFFF">'.
1.66 www 790: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 791: '</font></td>');
1.136 albertel 792: }
1.44 albertel 793: $r->print('</tr>');
1.57 albertel 794: $r->print("\n");
1.44 albertel 795: }
1.59 matthew 796:
1.44 albertel 797: sub print_td {
1.66 www 798: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 799: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 800: ' align="center">');
1.269 raeburn 801: if ($which<11 || $which > 12) {
1.114 www 802: $r->print(&plink($$typeoutpar[$which],
803: $$display{$value},$$outpar[$which],
804: $mprefix."$which",'parmform.pres','psub'));
805: } else {
806: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
807: }
808: $r->print('</td>'."\n");
1.57 albertel 809: }
810:
1.275 raeburn 811: sub print_usergroups {
812: my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
813: my $courseid = $env{'request.course.id'};
814: my $output;
815: my $symb = &symbcache($rid);
816: my $symbparm=$symb.'.'.$what;
817: my $map=(&Apache::lonnet::decode_symb($symb))[0];
818: my $mapparm=$map.'___(all).'.$what;
819: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
820: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
821: $courseopt);
822: my $bgcolor = $defbg;
823: my $grp_parm;
824: if (($coursereply) && ($cgroup ne $resultgroup)) {
825: if ($result > 3) {
826: $bgcolor = '"#AAFFAA"';
827: $grp_parm = &valout($coursereply,$resulttype);
828: }
829: $grp_parm = &valout($coursereply,$resulttype);
830: $output = '<td bgcolor='.$bgcolor.' align="center">';
831: if ($resultgroup && $resultlevel) {
832: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
833: } else {
834: $output .= ' ';
835: }
836: $output .= '</td>';
837: } else {
838: $output .= '<td bgcolor='.$bgcolor.'> </td>';
839: }
840: return ($coursereply,$output,$grp_parm,$resultgroup);
841: }
842:
843: sub parm_control_group {
844: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
845: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
846: my $grpfound = 0;
847: my @levels = ($symbparm,$mapparm,$what);
848: my @levelnames = ('resource','map/folder','general');
849: foreach my $group (@{$usersgroups}) {
850: if ($grpfound) { last; }
851: for (my $i=0; $i<@levels; $i++) {
852: my $item = $courseid.'.['.$group.'].'.$levels[$i];
853: if (defined($$courseopt{$item})) {
854: $coursereply = $$courseopt{$item};
855: $resultitem = $item;
856: $resultgroup = $group;
857: $resultlevel = $levelnames[$i];
858: $resulttype = $$courseopt{$item.'.type'};
859: $grpfound = 1;
860: last;
861: }
862: }
863: }
864: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
865: }
1.201 www 866:
1.63 bowersj2 867: =pod
868:
869: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
870:
871: Input: See list below:
872:
873: =over 4
874:
875: =item B<ids>: An array that will contain all of the ids in the course.
876:
877: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
878:
1.171 www 879: =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 880:
881: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
882:
883: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
884:
885: =item B<allkeys>: hash, full key to part->display value (what's display value?)
886:
887: =item B<allmaps>: hash, ???
888:
889: =item B<fcat>: ???
890:
891: =item B<defp>: hash, ???
892:
893: =item B<mapp>: ??
894:
895: =item B<symbp>: hash, id->full sym?
896:
897: =back
898:
899: =cut
900:
901: sub extractResourceInformation {
902: my $ids = shift;
903: my $typep = shift;
904: my $keyp = shift;
905: my $allparms = shift;
906: my $allparts = shift;
907: my $allmaps = shift;
908: my $mapp = shift;
909: my $symbp = shift;
1.82 www 910: my $maptitles=shift;
1.196 www 911: my $uris=shift;
1.210 www 912: my $keyorder=shift;
1.211 www 913: my $defkeytype=shift;
1.196 www 914:
1.210 www 915: my $keyordercnt=100;
1.63 bowersj2 916:
1.196 www 917: my $navmap = Apache::lonnavmaps::navmap->new();
918: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
919: foreach my $resource (@allres) {
920: my $id=$resource->id();
921: my ($mapid,$resid)=split(/\./,$id);
922: if ($mapid eq '0') { next; }
923: $$ids[$#$ids+1]=$id;
924: my $srcf=$resource->src();
925: $srcf=~/\.(\w+)$/;
926: $$typep{$id}=$1;
927: $$keyp{$id}='';
928: $$uris{$id}=$srcf;
929: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
930: if ($_=~/^parameter\_(.*)/) {
931: my $key=$_;
1.209 www 932: # Hidden parameters
933: if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
934: next;
1.63 bowersj2 935: }
1.196 www 936: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
937: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
938: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.209 www 939: #
940: # allparms is a hash of parameter names
941: #
1.196 www 942: my $parmdis = $display;
1.209 www 943: $parmdis =~ s/\[Part.*$//g;
944: $$allparms{$name}=$parmdis;
1.211 www 945: $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
1.209 www 946: #
947: # allparts is a hash of all parts
948: #
949: $$allparts{$part} = "Part: $part";
950: #
951: # Remember all keys going with this resource
952: #
1.196 www 953: if ($$keyp{$id}) {
954: $$keyp{$id}.=','.$key;
1.175 albertel 955: } else {
1.196 www 956: $$keyp{$id}=$key;
1.175 albertel 957: }
1.210 www 958: #
959: # Put in order
960: #
961: unless ($$keyorder{$key}) {
962: $$keyorder{$key}=$keyordercnt;
963: $keyordercnt++;
964: }
965:
1.63 bowersj2 966: }
967: }
1.196 www 968: $$mapp{$id}=
969: &Apache::lonnet::declutter($resource->enclosing_map_src());
970: $$mapp{$mapid}=$$mapp{$id};
971: $$allmaps{$mapid}=$$mapp{$id};
972: if ($mapid eq '1') {
973: $$maptitles{$mapid}='Main Course Documents';
974: } else {
975: $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
976: }
977: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
978: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
979: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.63 bowersj2 980: }
981: }
982:
1.208 www 983:
984: ##################################################
985: ##################################################
986:
1.213 www 987: sub isdateparm {
988: my $type=shift;
989: return (($type=~/^date/) && (!($type eq 'date_interval')));
990: }
991:
1.208 www 992: sub parmmenu {
1.211 www 993: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 994: my $tempkey;
995: $r->print(<<ENDSCRIPT);
996: <script type="text/javascript">
997: function checkall(value, checkName) {
998: for (i=0; i<document.forms.parmform.elements.length; i++) {
999: ele = document.forms.parmform.elements[i];
1000: if (ele.name == checkName) {
1001: document.forms.parmform.elements[i].checked=value;
1002: }
1003: }
1004: }
1.210 www 1005:
1006: function checkthis(thisvalue, checkName) {
1007: for (i=0; i<document.forms.parmform.elements.length; i++) {
1008: ele = document.forms.parmform.elements[i];
1009: if (ele.name == checkName) {
1010: if (ele.value == thisvalue) {
1011: document.forms.parmform.elements[i].checked=true;
1012: }
1013: }
1014: }
1015: }
1016:
1017: function checkdates() {
1018: checkthis('duedate','pscat');
1019: checkthis('opendate','pscat');
1020: checkthis('answerdate','pscat');
1.218 www 1021: }
1022:
1023: function checkdisset() {
1024: checkthis('discussend','pscat');
1025: checkthis('discusshide','pscat');
1026: }
1027:
1028: function checkcontdates() {
1029: checkthis('contentopen','pscat');
1030: checkthis('contentclose','pscat');
1031: }
1032:
1.210 www 1033:
1034: function checkvisi() {
1035: checkthis('hiddenresource','pscat');
1036: checkthis('encrypturl','pscat');
1037: checkthis('problemstatus','pscat');
1038: checkthis('contentopen','pscat');
1039: checkthis('opendate','pscat');
1040: }
1041:
1042: function checkparts() {
1043: checkthis('hiddenparts','pscat');
1044: checkthis('display','pscat');
1045: checkthis('ordered','pscat');
1046: }
1047:
1048: function checkstandard() {
1049: checkall(false,'pscat');
1050: checkdates();
1051: checkthis('weight','pscat');
1052: checkthis('maxtries','pscat');
1053: }
1054:
1.208 www 1055: </script>
1056: ENDSCRIPT
1.209 www 1057: $r->print();
1.208 www 1058: $r->print("\n<table><tr>");
1059: my $cnt=0;
1.211 www 1060: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.235 albertel 1061: $r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' ");
1.208 www 1062: $r->print('value="'.$tempkey.'"');
1063: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1064: $r->print(' checked');
1065: }
1.235 albertel 1066: $r->print('>'.$$allparms{$tempkey}.'</label></font></td>');
1.209 www 1067: $cnt++;
1068: if ($cnt==3) {
1069: $r->print("</tr>\n<tr>");
1070: $cnt=0;
1071: }
1.208 www 1072: }
1073: $r->print('
1074: </tr><tr><td>
1.233 albertel 1075: <a href="javascript:checkall(true, \'pscat\')">Select All</a><br />
1076: <a href="javascript:checkstandard()">Select Common Only</a>
1.210 www 1077: </td><td>
1.233 albertel 1078: <a href="javascript:checkdates()">Add Problem Dates</a>
1079: <a href="javascript:checkcontdates()">Add Content Dates</a><br />
1080: <a href="javascript:checkdisset()">Add Discussion Settings</a>
1081: <a href="javascript:checkvisi()">Add Visibilities</a><br />
1082: <a href="javascript:checkparts()">Add Part Parameters</a>
1.210 www 1083: </td><td>
1.233 albertel 1084: <a href="javascript:checkall(false, \'pscat\')">Unselect All</a>
1.208 www 1085: </td>
1086: ');
1087: $r->print('</tr></table>');
1088: }
1089:
1.209 www 1090: sub partmenu {
1091: my ($r,$allparts,$psprt)=@_;
1.211 www 1092: $r->print('<select multiple name="psprt" size="8">');
1.208 www 1093: $r->print('<option value="all"');
1094: $r->print(' selected') unless (@{$psprt});
1095: $r->print('>'.&mt('All Parts').'</option>');
1096: my %temphash=();
1097: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1098: foreach my $tempkey (sort {
1099: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1100: } keys(%{$allparts})) {
1.208 www 1101: unless ($tempkey =~ /\./) {
1102: $r->print('<option value="'.$tempkey.'"');
1103: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1104: $r->print(' selected');
1105: }
1106: $r->print('>'.$$allparts{$tempkey}.'</option>');
1107: }
1108: }
1.209 www 1109: $r->print('</select>');
1110: }
1111:
1112: sub usermenu {
1.275 raeburn 1113: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1114: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1115: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1116: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1117: my %lt=&Apache::lonlocal::texthash(
1.269 raeburn 1118: 'se' => "Section",
1119: 'gr' => "Group",
1.209 www 1120: 'fu' => "For User",
1121: 'oi' => "or ID",
1122: 'ad' => "at Domain"
1123: );
1124: my $sections='';
1.300 albertel 1125: my %sectionhash = &Apache::loncommon::get_sections();
1126:
1.269 raeburn 1127: my $groups;
1.299 albertel 1128: my %grouphash = &Apache::loncommon::coursegroups();
1129:
1.300 albertel 1130: if (%sectionhash) {
1.269 raeburn 1131: $sections=$lt{'se'}.': <select name="csec"';
1.299 albertel 1132: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 1133: $sections .= qq| onchange="group_or_section('csec')" |;
1134: }
1135: $sections .= '>';
1.275 raeburn 1136: foreach my $section ('',sort keys %sectionhash) {
1137: $sections.='<option value="'.$section.'" '.
1138: ($section eq $csec?'selected="selected"':'').'>'.$section.
1139: '</option>';
1.209 www 1140: }
1141: $sections.='</select>';
1.269 raeburn 1142: }
1.300 albertel 1143: if (%sectionhash && %grouphash && $parmlev ne 'full') {
1.269 raeburn 1144: $sections .= ' or ';
1145: $sections .= qq|
1146: <script type="text/javascript">
1147: function group_or_section(caller) {
1148: if (caller == "cgroup") {
1149: if (document.parmform.cgroup.selectedIndex != 0) {
1150: document.parmform.csec.selectedIndex = 0;
1151: }
1152: } else {
1153: if (document.parmform.csec.selectedIndex != 0) {
1154: document.parmform.cgroup.selectedIndex = 0;
1155: }
1156: }
1157: }
1158: </script>
1159: |;
1160: } else {
1161: $sections .= qq|
1162: <script type="text/javascript">
1163: function group_or_section(caller) {
1164: return;
1165: }
1166: </script>
1167: |;
1168: }
1.299 albertel 1169:
1170: if (%grouphash) {
1.269 raeburn 1171: $groups=$lt{'gr'}.': <select name="cgroup"';
1.300 albertel 1172: if (%sectionhash && $env{'form.action'} eq 'settable') {
1.269 raeburn 1173: $groups .= qq| onchange="group_or_section('cgroup')" |;
1174: }
1175: $groups .= '>';
1.275 raeburn 1176: foreach my $grp ('',sort keys %grouphash) {
1177: $groups.='<option value="'.$grp.'" ';
1178: if ($grp eq $cgroup) {
1179: unless ((defined($uname)) && ($grp eq '')) {
1180: $groups .= 'selected="selected" ';
1181: }
1182: } elsif (!defined($cgroup)) {
1183: if (@{$usersgroups} == 1) {
1184: if ($grp eq $$usersgroups[0]) {
1185: $groups .= 'selected="selected" ';
1186: }
1187: }
1188: }
1189: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1190: }
1191: $groups.='</select>';
1192: }
1193: $r->print(<<ENDMENU);
1.209 www 1194: <b>
1195: $sections
1.269 raeburn 1196: $groups
1.209 www 1197: <br />
1198: $lt{'fu'}
1199: <input type="text" value="$uname" size="12" name="uname" />
1200: $lt{'oi'}
1201: <input type="text" value="$id" size="12" name="id" />
1202: $lt{'ad'}
1203: $chooseopt
1204: </b>
1205: ENDMENU
1206: }
1207:
1208: sub displaymenu {
1.211 www 1209: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1210: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1211: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1212: &parmmenu($r,$allparms,$pscat,$keyorder);
1.209 www 1213: $r->print('</td><td>');
1214: &partmenu($r,$allparts,$psprt);
1215: $r->print('</td></tr></table>');
1216: }
1217:
1218: sub mapmenu {
1219: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1220: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1221: $r->print('<select name="pschp">');
1222: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1223: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1224: $r->print('<option value="'.$_.'"');
1.209 www 1225: if (($pschp eq $_)) { $r->print(' selected'); }
1226: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1227: }
1228: $r->print("</select>");
1229: }
1230:
1231: sub levelmenu {
1232: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1233: $r->print('<b>'.&mt('Select Parameter Level').
1234: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1235: $r->print('<select name="parmlev">');
1236: foreach (reverse sort keys %{$alllevs}) {
1237: $r->print('<option value="'.$$alllevs{$_}.'"');
1238: if ($parmlev eq $$alllevs{$_}) {
1239: $r->print(' selected');
1240: }
1241: $r->print('>'.$_.'</option>');
1.208 www 1242: }
1.209 www 1243: $r->print("</select>");
1.208 www 1244: }
1245:
1.211 www 1246:
1247: sub sectionmenu {
1248: my ($r,$selectedsections)=@_;
1.300 albertel 1249: my %sectionhash = &Apache::loncommon::get_sections();
1250: return if (!%sectionhash);
1251:
1252: $r->print('<select name="Section" multiple="true" size="8" >');
1253: foreach my $s ('all',sort keys %sectionhash) {
1254: $r->print(' <option value="'.$s.'"');
1255: foreach (@{$selectedsections}) {
1256: if ($s eq $_) {
1257: $r->print(' selected');
1258: last;
1.212 www 1259: }
1260: }
1.300 albertel 1261: $r->print('>'.$s."</option>\n");
1262: }
1263: $r->print("</select>\n");
1.269 raeburn 1264: }
1265:
1266: sub groupmenu {
1267: my ($r,$selectedgroups)=@_;
1.299 albertel 1268: my %grouphash = &Apache::loncommon::coursegroups();
1269: return if (!%grouphash);
1270:
1271: $r->print('<select name="Group" multiple="true" size="8" >');
1272: foreach my $group (sort(keys(%grouphash))) {
1273: $r->print(' <option value="'.$group.'"');
1274: foreach (@{$selectedgroups}) {
1275: if ($group eq $_) {
1276: $r->print(' selected');
1277: last;
1278: }
1279: }
1280: $r->print('>'.$group."</option>\n");
1.211 www 1281: }
1.299 albertel 1282: $r->print("</select>\n");
1.211 www 1283: }
1284:
1.269 raeburn 1285:
1.210 www 1286: sub keysplit {
1287: my $keyp=shift;
1288: return (split(/\,/,$keyp));
1289: }
1290:
1291: sub keysinorder {
1292: my ($name,$keyorder)=@_;
1293: return sort {
1294: $$keyorder{$a} <=> $$keyorder{$b};
1295: } (keys %{$name});
1296: }
1297:
1.236 albertel 1298: sub keysinorder_bytype {
1299: my ($name,$keyorder)=@_;
1300: return sort {
1301: my $ta=(split('_',$a))[-1];
1302: my $tb=(split('_',$b))[-1];
1303: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1304: return ($a cmp $b);
1305: }
1306: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1307: } (keys %{$name});
1308: }
1309:
1.211 www 1310: sub keysindisplayorder {
1311: my ($name,$keyorder)=@_;
1312: return sort {
1313: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1314: } (keys %{$name});
1315: }
1316:
1.214 www 1317: sub sortmenu {
1318: my ($r,$sortorder)=@_;
1.236 albertel 1319: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1320: if ($sortorder eq 'realmstudent') {
1321: $r->print(' checked="on"');
1322: }
1323: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1324: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1325: if ($sortorder eq 'studentrealm') {
1326: $r->print(' checked="on"');
1327: }
1.236 albertel 1328: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1329: '</label>');
1.214 www 1330: }
1331:
1.211 www 1332: sub standardkeyorder {
1333: return ('parameter_0_opendate' => 1,
1334: 'parameter_0_duedate' => 2,
1335: 'parameter_0_answerdate' => 3,
1336: 'parameter_0_interval' => 4,
1337: 'parameter_0_weight' => 5,
1338: 'parameter_0_maxtries' => 6,
1339: 'parameter_0_hinttries' => 7,
1340: 'parameter_0_contentopen' => 8,
1341: 'parameter_0_contentclose' => 9,
1342: 'parameter_0_type' => 10,
1343: 'parameter_0_problemstatus' => 11,
1344: 'parameter_0_hiddenresource' => 12,
1345: 'parameter_0_hiddenparts' => 13,
1346: 'parameter_0_display' => 14,
1347: 'parameter_0_ordered' => 15,
1348: 'parameter_0_tol' => 16,
1349: 'parameter_0_sig' => 17,
1.218 www 1350: 'parameter_0_turnoffunit' => 18,
1351: 'parameter_0_discussend' => 19,
1352: 'parameter_0_discusshide' => 20);
1.211 www 1353: }
1354:
1.59 matthew 1355: ##################################################
1356: ##################################################
1357:
1358: =pod
1359:
1360: =item assessparms
1361:
1362: Show assessment data and parameters. This is a large routine that should
1363: be simplified and shortened... someday.
1364:
1365: Inputs: $r
1366:
1367: Returns: nothing
1368:
1.63 bowersj2 1369: Variables used (guessed by Jeremy):
1370:
1371: =over 4
1372:
1373: =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.
1374:
1375: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
1376:
1377: =item B<allmaps>:
1378:
1379: =back
1380:
1.59 matthew 1381: =cut
1382:
1383: ##################################################
1384: ##################################################
1.30 www 1385: sub assessparms {
1.1 www 1386:
1.43 albertel 1387: my $r=shift;
1.201 www 1388:
1389: my @ids=();
1390: my %symbp=();
1391: my %mapp=();
1392: my %typep=();
1393: my %keyp=();
1394: my %uris=();
1395: my %maptitles=();
1396:
1.2 www 1397: # -------------------------------------------------------- Variable declaration
1.209 www 1398:
1.129 www 1399: my %allmaps=();
1400: my %alllevs=();
1.57 albertel 1401:
1.187 www 1402: my $uname;
1403: my $udom;
1404: my $uhome;
1405: my $csec;
1.269 raeburn 1406: my $cgroup;
1.275 raeburn 1407: my @usersgroups = ();
1.187 www 1408:
1.190 albertel 1409: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1410:
1.57 albertel 1411: $alllevs{'Resource Level'}='full';
1.215 www 1412: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1413: $alllevs{'Course Level'}='general';
1414:
1415: my %allparms;
1416: my %allparts;
1.210 www 1417: #
1418: # Order in which these parameters will be displayed
1419: #
1.211 www 1420: my %keyorder=&standardkeyorder();
1421:
1.43 albertel 1422: @ids=();
1423: %symbp=();
1424: %typep=();
1425:
1426: my $message='';
1427:
1.190 albertel 1428: $csec=$env{'form.csec'};
1.269 raeburn 1429: $cgroup=$env{'form.cgroup'};
1.188 www 1430:
1.190 albertel 1431: if ($udom=$env{'form.udom'}) {
1432: } elsif ($udom=$env{'request.role.domain'}) {
1433: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1434: } else {
1435: $udom=$r->dir_config('lonDefDomain');
1436: }
1.43 albertel 1437:
1.134 albertel 1438: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1439: my $pschp=$env{'form.pschp'};
1.134 albertel 1440: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1441: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1442:
1.43 albertel 1443: my $pssymb='';
1.57 albertel 1444: my $parmlev='';
1445:
1.190 albertel 1446: unless ($env{'form.parmlev'}) {
1.57 albertel 1447: $parmlev = 'map';
1448: } else {
1.190 albertel 1449: $parmlev = $env{'form.parmlev'};
1.57 albertel 1450: }
1.26 www 1451:
1.29 www 1452: # ----------------------------------------------- Was this started from grades?
1453:
1.190 albertel 1454: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1455: && (!$env{'form.dis'})) {
1456: my $url=$env{'form.url'};
1.194 albertel 1457: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1458: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1459: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1460: $pschp='';
1.57 albertel 1461: $parmlev = 'full';
1.190 albertel 1462: } elsif ($env{'form.symb'}) {
1463: $pssymb=$env{'form.symb'};
1.92 albertel 1464: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1465: $pschp='';
1.57 albertel 1466: $parmlev = 'full';
1.43 albertel 1467: } else {
1.190 albertel 1468: $env{'form.url'}='';
1.43 albertel 1469: }
1470:
1.190 albertel 1471: my $id=$env{'form.id'};
1.43 albertel 1472: if (($id) && ($udom)) {
1473: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1474: if ($uname) {
1475: $id='';
1476: } else {
1477: $message=
1.133 www 1478: "<font color=red>".&mt("Unknown ID")." '$id' ".
1479: &mt('at domain')." '$udom'</font>";
1.43 albertel 1480: }
1481: } else {
1.190 albertel 1482: $uname=$env{'form.uname'};
1.43 albertel 1483: }
1484: unless ($udom) { $uname=''; }
1485: $uhome='';
1486: if ($uname) {
1487: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1488: if ($uhome eq 'no_host') {
1489: $message=
1.133 www 1490: "<font color=red>".&mt("Unknown user")." '$uname' ".
1491: &mt("at domain")." '$udom'</font>";
1.43 albertel 1492: $uname='';
1.12 www 1493: } else {
1.103 albertel 1494: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1495: $env{'request.course.id'});
1.269 raeburn 1496:
1.43 albertel 1497: if ($csec eq '-1') {
1498: $message="<font color=red>".
1.133 www 1499: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1500: &mt("not in this course")."</font>";
1.43 albertel 1501: $uname='';
1.190 albertel 1502: $csec=$env{'form.csec'};
1.269 raeburn 1503: $cgroup=$env{'form.cgroup'};
1.43 albertel 1504: } else {
1505: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1506: ('firstname','middlename','lastname','generation','id'));
1.133 www 1507: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1508: $name{'firstname'}.' '.$name{'middlename'}.' '
1509: .$name{'lastname'}.' '.$name{'generation'}.
1.133 www 1510: "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1511: }
1.297 raeburn 1512: @usersgroups = &Apache::lonnet::get_users_groups(
1.275 raeburn 1513: $udom,$uname,$env{'request.course.id'});
1.297 raeburn 1514: if (@usersgroups > 0) {
1.306 ! albertel 1515: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
1.275 raeburn 1516: $cgroup = $usersgroups[0];
1.297 raeburn 1517: }
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.306 ! albertel 1933: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</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.280 albertel 1950: $r->print('</form>'.&Apache::loncommon::end_page());
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.280 albertel 1975:
1.298 albertel 1976: my $breadcrumbs =
1977: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
1.190 albertel 1978: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1979: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 1980:
1981: #
1982: # Go through list of changes
1.190 albertel 1983: foreach (keys %env) {
1.105 matthew 1984: next if ($_!~/^form\.(.+)\_setparmval$/);
1985: my $name = $1;
1.190 albertel 1986: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 1987: if ($name eq 'newp') {
1.190 albertel 1988: $name = $env{'form.newp_name'};
1.105 matthew 1989: }
1990: if ($name eq 'url') {
1991: $value=~s/^\/res\///;
1992: my $bkuptime=time;
1993: my @tmp = &Apache::lonnet::get
1994: ('environment',['url'],$dom,$crs);
1.130 www 1995: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 1996: &Apache::lonnet::put
1997: ('environment',
1998: {'top level map backup '.$bkuptime => $tmp[1] },
1999: $dom,$crs).
2000: '<br>';
2001: }
2002: #
2003: # Deal with modified default spreadsheets
2004: if ($name =~ /^spreadsheet_default_(classcalc|
2005: studentcalc|
2006: assesscalc)$/x) {
2007: my $sheettype = $1;
2008: if ($sheettype eq 'classcalc') {
2009: # no need to do anything since viewing the sheet will
2010: # cause it to be updated.
2011: } elsif ($sheettype eq 'studentcalc') {
2012: # expire all the student spreadsheets
2013: &Apache::lonnet::expirespread('','','studentcalc');
2014: } else {
2015: # expire all the assessment spreadsheets
2016: # this includes non-default spreadsheets, but better to
2017: # be safe than sorry.
2018: &Apache::lonnet::expirespread('','','assesscalc');
2019: # expire all the student spreadsheets
2020: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2021: }
1.105 matthew 2022: }
2023: #
1.107 matthew 2024: # Deal with the enrollment dates
2025: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2026: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2027: }
1.178 raeburn 2028: # Get existing cloners
2029: my @oldcloner = ();
2030: if ($name eq 'cloners') {
2031: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2032: if ($clonenames{'cloners'} =~ /,/) {
2033: @oldcloner = split/,/,$clonenames{'cloners'};
2034: } else {
2035: $oldcloner[0] = $clonenames{'cloners'};
2036: }
2037: }
1.107 matthew 2038: #
1.105 matthew 2039: # Let the user know we made the changes
1.153 albertel 2040: if ($name && defined($value)) {
1.239 raeburn 2041: my $failed_cloners;
1.178 raeburn 2042: if ($name eq 'cloners') {
1.239 raeburn 2043: $value =~ s/\s//g;
1.178 raeburn 2044: $value =~ s/^,//;
2045: $value =~ s/,$//;
1.239 raeburn 2046: # check requested clones are valid users.
2047: $failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2048: }
1.105 matthew 2049: my $put_result = &Apache::lonnet::put('environment',
2050: {$name=>$value},$dom,$crs);
2051: if ($put_result eq 'ok') {
1.130 www 2052: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
1.178 raeburn 2053: if ($name eq 'cloners') {
2054: &change_clone($value,\@oldcloner);
2055: }
1.179 raeburn 2056: # Flush the course logs so course description is immediately updated
2057: if ($name eq 'description' && defined($value)) {
2058: &Apache::lonnet::flushcourselogs();
2059: }
1.105 matthew 2060: } else {
1.130 www 2061: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2062: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2063: }
1.239 raeburn 2064: if (($name eq 'cloners') && ($failed_cloners)) {
2065: $setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '.
2066: &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
2067: '.<br />'.&mt('Please ').
2068: ' <a href="/adm/createuser">'.
2069: &mt('add the user(s)').'</a>, '.
2070: &mt('and then return to the ').
2071: '<a href="/admparmset?action=crsenv">'.
2072: &mt('Course Parameters page').'</a> '.
2073: &mt('to add the new user(s) to the list of possible cloners').
2074: '.<br />';
2075: }
1.30 www 2076: }
1.38 harris41 2077: }
1.108 www 2078: # ------------------------- Re-init course environment entries for this session
2079:
1.302 albertel 2080: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2081: {'freshen_cache' => 1});
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.278 www 2200: 'externalsyllabus'
1.279 www 2201: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2202: 'tthoptions'
2203: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
1.107 matthew 2204: );
1.177 raeburn 2205: my @Display_Order = ('url','description','courseid','cloners','grading',
1.278 www 2206: 'externalsyllabus',
1.107 matthew 2207: 'default_xml_style','pageseparators',
2208: 'question.email','comment.email','policy.email',
1.169 matthew 2209: 'student_classlist_view',
1.118 matthew 2210: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2211: 'pch.roles.denied','pch.users.denied',
2212: 'allow_limited_html_in_feedback',
1.170 raeburn 2213: 'allow_discussion_post_editing',
1.108 www 2214: 'languages',
1.150 www 2215: 'nothideprivileged',
1.107 matthew 2216: 'rndseed',
1.151 albertel 2217: 'receiptalg',
1.107 matthew 2218: 'problem_stream_switch',
1.164 sakharuk 2219: 'suppress_tries',
1.161 sakharuk 2220: 'default_paper_size',
1.115 www 2221: 'disable_receipt_display',
1.107 matthew 2222: 'spreadsheet_default_classcalc',
2223: 'spreadsheet_default_studentcalc',
2224: 'spreadsheet_default_assesscalc',
2225: 'hideemptyrows',
2226: 'default_enrollment_start_date',
2227: 'default_enrollment_end_date',
1.163 albertel 2228: 'tthoptions',
1.251 albertel 2229: 'disablesigfigs',
2230: 'disableexampointprint'
1.107 matthew 2231: );
2232: foreach my $parameter (sort(keys(%values))) {
1.244 banghart 2233: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
1.142 raeburn 2234: if (! $descriptions{$parameter}) {
2235: $descriptions{$parameter}=$parameter;
2236: push(@Display_Order,$parameter);
2237: }
2238: }
1.43 albertel 2239: }
1.107 matthew 2240: foreach my $parameter (@Display_Order) {
2241: my $description = $descriptions{$parameter};
1.51 matthew 2242: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2243: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2244: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2245: '.checked=true;"';
1.107 matthew 2246: $output .= '<tr><td>'.$description.'</td>';
2247: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2248: $output .= '<td>'.
2249: &Apache::lonhtmlcommon::date_setter('envform',
2250: $parameter.'_value',
2251: $values{$parameter},
2252: $onchange).
2253: '</td>';
2254: } else {
2255: $output .= '<td>'.
2256: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2257: $values{$parameter},
2258: 40,$onchange).'</td>';
2259: }
2260: $output .= '<td>'.
2261: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2262: '</td>';
2263: $output .= "</tr>\n";
1.51 matthew 2264: }
1.69 www 2265: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2266: '[\'envform\'].elements[\'newp_setparmval\']'.
2267: '.checked=true;"';
1.130 www 2268: $output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2269: '<input type="text" size=40 name="newp_name" '.
2270: $onchange.' /></td><td>'.
2271: '<input type="text" size=40 name="newp_value" '.
2272: $onchange.' /></td><td>'.
2273: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 2274: }
1.157 sakharuk 2275: my %lt=&Apache::lonlocal::texthash(
2276: 'par' => 'Parameter',
2277: 'val' => 'Value',
2278: 'set' => 'Set',
2279: 'sce' => 'Set Course Environment'
2280: );
2281:
1.140 sakharuk 2282: my $Parameter=&mt('Parameter');
2283: my $Value=&mt('Value');
1.141 sakharuk 2284: my $Set=&mt('Set');
1.280 albertel 2285: my $browse_js=
2286: '<script type="text/javascript" language="Javascript">'.
2287: &Apache::loncommon::browser_and_searcher_javascript('parmset').
2288: '</script>';
2289:
2290: my $start_page =
2291: &Apache::loncommon::start_page('Set Course Environment Parameters',
2292: $browse_js);
2293: my $end_page =
2294: &Apache::loncommon::end_page();
2295: $r->print(<<ENDENV);
2296: $start_page
1.193 albertel 2297: $breadcrumbs
2298: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2299: $setoutput
2300: <p>
2301: <table border=2>
1.157 sakharuk 2302: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
1.30 www 2303: $output
2304: </table>
1.157 sakharuk 2305: <input type="submit" name="crsenv" value="$lt{'sce'}">
1.30 www 2306: </form>
1.280 albertel 2307: $end_page
2308: ENDENV
1.30 www 2309: }
1.120 www 2310: ##################################################
1.207 www 2311: # Overview mode
2312: ##################################################
1.124 www 2313: my $tableopen;
2314:
2315: sub tablestart {
2316: if ($tableopen) {
2317: return '';
2318: } else {
2319: $tableopen=1;
1.295 albertel 2320: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 2321: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2322: }
2323: }
2324:
2325: sub tableend {
2326: if ($tableopen) {
2327: $tableopen=0;
1.295 albertel 2328: return &Apache::loncommon::end_data_table();
1.124 www 2329: } else {
2330: return'';
2331: }
2332: }
2333:
1.207 www 2334: sub readdata {
2335: my ($crs,$dom)=@_;
2336: # Read coursedata
2337: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2338: # Read userdata
2339:
2340: my $classlist=&Apache::loncoursedata::get_classlist();
2341: foreach (keys %$classlist) {
2342: # the following undefs are for 'domain', and 'username' respectively.
2343: if ($_=~/^(\w+)\:(\w+)$/) {
2344: my ($tuname,$tudom)=($1,$2);
2345: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2346: foreach my $userkey (keys %{$useropt}) {
2347: if ($userkey=~/^$env{'request.course.id'}/) {
2348: my $newkey=$userkey;
2349: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2350: $$resourcedata{$newkey}=$$useropt{$userkey};
2351: }
2352: }
2353: }
2354: }
2355: return $resourcedata;
2356: }
2357:
2358:
1.124 www 2359: # Setting
1.208 www 2360:
2361: sub storedata {
2362: my ($r,$crs,$dom)=@_;
1.207 www 2363: # Set userlevel immediately
2364: # Do an intermediate store of course level
2365: my $olddata=&readdata($crs,$dom);
1.124 www 2366: my %newdata=();
2367: undef %newdata;
2368: my @deldata=();
2369: undef @deldata;
1.190 albertel 2370: foreach (keys %env) {
1.124 www 2371: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2372: my $cmd=$1;
2373: my $thiskey=$2;
1.207 www 2374: my ($tuname,$tudom)=&extractuser($thiskey);
2375: my $tkey=$thiskey;
2376: if ($tuname) {
2377: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2378: }
1.124 www 2379: if ($cmd eq 'set') {
1.190 albertel 2380: my $data=$env{$_};
1.212 www 2381: my $typeof=$env{'form.typeof_'.$thiskey};
2382: if ($$olddata{$thiskey} ne $data) {
1.207 www 2383: if ($tuname) {
1.212 www 2384: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2385: $tkey.'.type' => $typeof},
2386: $tudom,$tuname) eq 'ok') {
1.290 www 2387: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.207 www 2388: $r->print('<br />'.&mt('Stored modified parameter for').' '.
2389: &Apache::loncommon::plainname($tuname,$tudom));
2390: } else {
2391: $r->print('<h2><font color="red">'.
2392: &mt('Error storing parameters').'</font></h2>');
2393: }
2394: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2395: } else {
2396: $newdata{$thiskey}=$data;
1.212 www 2397: $newdata{$thiskey.'.type'}=$typeof;
2398: }
1.207 www 2399: }
1.124 www 2400: } elsif ($cmd eq 'del') {
1.207 www 2401: if ($tuname) {
2402: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 2403: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 2404: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2405: } else {
2406: $r->print('<h2><font color="red">'.
2407: &mt('Error deleting parameters').'</font></h2>');
2408: }
2409: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2410: } else {
2411: push (@deldata,$thiskey);
2412: }
1.124 www 2413: } elsif ($cmd eq 'datepointer') {
1.190 albertel 2414: my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
1.212 www 2415: my $typeof=$env{'form.typeof_'.$thiskey};
1.207 www 2416: if (defined($data) and $$olddata{$thiskey} ne $data) {
2417: if ($tuname) {
1.212 www 2418: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2419: $tkey.'.type' => $typeof},
2420: $tudom,$tuname) eq 'ok') {
1.290 www 2421: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.207 www 2422: $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2423: } else {
2424: $r->print('<h2><font color="red">'.
2425: &mt('Error storing parameters').'</font></h2>');
2426: }
2427: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2428: } else {
1.212 www 2429: $newdata{$thiskey}=$data;
2430: $newdata{$thiskey.'.type'}=$typeof;
1.207 www 2431: }
2432: }
1.124 www 2433: }
2434: }
2435: }
1.207 www 2436: # Store all course level
1.144 www 2437: my $delentries=$#deldata+1;
2438: my @newdatakeys=keys %newdata;
2439: my $putentries=$#newdatakeys+1;
2440: if ($delentries) {
2441: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 2442: my %loghash=map { $_ => '' } @deldata;
2443: &log_parmset(\%loghash,1);
1.144 www 2444: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2445: } else {
2446: $r->print('<h2><font color="red">'.
2447: &mt('Error deleting parameters').'</font></h2>');
2448: }
1.205 www 2449: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2450: }
2451: if ($putentries) {
2452: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 2453: &log_parmset(\%newdata,0);
1.212 www 2454: $r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2455: } else {
2456: $r->print('<h2><font color="red">'.
2457: &mt('Error storing parameters').'</font></h2>');
2458: }
1.205 www 2459: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2460: }
1.208 www 2461: }
1.207 www 2462:
1.208 www 2463: sub extractuser {
2464: my $key=shift;
2465: return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
2466: }
1.206 www 2467:
1.208 www 2468: sub listdata {
1.214 www 2469: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2470: # Start list output
1.206 www 2471:
1.122 www 2472: my $oldsection='';
2473: my $oldrealm='';
2474: my $oldpart='';
1.123 www 2475: my $pointer=0;
1.124 www 2476: $tableopen=0;
1.145 www 2477: my $foundkeys=0;
1.248 albertel 2478: my %keyorder=&standardkeyorder();
1.214 www 2479: foreach my $thiskey (sort {
2480: if ($sortorder eq 'realmstudent') {
1.247 albertel 2481: my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2482: my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
2483: if (!defined($astudent)) {
2484: ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
1.237 albertel 2485: }
1.247 albertel 2486: if (!defined($bstudent)) {
2487: ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2488: }
1.248 albertel 2489: $arealm=~s/\.type//;
2490: my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
2491: $aparm=$keyorder{'parameter_0_'.$aparm};
2492: $brealm=~s/\.type//;
2493: my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
2494: $bparm=$keyorder{'parameter_0_'.$bparm};
2495: if ($ares eq $bres) {
2496: if (defined($aparm) && defined($bparm)) {
2497: ($aparm <=> $bparm);
2498: } elsif (defined($aparm)) {
2499: -1;
2500: } elsif (defined($bparm)) {
2501: 1;
2502: } else {
2503: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2504: }
2505: } else {
2506: ($arealm cmp $brealm) || ($astudent cmp $bstudent);
2507: }
1.214 www 2508: } else {
2509: $a cmp $b;
2510: }
2511: } keys %{$listdata}) {
1.247 albertel 2512:
1.211 www 2513: if ($$listdata{$thiskey.'.type'}) {
2514: my $thistype=$$listdata{$thiskey.'.type'};
2515: if ($$resourcedata{$thiskey.'.type'}) {
2516: $thistype=$$resourcedata{$thiskey.'.type'};
2517: }
1.207 www 2518: my ($middle,$part,$name)=
2519: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2520: my $section=&mt('All Students');
1.207 www 2521: if ($middle=~/^\[(.*)\]/) {
1.206 www 2522: my $issection=$1;
2523: if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
2524: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
2525: } else {
2526: $section=&mt('Group/Section').': '.$issection;
2527: }
1.207 www 2528: $middle=~s/^\[(.*)\]//;
1.122 www 2529: }
1.207 www 2530: $middle=~s/\.+$//;
2531: $middle=~s/^\.+//;
1.130 www 2532: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.122 www 2533: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.174 albertel 2534: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.122 www 2535: } elsif ($middle) {
1.174 albertel 2536: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
2537: $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 2538: }
1.214 www 2539: if ($sortorder eq 'realmstudent') {
2540: if ($realm ne $oldrealm) {
2541: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
2542: $oldrealm=$realm;
2543: $oldsection='';
2544: }
2545: if ($section ne $oldsection) {
2546: $r->print(&tableend()."\n<h2>$section</h2>");
2547: $oldsection=$section;
2548: $oldpart='';
2549: }
2550: } else {
2551: if ($section ne $oldsection) {
2552: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
2553: $oldsection=$section;
2554: $oldrealm='';
2555: }
2556: if ($realm ne $oldrealm) {
2557: $r->print(&tableend()."\n<h2>$realm</h2>");
2558: $oldrealm=$realm;
2559: $oldpart='';
2560: }
1.122 www 2561: }
2562: if ($part ne $oldpart) {
1.124 www 2563: $r->print(&tableend().
1.214 www 2564: "\n<font color='blue'>".&mt('Part').": $part</font>");
1.122 www 2565: $oldpart=$part;
2566: }
1.123 www 2567: #
1.230 www 2568: # Preset defaults?
2569: #
2570: my ($hour,$min,$sec,$val)=('','','','');
2571: unless ($$resourcedata{$thiskey}) {
2572: my ($parmname)=($thiskey=~/\.(\w+)$/);
2573: ($hour,$min,$sec,$val)=&preset_defaults($parmname);
2574: }
2575:
2576: #
1.123 www 2577: # Ready to print
2578: #
1.295 albertel 2579: $r->print(&tablestart().
2580: &Apache::loncommon::start_data_table_row().
2581: '<td><b>'.&standard_parameter_names($name).
1.293 www 2582: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 2583: $thiskey.'" /></td><td>');
1.145 www 2584: $foundkeys++;
1.213 www 2585: if (&isdateparm($thistype)) {
1.123 www 2586: my $jskey='key_'.$pointer;
2587: $pointer++;
2588: $r->print(
1.232 albertel 2589: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 2590: $jskey,
1.219 www 2591: $$resourcedata{$thiskey},
1.230 www 2592: '',1,'','',$hour,$min,$sec).
1.277 www 2593: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
2594: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 2595: );
1.219 www 2596: } elsif ($thistype eq 'string_yesno') {
1.230 www 2597: my $showval;
2598: if (defined($$resourcedata{$thiskey})) {
2599: $showval=$$resourcedata{$thiskey};
2600: } else {
2601: $showval=$val;
2602: }
1.219 www 2603: $r->print('<label><input type="radio" name="set_'.$thiskey.
2604: '" value="yes"');
1.230 www 2605: if ($showval eq 'yes') {
1.219 www 2606: $r->print(' checked="checked"');
2607: }
2608: $r->print(' />'.&mt('Yes').'</label> ');
2609: $r->print('<label><input type="radio" name="set_'.$thiskey.
2610: '" value="no"');
1.230 www 2611: if ($showval eq 'no') {
1.219 www 2612: $r->print(' checked="checked"');
2613: }
2614: $r->print(' />'.&mt('No').'</label>');
1.123 www 2615: } else {
1.230 www 2616: my $showval;
2617: if (defined($$resourcedata{$thiskey})) {
2618: $showval=$$resourcedata{$thiskey};
2619: } else {
2620: $showval=$val;
2621: }
1.211 www 2622: $r->print('<input type="text" name="set_'.$thiskey.'" value="'.
1.230 www 2623: $showval.'">');
1.123 www 2624: }
1.211 www 2625: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
2626: $thistype.'">');
1.295 albertel 2627: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 2628: }
1.121 www 2629: }
1.208 www 2630: return $foundkeys;
2631: }
2632:
2633: sub newoverview {
1.280 albertel 2634: my ($r) = @_;
2635:
1.208 www 2636: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2637: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 2638: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 2639: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 2640: $r->print(<<ENDOVER);
1.280 albertel 2641: $start_page
1.208 www 2642: $breadcrumbs
1.232 albertel 2643: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 2644: ENDOVER
1.211 www 2645: my @ids=();
2646: my %typep=();
2647: my %keyp=();
2648: my %allparms=();
2649: my %allparts=();
2650: my %allmaps=();
2651: my %mapp=();
2652: my %symbp=();
2653: my %maptitles=();
2654: my %uris=();
2655: my %keyorder=&standardkeyorder();
2656: my %defkeytype=();
2657:
2658: my %alllevs=();
2659: $alllevs{'Resource Level'}='full';
1.215 www 2660: $alllevs{'Map/Folder Level'}='map';
1.211 www 2661: $alllevs{'Course Level'}='general';
2662:
2663: my $csec=$env{'form.csec'};
1.269 raeburn 2664: my $cgroup=$env{'form.cgroup'};
1.211 www 2665:
2666: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
2667: my $pschp=$env{'form.pschp'};
2668: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
2669: if (!@psprt) { $psprt[0]='0'; }
2670:
2671: my @selected_sections =
2672: &Apache::loncommon::get_env_multiple('form.Section');
2673: @selected_sections = ('all') if (! @selected_sections);
2674: foreach (@selected_sections) {
2675: if ($_ eq 'all') {
2676: @selected_sections = ('all');
2677: }
2678: }
1.269 raeburn 2679: my @selected_groups =
2680: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 2681:
2682: my $pssymb='';
2683: my $parmlev='';
2684:
2685: unless ($env{'form.parmlev'}) {
2686: $parmlev = 'map';
2687: } else {
2688: $parmlev = $env{'form.parmlev'};
2689: }
2690:
2691: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
2692: \%mapp, \%symbp,\%maptitles,\%uris,
2693: \%keyorder,\%defkeytype);
2694:
2695: # Menu to select levels, etc
2696:
2697: $r->print('<table border="1"><tr><td>');
2698: &levelmenu($r,\%alllevs,$parmlev);
2699: if ($parmlev ne 'general') {
2700: $r->print('<td>');
2701: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
2702: $r->print('</td>');
2703: }
2704: $r->print('</td></tr></table>');
2705:
2706: $r->print('<table border="1"><tr><td>');
2707: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.269 raeburn 2708: $r->print('</td><td><table border="0" cellspacing="0" cellpadding="0">'.
2709: '<tr><td>'.&mt('Parts').'</td><td></td><td>'.&mt('Section(s)').
2710: '</td><td></td><td>'.&mt('Group(s)').'</td></tr><tr><td>');
1.211 www 2711: &partmenu($r,\%allparts,\@psprt);
1.269 raeburn 2712: $r->print('</td><td> </td><td>');
1.211 www 2713: §ionmenu($r,\@selected_sections);
1.269 raeburn 2714: $r->print('</td><td> </td><td>');
2715: &groupmenu($r,\@selected_groups);
2716: $r->print('</td></tr></table>');
1.214 www 2717: $r->print('</td></tr></table>');
2718:
2719: my $sortorder=$env{'form.sortorder'};
2720: unless ($sortorder) { $sortorder='realmstudent'; }
2721: &sortmenu($r,$sortorder);
2722:
2723: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 2724:
2725: # Build the list data hash from the specified parms
2726:
2727: my $listdata;
2728: %{$listdata}=();
2729:
2730: foreach my $cat (@pscat) {
1.269 raeburn 2731: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
2732: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 2733: }
2734:
1.212 www 2735: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 2736:
1.212 www 2737: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 2738:
2739: # Read modified data
2740:
2741: my $resourcedata=&readdata($crs,$dom);
2742:
2743: # List data
2744:
1.214 www 2745: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 2746: }
2747: $r->print(&tableend().
1.212 www 2748: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':'').
1.280 albertel 2749: '</form>'.&Apache::loncommon::end_page());
1.208 www 2750: }
2751:
1.269 raeburn 2752: sub secgroup_lister {
2753: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
2754: foreach my $item (@{$selections}) {
2755: foreach my $part (@{$psprt}) {
2756: my $rootparmkey=$env{'request.course.id'};
2757: if (($item ne 'all') && ($item ne 'none') && ($item)) {
2758: $rootparmkey.='.['.$item.']';
2759: }
2760: if ($parmlev eq 'general') {
2761: # course-level parameter
2762: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
2763: $$listdata{$newparmkey}=1;
2764: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2765: } elsif ($parmlev eq 'map') {
2766: # map-level parameter
2767: foreach my $mapid (keys %{$allmaps}) {
2768: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
2769: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
2770: $$listdata{$newparmkey}=1;
2771: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2772: }
2773: } else {
2774: # resource-level parameter
2775: foreach my $rid (@{$ids}) {
2776: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
2777: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
2778: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
2779: $$listdata{$newparmkey}=1;
2780: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
2781: }
2782: }
2783: }
2784: }
2785: }
2786:
1.208 www 2787: sub overview {
1.280 albertel 2788: my ($r) = @_;
1.208 www 2789: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2790: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 2791:
2792: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 2793: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 2794: $r->print(<<ENDOVER);
1.280 albertel 2795: $start_page
1.208 www 2796: $breadcrumbs
1.232 albertel 2797: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 2798: ENDOVER
2799: # Store modified
2800:
2801: &storedata($r,$crs,$dom);
2802:
2803: # Read modified data
2804:
2805: my $resourcedata=&readdata($crs,$dom);
2806:
1.214 www 2807:
2808: my $sortorder=$env{'form.sortorder'};
2809: unless ($sortorder) { $sortorder='realmstudent'; }
2810: &sortmenu($r,$sortorder);
2811:
1.208 www 2812: # List data
2813:
1.214 www 2814: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 2815:
1.145 www 2816: $r->print(&tableend().'<p>'.
1.280 albertel 2817: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
2818: &Apache::loncommon::end_page());
1.120 www 2819: }
1.121 www 2820:
1.59 matthew 2821: ##################################################
2822: ##################################################
1.178 raeburn 2823:
2824: =pod
1.239 raeburn 2825:
2826: =item check_cloners
2827:
2828: Checks if new users included in list of allowed cloners
2829: are valid users. Replaces supplied list with
2830: cleaned list containing only users with valid usernames
2831: and domains.
2832:
2833: Inputs: $clonelist, $oldcloner
2834: where $clonelist is ref to array of requested cloners,
2835: and $oldcloner is ref to array of currently allowed
2836: cloners.
2837:
2838: Returns: string - comma separated list of requested
2839: cloners (username:domain) who do not exist in system.
2840:
2841: =item change_clone
2842:
1.178 raeburn 2843: Modifies the list of courses a user can clone (stored
1.239 raeburn 2844: in the user's environment.db file), called when a
1.178 raeburn 2845: change is made to the list of users allowed to clone
2846: a course.
1.239 raeburn 2847:
1.178 raeburn 2848: Inputs: $action,$cloner
2849: where $action is add or drop, and $cloner is identity of
2850: user for whom cloning ability is to be changed in course.
2851:
2852: =cut
2853:
2854: ##################################################
2855: ##################################################
2856:
1.239 raeburn 2857: sub extract_cloners {
2858: my ($clonelist,$allowclone) = @_;
2859: if ($clonelist =~ /,/) {
2860: @{$allowclone} = split/,/,$clonelist;
2861: } else {
2862: $$allowclone[0] = $clonelist;
2863: }
2864: }
2865:
2866:
2867: sub check_cloners {
2868: my ($clonelist,$oldcloner) = @_;
2869: my ($clean_clonelist,$disallowed);
2870: my @allowclone = ();
2871: &extract_cloners($$clonelist,\@allowclone);
2872: foreach my $currclone (@allowclone) {
2873: if (!grep/^$currclone$/,@$oldcloner) {
2874: my ($uname,$udom) = split/:/,$currclone;
2875: if ($uname && $udom) {
2876: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2877: $disallowed .= $currclone.',';
2878: } else {
2879: $clean_clonelist .= $currclone.',';
2880: }
2881: }
2882: } else {
2883: $clean_clonelist .= $currclone.',';
2884: }
2885: }
2886: if ($disallowed) {
2887: $disallowed =~ s/,$//;
2888: }
2889: if ($clean_clonelist) {
2890: $clean_clonelist =~ s/,$//;
2891: }
2892: $$clonelist = $clean_clonelist;
2893: return $disallowed;
2894: }
1.178 raeburn 2895:
2896: sub change_clone {
2897: my ($clonelist,$oldcloner) = @_;
2898: my ($uname,$udom);
1.190 albertel 2899: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2900: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 2901: my $clone_crs = $cnum.':'.$cdom;
2902:
2903: if ($cnum && $cdom) {
1.239 raeburn 2904: my @allowclone;
2905: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 2906: foreach my $currclone (@allowclone) {
2907: if (!grep/^$currclone$/,@$oldcloner) {
2908: ($uname,$udom) = split/:/,$currclone;
2909: if ($uname && $udom) {
2910: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2911: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2912: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
2913: if ($currclonecrs{'cloneable'} eq '') {
2914: $currclonecrs{'cloneable'} = $clone_crs;
2915: } else {
2916: $currclonecrs{'cloneable'} .= ','.$clone_crs;
2917: }
2918: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
2919: }
2920: }
2921: }
2922: }
2923: }
2924: foreach my $oldclone (@$oldcloner) {
2925: if (!grep/^$oldclone$/,@allowclone) {
2926: ($uname,$udom) = split/:/,$oldclone;
2927: if ($uname && $udom) {
2928: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2929: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2930: my %newclonecrs = ();
2931: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
2932: if ($currclonecrs{'cloneable'} =~ /,/) {
2933: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
2934: foreach (@currclonecrs) {
2935: unless ($_ eq $clone_crs) {
2936: $newclonecrs{'cloneable'} .= $_.',';
2937: }
2938: }
2939: $newclonecrs{'cloneable'} =~ s/,$//;
2940: } else {
2941: $newclonecrs{'cloneable'} = '';
2942: }
2943: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
2944: }
2945: }
2946: }
2947: }
2948: }
2949: }
2950: }
2951:
1.193 albertel 2952:
2953: ##################################################
2954: ##################################################
2955:
2956: =pod
2957:
2958: =item * header
2959:
2960: Output html header for page
2961:
2962: =cut
2963:
2964: ##################################################
2965: ##################################################
2966: sub header {
1.280 albertel 2967: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 2968: }
2969: ##################################################
2970: ##################################################
2971: sub print_main_menu {
2972: my ($r,$parm_permission)=@_;
2973: #
2974: $r->print(<<ENDMAINFORMHEAD);
2975: <form method="post" enctype="multipart/form-data"
2976: action="/adm/parmset" name="studentform">
2977: ENDMAINFORMHEAD
2978: #
1.195 albertel 2979: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2980: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 2981: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
2982:
1.193 albertel 2983: my @menu =
2984: (
2985: { text => 'Set Course Environment Parameters',
1.204 www 2986: action => 'crsenv',
1.193 albertel 2987: permission => $parm_permission,
2988: },
1.255 banghart 2989: { text => 'Set Portfolio Metadata',
1.259 banghart 2990: action => 'setrestrictmeta',
1.240 banghart 2991: permission => $parm_permission,
2992: },
1.271 www 2993: { text => 'Manage Course Slots',
1.268 albertel 2994: url => '/adm/slotrequest?command=showslots',
2995: permission => $vgr,
2996: },
2997: { divider => 1,
2998: },
1.216 www 2999: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3000: url => '/adm/helper/parameter.helper',
3001: permission => $parm_permission,
3002: },
1.216 www 3003: { text => 'Modify Resource Parameters - Overview Mode',
1.193 albertel 3004: action => 'setoverview',
3005: permission => $parm_permission,
1.208 www 3006: },
1.216 www 3007: { text => 'Set Resource Parameters - Overview Mode',
1.208 www 3008: action => 'newoverview',
3009: permission => $parm_permission,
1.193 albertel 3010: },
1.216 www 3011: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3012: action => 'settable',
3013: permission => $parm_permission,
1.204 www 3014: help => 'Cascading_Parameters',
1.193 albertel 3015: },
1.220 www 3016: { text => 'Set Parameter Setting Default Actions',
3017: action => 'setdefaults',
3018: permission => $parm_permission,
1.284 www 3019: },
1.292 www 3020: { text => 'Parameter Change Log and Course Blog Posting/User Notification',
1.284 www 3021: action => 'parameterchangelog',
3022: permission => $parm_permission,
1.220 www 3023: },
1.193 albertel 3024: );
3025: my $menu_html = '';
3026: foreach my $menu_item (@menu) {
1.268 albertel 3027: if ($menu_item->{'divider'}) {
3028: $menu_html .= '<hr />';
3029: next;
3030: }
1.193 albertel 3031: next if (! $menu_item->{'permission'});
3032: $menu_html.='<p>';
3033: $menu_html.='<font size="+1">';
3034: if (exists($menu_item->{'url'})) {
3035: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3036: } else {
3037: $menu_html.=
3038: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3039: }
3040: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
3041: if (exists($menu_item->{'help'})) {
3042: $menu_html.=
3043: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3044: }
3045: $menu_html.='</p>'.$/;
3046: }
3047: $r->print($menu_html);
3048: return;
3049: }
1.255 banghart 3050: ### Set portfolio metadata
1.252 banghart 3051: sub output_row {
1.255 banghart 3052: my ($r, $field_name, $field_text) = @_;
1.252 banghart 3053: my $output;
1.263 banghart 3054: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3055: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.254 banghart 3056: unless (defined($options)) {
3057: $options = 'active,stuadd';
1.261 banghart 3058: $values = '';
1.252 banghart 3059: }
1.260 banghart 3060: $output.='<strong>'.$field_text.':</strong>';
1.264 albertel 3061: $output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />';
3062:
3063: my @options= ( ['active', 'Show to student'],
3064: ['onlyone','Student may select only one choice'],
3065: ['stuadd', 'Student may type choices']);
3066: foreach my $opt (@options) {
3067: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
3068: $output.=(' 'x5).'<label><input type="checkbox" name="'.
3069: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3070: &mt($opt->[1]).'</label> <br />';
1.252 banghart 3071: }
3072: return ($output);
3073: }
1.259 banghart 3074:
3075: sub setrestrictmeta {
1.240 banghart 3076: my ($r)=@_;
1.242 banghart 3077: my $next_meta;
1.244 banghart 3078: my $output;
1.245 banghart 3079: my $item_num;
1.246 banghart 3080: my $put_result;
1.280 albertel 3081:
3082: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 3083: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 3084: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3085: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3086: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3087: my $save_field = '';
1.259 banghart 3088: if ($env{'form.restrictmeta'}) {
1.254 banghart 3089: foreach my $field (sort(keys(%env))) {
1.252 banghart 3090: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3091: my $options;
1.252 banghart 3092: my $meta_field = $1;
3093: my $meta_key = $2;
1.253 banghart 3094: if ($save_field ne $meta_field) {
1.252 banghart 3095: $save_field = $meta_field;
1.253 banghart 3096: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3097: $options.='stuadd,';
3098: }
1.253 banghart 3099: if ($env{'form.'.$meta_field.'_onlyone'}) {
1.254 banghart 3100: $options.='onlyone,';
3101: }
3102: if ($env{'form.'.$meta_field.'_active'}) {
3103: $options.='active,';
1.253 banghart 3104: }
1.259 banghart 3105: my $name = $save_field;
1.253 banghart 3106: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3107: {'metadata.'.$meta_field.'.options'=>$options,
3108: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 3109: },$dom,$crs);
1.252 banghart 3110: }
3111: }
3112: }
3113: }
1.296 albertel 3114: &Apache::lonnet::coursedescription($env{'request.course.id'},
3115: {'freshen_cache' => 1});
1.258 albertel 3116: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
3117: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 3118: &Apache::lonnet::logthis ($field);
3119: if ($field ne 'courserestricted') {
3120: $output.= &output_row($r, $field, $metadata_fields{$field});
3121: }
1.255 banghart 3122: }
1.244 banghart 3123: $r->print(<<ENDenv);
1.259 banghart 3124: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 3125: <p>
3126: $output
1.259 banghart 3127: <input type="submit" name="restrictmeta" value="Update Metadata Restrictions">
1.244 banghart 3128: </form>
3129: ENDenv
1.280 albertel 3130: $r->print(&Apache::loncommon::end_page());
1.240 banghart 3131: return 'ok';
3132: }
1.220 www 3133: ##################################################
1.193 albertel 3134:
1.220 www 3135: sub defaultsetter {
1.280 albertel 3136: my ($r) = @_;
3137:
3138: my $start_page =
3139: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 3140: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 3141: $r->print(<<ENDDEFHEAD);
1.280 albertel 3142: $start_page
1.220 www 3143: $breadcrumbs
3144: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
3145: ENDDEFHEAD
1.280 albertel 3146:
3147: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3148: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 3149: my @ids=();
3150: my %typep=();
3151: my %keyp=();
3152: my %allparms=();
3153: my %allparts=();
3154: my %allmaps=();
3155: my %mapp=();
3156: my %symbp=();
3157: my %maptitles=();
3158: my %uris=();
3159: my %keyorder=&standardkeyorder();
3160: my %defkeytype=();
3161:
3162: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3163: \%mapp, \%symbp,\%maptitles,\%uris,
3164: \%keyorder,\%defkeytype);
1.224 www 3165: if ($env{'form.storerules'}) {
3166: my %newrules=();
3167: my @delrules=();
1.226 www 3168: my %triggers=();
1.225 albertel 3169: foreach my $key (keys(%env)) {
3170: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 3171: my $tempkey=$1;
1.226 www 3172: my $action=$env{$key};
3173: if ($action) {
3174: $newrules{$tempkey.'_action'}=$action;
3175: if ($action ne 'default') {
3176: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
3177: $triggers{$whichparm}.=$tempkey.':';
3178: }
3179: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 3180: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3181: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 3182: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
3183: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
3184: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
3185: } else {
3186: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 3187: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 3188: }
3189: } else {
1.225 albertel 3190: push(@delrules,$tempkey.'_action');
1.226 www 3191: push(@delrules,$tempkey.'_type');
1.225 albertel 3192: push(@delrules,$tempkey.'_hours');
3193: push(@delrules,$tempkey.'_min');
3194: push(@delrules,$tempkey.'_sec');
3195: push(@delrules,$tempkey.'_value');
1.224 www 3196: }
3197: }
3198: }
1.226 www 3199: foreach my $key (keys %allparms) {
3200: $newrules{$key.'_triggers'}=$triggers{$key};
3201: }
1.224 www 3202: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
3203: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
3204: &resetrulescache();
3205: }
1.227 www 3206: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
3207: 'hours' => 'Hours',
1.221 www 3208: 'min' => 'Minutes',
3209: 'sec' => 'Seconds',
3210: 'yes' => 'Yes',
3211: 'no' => 'No');
1.222 www 3212: my @standardoptions=('','default');
3213: my @standarddisplay=('',&mt('Default value when manually setting'));
3214: my @dateoptions=('','default');
3215: my @datedisplay=('',&mt('Default value when manually setting'));
3216: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
3217: unless ($tempkey) { next; }
3218: push @standardoptions,'when_setting_'.$tempkey;
3219: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
3220: if (&isdateparm($defkeytype{$tempkey})) {
3221: push @dateoptions,'later_than_'.$tempkey;
3222: push @datedisplay,&mt('Automatically set later than ').$tempkey;
3223: push @dateoptions,'earlier_than_'.$tempkey;
3224: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
3225: }
3226: }
1.231 www 3227: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
3228: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.221 www 3229: $r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'.
1.222 www 3230: &mt('Action').'</th><th>'.&mt('Value').'</th></tr>');
1.221 www 3231: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 3232: unless ($tempkey) { next; }
1.221 www 3233: $r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 3234: my $action=&rulescache($tempkey.'_action');
3235: $r->print('<select name="'.$tempkey.'_action">');
3236: if (&isdateparm($defkeytype{$tempkey})) {
3237: for (my $i=0;$i<=$#dateoptions;$i++) {
3238: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
3239: $r->print("\n<option value='$dateoptions[$i]'".
3240: ($dateoptions[$i] eq $action?' selected="selected"':'').
3241: ">$datedisplay[$i]</option>");
3242: }
3243: } else {
3244: for (my $i=0;$i<=$#standardoptions;$i++) {
3245: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
3246: $r->print("\n<option value='$standardoptions[$i]'".
3247: ($standardoptions[$i] eq $action?' selected="selected"':'').
3248: ">$standarddisplay[$i]</option>");
3249: }
3250: }
3251: $r->print('</select>');
1.227 www 3252: unless (&isdateparm($defkeytype{$tempkey})) {
3253: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
3254: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
3255: }
1.222 www 3256: $r->print("\n</td><td>\n");
3257:
1.221 www 3258: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 3259: my $days=&rulescache($tempkey.'_days');
1.222 www 3260: my $hours=&rulescache($tempkey.'_hours');
3261: my $min=&rulescache($tempkey.'_min');
3262: my $sec=&rulescache($tempkey.'_sec');
1.221 www 3263: $r->print(<<ENDINPUTDATE);
1.227 www 3264: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 3265: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
3266: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
3267: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 3268: ENDINPUTDATE
3269: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 3270: my $yeschecked='';
3271: my $nochecked='';
3272: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
3273: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
3274:
1.221 www 3275: $r->print(<<ENDYESNO);
1.224 www 3276: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
3277: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 3278: ENDYESNO
3279: } else {
1.224 www 3280: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 3281: }
3282: $r->print('</td></tr>');
3283: }
1.224 www 3284: $r->print("</table>\n<input type='submit' name='storerules' value='".
1.280 albertel 3285: &mt('Store Rules')."' /></form>\n".
3286: &Apache::loncommon::end_page());
1.220 www 3287: return;
3288: }
1.193 albertel 3289:
1.290 www 3290: sub components {
1.291 www 3291: my ($key,$uname,$udom,$exeuser,$exedomain)=@_;
1.290 www 3292: my $typeflag=0;
3293: if ($key=~/\.type$/) {
3294: $key=~s/\.type$//;
3295: $typeflag=1;
3296: }
1.291 www 3297: my $issection;
1.290 www 3298: my ($middle,$part,$name)=($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3299: my $section=&mt('All Students');
3300: if ($middle=~/^\[(.*)\]/) {
1.291 www 3301: $issection=$1;
3302: $section=&mt('Group/Section').': '.$issection;
1.290 www 3303: $middle=~s/^\[(.*)\]//;
3304: }
3305: $middle=~s/\.+$//;
3306: $middle=~s/^\.+//;
1.291 www 3307: if ($uname) {
3308: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
3309: $issection='';
3310: }
1.290 www 3311: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.304 www 3312: my $realmdescription=&mt('all resources');
1.290 www 3313: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3314: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.304 www 3315: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
3316: } elsif ($middle) {
1.290 www 3317: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
3318: $realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
1.304 www 3319: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 3320: }
1.291 www 3321: my $what=$part.'.'.$name;
3322: return ($realm,$section,$name,$part,$typeflag,
1.304 www 3323: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 3324: }
1.293 www 3325:
1.292 www 3326: sub standard_parameter_names {
3327: my ($name)=@_;
3328: my %standard_parms=&Apache::lonlocal::texthash('duedate' => 'Due Date',
3329: 'answerdate' => 'Answer Date',
3330: 'opendate' => 'Open Date',
3331: 'maxtries' => 'Max. Number of Tries',
3332: 'weight' => 'Weight',
3333: 'date_start' => 'Starting Date',
1.293 www 3334: 'date_end' => 'Ending Date',
3335: 'int_pos' => 'Positive Integer',
3336: 'int_zero_pos' => 'Positive Integer or Zero',
3337: 'hinttries' => 'Number of Tries till Hints appear');
1.292 www 3338: if ($standard_parms{$name}) {
3339: return $standard_parms{$name};
3340: } else {
3341: return $name;
3342: }
3343: }
1.290 www 3344:
1.285 albertel 3345: sub parm_change_log {
1.284 www 3346: my ($r)=@_;
3347: &startpage($r);
1.286 www 3348: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
3349: $env{'course.'.$env{'request.course.id'}.'.domain'},
3350: $env{'course.'.$env{'request.course.id'}.'.num'});
1.301 www 3351: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
3352:
1.291 www 3353: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
3354: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 3355: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
3356: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
3357: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
3358: &Apache::loncommon::end_data_table_header_row());
1.294 www 3359: foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) {
3360: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.290 www 3361: my $count=$#changes+1;
1.288 albertel 3362: my $time =
1.294 www 3363: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 3364: my $plainname =
1.294 www 3365: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
3366: $parmlog{$id}{'exe_udom'});
1.288 albertel 3367: my $about_me_link =
1.289 www 3368: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 3369: $parmlog{$id}{'exe_uname'},
3370: $parmlog{$id}{'exe_udom'});
1.293 www 3371: my $send_msg_link='';
1.294 www 3372: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
3373: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 3374: $send_msg_link ='<br />'.
1.288 albertel 3375: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 3376: $parmlog{$id}{'exe_uname'},
3377: $parmlog{$id}{'exe_udom'});
1.288 albertel 3378: }
1.301 www 3379: my $row_start=&Apache::loncommon::start_data_table_row();
3380: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.290 www 3381: <td rowspan="'.$count.'">'.$about_me_link.
1.294 www 3382: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
3383: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
1.290 www 3384: $send_msg_link.'</td>');
3385: my $makenewrow=0;
3386: my %istype=();
1.293 www 3387: foreach my $changed (reverse(sort(@changes))) {
1.294 www 3388: my $value=$parmlog{$id}{'logentry'}->{$changed};
1.304 www 3389: my ($realm,$section,$parmname,$part,$typeflag,$what,$middle,$uname,$udom,$issection,$realmdescription)=
1.294 www 3390: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'});
1.290 www 3391: if ($typeflag) { $istype{$parmname}=$value; }
1.301 www 3392: if ($makenewrow) { $r->print($row_start); } else { $makenewrow=1; }
1.290 www 3393: $r->print('<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 3394: &standard_parameter_names($parmname).'</td><td>'.
3395: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>');
1.291 www 3396: my $stillactive=0;
1.294 www 3397: if ($parmlog{$id}{'deleteflag'}) {
1.290 www 3398: $r->print(&mt('Deleted'));
1.288 albertel 3399: } else {
1.290 www 3400: if ($typeflag) {
1.292 www 3401: $r->print(&mt('Type: [_1]',&standard_parameter_names($value)));
1.290 www 3402: } else {
1.291 www 3403: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
3404: $uname,$udom,$issection,$issection,$courseopt);
3405: if (&isdateparm($istype{$parmname})) {
3406: $r->print(&Apache::lonlocal::locallocaltime($value));
3407: } else {
3408: $r->print($value);
3409: }
3410: if ($value ne $all[$level]) {
3411: $r->print('<br /><font color="red">'.&mt('Not active anymore').'</font>');
3412: } else {
3413: $stillactive=1;
3414: }
1.290 www 3415: }
1.288 albertel 3416: }
1.291 www 3417: $r->print('</td>');
3418: if ($stillactive) {
1.304 www 3419: my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
3420: my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
3421: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 3422: if (($uname) && ($udom)) {
1.304 www 3423: $r->print('<td>'.
3424: &Apache::loncommon::messagewrapper('Notify User',$uname,$udom,$title,$description).
3425: '</td>');
1.292 www 3426: } else {
1.303 www 3427: $r->print('<td>'.
1.304 www 3428: &Apache::lonrss::course_blog_link($id,$title,$description).
3429: '</td>');
1.292 www 3430: }
1.291 www 3431: } else {
3432: $r->print('<td> </td>');
3433: }
1.301 www 3434: $r->print(&Apache::loncommon::end_data_table_row());
1.288 albertel 3435: }
1.286 www 3436: }
1.301 www 3437: $r->print(&Apache::loncommon::end_data_table());
1.284 www 3438: $r->print(&Apache::loncommon::end_page());
3439: }
3440:
1.178 raeburn 3441: ##################################################
3442: ##################################################
1.30 www 3443:
1.59 matthew 3444: =pod
3445:
1.83 bowersj2 3446: =item * handler
1.59 matthew 3447:
3448: Main handler. Calls &assessparms and &crsenv subroutines.
3449:
3450: =cut
3451: ##################################################
3452: ##################################################
1.220 www 3453: # use Data::Dumper;
3454:
1.259 banghart 3455:
1.30 www 3456: sub handler {
1.43 albertel 3457: my $r=shift;
1.30 www 3458:
1.43 albertel 3459: if ($r->header_only) {
1.126 www 3460: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 3461: $r->send_http_header;
3462: return OK;
3463: }
1.193 albertel 3464: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 3465: ['action','state',
3466: 'pres_marker',
3467: 'pres_value',
1.206 www 3468: 'pres_type',
1.243 banghart 3469: 'udom','uname','symb','serial']);
1.131 www 3470:
1.83 bowersj2 3471:
1.193 albertel 3472: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 3473: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
3474: text=>"Parameter Manager",
1.204 www 3475: faq=>10,
1.194 albertel 3476: bug=>'Instructor Interface'});
1.203 www 3477:
1.30 www 3478: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 3479: my $parm_permission =
3480: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 3481: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 3482: $env{'request.course.sec'}));
1.194 albertel 3483: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 3484:
3485: # Start Page
1.126 www 3486: &Apache::loncommon::content_type($r,'text/html');
1.106 www 3487: $r->send_http_header;
1.30 www 3488:
1.203 www 3489:
3490: # id numbers can change on re-ordering of folders
3491:
3492: &resetsymbcache();
3493:
1.193 albertel 3494: #
3495: # Main switch on form.action and form.state, as appropriate
3496: #
3497: # Check first if coming from someone else headed directly for
3498: # the table mode
3499: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
3500: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
3501: &assessparms($r);
3502:
3503: } elsif (! exists($env{'form.action'})) {
3504: $r->print(&header());
1.298 albertel 3505: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 3506: &print_main_menu($r,$parm_permission);
3507: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 3508: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
3509: text=>"Course Environment"});
1.193 albertel 3510: &crsenv($r);
3511: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 3512: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3513: text=>"Overview Mode"});
1.121 www 3514: &overview($r);
1.259 banghart 3515: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
3516: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
3517: text=>"Restrict Metadata"});
3518: &setrestrictmeta($r);
1.208 www 3519: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
3520: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
3521: text=>"Overview Mode"});
3522: &newoverview($r);
1.220 www 3523: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
3524: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
3525: text=>"Set Defaults"});
3526: &defaultsetter($r);
3527: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 3528: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 3529: text=>"Table Mode",
3530: help => 'Course_Setting_Parameters'});
1.121 www 3531: &assessparms($r);
1.284 www 3532: } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) {
3533: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.292 www 3534: text=>"Parameter Change Log"});
1.285 albertel 3535: &parm_change_log($r);
1.284 www 3536: }
1.43 albertel 3537: } else {
1.1 www 3538: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 3539: $env{'user.error.msg'}=
1.43 albertel 3540: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
3541: return HTTP_NOT_ACCEPTABLE;
3542: }
3543: return OK;
1.1 www 3544: }
3545:
3546: 1;
3547: __END__
3548:
1.59 matthew 3549: =pod
1.38 harris41 3550:
3551: =back
3552:
3553: =cut
1.1 www 3554:
3555:
3556:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>