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