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