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