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