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