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