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