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