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